ソースを参照

聚水潭、速风平台数据同步

dong025 3 日 前
コミット
d51357830f

+ 39 - 18
app/admin/command/FengSu.php

@@ -18,14 +18,15 @@ use think\console\Input;
 use think\console\Output;
 use GuzzleHttp\Client;
 use app\common\model\CrontabLog;
-use app\common\model\FengsuSku;
+use app\common\model\ImportSku;
 use app\common\model\ShopList;
 use app\common\model\ProductConfig;
 use app\common\model\ShopDelivery;
 use app\common\model\CustomerSpec;
 use app\admin\service\FengsuService;
 use GuzzleHttp\Psr7\Request;
-
+use app\common\model\ImportList;
+use app\admin\service\JuShuiTanService;
 //抖音
 class FengSu extends Command
 {
@@ -39,9 +40,11 @@ class FengSu extends Command
         'Accept' => 'application/json, text/plain, */*',
         'Authorization' => 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxODYwNTQ1MTExNSIsImRhdGFfcGVybWlzc2lvbiI6InByb2R1Y3RDb3N0IiwibmlrZSI6IjE4NjA1NDUxMTE1IiwiY3JlYXRlZCI6MTc2NDEyNTQwMzQ0OSwiZHBJZCI6MTAwNjczLCJleHAiOjE3NjQ3MzAyMDMsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTAwNjczfQ.ihv6NRfD2hzU1NQoqttTaZ-mPxqAEXIUICM8MuxVx2tVLEPW9j-uPhHoFz4T3-lH07wTt2ORf1k_SPOQP4PuQg',
         'Content-Type' => 'application/json',
-        'platform' => 'dy',
+        // 'platform' => 'dy',
     ];
 
+    // 打单平台 1:风速  2:聚水潭
+    protected $type_id=1;
     // 指令配置
     protected function configure()
     {
@@ -53,10 +56,12 @@ class FengSu extends Command
     {
         $output->writeln('开始同步订单');
 
-        $resquet = $this->getOrderList('dy');
+        $resquet = $this->getOrderList('');
         if($resquet['code'] == 0){
             if($resquet['data']['total'] > 0){
                 $list = $resquet['data']['list'];
+                // dump($list);
+                // return;
                 $this->insertOrder($list);
                 //dump($resquet);
             }else{
@@ -69,7 +74,7 @@ class FengSu extends Command
         $output->writeln('ok');
     }
 
-    public function getOrderList($platform = 'dy')
+    public function getOrderList($platform = '')
     {
         $client = new \GuzzleHttp\Client([
             'verify' => false,
@@ -88,11 +93,11 @@ class FengSu extends Command
                 "sort": "CONSIGN_TIME",
                 "sortAsc": false,
                 "current": 1,
-                "size": 100,
+                "size": 1,
                 "tradeStatus": 2,
                 "fromAccountId": [],
-                "goodType": 3,
-                "goodsFlag": 1
+                "goodType": 2,
+                "goodsFlag": 2
         }';
         $request = new Request('POST', 'https://fsdy2.fengsutb.com/amount/ship-list-new', $headers, $body);
         $res = $client->sendAsync($request)->wait();
@@ -111,33 +116,49 @@ class FengSu extends Command
         }
         $queue = [];
         $shopList = new ShopList();
-        $fengsuSku = new FengsuSku();
+        $importSku = new ImportSku();
         $productConfig = new ProductConfig();
         $shopDelivery = new ShopDelivery();
         $customerSpec = new CustomerSpec();
         foreach($order_list as $item) {
-            dump($item['shopId'], '店铺id');
-            $status = FengsuService::getAdditionalPrice( $shopList, $fengsuSku, $productConfig, $shopDelivery, $customerSpec, $item);
+           $goods_id=$item['tradeOrderPrintVos'][0]['goodsId'];
+            $oid=$item['tradeOrderPrintVos'][0]['oid'];
+            $waybill_no=$item['waybillNo'];
+            if(empty($waybill_no)) continue;
+            $add_status = JuShuiTanService::prevent_duplicate_additions($oid,$waybill_no);
+            if($add_status) continue;
+            $status = FengsuService::getAdditionalPrice( $shopList, $importSku, $productConfig, $shopDelivery, $customerSpec, $item);
+       
+            $weight=$item['tradeOrderPrintVos'][0]['weight'];
+            $weight=strval($weight);
+            $weight=bcdiv($weight, '500', 2);
+            $weight=(float)$weight;
+            $price=$item['tradeOrderPrintVos'][0]['payment'];
+            $price=strval($price);
+            $price=bcdiv($price, '100', 2);
+            $price=(float)$price;
             $queue[] = [
+                'type_id'       => $this->type_id,
                 'shop_id'       => $item['shopId'],
+                'order_id'       => $oid,
                 'trade_from'    => $item['tradeFrom'],
                 'province'      => $item['receiverProvince'],
                 'city'          => $item['receiverCity'],
-                'company_name'  => $item['tradeOrderPrintVos'][0]['companyName'],
-                'waybill_no'    => $item['waybillNo'],
+                'company_name'  => $item['companyName'],
+                'waybill_no'    => $waybill_no,
                 'consign_time'  => $item['consignTime'],
-                'goods_id'      => $item['tradeOrderPrintVos'][0]['goodsId'],
+                'goods_id'      => $goods_id,
                 'sku_id'        => $item['tradeOrderPrintVos'][0]['skuId'],
                 'num'           => $item['tradeOrderPrintVos'][0]['total'],
                 'goods_title'   => $item['tradeOrderPrintVos'][0]['goodsTitle'],
-                'weigh'         => $item['tradeOrderPrintVos'][0]['weight'],
-                'price'         => bcdiv((string)$item['payment'], '100', 2),
+                'goods_info'   => $item['tradeOrderPrintVos'][0]['skuProp'],
+                'weight'         =>$weight,
+                'price'         => $price,
                 'status'        => $status,
             ];
         }
-
         // 保存到数据库
-        (new FengsuShip())->saveAll($queue);
+        (new ImportList())->saveAll($queue);
         // 更新最后执行时间
         CrontabLog::create(['type_id' => 2,'last_time' => date('Y-m-d H:i:s')]);
     }

+ 9 - 6
app/admin/command/JuShuiTan.php

@@ -18,7 +18,7 @@ use think\console\Input;
 use think\console\Output;
 use GuzzleHttp\Client;
 use app\common\model\CrontabLog;
-use app\common\model\FengsuSku;
+use app\common\model\ImportSku;
 use app\common\model\ShopList;
 use app\common\model\ProductConfig;
 use app\common\model\ShopDelivery;
@@ -100,7 +100,7 @@ class JuShuiTan extends Command
             "uid": "21943091",
             "upSendFailed": false,
             "isExceptAddress": "Except",
-            "pageNum": 1,
+            "pageNum": 2,
             "pageSize": 50,
             "searchType": 1,
             "orderStatus": [
@@ -126,7 +126,7 @@ class JuShuiTan extends Command
         }
         $queue = [];
         $shopList = new ShopList();
-        $fengsuSku = new FengsuSku();
+        $importSku = new ImportSku();
         $productConfig = new ProductConfig();
         $shopDelivery = new ShopDelivery();
         $customerSpec = new CustomerSpec();
@@ -146,11 +146,14 @@ class JuShuiTan extends Command
             // dump($item['shopId'], '店铺id');
             // 防止重复记录,订单号+快递单号
             $goods_id=$item['disInnerOrderGoodsViewList'][0]['shopIid'];
+            
             $oid=$item['oid'];
-            $waybill_no=ltrim($item['trackNo'], '@');
+            // $waybill_no=ltrim($item['trackNo'], '@');
+            $waybill_no=$item['trackNo'];
+            if(empty($waybill_no)) continue;
             $add_status = JuShuiTanService::prevent_duplicate_additions($oid,$waybill_no);
             if($add_status) continue;
-            $status = JuShuiTanService::getAdditionalPrice( $shopList, $fengsuSku, $productConfig, $shopDelivery, $customerSpec, $item);
+            $status = JuShuiTanService::getAdditionalPrice( $shopList, $importSku, $productConfig, $shopDelivery, $customerSpec, $item);
             $queue[] = [
                 'type_id'       => $this->type_id,
                 'shop_id'       => $item['shopId'],
@@ -166,7 +169,7 @@ class JuShuiTan extends Command
                 'num'           => $item['disInnerOrderGoodsViewList'][0]['itemCount'],
                 'goods_title'   => $item['disInnerOrderGoodsViewList'][0]['itemName'],
                 'goods_info'   => $item['disInnerOrderGoodsViewList'][0]['properties'],
-                'weigh'         => $item['weight'],
+                'weight'         => $item['weight'],
                 'price'         => bcdiv((string)$item['disInnerOrderGoodsViewList'][0]['price'], '1', 2),
                 'status'        => $status,
             ];

+ 0 - 175
app/admin/controller/goods/FengsuShip.php

@@ -1,175 +0,0 @@
-<?php
-declare (strict_types = 1);
-
-namespace app\admin\controller\goods;
-
-use app\common\controller\Backend;
-use app\admin\traits\Actions;
-use think\annotation\route\Group;
-use think\annotation\route\Route;
-use think\facade\Db;
-use app\common\model\FengsuSku;
-use app\common\model\ShopList;
-use app\common\model\StockConfig;
-use app\common\model\ShopDelivery;
-use app\admin\service\FengsuService;
-use app\common\model\CustomerSpec;
-use app\common\model\ProductConfig;
-use app\common\model\FengsuShip as FengsuShipModel;
-
-#[Group("goods/fengsu_ship")]
-class FengsuShip extends Backend
-{
-    //app\admin\controller\goods\FengsuShip
-    use Actions{
-        index as private _index;
-        del as private _del;
-    }
-
-    protected function _initialize()
-    {
-        parent::_initialize();
-        $this->model = new FengsuShipModel();
-        $this->assign('shopList', ShopList::where('status', 1)->where('shop_id', '')->column('name','id'));
-        $this->assign('typeList',  StockConfig::where('type_id', 'variety_name')->order('sort desc')->column('title','id'));
-        $this->assign('packingList', StockConfig::where('type_id', 'packing_box')->column('title','id'));
-    }
-
-    //查看
-    #[Route("GET,JSON","index")]
-    public function index()
-    {
-        return $this->_index();
-    }
-
-    /**
-     * 关联店铺
-     */
-    #[Route('GET,POST','shops')]
-    public function shops()
-    {
-        if (false === $this->request->isPost()) {
-            $ids =$this->request->get('ids/s', '');
-            return $this->fetch();
-        }
-        $params = array_merge($this->request->post("row/a"),$this->postParams);
-        if (empty($params)) {
-            $this->error(__('提交的参数不能为空'));
-        }
-        if(!$this->request->checkToken('__token__',['__token__'=>$this->request->post('__token__')])){
-            $this->error(__('token错误,请刷新页面重试'));
-        }
-        foreach ($params as &$value){
-            if(is_array($value)){
-                $value=implode(',',$value);
-            }
-            if($value===''){
-                $value=null;
-            }
-        }
-        $ids =$this->request->get('ids/s', '');
-        if(empty($params['shop_id'])) $this->error(__('请选择店铺'));
-        $result = false;
-        Db::startTrans();
-        try {
-            //更新店铺
-            ShopList::where('id', $params['shop_id'])->update(['shop_id' => $ids]);
-            //更新状态
-            $result = $this->model->where('shop_id', $ids)->update(['status' => 2]);
-            if($this->callback){
-                $callback=$this->callback;
-                $callback($this->model);
-            }
-            Db::commit();
-        } catch (\Exception $e) {
-            Db::rollback();
-            $this->error($e->getMessage());
-        }
-        if ($result === false) {
-            $this->error(__('没有新增任何数据'));
-        }
-        $this->success();
-    }
-
-    /**
-     * 关联规格
-     */
-    #[Route('GET,POST','specs')]
-    public function specs(mixed $row=null)
-    {
-        $ids = $this->request->param('ids');
-        if(!$row || is_array($row)){
-            $row = $this->model->find($ids);
-        }
-        if (!$row) {
-            $this->error(__('没有找到记录'));
-        }
-        if(count($this->volidateFields)>0){
-            foreach ($this->volidateFields as $field=>$value){
-                if($row[$field]!=$value){
-                    $this->error(__('没有操作权限'));
-                }
-            }
-        }
-        if (false === $this->request->isPost()) {
-            $this->assign('row', $row);
-            return $this->fetch();
-        }
-        $params = $this->request->post("");
-        if (empty($params['all_data'])) $this->error(__('请选择规格'));
-        $count = 0;
-        Db::startTrans();
-        try {
-
-            //插入规格
-            FengsuSku::insertSpecs($row['shop_id'], $row['sku_id'], (int)$params['all_data'][0]['type_id'], (int)$params['all_data'][0]['id']);
-            
-            //查看有多少规格
-            $list = $this->model::where('shop_id', $row['shop_id'])->where('sku_id', $row['sku_id'])->where('status', 2)->select();
-            $shopList = new ShopList();
-            $productConfig = new ProductConfig();
-            $shopDelivery = new ShopDelivery();
-            $customerSpec = new CustomerSpec();
-            foreach ($list as $item) {
-                //插入发货数据
-                FengsuService::setAdditionalPrice(
-                    $shopList,
-                    $productConfig,
-                    $shopDelivery,
-                    $customerSpec,
-                    $row['shop_id'],
-                    $params['all_data'][0]['type_id'],
-                    $params['all_data'][0]['id'],
-                    $params['all_data'][0]['name'],
-                    $row
-                );
-
-                $count += $item->save(['status' => 3]);
-            }
-            if($this->callback){
-                $callback=$this->callback;
-                $callback($ids);
-            }
-            Db::commit();
-        } catch (\Exception $e) {
-            Db::rollback();
-            $this->error($e->getMessage());
-        }
-
-        if ($count) {
-            return resp_json(200,'操作成功');
-        }
-        $this->error(__('没有数据被更新'));
-    }
-
-
-    //删除
-    #[Route("GET,POST","del")]
-    public function del()
-    {
-        //通过定义callback回调函数来执行删除后的操作
-        $this->callback=function ($ids){};
-        return $this->_del();
-    }
-
-}

+ 31 - 9
app/admin/controller/goods/ImportList.php

@@ -9,7 +9,7 @@ use app\admin\traits\Actions;
 use think\annotation\route\Group;
 use think\annotation\route\Route;
 use think\facade\Db;
-use app\common\model\FengsuSku;
+use app\common\model\ImportSku;
 use app\common\model\ShopList;
 use app\common\model\StockConfig;
 use app\common\model\ShopDelivery;
@@ -31,7 +31,7 @@ class ImportList extends Backend
     {
         parent::_initialize();
         $this->model = new ImportListModel();
-        $this->assign('shopList', ShopList::where('status', 1)->column('name', 'id'));
+        // $this->assign('shopList', ShopList::where('status', 1)->column('name', 'id'));
         $this->assign('typeList',  StockConfig::where('type_id', 'variety_name')->order('sort desc')->column('title', 'id'));
         $this->assign('packingList', StockConfig::where('type_id', 'packing_box')->column('title', 'id'));
     }
@@ -60,12 +60,22 @@ class ImportList extends Backend
             ->each(function ($item, $key) {
                 if(empty($item['type_id'])){
                     $item['type_id']=0;
-
-                    
                 }
-                $trade_from_list=site_config("addonsd.ju_shui_tan_trade_from_list");
+                $trade_from_list=[];
+                if($item['type_id']==1){
+                    $feng_su_trade_from_list=site_config("addonsd.feng_su_trade_from_list");
+                    $trade_from_list=$feng_su_trade_from_list;
+                }else{
+                    $ju_shui_tan_trade_from_list=site_config("addonsd.ju_shui_tan_trade_from_list");
+                    $trade_from_list=$ju_shui_tan_trade_from_list;
+                }
+                
+                
                 $trade_from=$item['trade_from'];
-                $item['trade_from']=empty($item['trade_from'])?'无':$trade_from_list[$trade_from];
+                $trade_from=isset($trade_from_list[$trade_from])?$trade_from_list[$trade_from]:$item['trade_from'];
+                $item['trade_from']=$trade_from;
+                // $item['trade_from']=empty($item['trade_from'])?'无':$trade_from_list[$trade_from];
+                
                 
                 return $item;
             });
@@ -81,6 +91,18 @@ class ImportList extends Backend
     {
         if (false === $this->request->isPost()) {
             $ids = $this->request->get('ids/s', '');
+            $shopList=new ShopList();
+            $sql_restul=$shopList->alias('s')
+                ->join("yun_customer c", "s.customer_id = c.id", "INNER")
+                ->where(['s.status' => 1, 'c.status' => 1])
+                ->field(['s.id','s.name','c.name'=>'nickname'])
+                ->select();
+            $arr=[];
+            foreach ($sql_restul as $item) {
+                $arr[$item['id']]=$item['name'].'(客户:'.$item['nickname'].')';
+            }
+                
+            $this->assign('shopList',$arr );
             return $this->fetch();
         }
         $params = array_merge($this->request->post("row/a"), $this->postParams);
@@ -158,7 +180,7 @@ class ImportList extends Backend
         try {
 
             //插入规格
-            FengsuSku::insertSpecs($row['shop_id'], $row['sku_id'], (int)$params['all_data'][0]['type_id'], (int)$params['all_data'][0]['id']);
+            ImportSku::insertSpecs($row['shop_id'], $row['sku_id'], (int)$params['all_data'][0]['type_id'], (int)$params['all_data'][0]['id']);
 
             //查看有多少规格
             $list = $this->model::where('shop_id', $row['shop_id'])->where('sku_id', $row['sku_id'])->where('status', 2)->select();
@@ -166,11 +188,11 @@ class ImportList extends Backend
             $productConfig = new ProductConfig();
             $shopDelivery = new ShopDelivery();
             $customerSpec = new CustomerSpec();
-            $fengsuSku = new FengsuSku();
+            $importSku = new ImportSku();
             foreach ($list as $item) {
                 //插入发货数据
                 JuShuiTanService::setAdditionalPrice(
-                    $fengsuSku,
+                    $importSku,
                     $shopList,
                     $productConfig,
                     $shopDelivery,

+ 5 - 5
app/admin/service/FengsuService.php

@@ -22,26 +22,26 @@ class FengsuService {
      */
     public static function getAdditionalPrice(object $shopList, object $fengsuSku, object $productConfig, object $shopDelivery, object $customerSpec, array $item):int
     {
-        dump('店铺0');
+        // dump('店铺0');
 
         $status = 1;
         //判断是否存在店铺
         $shops = $shopList::getSpecsIdByShopId($item['shopId']);
-        dump('店铺00');
+        // dump('店铺00');
 
         if(!$shops->isEmpty()){
-            dump('店铺1');
+            // dump('店铺1');
 
             //判断是否存在规格-获取重量
             $specs = $fengsuSku::getSpecsIdByShopId($shops->shop_id, $item['tradeOrderPrintVos'][0]['skuId']);
             if(!$specs->isEmpty()) {
-                dump('店铺2');
+                // dump('店铺2');
 
                 //根据规格重量获取,加收价格
                 $weight = $productConfig::getWeight($specs->spec_id);
                 $status = 3;
                 if($weight){
-                    dump('店铺3');
+                    // dump('店铺3');
 
                     $other_price = self::getRemoteAreaFee($item['tradeOrderPrintVos'][0]['companyName'],  $weight, $item['receiverProvince'], $item['receiverCity']);
                     //获取包装箱

+ 0 - 109
app/admin/view/goods/fengsu_ship/index.html

@@ -1,109 +0,0 @@
-<template>
-    <el-card shadow="never">
-        <yun-table
-                :columns="columns"
-                ref="yuntable"
-                @render="onTableRender"
-                toolbar="refresh,del"
-                :auth="{
-               
-                    del:{:$auth->check('app\\admin\\controller\\goods\\FengsuShip','del')},
-         
-                }"
-                :extend="extend">
-        </yun-table>
-    </el-card>
-</template>
-<script>
-import table from "@components/Table.js";
-export default{
-    components:{
-        'YunTable':table
-    },
-    data:{
-        extend:{
-            index_url: 'goods/fengsu_ship/index',
-            del_url: 'goods/fengsu_ship/del',
-            multi_url: 'goods/fengsu_ship/multi',
-        },
-        columns:[
-            {checkbox: true,selectable:function (row,index){
-                //可以根据业务需求返回false让某些行不可选中
-                return true;
-            }},
-            {field:"id",title:"ID",operate:false},
-            {field:"shop_id",title:"店铺ID"},
-            {field:"trade_from",title:"平台"},
-            {field:"province",title:"省份",operate: false},
-            {field:"city",title:"城市",operate: false},
-            {field:"company_name",title:"快递名称"},
-            {field:"waybill_no",title:"快递单号"},
-            {field:"goods_title",title:"产品名称"},
-            {field:"sku_id",title:"规格id"},
-            {field:"num",title:"件数",operate: false},
-            {field:"price",title:"实付价格",operate: false},
-            {field:"consign_time",title:"发货时间",operate:"daterange",formatter:Yunqi.formatter.datetime},
-            {field:"status",title:"状态",operate:"select",searchList:{1:"无店铺", 2:"无Sku", 3:"正常"},formatter:Yunqi.formatter.tags},
-            // {field:"user_id",title:"录入人",operate: false},
-            {field:"createtime",title:"创建时间",operate: false,formatter:Yunqi.formatter.datetime},
-            {field:"updatetime",title:"修改时间",visible:false,operate: false,formatter:Yunqi.formatter.datetime},
-            {
-                field: 'operate',
-                title: __('操作'),
-                width:150,
-                      action:{
-                        shops:{
-                            tooltip:true,
-                            icon:'fa fa-certificate',
-                            type:'success',
-                            text:__('关联店铺'),
-                            method:'shops',
-                            visible:function(row,index){
-                                return row.status == 1;
-                            }
-                        },
-                        specs:{
-                            tooltip:true,
-                            icon:'fa fa-list',
-                            type:'info',
-                            text:__('关联规格'),
-                            method:'specs',
-                            visible:function(row,index){
-                                return row.status == 2;
-                            }
-                        },
-                        del:true
-                    }
-            }
-        ]
-    },
-    methods: {
-        shops:function (row){
-            Yunqi.api.open({
-                url:'goods/fengsu_ship/shops?ids='+row.shop_id,
-                width:1000,
-                title:__('关联店铺'),
-                icon:'fa fa-list'
-            });
-        },
-        specs:function (row){
-            let that=this;
-            Yunqi.api.open({
-                url:'goods/fengsu_ship/specs?ids='+row.id,
-                width:1000,
-                title:__('关联规格'),
-                icon:'fa fa-list',
-                close:function (r){
-                    if(r){
-                        that.$refs.yuntable.reload();
-                    }
-                }
-            })
-            
-        },
-  
-    }
-}
-</script>
-<style>
-</style>

+ 0 - 74
app/admin/view/goods/fengsu_ship/shops.html

@@ -1,74 +0,0 @@
-<template>
-    <el-card shadow="never" style="border: 0;">
-        <yun-form
-            ref="yunform"
-            @render="onFormRender"
-            @submit="onSubmit"
-            @success="onSuccess"
-            @fail="onFail"
-            :data="row"
-            :columns="columns">
-            <template #default>
-                {:token_field()}
-            </template>
-    
-        </yun-form>
-    </el-card>
-</template>
-<script>
-import form from "@components/Form.js";
-export default{
-    components:{
-        'YunForm':form
-    },
-    data:{
-        columns:[
-            {field:"id",title:"ID",edit:"hidden"},
-            {field:"shop_id",title:"店铺名称",searchList:Yunqi.data.shopList,edit: 'select',rules:'required'},
-        ],
-        row:Yunqi.data.row || {}
-    },
-    //页面加载完成时执行
-    onLoad:function(query){
-        console.log(query);
-    },
-    //页面初始显示或在框架内显示时执行
-    onShow:function(){
-
-    },
-    //页面在框架内隐藏时执行
-    onHide:function(){
-
-    },
-    //页面在框架内关闭时执行
-    onUnload:function(){
-
-    },
-    methods: {
-        onFormRender:function(rows){
-            //表单渲染完成后执行
-        },
-        onSubmit:function(rows){
-            //表单提交前执行,返回false可以阻止表单提交
-            /**
-             * form常用方法
-             * this.$refs.yunform.setError(field,message);//聚焦表单项并显示错误信息
-             * this.$refs.yunform.hideField(field);//隐藏表单项
-             * this.$refs.yunform.showField(field);//显示表单项
-             * this.$refs.yunform.setValue(field,value);//为表单项设置值
-             * this.$refs.yunform.getValue(field);//为获取表单项的值
-             * this.$refs.yunform.setField(field,key,value);//修改表单json的其他属性值,比如rules,title,searchList等
-             */
-            return true;
-        },
-        onSuccess:function(response){
-            //表单提交成功后执行
-        },
-        onFail:function(err){
-            //表单提交失败后执行
-        }
-    }
-}
-</script>
-<style>
-</style>

+ 0 - 165
app/admin/view/goods/fengsu_ship/specs.html

@@ -1,165 +0,0 @@
-<template>
-    <el-card shadow="never" style="min-height: 450px; max-height: 450px; overflow: auto;">
-        <el-tabs tab-position="left" style="height: 100%; overflow: auto;" v-model="tabValue" @tab-click="handleClick">
-            <el-tab-pane v-for="(item,index) in tabData" :label="item.label" :name="item.value">
-            </el-tab-pane>
-            <el-table :data="tableData" style="width: 100%" border :ref="'multipleTable_' + tabValue" stripe  highlight-current-row
-                @select="handleSelectionChange" @select-all="handleAllSelect" @current-change="handleCurrentChange">
-                <el-table-column type="index" width="55">
-                </el-table-column>
-                <el-table-column prop="name" label="规格" align="center">
-                </el-table-column>
-                <!-- <el-table-column prop="packet" label="包装箱" align="center">
-                    <template #default="{row}">
-                        <span>{{options[row.box_id]}}</span>
-                    </template>
-                </el-table-column>
-                <el-table-column prop="price" label="发货价" align="center" ></el-table-column> -->
-                    
-            </el-table>
-        </el-tabs>
-    </el-card>
-    <div style="width: 100%;display: flex; align-items: center; justify-content: center; position: fixed; bottom: 6px;">
-        <el-button type="primary" @click="onSubmit">立即创建</el-button>
-        <el-button>取消</el-button>
-    </div>
-</template>
-<script>
-    import table from "@components/Table.js";
-
-    export default {
-        components: { 'YunTable': table },
-        data: {
-            extend: {
-                index_url: 'general/category/index',
-            },
-            row: Yunqi.data.row,
-            tabData: Object.entries(Yunqi.data.typeList).map(([value, label]) => ({ label, value })),
-            tableData: [],
-            value: "",
-            form: {
-                nameValue: null,
-            },
-            options: Yunqi.data.packingList,//品种
-            tabValue: Object.entries(Yunqi.data.typeList).map(([value, label]) => ({ label, value }))[0].value, //选中的品种 获取到品种数据后要给他默认赋值第一个
-            chooseSpec: [], // 当前分类选中的规格  
-            allData: {},
-            type: 0, // 1编辑 0新增
-        },
-        methods: {
-            onSubmit() {
-                if (this.allData == "") return;
-                let arr = Object.values(this.allData).flat(Infinity)
-                Yunqi.ajax.post('goods/fengsu_ship/specs', { ids: Yunqi.data.row.id, all_data: arr }, false, false, true).then(res => {
-                    if (res.code == 200) {
-                        this.$message.success(__('设置成功'));
-                        //倒计时刷新窗口
-                        setTimeout(() => {
-                            Yunqi.api.closelayer(Yunqi.app.window.id, true);
-                        }, 1000);
-                        
-                    } else {
-                        Yunqi.alert(__('请填写发货价格'), __('温馨提示'), { type: 'error' });
-                    }
-                });
-            },
-            handleAllSelect(e){
-                this.allData[this.tabValue] = e || []
-            },
-            handleCurrentChange(e){
-               
-                this.allData[this.tabValue] = e || []
-            },
-            handleSelectionChange(e) {
-                console.log(this.allData,"=====this.allData")
-            },
-            handleClick(data, row) {
-                // 品种切换事件 可以在这里请求规格接口
-                this.tabValue = data.props.name
-                this.tabName = data.props.label
-                this.tableData = [];
-                this.getSpecData()
-            },
-            getSpecData() {
-
-                //获取规格 ;
-                Yunqi.ajax.get('shop/customer_spec/get_box', {  type_id: this.tabValue }, false, false, true).then(res => {
-                    //编辑数据
-                    if (res.length > 0) {
-                        for (var key in Object(res)) {
-                            let index = this.tableData.findIndex(item => item.id == res[key]['id']);
-                            if (index != -1) {
-                                this.tableData.splice(index, 1)
-                            } else {
-                                this.tableData.push({name: res[key]['title'], id: res[key]['id'], type_id: this.tabValue });
-                            }
-                        }
-                        this.$nextTick(() => {
-                            const tableRef = this.$refs['multipleTable_' + this.tabValue];
-                            if (this.type == 0 && this.allData[this.tabValue]?.length > 0 && tableRef) {
-                                this.tableData.forEach((item, index) => {
-                                    const matched = this.allData[this.tabValue].find(row => {
-                                        return row.id == item.id
-                                    });
-                                    if (matched) {
-                                        this.tableData[index] = matched
-                                    }
-                                })
-                                this.allData[this.tabValue].forEach(selected => {
-                                    const matched = this.tableData.find(row => row.id === selected.id);
-                                    if (matched) {
-                                        this.$refs['multipleTable_' + this.tabValue].toggleRowSelection(matched, true); // 勾选
-                                    }
-                                });
-                            }
-                            else if (this.type == 1 && this.allData[Number(this.tabValue)]) {
-                                this.tableData.forEach((item, index) => {
-                                    const matched = this.allData[Number(this.tabValue)].find(row => {
-                                        if (row.product_id) {
-                                            return row.product_id == item.value
-                                        } else {
-                                            return row.value == item.value
-                                        }
-                                    });
-                                    if (matched) {
-                                        // this.tableData[index] = { name: 'kam', value: 3, price: '111', type_id: '4', packet: '3' }
-                                        if (matched.product_id) {
-                                            this.tableData[index].name = matched.name
-                                            this.tableData[index].box_name = matched.box_name
-                                            this.tableData[index].type_name = matched.type_name
-                                            this.tableData[index].price = matched.price
-                                            this.tableData[index].packet = matched.box_id != 0 ? matched?.box_id.toString() : ""
-                                        } else {
-                                            this.tableData[index] = matched
-                                        }
-                                    }
-                                })
-                                this.allData[Number(this.tabValue)].forEach(selected => {
-                                    const matched = this.tableData.find(row => {
-                                        if (selected.product_id) {
-                                            return selected.product_id == row.value
-                                        } else {
-                                            return row.value === selected.value
-                                        }
-                                    });
-                                    if (matched) {
-                                        this.$refs['multipleTable_' + this.tabValue].toggleRowSelection(matched, true); // 勾选
-                                    }
-                                });
-                            }
-                        });
-                    }
-                });
-            }
-
-        },
-        onLoad: function (query) {
-     
-          
-            //你只需要保存规格是吧, 是你末尾加了个row
-            this.getSpecData()
-        },
-    }
-</script>
-<style>
-</style>

+ 1 - 0
app/admin/view/goods/import_list/index.html

@@ -57,6 +57,7 @@ export default{
             {field:"sku_id",title:"规格id"},
             {field:"num",title:"件数",operate: false},
             {field:"price",title:"实付价格",operate: false},
+            // {field:"weight",title:"重量(斤)",operate: false},
             {field:"consign_time",title:"发货时间",operate:"daterange",formatter:Yunqi.formatter.datetime},
             {field:"status",title:"状态",operate:"select",searchList:{1:"无店铺", 2:"无Sku", 3:"正常"},formatter:Yunqi.formatter.tags},
             // {field:"user_id",title:"录入人",operate: false},

+ 1 - 1
app/admin/view/goods/import_list/specs.html

@@ -62,7 +62,7 @@
                         }, 1000);
 
                     } else {
-                        Yunqi.alert(__('请填写发货价格'), __('温馨提示'), { type: 'error' });
+                        Yunqi.alert(__('请选择规格'), __('温馨提示'), { type: 'error' });
                     }
                 });
             },

+ 1 - 3
app/admin/view/shop/shop_list/specs.html

@@ -161,9 +161,7 @@
 
         },
         onLoad: function (query) {
-            let row = Yunqi.data.row;
-
-            console.log(row,"====11=")    
+            let row = Yunqi.data.row;  
             if (row) {
                 this.type = 1
                 const grouped = JSON.parse(row).reduce((acc, item) => {

+ 0 - 26
app/common/model/FengsuShip.php

@@ -1,26 +0,0 @@
-<?php
-declare(strict_types=1);
-
-namespace app\common\model;
-
-use think\Model;
-
-class FengsuShip Extends Model
-{
-    // 自动写入时间戳字段
-    protected $autoWriteTimestamp = true;
-    protected $createTime = 'createtime';
-    protected $updateTime = 'updatetime';
-
-    protected $type = [
-        'createtime'     =>  'timestamp:Y-m-d H:i',
-        'updatetime'     =>  'timestamp:Y-m-d H:i',
-    ];
-
-    
-    //获取最后一条记录
-    public static function getLastRecord()
-    {
-        return self::order('id','desc')->getByName('createtime');
-    }
-} 

+ 51 - 0
app/common/model/ImportSku.php

@@ -0,0 +1,51 @@
+<?php
+declare(strict_types=1);
+
+namespace app\common\model;
+
+use think\Model;
+
+class ImportSku Extends Model
+{
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = true;
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+
+    protected $type = [
+        'createtime'     =>  'timestamp:Y-m-d H:i',
+        'updatetime'     =>  'timestamp:Y-m-d H:i',
+    ];
+
+
+    public function stockconfig()
+    {
+        return $this->hasOne(StockConfig::class,'id','variety_id')->field('id,title');
+    }
+    
+    //获取店铺下规格
+    public static function getSpecsIdByShopId(string $shop_id,  string $spec_id): object
+    {
+        // return self::where('shop_id', $shop_id)->where('sku_id', $spec_id)->findOrEmpty();
+        $result = self::alias('f')
+                ->where(['f.shop_id'=>$shop_id,'f.sku_id'=>$spec_id])
+                ->join('yun_product_config p', 'f.variety_id = p.type_id AND f.spec_id = p.id', 'INNER')
+                ->field([
+                    'f.*',
+                    'p.type_id',
+                    'p.title as spec_name',
+                    'p.another_name as box_name',
+                    'p.weight',
+                    'p.box_id'
+                ])
+                ->findOrEmpty();
+        return $result;
+    }
+
+    //批量插入规格
+    public static function insertSpecs(string $shop_id, string $sku_id, int $variety_id, int $spec_id)
+    {       
+        return self::create(['shop_id'=> $shop_id, 'variety_id'=>$variety_id, 'spec_id'=>$spec_id, 'sku_id'=>$sku_id]);
+    }
+
+}