Переглянути джерело

2023-02-06阶段性提交合并

wufeng 2 роки тому
батько
коміт
2adebb4007

+ 34 - 13
app/admin/controller/After.php

@@ -424,10 +424,10 @@ class After extends Base
                 'returnCode' => 'require',
                 'status' => 'require|number|in:1,2,4,5,6,9,10',
                 'remark' => 'requireIf:status,6|requireIf:status,2|requireIf:status,10',
-                'contactor|收货人' => 'requireIf:status,4',
-                'mobile|联系电话' => 'requireIf:status,4',
-                'addr_code|省市区编码' => 'requireIf:status,4',
-                'addr|退货地址' => 'requireIf:status,4',
+//                'contactor|收货人' => 'requireIf:status,4',
+//                'mobile|联系电话' => 'requireIf:status,4',
+//                'addr_code|省市区编码' => 'requireIf:status,4',
+//                'addr|退货地址' => 'requireIf:status,4',
             ]);
 
             if ($val->check($param) == false) throw new Exception($val->getError());
@@ -452,12 +452,33 @@ class After extends Base
                 case 9:
                     if (in_array($param['status'], [2, 4]) == false) throw new Exception('选项错误');
                     if ($this->level !== 3) throw new Exception('当前状态下只能由供应商账号操作');
+                    if ($param['status'] == 4) {
+                        if ($param['contactor'] == '') throw new Exception('收货人不能为空');
+                        if ($param['mobile'] == '') throw new Exception('联系电话不能为空');
+                        if ($param['addr_code'] == '') throw new Exception('省市区编码不能为空');
+                        if ($param['addr'] == '') throw new Exception('退货地址不能为空');
+                    }
                     break;
                 case 2:
                     if (in_array($param['status'], [10, 4]) == false) throw new Exception('选项错误');
+                    if($param['wsm_code']=='') throw new Exception('请填写退回仓库');
+                    else{
+                        $ware = Db::name('warehouse_info')
+                            ->field('contactor_name contactor,mobile,addr,addr_code')
+                            ->where(['wsm_code'=>$param['wsm_code'],'is_del'=>0])
+                            ->findOrEmpty();
+                        if(empty($ware)) throw new Exception('该仓库不存在');
+                        else $param = array_merge($param,$ware);
+                    }
                     break;
                 case 10:
                     if (in_array($param['status'], [2, 4]) == false) throw new Exception('选项错误');
+                    if ($param['status'] == 4) {
+                        if ($param['contactor'] == '') throw new Exception('收货人不能为空');
+                        if ($param['mobile'] == '') throw new Exception('联系电话不能为空');
+                        if ($param['addr_code'] == '') throw new Exception('省市区编码不能为空');
+                        if ($param['addr'] == '') throw new Exception('退货地址不能为空');
+                    }
                     break;
             }
 
@@ -1150,21 +1171,19 @@ class After extends Base
     //客户发货
     public function setdelivery()
     {
-        $param = $this->request->only(['returnCode', 'is_th', 'company', 'post_code', 'post_fee'], 'post', 'trim');
+        $param = $this->request->only(['returnCode', 'company', 'post_code', 'post_fee'], 'post', 'trim');
 
         $val = Validate::rule([
             'returnCode|售后申请单编号' => 'require',
-            'is_th|供应商是否退货' => 'require|in:0,1',
-            'company|快递公司名' => 'requireIf:is_th,1|max:255',
-            'post_code|快递单号' => 'requireIf:is_th,1|max:255',
-            'post_fee|快递费用' => 'requireIf:is_th,1|float',
+            'company|快递公司名' => 'require|max:255',
+            'post_code|快递单号' => 'require|max:255',
+            'post_fee|快递费用' => 'require|float',
         ]);
 
         if ($val->check($param) == false) return json_show(1004, $val->getError());
 
 
         $bkcode = $param['returnCode'];
-//        $is_th = $param['is_th'];
         $company = $param['company'];
         $post_code = $param['post_code'];
         $post_fee = $param['post_fee'];
@@ -1174,7 +1193,7 @@ class After extends Base
 //            return error_show(1005,"参数returnCode 不能为空");
 //        }
         $info = Db::name("order_return")
-            ->where(['returnCode' => $bkcode])
+            ->where(['is_del' => 0, 'returnCode' => $bkcode])
             ->findOrEmpty();
         if (empty($info)) return error_show(1005, "未找到售后数据");
 
@@ -1211,7 +1230,7 @@ class After extends Base
 
         Db::startTrans();
         try {
-            $returninfo = Db::name("order_returninfo")->where(["returnCode"=>$bkcode])->find();
+            $returninfo = Db::name("order_returninfo")->where(["returnCode" => $bkcode])->find();
 //            if($returninfo==false){
 //                $returninfo=[
 //                    "returnCode"=>$bkcode,
@@ -1293,7 +1312,7 @@ class After extends Base
                         "post_code" => $returninfo["post_code"],
                         "post_company" => $returninfo["post_company"],
                         "customer_code" => $info["customer_code"],
-                        "status" => $info['return_tag'] == 1 ? 4 : 1,
+                        "status" => $info['return_tag'] == 1 ? 4 : 1, //return_tag==1退回供应商,status:4完成退货,1待验收
                         "addtime" => date("Y-m-d H:i:s"),
                         "updatetime" => date("Y-m-d H:i:s")
                     ];
@@ -1382,6 +1401,8 @@ class After extends Base
 //						}else{
 //
 //						}
+
+                        //退回供应商的时候,处理库存
                         if ($info['return_tag'] == 1) {
                             $sale['th_num'] += $info['error_num'];
                             if ($sale['th_num'] == $sale['send_num'] && $sale['wsend_num'] == 0) {

+ 36 - 2
app/admin/controller/CompanyCatProfit.php

@@ -201,7 +201,41 @@ class CompanyCatProfit extends Base
             ['b.level', '=', 3],
         ];
 
-        if ($param['cat_name'] != '') $where[] = ['b.cat_name', 'like', '%' . $param['cat_name'] . '%'];
+        //如果搜索名字,要把所有符合要求的三级分类id展现出来
+        if ($param['cat_name'] != '') {
+
+            $cat_id = Db::name('cat')
+                ->where(['is_del' => 0])
+                ->whereLike('cat_name', '%' . $param['cat_name'] . '%')
+                ->column('id');
+            if (!empty($cat_id)) {
+                $catid = [];
+//                $tmp_1 = Db::name('cat')
+//                    ->where(['is_del'=>0,'pid'=>$cat_id,'level'=>3])
+//                    ->column('id');
+//                if(!empty($tmp_1)) $catid = array_merge($catid,$tmp_1);
+
+                $tmp_1 = Db::name('cat')
+                    ->where(['is_del' => 0, 'pid' => $cat_id])
+                    ->column('id');
+                if (!empty($tmp_1)) {
+                    $catid = array_merge($catid, $tmp_1);
+                    $tmp_2 = Db::name('cat')
+                        ->where(['is_del' => 0, 'pid' => $tmp_1])
+                        ->column('id');
+                    if (!empty($tmp_2)) {
+                        $catid = array_merge($catid, $tmp_2);
+                        $tmp_3 = Db::name('cat')
+                            ->where(['is_del' => 0, 'pid' => $tmp_2])
+                            ->column('id');
+                        if (!empty($tmp_3)) $catid = array_merge($catid, $tmp_3);
+                    }
+                }
+
+                if ($catid) $where[] = ['a.cat_id', 'in', $catid];
+            }
+
+        }
 
         $count = Db::name('company_cat_profit')
             ->alias('a')
@@ -216,7 +250,7 @@ class CompanyCatProfit extends Base
             ->leftJoin('cat b', 'b.id=a.cat_id')
             ->leftJoin('cat c', 'c.id=b.pid')
             ->leftJoin('cat d', 'd.id=c.pid')
-            ->field('a.id,concat_ws("_",d.cat_name,c.cat_name,b.cat_name) cat_name,a.cat_id,a.rate,a.order_rate,a.money_rate,a.low_rate,a.sale_rate,a.status')
+            ->field('a.id,concat_ws("_",d.cat_name,c.cat_name,b.cat_name) cat_name,a.cat_id,a.rate,a.order_rate,a.money_rate,a.low_rate,a.sale_rate,a.status,c.pid')
             ->where($where)
             ->order(['a.id' => 'desc'])
             ->page($param['page'], $param['size'])

+ 24 - 7
app/admin/controller/Consult.php

@@ -1548,11 +1548,19 @@ class Consult extends Base
         if($status===''){
             return error_show(1005,"参数status不能为空");
         }
-        $catinfo = Db::name("cat")->where(["id"=>$bids['cat_id']])->find();
-        $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
+//        $catinfo = Db::name("cat")->where(["id"=>$bids['cat_id']])->find();
+
+        $tmp = Db::name('consult_order')
+            ->field('id,companyNo,platform_code')
+            ->where(['is_del'=>0,'zxNo'=>$bids['zxNo']])
+            ->findOrEmpty();
+
+        $catinfo = get_budget($bids['cat_id'],$tmp['companyNo']??'',$tmp['platform_code']??0,true);
+
+        $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
         $rate = isset($catinfo['rate']) ? $catinfo['rate']/100:0; //业务主管利率
-        $money_rate = isset($catinfo['money_rate']) ? $catinfo['money_rate']/100:0;//财务主管利率
-        $lower_rate = isset($catinfo['lower_rate']) ? $catinfo['lower_rate']/100:0;//boss主管利率
+        $money_rate = isset($catinfo['money_rate']) ? $catinfo['money_rate']:0;//财务主管利率
+        $lower_rate = isset($catinfo['lower_rate']) ? $catinfo['lower_rate']:0;//boss主管利率
         if($bids['is_gold_price']==1){
             $gold = Db::name("gold_price1")->where(["type"=>$bids['metal_id'],"is_del"=>0,"status"=>1])->order("addtime desc")
                 ->find();
@@ -1719,13 +1727,22 @@ class Consult extends Base
             $info["brand_name"]="";
             $info["brand_id"]="";
         }
-        $catinfo = Db::name("cat")->where(["id"=>$bidinfos['cat_id']])->find();
+//        $catinfo = Db::name("cat")->where(["id"=>$bidinfos['cat_id']])->find();
+
+        //获取竞价单详情
+        $tmp = Db::name('consult_order')
+            ->field('id,companyNo,platform_code')
+            ->where(['is_del'=>0,'zxNo'=>$bidinfos['zxNo']])
+            ->findOrEmpty();
+
+        $catinfo = get_budget($bidinfos['cat_id'],$tmp['companyNo']??'',$tmp['platform_code']??0,true);
+
         $info['can']= isset($bidinfos['cat_id']) && $bidinfos['cat_id'] !=0 ? made($bidinfos['cat_id']):[];
         $unit =Db::name("unit")->where(["id"=>$bidinfos['unit_id']])->find();
         $info['unit'] = isset($unit['unit'])?$unit['unit']:'';
         $bidinfoe = Db::name("consult_info")->where(["infoNo"=>$info["infoNo"]])->find();
         $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
-        $lower_rate = isset($catinfo['lower_rate']) ? $catinfo['lower_rate']/100:0;//boss主管利率
+        $lower_rate = isset($catinfo['lower_rate']) ? $catinfo['lower_rate']:0;//boss主管利率
         $info['budget'] =$budget;
         $info['rate_status'] =0; //利率状态 0 业务主管利率无法通过 1 财务主管利率无法通过 2 boos利率无法通过 3 完全通过
         if($info['after_rate']>=$catinfo['rate']){
@@ -1761,7 +1778,7 @@ class Consult extends Base
                 $gold = Db::name("gold_price1")->where(["type"=>$bidinfos["metal_id"],"is_del"=>0,"status"=>1])->order("addtime desc")
                     ->find();
                 $info['gold_price'] =$gold['price'];
-                $lower_price = ($bidinfos['demo_fee']/$consultinfos['num']+$bidinfos['delivery_fee']+$bidinfos['open_fee']/$consultinfos['num'] + $bidinfos['good_weight']* $gold["price"] +$bidinfos['cost_fee']*$bidinfos['good_weight'] + $bidinfos['pakge_fee'] +$bidinfos['mark_fee'] + $bidinfos['cert_fee'] + $bidinfos['nake_fee']) / (1 - $lower_rate);
+                $lower_price =($bidinfos['demo_fee']/$consultinfos['num']+$bidinfos['delivery_fee']+$bidinfos['open_fee']/$consultinfos['num'] + $bidinfos['good_weight']* $gold["price"] +$bidinfos['cost_fee']*$bidinfos['good_weight'] + $bidinfos['pakge_fee'] +$bidinfos['mark_fee'] + $bidinfos['cert_fee'] + $bidinfos['nake_fee']) / (1 - $lower_rate);
 
             }else{
                 if($bidinfos['nake_fee']!=0){

Різницю між файлами не показано, бо вона завелика
+ 437 - 421
app/admin/controller/Reorder.php


+ 7 - 2
app/admin/controller/Resign.php

@@ -345,8 +345,13 @@ class Resign extends Base
         }
         $supplier =Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
         $info['supplier_name'] = isset($supplier['name'])?$supplier['name']:"";
-        $company =Db::name("business")->where(["companyNo"=>$info['companyNo']])->find();
-        $info['company_name'] = isset($company['company'])?$company['company']:"";
+
+        $userCommon = new \app\admin\common\User();
+        $tmp = $userCommon->handle('getCodeAndName', ['code' => $info['companyNo']]);
+        if (!isset($tmp['code']) || $tmp['code'] != 0) return json_show($tmp['code'], $tmp['message'], $tmp['data']);
+
+//        $company =Db::name("business")->where(["companyNo"=>$info['companyNo']])->find();
+        $info['company_name'] = $tmp['data'][$info['companyNo']] ?? '';
         $info['can']=$int;
         return app_show(0,"获取成功",$info);
     }

+ 19 - 8
app/admin/controller/Sale.php

@@ -956,15 +956,26 @@ class Sale extends Base
         if ($companyNo == "") {
             return error_show(1003, "参数 companyNo 不能为空");
         }
-        $company = Db::name("business")->where(["companyNo" => $companyNo, "is_del" => 0])->find();
-        if ($company == false) {
-            return error_show(1003, "业务公司数据未找到");
-        }
+
+        $userCommon = new \app\admin\common\User();
+        $tmp = $userCommon->handle('bInfo',['companyNo'=>$companyNo]);
+        if(!isset($tmp['code']) || $tmp['code']!=0) return json_show($tmp['code'],$tmp['message'],$tmp['data']);
+        if(empty($tmp['data'])) return json_show(1003, "业务公司数据未找到");
+
+//        $company = Db::name("business")->where(["companyNo" => $companyNo, "is_del" => 0])->find();
+//        if ($company == false) {
+//            return error_show(1003, "业务公司数据未找到");
+//        }
         $remark = isset($this->post['remark']) && $this->post['remark'] != "" ? trim($this->post['remark']) : "";
-		 $supplier_temp_info=Db::name("supplier")
-                ->field('id,person,personid')
-                ->where(["code"=>$zxinfo['supplierNo']])
-                ->findOrEmpty();
+
+        $tmp = $userCommon->handle('sInfo',['code'=>$zxinfo['supplierNo']]);
+        if(!isset($tmp['code']) || $tmp['code']!=0) return json_show($tmp['code'],$tmp['message'],$tmp['data']);
+        $supplier_temp_info = $tmp['data'];
+//        if(empty($tmp['data'])) return json_show(1003, "业务公司数据未找到");
+//		 $supplier_temp_info=Db::name("supplier")
+//                ->field('id,person,personid')
+//                ->where(["code"=>$zxinfo['supplierNo']])
+//                ->findOrEmpty();
         $orderCode = makeNo("QR");
         $spuCode = $zxinfo['spuCode'];
         $skuCode = "";

+ 11 - 4
app/admin/controller/WareHouse.php

@@ -60,10 +60,17 @@ class WareHouse extends Base
         if($companyNo==""){
             return error_show(1004,"参数companyNo不能为空");
         }
-        $company = Db::name("business")->where(["companyNo"=>$companyNo,"is_del"=>0])->find();
-        if($company==false){
-            return error_show(1004,"业务企业未找到");
-        }
+//        $company = Db::name("business")->where(["companyNo"=>$companyNo,"is_del"=>0])->find();
+//        if($company==false){
+//            return error_show(1004,"业务企业未找到");
+//        }
+
+        $userCommon = new \app\admin\common\User();
+        $tmp = $userCommon->handle('getCodeAndName', ['code' => $companyNo]);
+        if (!isset($tmp) || $tmp['code'] != 0) return json_show($tmp['code'], $tmp['message'], $tmp['data']);
+        if (!isset($tmp['data'][$companyNo])) return json_show(1004, '业务企业未找到');
+
+
         $wsm_type = isset($post['wsm_type']) && $post['wsm_type']!=="" ? intval($post['wsm_type']):"1";
         $wsm_name = isset($post['wsm_name']) && $post['wsm_name']!=="" ? trim($post['wsm_name']):"";
         $wsm_mobile = isset($post['wsm_mobile']) && $post['wsm_mobile']!=="" ? trim($post['wsm_mobile']):"";

+ 2 - 2
app/admin/route/app.php

@@ -315,12 +315,12 @@ Route::rule('goldadd', 'admin/Gold/add');
 Route::rule('gold', 'admin/Gold/GetByType');
 
 Route::rule('reorderlist', 'admin/Reorder/list');//退货单列表
-Route::rule('reordercreate', 'admin/Reorder/create');
+Route::rule('reordercreate', 'admin/Reorder/create');//批量退货
 Route::rule('reorderinfo', 'admin/Reorder/info');
 Route::rule('reorderdel', 'admin/Reorder/delete');
 Route::rule('reorderexam', 'admin/Reorder/exam');
 Route::rule('reorderzx', 'admin/Reorder/zxcreate');
-Route::rule('reorderall', 'admin/Reorder/allReturn');
+Route::rule('reorderall', 'admin/Reorder/allReturn');//全部退货
 
 Route::rule('salezxcreate', 'admin/Salezx/create');
 Route::rule('salezxedit', 'admin/Salezx/edit');

+ 14 - 5
app/common.php

@@ -1596,18 +1596,27 @@ if (!function_exists('get_headquarters_code_and_name')) {
 
 //获取毛利率
 if (function_exists('get_budget') == false) {
-    function get_budget(int $cat_id = 0, string $relaComNo = '', int $platform_id = 0)
+    function get_budget(int $cat_id = 0, string $relaComNo = '', int $platform_id = 0,bool $is_show_more=false)
     {
         $sale_rate_1 = Db::name('company_cat_profit')
             ->where(['is_del' => 0, 'cat_id' => $cat_id, 'companyNo' => $relaComNo])
-            ->value('sale_rate', 0);
+            ->findOrEmpty();
 
         $sale_rate_2 = Db::name('company_platform_cat_profit')
             ->where(['is_del' => 0, 'companyNo' => $relaComNo, 'platform_id' => $platform_id, 'cat_id' => $cat_id, 'status' => 1])
-            ->value('sale_rate', 0);
+            ->findOrEmpty();
 
-        //此时的毛利率要取两个毛利的和
-        return ($sale_rate_1 + $sale_rate_2) / 100;
+        if ($is_show_more) {
+            //返回多个字段的和
+            return [
+                'rate' => (($sale_rate_1['rate'] ?? 0) + ($sale_rate_2['rate'] ?? 0)) / 100,
+                'order_rate' => (($sale_rate_1['order_rate'] ?? 0) + ($sale_rate_2['order_rate'] ?? 0)) / 100,
+                'money_rate' => (($sale_rate_1['money_rate'] ?? 0) + ($sale_rate_2['money_rate'] ?? 0)) / 100,
+                'low_rate' => (($sale_rate_1['low_rate'] ?? 0) + ($sale_rate_2['low_rate'] ?? 0)) / 100,
+                'sale_rate' => (($sale_rate_1['sale_rate'] ?? 0) + ($sale_rate_2['sale_rate'] ?? 0)) / 100,
+                'lower_rate'=>0,//boss利率,默认0,数据库没有这个值
+            ];
+        } else return (($sale_rate_1['sale_rate'] ?? 0) + ($sale_rate_2['sale_rate'] ?? 0)) / 100; //此时的毛利率要取两个毛利的和
 
     }
 }

Деякі файли не було показано, через те що забагато файлів було змінено