Browse Source

订单任务

afa 2 months ago
parent
commit
0e2ee55481

+ 3 - 1
app/admin/command/TaskDy.php

@@ -38,7 +38,7 @@ class TaskDy extends Command
         'Host' => 'fsdy2.fengsutb.com',
         'Connection' => 'keep-alive',
         'sec-ch-ua-platform' => 'Windows',
-        'Authorization' => 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODcwMzg4MzMyMSwiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTg5NjMwODMsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.ZXaztcUDDlZDgepOqFwaQfzd4RcINNiIv54or0r-b7DJw9aKw7zjH8RmUIE7yqTcyQ_g6r7aGdpn9hf-hIukBg',
+        'Authorization' => 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODk2NjM3NjU5MywiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkyMjU1NzYsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.S37D56hG2SwttUYy7OBFet-GOeG5wW6U7j1d2NF7UoFzHWlSpSA4IjwZU1d9Z33xD44Zyiib4zGa_QRxCO2imw',
         'sec-ch-ua' => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"',
         'sec-ch-ua-mobile' => '?0',
         'doudian-event-id' => '1757940551000163',
@@ -82,6 +82,8 @@ class TaskDy extends Command
         "timeType": 2,
         "tradeStatus": 2
         }';
+        //获取Token
+        $this->headers['Authorization'] = site_config('addonsd.authorization_token');
         $request = new Request('POST', $this->url, $this->headers, $body);
         $res = $client->sendAsync($request)->wait();
         if($res->getStatusCode() == 200) {

+ 2 - 0
app/admin/command/TaskJd.php

@@ -80,6 +80,8 @@ class TaskJd extends Command
         "timeType": 2,
         "tradeStatus": 2
         }';
+        //获取Token
+        $this->headers['Authorization'] = site_config('addonsd.authorization_token');
         $request = new Request('POST', $this->url, $this->headers, $body);
         $res = $client->sendAsync($request)->wait();
         if($res->getStatusCode() == 200) {

+ 2 - 0
app/admin/command/TaskKs.php

@@ -80,6 +80,8 @@ class TaskKs extends Command
         "timeType": 2,
         "tradeStatus": 2
         }';
+        //获取Token
+        $this->headers['Authorization'] = site_config('addonsd.authorization_token');
         $request = new Request('POST', $this->url, $this->headers, $body);
         $res = $client->sendAsync($request)->wait();
         if($res->getStatusCode() == 200) {

+ 2 - 0
app/admin/command/TaskPdd.php

@@ -84,6 +84,8 @@ class TaskPdd extends Command
         "timeType": 2,
         "tradeStatus": 2
         }';
+        //获取Token
+        $this->headers['Authorization'] = site_config('addonsd.authorization_token');
         $request = new Request('POST', $this->url, $this->headers, $body);
         $res = $client->sendAsync($request)->wait();
         if($res->getStatusCode() == 200) {

+ 2 - 0
app/admin/command/TaskTb.php

@@ -81,6 +81,8 @@ class TaskTb extends Command
         "timeType": 2,
         "tradeStatus": 2
         }';
+        //获取Token
+        $this->headers['Authorization'] = site_config('addonsd.authorization_token');
         $request = new Request('POST', $this->url, $this->headers, $body);
         $res = $client->sendAsync($request)->wait();
         if($res->getStatusCode() == 200) {

+ 2 - 0
app/admin/command/TaskXhs.php

@@ -81,6 +81,8 @@ class TaskXhs extends Command
         "timeType": 2,
         "tradeStatus": 2
         }';
+        //获取Token
+        $this->headers['Authorization'] = site_config('addonsd.authorization_token');
         $request = new Request('POST', $this->url, $this->headers, $body);
         $res = $client->sendAsync($request)->wait();
         if($res->getStatusCode() == 200) {

+ 40 - 25
app/admin/controller/goods/FengsuShip.php

@@ -8,9 +8,13 @@ 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")]
@@ -93,7 +97,7 @@ class FengsuShip extends Backend
     #[Route('GET,POST','specs')]
     public function specs(mixed $row=null)
     {
-        $ids = $this->request->get('ids');
+        $ids = $this->request->param('ids');
         if(!$row || is_array($row)){
             $row = $this->model->find($ids);
         }
@@ -111,42 +115,53 @@ class FengsuShip extends Backend
             $this->assign('row', $row);
             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;
-            }
-        }
-        if($params['account_term'] == 2 && empty($params['cycle'])) $this->error(__('请选择周结日期'));
-        $result = false;
+        $params = $this->request->post("");
+        if (empty($params['all_data'])) $this->error(__('请选择规格'));
+        $count = 0;
         Db::startTrans();
         try {
-            $result = $row->save($params);
+
+            //插入规格
+            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($row);
+                $callback($ids);
             }
             Db::commit();
         } catch (\Exception $e) {
             Db::rollback();
             $this->error($e->getMessage());
         }
-        if (false === $result) {
-            $this->error(__('没有数据被更新'));
+
+        if ($count) {
+            return resp_json(200,'操作成功');
         }
-        $this->success();
+        $this->error(__('没有数据被更新'));
     }
 
-   
 
     //删除
     #[Route("GET,POST","del")]

+ 0 - 3
app/admin/controller/shop/CustomerSpec.php

@@ -101,9 +101,6 @@ class CustomerSpec extends Backend
         return resp_json(200,'操作成功');
     }
 
-  
-
-
     //删除
     #[Route("GET,POST","del")]
     public function del()

+ 38 - 0
app/admin/service/FengsuService.php

@@ -65,6 +65,44 @@ class FengsuService {
     }
 
 
+    /** 编辑规格-加收价格 
+     * @param array $item
+     * @return int
+     */
+    public static function setAdditionalPrice(object $shopList, object $productConfig, object $shopDelivery, object $customerSpec, string $shop_id, $variety_id, $spec_id, string $spec_name, object $item):bool
+    {
+        //判断是否存在店铺
+        $shops = $shopList::getSpecsIdByShopId($shop_id);
+     
+        //根据规格重量获取,加收价格
+        $weight = $productConfig::getWeight((int)$spec_id);
+    
+        $other_price = self::getRemoteAreaFee($item['company_name'],  $weight??0, $item['province'], $item['city']);
+        //获取包装箱
+        $box = $customerSpec::getBoxId($shops->customer_id, (int)$variety_id, (int)$spec_id);
+        $shopDelivery::create([
+            'customer_id'   => $shops->customer_id,
+            'shop_id'       => $shops->id,
+            'plat_id'       => $shops->platform,
+            'variety_id'    => $variety_id,
+            'spec_id'       => $spec_id,
+            'spec_name'     => $spec_name,
+            'box_id'        => $box->id??0,
+            'box_name'      => $box->box_name??'',
+            'variety_name'  => $box->variety_name,
+            'num'           => $item['num'],
+            'weigh'         => $weight??0,
+            'price'         => $box->price??0,
+            'total_price'   => bcmul((string)$box->price, (string)$item['num'], 2),
+            'company_name'  => $item['company_name'],
+            'waybill_no'    => $item['waybill_no'],
+            'region'        => $item['province'].' '.$item['city'],
+            'other_price'   => $other_price,
+            'ship_date'     => substr($item['consign_time'], 0, 10),
+        ]);
+        return true;
+    }
+
     /**
      * 获取偏远地区加收费用
      * @param string $express 快递公司名称

+ 10 - 3
app/admin/view/goods/fengsu_ship/index.html

@@ -43,7 +43,7 @@ export default{
             // {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:"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},
@@ -84,12 +84,19 @@ export default{
             });
         },
         specs:function (row){
+            let that=this;
             Yunqi.api.open({
                 url:'goods/fengsu_ship/specs?ids='+row.id,
                 width:1000,
                 title:__('关联规格'),
-                icon:'fa fa-list'
-            });
+                icon:'fa fa-list',
+                close:function (r){
+                    if(r){
+                        that.$refs.yuntable.reload();
+                    }
+                }
+            })
+            
         },
   
     }

+ 20 - 41
app/admin/view/goods/fengsu_ship/specs.html

@@ -3,18 +3,18 @@
         <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
-                @select="handleSelectionChange" @select-all="handleAllSelect">
-                <el-table-column type="selection" width="55">
+            <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">
+                <!-- <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-column prop="price" label="发货价" align="center" ></el-table-column> -->
                     
             </el-table>
         </el-tabs>
@@ -42,39 +42,36 @@
             },
             options: Yunqi.data.packingList,//品种
             tabValue: Object.entries(Yunqi.data.typeList).map(([value, label]) => ({ label, value }))[0].value, //选中的品种 获取到品种数据后要给他默认赋值第一个
-
             chooseSpec: [], // 当前分类选中的规格  
-
             allData: {},
-            type: 1, // 1编辑 0新增
+            type: 0, // 1编辑 0新增
         },
         methods: {
             onSubmit() {
-
                 if (this.allData == "") return;
                 let arr = Object.values(this.allData).flat(Infinity)
-
-                Yunqi.ajax.post('shop/shop_list/specs', { ids: Yunqi.data.ids, all_data: arr }, false, false, true).then(res => {
+                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(e,"选中的数据")
-                // if (e.length > 0) {
-                    this.allData[this.tabValue] = e || []
-                // }
+                console.log(this.allData,"=====this.allData")
             },
             handleClick(data, row) {
                 // 品种切换事件 可以在这里请求规格接口
@@ -86,15 +83,15 @@
             getSpecData() {
 
                 //获取规格 ;
-                Yunqi.ajax.get('shop/shop_list/get_box', { ids: Yunqi.data.ids, type_id: this.tabValue }, false, false, true).then(res => {
+                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.value == res[key]['id']);
+                            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'], value: res[key]['product_id'], price: res[key]['price'], box_id: res[key]['box_id'],box_name: res[key]['box_name'], type_name: res[key]['type_name'], type_id: this.tabValue });
+                                this.tableData.push({name: res[key]['title'], id: res[key]['id'], type_id: this.tabValue });
                             }
                         }
                         this.$nextTick(() => {
@@ -102,15 +99,14 @@
                             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.value == item.value
+                                        return row.id == item.id
                                     });
-
                                     if (matched) {
                                         this.tableData[index] = matched
                                     }
                                 })
                                 this.allData[this.tabValue].forEach(selected => {
-                                    const matched = this.tableData.find(row => row.value === selected.value);
+                                    const matched = this.tableData.find(row => row.id === selected.id);
                                     if (matched) {
                                         this.$refs['multipleTable_' + this.tabValue].toggleRowSelection(matched, true); // 勾选
                                     }
@@ -124,9 +120,7 @@
                                         } 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) {
@@ -152,7 +146,6 @@
                                         this.$refs['multipleTable_' + this.tabValue].toggleRowSelection(matched, true); // 勾选
                                     }
                                 });
-                                // this.type = 0
                             }
                         });
                     }
@@ -161,22 +154,8 @@
 
         },
         onLoad: function (query) {
-            let row = Yunqi.data.row;
-            if (row) {
-                this.type = 1
-                const grouped = JSON.parse(row).reduce((acc, item) => {
-                    const key = item.type_id;
-                    if (!acc[key]) {
-                        acc[key] = [];
-                    }
-
-                    acc[key].push(item);
-                    return acc;
-                }, {});
-                this.allData = JSON.parse(JSON.stringify(grouped))
-            } else {
-                this.type = 0
-            }
+     
+          
             //你只需要保存规格是吧, 是你末尾加了个row
             this.getSpecData()
         },

+ 2 - 0
app/admin/view/shop/shop_list/specs.html

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

+ 7 - 0
app/common/model/FengsuSku.php

@@ -4,6 +4,7 @@ declare(strict_types=1);
 namespace app\common\model;
 
 use think\Model;
+use app\admin\service\FengsuService;
 
 //风速-发货记录
 class FengsuSku Extends Model
@@ -29,4 +30,10 @@ class FengsuSku Extends Model
     {
         return self::where('shop_id', $shop_id)->where('sku_id', $spec_id)->findOrEmpty();
     }
+
+    //批量插入规格
+    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]);
+    }
 }

+ 10 - 5
app/common/model/ProductConfig.php

@@ -9,12 +9,17 @@ class ProductConfig extends BaseModel
 {
 
 
-      //获取规格重量
-      public static function getWeight(int $id): float|string|null
-      {
-          return self::where('id', $id)->value('weight');
-      }
+    //获取规格重量
+    public static function getWeight(int $id): float|string|null
+    {
+        return self::where('id', $id)->value('weight');
+    }
 
+    //获取规格信息
+    public static function getInfo(int $id): float|string|null
+    {
+        return self::where('id', $id)->field('weight,title')->findOrEmpty();
+    }
       
 
 }

File diff suppressed because it is too large
+ 0 - 0
public/assets/css/element-plus.css


Some files were not shown because too many files changed in this diff