Эх сурвалжийг харах

Merge branch 'master-new-wgg' of wugg/phpstock into master-new

wugg 1 жил өмнө
parent
commit
d02de2bdc8

+ 41 - 361
app/admin/controller/After.php

@@ -7,7 +7,7 @@ use app\admin\model\DataGroup as DataGroupModel;
 use app\admin\model\GoodLog;
 use app\admin\model\GoodStockInfo;
 use app\admin\model\ProcessOrder;
-use think\App;
+use app\admin\model\ThData;use think\App;
 use think\Exception;
 use think\facade\Db;
 use think\facade\Validate;
@@ -505,7 +505,7 @@ class After extends Base
     //9供应商审核,
     //10业务公司修改待供应商确认
     //11待设置退货工单(已收到货才有),
-    //12待库管收货(已收到货才有)
+    //12待库管收货(已收到货才有),
     public function status()
     {
         try {
@@ -544,7 +544,7 @@ class After extends Base
                     //库存品不允许供应商审核,只允许走2-11-4-12-5流程
                     break;
                 case 9:
-                    if ((($info['is_receive'] == 1) && (in_array($param['status'], [2, 4]) == false) || (($info['is_receive'] == 0) && (in_array($param['status'], [2, 5]) == false)))) throw new Exception('选项错误');
+                    if (in_array($param['status'], [2, 4]) == false) throw new Exception('选项错误');
                     if ($param['status'] == 2 && $param['remark'] == '') throw new Exception('remark不能为空');
                     if ($param['status'] == 4) {
                     	$info['return_tag'] = 1;
@@ -552,16 +552,17 @@ class After extends Base
                         if ($param['mobile'] == '') throw new Exception('联系电话不能为空');
                         if ($param['addr_code'] == '') throw new Exception('省市区编码不能为空');
                         if ($param['addr'] == '') throw new Exception('退货地址不能为空');
+                    }else{
+                    	$info['return_tag'] = 2;
                     }
                     break;
                 case 2:
 
-                    if ((($info['is_receive'] == 1) && (in_array($param['status'], [10, 11]) == false) || (($info['is_receive'] == 0) && (in_array($param['status'], [10, 5]) == false)))) throw new Exception('选项错误');
-                    if ($info['order_type'] == 1 && $param['status'] != 11) throw new Exception('选项错误');//库存品不允许供应商审核,只允许走2-11-4-12-5流程
-
+                    if ((($info['order_type'] == 1) && (in_array($param['status'], [10, 11]) == false)
+                    || (($info['order_type'] != 1) && (in_array($param['status'], [10,4]) == false)))) throw new Exception('选项错误');
                     break;
                 case 10:
-                    if ((($info['is_receive'] == 1) && (in_array($param['status'], [2, 4]) == false) || (($info['is_receive'] == 0) && (in_array($param['status'], [2, 5]) == false)))) throw new Exception('选项错误');
+                    if (in_array($param['status'], [2, 4]) == false) throw new Exception('选项错误');
                     if ($param['status'] == 2 && $param['remark'] == '') throw new Exception('remark不能为空');
 
                     if ($param['status'] == 4) {
@@ -570,6 +571,8 @@ class After extends Base
                         if ($param['mobile'] == '') throw new Exception('联系电话不能为空');
                         if ($param['addr_code'] == '') throw new Exception('省市区编码不能为空');
                         if ($param['addr'] == '') throw new Exception('退货地址不能为空');
+                    }else{
+                    	$info['return_tag'] = 2;
                     }
                     break;
             }
@@ -582,8 +585,8 @@ class After extends Base
 			}
             //获取最新的供应商负责人
             $s_info = \app\admin\common\User::getIns()->handle('sInfo', ['code' => $info['supplierNo']]);
-            $info['person_id'] = $s_info['data']['personid'];
-            $info['person'] = $s_info['data']['person'];
+            $info['person_id'] = $s_info['data']['personid']??"0";
+            $info['person'] = $s_info['data']['person']??"";
 
             //当处于以下节点时,level2账号必须是供应商负责人操作,level3账号不做限制
 //            if (in_array($info['status'], [9, 10]) && ($this->level == 2) && ($this->uid != $info['person_id'])) return json_show(1004, '您不是供应商负责人,此时无权操作');
@@ -600,13 +603,10 @@ class After extends Base
 
                 //判断 退回供应商 or 退回业务公司
                 if ($info['status'] == 2 && $param['status'] == 11) {
-                    $info['return_tag'] = 2;
                     //退入次品仓,维护
                     $wsm = Db::name('warehouse_info')->where(['is_del' => 0, 'wsm_code' => $param['wsm_code']])->findOrEmpty();
                     if (empty($wsm)) throw new Exception('返回仓库不存在');
                     if ($wsm['wsm_type'] != 4) throw new Exception('不是次品仓');
-
-//                    if ($wsm['wsm_type'] == 4) {
                     Db::name('order_returninfo')->insert([
                         'returnCode' => $param['returnCode'],
                         'return_wsm' => $param['wsm_code'],
@@ -620,7 +620,6 @@ class After extends Base
                         'gys_remark' => '',
                         'addtime' => $date,
                     ]);
-//                    }
 
                 }
 
@@ -629,7 +628,6 @@ class After extends Base
                 $var = $info['status'];
                 $info['status'] = $param['status'];
                 $info['updatetime'] = $date;
-
                 $up = Db::name("order_return")->save($info);
                 if ($up) {
 
@@ -724,29 +722,7 @@ class After extends Base
                     $order = ["order_code" => $info['returnCode'], "status" => $var, "action_remark" => '', "action_type" => "edit"];
                     ActionLog::logAdd($action_log_user, $order, "SHD", $info['status'], $this->post);
 
-//                switch ($param['status']) {
-//                    //待采购审核
-//                    case 2:
-//                        $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['person_id'], 'wait_name' => $info['person'], 'holder_id' => $info['person_id']];
-//                        break;
-//
-//                    //待设置仓库
-//                    case 3:
-//                        $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['cgderid'], 'wait_name' => $info['cgder'], 'holder_id' => $info['cgderid']];
-//                        break;
-//
-//                    //待客户退货
-//                    case 4:
-//                        $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['apply_id'], 'wait_name' => $info['apply_name'], 'holder_id' => $info['apply_id']];
-//                        break;
-//
-//                    default:
-//                        $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'holder_id' => $info['apply_id']];
-//                }
-//                if (in_array($param['status'], [2, 3])) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['cgderid'], 'wait_name' => $info['cgder'],'holder_id'=>$info['cgderid']];
-//                elseif ($param['status'] == 4) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['apply_id'], 'wait_name' => $info['apply_name'],'holder_id'=>$info['apply_id']];
-//                else $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var,'holder_id'=>$info['apply_id']];
-                    $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['person_id'], 'wait_name' => $info['person'], 'holder_id' => $info['person_id']];
+				   $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['person_id'], 'wait_name' => $info['person'], 'holder_id' => $info['person_id']];
 
                     ProcessOrder::AddProcess($action_log_user, $process);
                     Db::commit();
@@ -1312,25 +1288,6 @@ class After extends Base
             ->where(["outCode" => $info["outCode"], "is_del" => 0])
             ->findOrEmpty();
         if (empty($out)) return error_show(1005, "未找到发货单数据");
-
-//        $is_th = isset($this->post['is_th'])&&$this->post['is_th']!=="" ? intval($this->post['is_th']):"";
-//        if($is_th===""){
-//            return error_show(1005,"参数is_th不能为空");
-//        }
-//        $company=isset($this->post['company'])&&$this->post['company']!=""?trim($this->post['company']):"";
-//        $post_code=isset($this->post['post_code'])&&$this->post['post_code']!=""?trim($this->post['post_code']):"";
-//        $post_fee=isset($this->post['post_fee'])&&$this->post['post_fee']!==""?floatval($this->post['post_fee']):"";
-//        if($is_th==1){
-//            if($company==""){
-//                return error_show(1005,"参数company不能为空");
-//            }
-//            if($post_code==""){
-//                return error_show(1005,"参数post_code不能为空");
-//            }
-//            if($post_fee===""){
-//                return error_show(1005,"参数post_fee不能为空");
-//            }
-//        }
         $sale = Db::name('sale')
             ->where(['orderCode' => $info['orderCode'], "is_del" => 0])
             ->findOrEmpty();
@@ -1406,9 +1363,7 @@ class After extends Base
                     //如果售后已完成,维护销售单、发货单和采购单
                     if ($info['status'] == 5) {
                         $sale['th_num'] += $info['error_num'];
-//                        if ($sale['th_num'] == $sale['send_num'] && $sale['wsend_num'] == 0)  $sale['status'] = 3;
                         if ($sale['th_num'] == $sale['good_num']) $sale['status'] = 3;
-
                         $sale['th_fee'] += round($info['error_num'] * $sale['sale_price'], 2);
                         $sale['updatetime'] = date("Y-m-d H:i:s");
                         Db::name("sale")->save($sale);
@@ -1419,14 +1374,6 @@ class After extends Base
                         $out['updatetime'] = date("Y-m-d H:i:s");
                         $upout = Db::name("order_out")->save($out);
                         if ($upout == false) throw new Exception('出库单数据更新失败');
-
-                        //发货工单,有可能会有多个,要按照顺序扣减发货数
-//                        Db::name('order_out_child')
-//                        ->data(['updatetime' => date("Y-m-d H:i:s")])
-//                            ->where(['is_del' => 0, 'outCode' => $info["outCode"]])
-//                            ->dec('num', $info['error_num'])
-//                            ->update();
-
                         $error_num = $info['error_num'];
                         $tmp_ooc = Db::name('order_out_child')
                             ->where(['is_del' => 0, 'outCode' => $info["outCode"]])
@@ -1452,11 +1399,11 @@ class After extends Base
 
                         }
 
-                        //如果供应商承担,维护采购单
-                        if ($info['return_tag'] == 1) {
+                        //如果供应商承担,维护采购单 todo:: 新逻辑 无论供应商是否同意退货采购单都要减退回
+//                        if ($info['return_tag'] == 1) {
                             $cgd_info = Db::name('order_num')
                                 ->alias('a')
-                                ->field('a.id,b.id cgd_id,b.good_price')
+                                ->field('a.id,b.id cgd_id,b.good_price,b.cgdNo')
                                 ->leftJoin('purchease_order b','b.cgdNo=a.cgdNo')
                                 ->where(['a.orderCode' => $info['orderCode']])
                                 ->findOrEmpty();
@@ -1469,305 +1416,38 @@ class After extends Base
                                     ->update();
                                if($up==false) throw new Exception('采购单更新失败');
                             }
-                        }
-						 $data = [
-                            "orderCode" => $info['orderCode'],
-                            "th_type" => 2,
-                            "th_num" => $info['error_num'],
-                            "th_fee" => round($info['error_num'] * $sale['sale_price'], 2),
-                            "thCode" => $info['returnCode'],
-                            "spuCode" => $sale['good_code'],
-                            "good_name" => $sale['good_name'],
-                            "cat_id" => $sale['cat_id'],
-                            "apply_id" => $info['apply_id'],
-                            "apply_name" => $info['apply_name'],
-                            "addtime" => $info['updatetime'],
-                            "status" => 1,
-                            "is_del" => 0
-                        ];
-                        $inse = Db::name("th_data")->insert($data);
-                        if ($inse == false) throw new Exception('退回单更新失败');
+//                        }
+//todo::供应商不同意退货 生成转库存数据
+					
                     }
-
+				
                     Db::commit();
+                    if($info["status"]==5){
+                    	 $data = [
+                            'orderCode' => $info['orderCode'],
+                            'th_type' => 2,
+                            'th_num' => $info['error_num'],
+                            'th_fee' => round($info['error_num'] * $sale['sale_price'], 2),
+                            'thCode' => $info['returnCode'],
+                            'spuCode' => $sale['good_code'],
+                            'good_name' => $sale['good_name'],
+                            'sale_price' => $sale['sale_price'],
+                            'cgd_price' => $cgd_info['good_price'],
+                            'cgdNo' => $cgd_info['cgdNo'],
+                            'cat_id' => $sale['cat_id'],
+                            'apply_id' => $info['apply_id'],
+                            'apply_name' => $info['apply_name'],
+                            'addtime' => $info['updatetime'],
+                            'status' => 1,
+                            'is_del' => 0
+                        ];
+                        event('thdata',$data);
+                    }
                     return json_show(0, '退货成功');
                 } else throw new Exception('修改售后申请单状态失败');
 
             } else throw new Exception('退货失败');
 
-            //售后退货单数据
-//                    $thNo = makeNo("ST");
-//                    $thdata = [
-//                        "thNo" => $thNo,
-//                        "orderCode" => $out["orderCode"],
-//                        "outCode" => $out["outCode"],
-//                        "order_type" => $info["order_type"],
-//                        "returnCode" => $info["returnCode"],
-//                        "good_code" => $info["good_code"],
-//                        "good_name" => $info["good_name"],
-//                        "return_wsm" => $returninfo["return_wsm"],
-//                        "total_fee" => round($sale['sale_price'] * $info["error_num"], 2),
-//                        "good_price" => $sale['sale_price'],
-//                        "platform_id" => $sale['platform_id'],
-//                        "return_msg" => $info["error_msg"],
-//                        "return_num" => $info["error_num"],
-//                        "normal_num" => 0,
-//                        "received_num" => 0,
-//                        "apply_id" => $info['apply_id'],
-//                        "apply_name" => $info['apply_name'],
-//                        "cgder" => $info['cgder'],
-//                        "cgderid" => $info['cgderid'],
-//                        "person" => $info['person'],
-//                        "person_id" => $info['person_id'],
-//                        "contactor" => $returninfo["contactor"],
-//                        "mobile" => $returninfo["mobile"],
-//                        "addr" => $returninfo["addr"],
-//                        "addr_code" => $returninfo["addr_code"],
-//                        "return_code" => $info["error_code"],
-//                        "post_fee" => $returninfo["post_fee"],
-//                        "post_code" => $returninfo["post_code"],
-//                        "post_company" => $returninfo["post_company"],
-//                        "customer_code" => $info["customer_code"],
-//                        "customer_name" => $info["customer_name"],
-//                        "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"),
-//                        'supplierNo' => $info['supplierNo'],
-//                        'supplierName' => $info['supplierName'],
-//                        'companyNo' => $info['companyNo'],
-//                        'companyName' => $info['companyName'],
-//                    ];
-//                    $sav = Db::name("order_back")->insert($thdata, true);
-//                    if ($sav) {
-//
-//                        //修改状态,添加待办
-//                        ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
-//                            "order_code" => $thdata['thNo'],//销售单code
-//                            "status" => $thdata['status'],//这里的status是之前的值
-//                            "action_remark" => '',//备注
-//                            "action_type" => "create"//新建create,编辑edit,更改状态status
-//                        ], "CKTHD", $thdata['status'], $thdata);
-//
-//
-//                        //售后退货单,供应商不同意退货,退回到业务公司仓的时候,要把待办数据推给供应商负责人和库管人员
-//                        if ($thdata['status'] == 1) {
-//
-//                            //31库管人员,41库管-张凯旋
-//                            $uids = Db::name('user_role')
-//                                ->where(['is_del' => 0, 'roleid' => [31, 41], 'status' => 1])
-//                                ->column('uid');
-//
-//                            ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
-//                                "order_type" => 'CKTHD',
-//                                "order_code" => $thdata['thNo'],//销售单code
-//                                "order_id" => $sav,
-//                                "order_status" => $thdata['status'],
-//                                "before_status" => 0,
-//                                'handle_user_list' => implode(',', array_merge($uids, [$sale['cgderid']])),
-//                            ]);
-//                        } else {
-//                            ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
-//                                "order_type" => 'CKTHD',
-//                                "order_code" => $thdata['thNo'],//销售单code
-//                                "order_id" => $sav,
-//                                "order_status" => $thdata['status'],
-//                                "before_status" => 0
-//                            ]);
-//                        }
-//
-//
-//                        //维护台账记录
-////                        Db::name('standing_book')
-////                            ->where(['returnCode' => $bkcode])
-////                            ->update([
-////                                'thNo' => $thNo,
-////                                'updatetime' => date("Y-m-d H:i:s")
-////                            ]);
-//                        Db::execute("UPDATE `wsm_standing_book` SET `thNo`=CONCAT(IFNULL(`thNo`,''),',{$thNo}'),`updatetime`='" . date('Y-m-d H:i:s') . "' WHERE FIND_IN_SET('{$bkcode}',`returnCode`)");//这里的returnCode可能有多个
-//                        // 库存品退货 不退商品 需要计算成本
-////						if($info['except_code']==1){
-////							$sabebn =Db::name("sale_info")->where(["orderCode"=>$info['orderCode']])->select()->toArray();
-////                            	 if(!empty($sabebn)){
-////                        	$total_num =$info["error_num"];
-////                        	foreach ($sabebn as $ve){
-////
-////                        		$tempnum=0;
-////                        		if ($total_num==0) break;
-////                        		if($total_num>=$ve['num']){
-////                        			$tempnum = $ve['num'];
-////                        			$total_num-=$ve['num'];
-////                        			$ve['num']=0;
-////                        		}else{
-////                        		    $tempnum = $total_num;
-////                        			$ve['num']-=$total_num;
-////                        			$total_num=0;
-////                        		}
-////                        		$bnin=GoodStockInfo::ReturnAdd($stockid,$ve['bnCode'],$tempnum,$ve['stockid']);
-////                        		if($bnin==false){
-////                        			 Db::rollback();
-////                                    return error_show(1005, '可售商品Bn库存数入库失败');
-////                        		}
-////								$up=Db::name("sale_info")->save($ve);
-////                        		if($up==false){
-////                        			 Db::rollback();
-////                                    return error_show(1005, '可售商品Bn库存数入库失败');
-////                        		}
-////								$bnin=GoodStockInfo::ReturnBn($info['returnCode'],$ve['id'],$tempnum);
-////                        		if($bnin==false){
-////                        			 Db::rollback();
-////                                    return error_show(1005, '可售商品Bn库存数入库失败');
-////                        		}
-////                        	}
-////                        }
-////						}else{
-////
-////						}
-//
-//                        //退回供应商的时候,处理库存
-//                        if ($info['return_tag'] == 1) {
-//                            $sale['th_num'] += $info['error_num'];
-//                            if ($sale['th_num'] == $sale['send_num'] && $sale['wsend_num'] == 0) {
-//                                $sale['status'] = 3;
-//                            }
-//                            $sale['th_fee'] += round($info['error_num'] * $sale['sale_price'], 2);
-//                            $sale['updatetime'] = date("Y-m-d H:i:s");
-//                            $uap = Db::name("sale")->save($sale);
-//
-//                            if ($uap == false) throw new Exception('销售单订单更新失败');
-////                            if($uap==false){
-////                                Db::rollback();
-////                                return error_show(1005,'销售单订单更新失败');
-////                            }
-//                            if ($sale['is_stock'] == 0) {
-//                                $ordernum = Db::name("order_num")
-//                                    ->where(['orderCode' => $info['orderCode']])
-//                                    ->find();
-//                                if ($ordernum == false) throw new Exception('未找到关联采购单1');
-////	                            if($ordernum==false){
-////	                                Db::rollback();
-////	                                return error_show(1005,'未找到关联采购单');
-////	                            }
-//                                $ordernum['send_num'] -= $info['error_num'];
-//                                $orderup = Db::name("order_num")->save($ordernum);
-//
-//                                if ($orderup == false) throw new Exception('关联数据更新失败');
-//
-////	                            if($orderup==false){
-////	                                Db::rollback();
-////	                                return error_show(1005,'关联数据更新失败');
-////	                            }
-//                                $cgd = Db::name("purchease_order")
-//                                    ->where(["cgdNo" => $ordernum['cgdNo'], "is_del" => 0])
-//                                    ->findOrEmpty();
-//                                if (empty($cgd)) throw new Exception('未找到采购单数据');
-////	                            if($cgd==false){
-////	                                Db::rollback();
-////	                                return error_show(1005,'未找到采购单数据');
-////	                            }
-//                                $cgd['th_num'] += $info['error_num'];
-//                                if ($cgd['th_num'] == $cgd['send_num'] && $cgd['wsend_num'] == 0) {
-//                                    $cgd['status'] = 4;
-//                                }
-//                                $cgd['th_fee'] += round($info['error_num'] * $cgd['good_price'], 2);
-//                                $cgd['updatetime'] = date("Y-m-d H:i:s");
-//                                $cgdup = Db::name("purchease_order")->save($cgd);
-//
-//                                if ($cgdup == false) throw new Exception('采购单数据更新失败');
-////	                            if($cgdup==false){
-////	                                Db::rollback();
-////	                                return error_show(1005,'采购单数据更新失败');
-////	                            }
-//                            }
-//
-//                            $sabebn = Db::name("sale_info")
-//                                ->where([["orderCode", "=", $info['orderCode']], ["num", ">", 0]])
-//                                ->select()
-//                                ->toArray();
-//                            if (!empty($sabebn)) {
-//                                $total_num = $info["error_num"];
-//                                foreach ($sabebn as $ve) {
-//                                    $tempnum = 0;
-//                                    if ($total_num == 0) break;
-//                                    if ($total_num >= $ve['num']) {
-//                                        $tempnum = $ve['num'];
-//                                        $total_num -= $ve['num'];
-//                                        $ve['th_num'] += $ve['num'];
-//                                        $ve['num'] = 0;
-//                                    } else {
-//                                        $tempnum = $total_num;
-//                                        $ve['num'] -= $total_num;
-//                                        $ve['th_num'] += $total_num;
-//                                        $total_num = 0;
-//                                    }
-//
-//                                    if ($info['except_code'] == 1) {
-////		                                	if($sale['is_stock']==1){
-////		                                		$bnin=GoodStockInfo::AddBn($ve['stockid'],$ve['bnCode'],$tempnum);
-////				                                if($bnin==false){
-////				                                     Db::rollback();
-////				                                    return error_show(1005, '可售商品Bn库存数入库失败');
-////				                                }
-////		                                	}
-//                                        $up = Db::name("sale_info")->save($ve);
-//
-//                                        if ($up == false) throw new Exception('可售商品Bn库存数入库失败');
-////				                                if($up==false){
-////				                                     Db::rollback();
-////				                                    return error_show(1005, '可售商品Bn库存数入库失败');
-////				                                }
-//                                    }
-//
-//                                    $bnin = GoodStockInfo::ReturnBn($info['returnCode'], $ve['id'], $tempnum);
-//                                    if ($bnin == false) throw new Exception('可售商品Bn库存数入库失败');
-////		                                if($bnin==false){
-////		                                     Db::rollback();
-////		                                    return error_show(1005, '可售商品Bn库存数入库失败');
-////		                                }
-//                                }
-//                            }
-//                            if ($info['error_num'] >= $out['send_num']) {
-//                                $out['status'] = 4;
-//                                $out['updatetime'] = date("Y-m-d H:i:s");
-//                                $upout = Db::name("order_out")->save($out);
-//                                if ($upout == false) throw new Exception('出库单数据更新失败');
-////                                    if($upout==false){
-////                                        Db::rollback();
-////                                        return error_show(1005,'出库单数据更新失败');
-////                                    }
-//                            }
-//                            $data = [
-//                                "orderCode" => $info['orderCode'],
-//                                "th_type" => 3,
-//                                "th_num" => $info['error_num'],
-//                                "th_fee" => round($sale['sale_price'] * $info["error_num"], 2),
-//                                "thCode" => $thNo,
-//                                "spuCode" => $sale['good_code'],
-//                                "good_name" => $sale['good_name'],
-//                                "cat_id" => $sale['cat_id'],
-//                                "apply_id" => $info['apply_id'],
-//                                "apply_name" => $info['apply_name'],
-//                                "addtime" => date("Y-m-d H:i:s"),
-//                                "status" => 1,
-//                                "is_del" => 0
-//                            ];
-//                            $inse = Db::name("th_data")->insert($data);
-//                            if ($inse == false) throw new Exception('退货单创建失败');
-//
-//
-////                            if($inse==false){
-////                                Db::rollback();
-////                                return error_show(1004,"退货单更新失败");
-////                            }
-//
-//                        }
-//
-//                        Db::commit();
-//                        return app_show(0, "退货单新建成功", ["thNo" => $thNo]);
-//                    }
-//                }
-//            }
-//            Db::commit();
-//            return json_show(0, '退货成功');
         } catch (Exception $e) {
             Db::rollback();
             return json_show(1004, $e->getMessage());

+ 75 - 18
app/admin/controller/Manager.php

@@ -26,42 +26,48 @@ class Manager extends Base
    		]);
    	if($valid->check($param)==false) return error_show(1004,$valid->getError());
    	$orderinfo= Db::name("sale")->whereIn("orderCode",$param['orderCode'])->where("supplierNo",$param['companyNo'])
-   	->column("orderCode");
+   	->column("orderCode,manager,managerid","orderCode");
    	if(count($orderinfo)!= count($param['orderCode'])) return error_show(1004,"数据存在业务公司不一致");
    	$userCommon = \app\admin\common\User::getIns();
    	$supp = $userCommon->handle("getCodeAndName",["code"=>$param['companyNo']]);
    	if(!isset($supp['data']) || empty($supp['data'])) return error_show(1004,'业务公司数据未获取到');
    	$companyName = $supp['data'][$param['companyNo']]?:"";
-   	$data=[
-   		"apply_id"=>$this->uid,
-   		"apply_name"=>$this->uname,
-   		"orderCode"=>json_encode($param['orderCode']),
-   		"companyName"=>$companyName,
-   		"companyNo"=>$param['companyNo'],
-   		"manager"=>$param['manager'],
-   		"managerid"=>$param['managerid'],
-   		"remark"=>$param['remark'],
-   		"status"=>1
-   		];
-   	$ad =$this->model->save($data);
+   	foreach ($orderinfo as $item){
+   			$data[]=[
+		        'apply_id'=>$this->uid,
+		        'apply_name'=>$this->uname,
+		        'orderCode'=>$item['orderCode'],
+		        'old_manager'=>$item['manager'],
+		        'old_managerid'=>$item['managerid'],
+		        'companyName'=>$companyName,
+		        'companyNo'=>$param['companyNo'],
+		        'manager'=>$param['manager'],
+		        'managerid'=>$param['managerid'],
+		        'remark'=>$param['remark'],
+		        'status'=>1
+   		    ];
+   	}
+   
+   	$ad =$this->model->saveAll($data);
    	return $ad? app_show(0,"创建成功"): error_show(1004,"创建失败");
    }
    
    public function list(){
-  	$param = $this->request->only(['orderCode'=>'','oaCode'=>'','companyNo'=>'','apply_name'=>'','status'=>'','manager'=>'','page'=>1,'size'=>15],'post','trim');
+  	$param = $this->request->only(['orderCode'=>'','oaCode'=>'','companyNo'=>'','apply_name'=>'','status'=>'','manager'=>'','old_manager'=>'','page'=>1,'size'=>15],'post','trim');
   	$where=[];
   	$param['orderCode']==''?: $where[]=['orderCode','like',"%{$param['orderCode']}%"];
   	$param['apply_name']==''?: $where[]=['apply_name','like',"%{$param['apply_name']}%"];
   	$param['companyNo']==''?: $where[]=['companyNo','like',"%{$param['companyNo']}%"];
   	$param['manager']==''?: $where[]=['manager','like',"%{$param['manager']}%"];
+  	$param['old_manager']==''?: $where[]=['old_manager','like',"%{$param['old_manager']}%"];
   	$param['status']==''?: $where[]=['status','=',$param['status']];
-  	$list = $this->model->where($where)->json(['orderCode'])->order('id','desc')->paginate(['page'=>$param['page'],'list_rows'=>$param['size']]);
+  	$list = $this->model->where($where)->order('id','desc')->paginate(['page'=>$param['page'],'list_rows'=>$param['size']]);
   	return app_show(0,'获取成功',['list'=>$list->items(),'count'=>$list->total()]);
   }
   
   public function  info(){
      $param = $this->request->only(['id'],'post','trim');
-     $info = $this->model->json(['orderCode'])->findOrEmpty($param['id']);
+     $info = $this->model->findOrEmpty($param['id']);
      return app_show(0,'获取成功',$info);
   }
   
@@ -81,8 +87,7 @@ class Manager extends Base
         if($up==false)throw  new \Exception('申请单审核失败');
         if($param['status']==2){
         	$update=["manager"=>$info->manager,"managerid"=>$info->managerid,"updatetime"=>date("Y-m-d H:i:s")];
-        	$orderCode =json_decode($info->orderCode,true);
-            Db::name("sale")->whereIn("orderCode",$orderCode)->update($update);
+            Db::name("sale")->where("orderCode",$info->orderCode)->update($update);
         }
     	$this->model->commit();
     }catch (\Exception $exception){
@@ -91,4 +96,56 @@ class Manager extends Base
     }
     return app_show(0,'申请数据处理完成');
   }
+  //批量导入
+  public function export(){
+  	$param = $this->request->only(['list'=>[],'companyNo'=>''],'post','trim');
+  	$Valid =Validate::rule([
+  		'list|申请修改数据'=>'require|array',
+  		'companyNo|业务公司'=>'require'
+  		]);
+  	if($Valid->check($param)==false) return error_show(1004,$Valid->getError());
+	$valid=Validate::rule([
+   		'orderCode|订单集合'=>'require',
+   		'manager|项目经理'=>'require|max:255',
+   		'managerid|项目经理'=>'require|number|gt:0'
+   		]);
+	$userCommon = \app\admin\common\User::getIns();
+   	$supp = $userCommon->handle('getCodeAndName',['code'=>$param['companyNo']]);
+   	if(!isset($supp['data']) || empty($supp['data'])) return error_show(1004,'业务公司数据未获取到');
+   	$companyName = $supp['data'][$param['companyNo']]?:'';
+   	$orderUp=[];
+   	$changeIn=[];
+   	$sale=new \app\admin\model\Sale();
+	foreach ($param['list'] as $item){
+		if($valid->check($item)==false) return error_show(1004,$valid->getError());
+		$orderInfo = $sale->where(["orderCode"=>$item['orderCode'],"is_del"=>0])->findOrEmpty();
+		if($orderInfo->isEmpty()) return error_show(1004,"{$item['orderCode']} 未找到数据");
+		if($orderInfo['supplierNo']!=$param['companyNo'])return error_show(1004,"{$item['orderCode']} 业务公司不一致");
+		$orderUp[]=["id"=>$orderInfo['id'],"manager"=>$item['manager'],"managerid"=>$item['managerid'],"updatetime"=>date("Y-m-d H:i:s")];
+		$changeIn[]=[
+					'orderCode'=>$item['orderCode'],
+					'apply_id'=>$this->uid,
+		            'apply_name'=>$this->uname,
+					'manager'=>$item['manager'],
+					'managerid'=>$item['managerid'],
+					'companyName'=>$companyName,
+		            'companyNo'=>$param['companyNo'],
+					'old_manager'=>$orderInfo->manager,
+					'remark'=>'',
+		            'status'=>2,
+					'old_managerid'=>$orderInfo->managerid
+				];
+	}
+	
+	$this->model->startTrans();
+	try{
+		if(empty($orderUp)==false)$sale->saveAll($orderUp);
+		if(empty($orderUp)==false)$this->model->saveAll($changeIn);
+		$this->model->commit();
+	}catch (\Exception $e){
+		$this->model->rollback();
+		return error_show(1004,$e->getMessage());
+	}
+	return app_show(0,'申请数据处理完成');
+  }
 }

+ 96 - 73
app/admin/controller/Reorder.php

@@ -828,7 +828,8 @@ class Reorder extends Base
                 if (in_array($param['status'], [4, 8]) == false) return json_show(1004, '选项错误');
                 break;
             case 8:
-                if (in_array($param['status'], [11, 10]) == false) return json_show(1004, '选项错误');
+                if (in_array($param['status'], [4,10]) == false && $info['order_type']!=1) return json_show(1004,'选项错误');
+                if (in_array($param['status'], [11, 10]) == false && $info['order_type']==1) return json_show(1004,'选项错误');
                 break;
             case 10:
                 if (in_array($param['status'], [4, 8]) == false) return json_show(1004, '选项错误');
@@ -967,7 +968,7 @@ class Reorder extends Base
                         if ($stock == false) throw new Exception('商品库存更新失败');
                     }
                     else {
-                        if ($info['is_th'] == 1) {
+//                        if ($info['is_th'] == 1) {
                             $orderinfo['th_num'] += $info['num'];
                             if ($orderinfo['th_num'] == $orderinfo['send_num'] && $orderinfo['wsend_num'] == 0) {
                                 $orderinfo['status'] = 3;
@@ -1035,60 +1036,61 @@ class Reorder extends Base
                             if ($st_up == false) throw new Exception('可售商品入库失败');
 
 
-                        } else {
-                            $orderinfo['th_num'] += $info['num'];
-                            if ($orderinfo['th_num'] == $orderinfo['send_num'] && $orderinfo['wsend_num'] == 0) {
-                                $orderinfo['status'] = 3;
-                            }
-                            $orderinfo['th_fee'] += round($info['num'] * $orderinfo['sale_price'], 2);
-                            $orderinfo['updatetime'] = $date;
-                            $uap = Db::name("sale")->save($orderinfo);
-                            if ($uap == false) throw new Exception('销售单订单更新失败');
-
-                            $ordernum = Db::name("order_num")
-                                ->where(['orderCode' => $orderinfo['orderCode']])
-                                ->findOrEmpty();
-                            if (empty($ordernum)) throw new Exception('未找到关联采购单');
-
-                            $ordernum['send_num'] -= $info['num'];
-                            $ordernum['wsend_num'] = $info['num'];
-                            $orderup = Db::name("order_num")->save($ordernum);
-                            if ($orderup == false) throw new Exception('关联数据更新失败');
-
-                            $cgd = Db::name("purchease_order")
-                                ->where(["cgdNo" => $ordernum['cgdNo'], "is_del" => 0])
-                                ->findOrEmpty();
-                            if (empty($cgd)) throw new Exception('未找到采购单数据');
-
-                            $stock = Db::name("good_stock")
-                                ->where(['is_del' => 0, "spuCode" => $orderinfo['good_code'], 'wsm_code' => $cgd['wsm_code']])
-                                ->findOrEmpty();
-                            if (empty($stock)) throw new Exception('商品仓库未找到');
-
-                            if ($info['is_all'] == 1) {
-                                if ($stock['wait_in_stock'] < $info['num']) throw new Exception('商品可用库存不足退回数量');
-                                else $stock['wait_in_stock'] -= $info['num'];
-
-                            } else {
-
-                                if ($stock['usable_stock'] + $stock['wait_out_stock'] < $info['num']) throw new Exception('商品可用库存不足退回数量');
-                                else {
-
-                                    if ($stock['usable_stock'] > $info['num']) {
-                                        $stock['usable_stock'] -= $info['num'];
-                                    } else {
-                                        $stock['usable_stock'] = 0;
-                                        $stock['wait_out_stock'] -= $info['num'] - $stock['usable_stock'];
-                                    }
-                                    $stock['total_stock'] = $stock['usable_stock'] + $stock['wait_out_stock'];
-                                }
-                            }
-
-                            $stock['updatetime'] = $date;
-                            $st_up = Db::name("good_stock")->save($stock);
-                            if ($st_up == false) throw new Exception('可售商品入库失败');
-
-                        }
+//                        }
+//                        else {
+//                            $orderinfo['th_num'] += $info['num'];
+//                            if ($orderinfo['th_num'] == $orderinfo['send_num'] && $orderinfo['wsend_num'] == 0) {
+//                                $orderinfo['status'] = 3;
+//                            }
+//                            $orderinfo['th_fee'] += round($info['num'] * $orderinfo['sale_price'], 2);
+//                            $orderinfo['updatetime'] = $date;
+//                            $uap = Db::name("sale")->save($orderinfo);
+//                            if ($uap == false) throw new Exception('销售单订单更新失败');
+//
+//                            $ordernum = Db::name("order_num")
+//                                ->where(['orderCode' => $orderinfo['orderCode']])
+//                                ->findOrEmpty();
+//                            if (empty($ordernum)) throw new Exception('未找到关联采购单');
+//
+//                            $ordernum['send_num'] -= $info['num'];
+//                            $ordernum['wsend_num'] = $info['num'];
+//                            $orderup = Db::name("order_num")->save($ordernum);
+//                            if ($orderup == false) throw new Exception('关联数据更新失败');
+//
+//                            $cgd = Db::name("purchease_order")
+//                                ->where(["cgdNo" => $ordernum['cgdNo'], "is_del" => 0])
+//                                ->findOrEmpty();
+//                            if (empty($cgd)) throw new Exception('未找到采购单数据');
+//
+//                            $stock = Db::name("good_stock")
+//                                ->where(['is_del' => 0, "spuCode" => $orderinfo['good_code'], 'wsm_code' => $cgd['wsm_code']])
+//                                ->findOrEmpty();
+//                            if (empty($stock)) throw new Exception('商品仓库未找到');
+//
+//                            if ($info['is_all'] == 1) {
+//                                if ($stock['wait_in_stock'] < $info['num']) throw new Exception('商品可用库存不足退回数量');
+//                                else $stock['wait_in_stock'] -= $info['num'];
+//
+//                            } else {
+//
+//                                if ($stock['usable_stock'] + $stock['wait_out_stock'] < $info['num']) throw new Exception('商品可用库存不足退回数量');
+//                                else {
+//
+//                                    if ($stock['usable_stock'] > $info['num']) {
+//                                        $stock['usable_stock'] -= $info['num'];
+//                                    } else {
+//                                        $stock['usable_stock'] = 0;
+//                                        $stock['wait_out_stock'] -= $info['num'] - $stock['usable_stock'];
+//                                    }
+//                                    $stock['total_stock'] = $stock['usable_stock'] + $stock['wait_out_stock'];
+//                                }
+//                            }
+//
+//                            $stock['updatetime'] = $date;
+//                            $st_up = Db::name("good_stock")->save($stock);
+//                            if ($st_up == false) throw new Exception('可售商品入库失败');
+//
+//                        }
 
                     }
                     ActionLog::logAdd(['id' => $info['apply_id'], 'nickname' => $info['apply_name']], [
@@ -1144,27 +1146,48 @@ class Reorder extends Base
                         }
                     }
 
-                    $data = [
-                        "orderCode" => $info['orderCode'],
-                        "th_type" => 1,
-                        "th_num" => $info['num'],
-                        "th_fee" => round($info['num'] * $orderinfo['sale_price'], 2),
-                        "thCode" => $info['returnCode'],
-                        "spuCode" => $orderinfo['good_code'],
-                        "good_name" => $orderinfo['good_name'],
-                        "cat_id" => $orderinfo['cat_id'],
-                        "apply_id" => $info['apply_id'],
-                        "apply_name" => $info['apply_name'],
-                        "addtime" => $date,
-                        "status" => 1,
-                        "is_del" => 0
-                    ];
-                    $inse = Db::name("th_data")->insert($data);
-                    if ($inse == false) throw new Exception('退货单更新失败');
+//                    $data = [
+//                        "orderCode" => $info['orderCode'],
+//                        "th_type" => 1,
+//                        "th_num" => $info['num'],
+//                        "th_fee" => round($info['num'] * $orderinfo['sale_price'], 2),
+//                        "thCode" => $info['returnCode'],
+//                        "spuCode" => $orderinfo['good_code'],
+//                        "good_name" => $orderinfo['good_name'],
+//                        "cat_id" => $orderinfo['cat_id'],
+//                        "apply_id" => $info['apply_id'],
+//                        "apply_name" => $info['apply_name'],
+//                        "addtime" => $date,
+//                        "status" => 1,
+//                        "is_del" => 0
+//                    ];
+//                    $inse = Db::name("th_data")->insert($data);
+//                    if ($inse == false) throw new Exception('退货单更新失败');
 
                 }
             }
             Db::commit();
+             if($status==4){
+                    	  $data = [
+	                        'orderCode' => $info['orderCode'],
+	                        'th_type' => 1,
+	                        'th_num' => $info['num'],
+	                        'th_fee' => round($info['num'] * $orderinfo['sale_price'], 2),
+	                        'thCode' => $info['returnCode'],
+	                        'spuCode' => $orderinfo['good_code'],
+	                        'good_name' => $orderinfo['good_name'],
+	                        'cat_id' => $orderinfo['cat_id'],
+	                        'sale_price' => $orderinfo['sale_price'],
+                            'cgd_price' => $cgd['good_price'],
+                            'cgdNo' => $cgd['cgdNo'],
+	                        'apply_id' => $info['apply_id'],
+	                        'apply_name' => $info['apply_name'],
+	                        'addtime' => $date,
+	                        'status' => 1,
+	                        'is_del' => 0
+                            ];
+                        event('thdata',$data);
+                    }
             return json_show(0, "更新成功");
 
         } catch (Exception $e) {

+ 2 - 2
app/admin/controller/Sale.php

@@ -5411,9 +5411,9 @@ class Sale extends Base
                 ->where(['is_del' => 0, 'id' => $cgdId])
                 ->update([
                 	'status' => 4,
-                    'th_num' => Db::raw('wsend_num'),
+                    'th_num' => Db::raw('wsend_num+send_num'),
                 	'th_fee' =>Db::raw('total_fee'),
-                	'send_num' =>Db::raw('wsend_num'),
+                	'send_num' =>Db::raw('wsend_num+send_num'),
                 	'wsend_num' =>0,
                 	'send_status' =>3,
                     'updatetime' => $date]);

+ 57 - 0
app/admin/controller/ThStock.php

@@ -0,0 +1,57 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\controller;
+
+use app\admin\model\PurcheaseOrder;use think\App;use think\facade\Validate;use think\Request;
+
+class ThStock extends Base
+{
+	protected $model=null;
+    public function __construct(App $app) {
+    	parent::__construct($app);
+    	$this->model=new \app\admin\model\ThStock();
+    }
+    
+    public function List(){
+    	$param=$this->request->param(['start'=>"","end"=>'',"orderCode"=>'',"thCode"=>'',"good_code"=>'',"companyNo"=>'',"status"=>'',
+    	"page"=>1,"size"=>15],"post","trim");
+    	$where=[];
+    	if($param['start']!='' && $param['end']!=""){
+    		$where[]=["addtime","between",[date("Y-m-d 00:00:00",strtotime($param['start'])),date('Y-m-d 23:59:59',strtotime($param['end']))]];
+    	}
+    	$param['orderCode']==""?:$where[]=["orderCode","like","%{$param["orderCode"]}%"];
+    	$param['thCode']==""?:$where[]=["thCode","like","%{$param["thCode"]}%"];
+    	$param['good_code']==""?:$where[]=["good_code","like","%{$param["good_code"]}%"];
+    	$param['companyNo']==""?:$where[]=["companyNo","=",$param["companyNo"]];
+    	$param['status']==""?:$where[]=["status","=",$param["status"]];
+    	$list=$this->model->with(["purcheaseOrder"])->where($where)->order("id desc")->paginate(["list_rows"=>$param['size'],
+    	"page"=>$param["page"]]);
+    	return app_show(0,"获取成功",["list"=>$list->items(),"count"=>$list->total()]);
+    }
+    
+    
+    public function status(){
+    	$param=$this->request->param(['id'=>"","rela_cgdNo"=>"","status"=>""],'post','trim');
+    	$valid=Validate::rule([
+    		"id|主键ID"=>"require|number|gt:0",
+    	    "rela_cgdNo|关联采购单编号"=>"requireIf:status,2|max:255|unique:th_stock",
+    	    "status|状态"=>"require|number|in:1,2,3"
+    	    ]);
+    	if($valid->check($param)==false) return error_show(1004,$valid->getError());
+    	$info =$this->model->findOrEmpty($param['id']);
+    	if($info->isEmpty())return error_show(1004,'未找到数据');
+    	if($param['status']==2){
+    		$cgd  = (new PurcheaseOrder())->where(["cgdNo"=>$param['rela_cgdNo']])->findOrEmpty();
+    		if($cgd->isEmpty())return error_show(1004,'未找到采购单数据');
+    		if($info->supplierNo!=$cgd->supplierNo) return error_show(1004,'供应商信息不一致');
+    		if($info->companyNo!=$cgd->companyNo) return error_show(1004,'业务公司信息不一致');
+    		if($info->th_num!=$cgd->good_num) return error_show(1004,'商品数量不一致');
+    		if($info->th_cgd_price!=$cgd->good_price) return error_show(1004,'商品采购价不一致');
+    	}
+    	    $info->status=$param['status'];
+    	    $info->rela_cgdNo=$param['status']==3?"":$param['rela_cgdNo'];
+    	    $up =$info->save();
+    	  return  $up?app_show(0,"数据更新成功"):error_show(1004,"数据更新失败");
+    }
+}

+ 92 - 0
app/admin/listener/ThData.php

@@ -0,0 +1,92 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\listener;
+
+use app\admin\model\OrderReturn;use app\admin\model\SaleReturn;class ThData
+{
+    /**
+     * 事件监听处理
+     *
+     * @return mixed
+     */
+    public function handle($event)
+    {//
+        \app\admin\model\ThData::create($event);
+            $data=[];
+	       switch ($event['th_type']){
+	       	case 1:
+	       		$data=$this->beforeOrder($event);
+	       		break;
+	       	case 2:
+	       		$data=$this->afterOrder($event);
+	       		break;
+	       	case 3:
+	       	case 4:
+	       		break;
+	       }
+	       if(empty($data)==false)\app\admin\model\ThStock::create($data);
+	       
+    }
+     //售后退货 供应商不同意退货
+    protected function afterOrder($event){
+    	$model =new OrderReturn();
+    	$info =$model->where(["returnCode"=>$event['thCode']])->findOrEmpty();
+    	if($info->isEmpty())return[];
+    	if($info->status==5 && $info->return_tag==2){
+    	    $data=[
+    	    	"thCode"=>$info->returnCode,
+    	    	"th_type"=>2,
+    	    	"order_type"=>$info->order_type,
+    	    	"supplierNo"=>$info->supplierNo,
+    	    	"supplierName"=>$info->supplierName,
+    	    	"companyNo"=>$info->companyNo,
+    	    	"companyName"=>$info->companyName,
+    	    	"customerNo"=>$info->customer_code,
+    	    	"customerName"=>$info->customer_name,
+    	    	"th_num"=>$info->error_num,
+    	    	"th_cgd_price"=>$event['sale_price'],
+    	    	"th_sale_price"=>$event['cgd_price'],
+    	    	"good_code"=>$info->good_code,
+    	    	"good_name"=>$info->good_name,
+    	    	"orderCode"=>$info->orderCode,
+    	    	'cgdCode'=>$event['cgdNo'],
+    	    	"apply_id"=>$info->apply_id,
+    	    	"apply_name"=>$info->apply_name,
+    	    ];
+    	}else $data=[];
+    	return $data;
+    }
+    //售前退货 供应商不同意退货
+    protected function beforeOrder($event){
+    	$model =new SaleReturn();
+    	$info =$model->where(['returnCode'=>$event['thCode']])->findOrEmpty();
+    	if($info->isEmpty())return[];
+    	if($info->status==4 && $info->is_th==0){
+    	    $data=[
+    	    	'thCode'=>$info->returnCode,
+    	    	'th_type'=>1,
+    	    	'order_type'=>$info->order_type,
+    	    	'supplierNo'=>$info->supplierNo,
+    	    	'supplierName'=>$info->supplierName,
+    	    	'companyNo'=>$info->companyNo,
+    	    	'companyName'=>$info->companyName,
+    	    	'customerNo'=>$info->customer_code,
+    	    	'customerName'=>$info->customer_name,
+    	    	'th_num'=>$info->num,
+    	    	'th_cgd_price'=>$event['sale_price'],
+    	    	'th_sale_price'=>$event['cgd_price'],
+    	    	'good_code'=>$info->good_code,
+    	    	'good_name'=>$info->good_name,
+    	    	'orderCode'=>$info->orderCode,
+    	    	'cgdCode'=>$event['cgdNo'],
+    	    	'apply_id'=>$info->apply_id,
+    	    	'apply_name'=>$info->apply_name,
+    	    ];
+    	}else $data=[];
+    	return $data;
+    }
+    
+    
+    
+}

+ 16 - 0
app/admin/listener/ThStock.php

@@ -0,0 +1,16 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\listener;
+
+class ThStock
+{
+    /**
+     * 事件监听处理
+     *
+     * @return mixed
+     */
+    public function handle($event)
+    {
+    }
+}

+ 14 - 0
app/admin/model/OrderReturn.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class OrderReturn extends Model
+{
+    //
+}

+ 14 - 0
app/admin/model/PurcheaseOrder.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class PurcheaseOrder extends Model
+{
+    //
+}

+ 14 - 0
app/admin/model/Sale.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class Sale extends Model
+{
+    //
+}

+ 14 - 0
app/admin/model/SaleReturn.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class SaleReturn extends Model
+{
+    //
+}

+ 14 - 0
app/admin/model/ThData.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class ThData extends Model
+{
+    //
+}

+ 17 - 0
app/admin/model/ThStock.php

@@ -0,0 +1,17 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class ThStock extends Model
+{
+ 
+	public function purcheaseOrder(){
+		return $this->belongsTo(PurcheaseOrder::class,"rela_cgdNo","cgdNo");
+	}
+}

+ 4 - 0
app/admin/route/app.php

@@ -859,6 +859,10 @@ route::rule('managerlist','admin/Manager/list');
 route::rule('manageradd','admin/Manager/create');
 route::rule('managerinfo','admin/Manager/info');
 route::rule('managerstatus','admin/Manager/status');
+route::rule('managerexport','admin/Manager/export');
+//供应商不同意退货 生成数据转未库存商品
+route::rule('thstocklist','admin/ThStock/List');
+route::rule('thstockstatus','admin/ThStock/status');
 
 
 

+ 5 - 17
app/common.php

@@ -186,8 +186,8 @@ function UploadImg($files)
     try {
         //验证
         validate(['imgFile' => [
-        	'fileSize' => 10240000,
-        	'fileExt' => 'jpg,jpeg,png,bmp,gif',
+        	'fileSize' => 2*1024*1024,
+	        'fileExt' => 'jpg,jpeg,png,bmp,gif',
         	'fileMime' => 'image/jpeg,image/png,image/gif']
         	])->check(['imgFile' => $files]);
 
@@ -223,16 +223,10 @@ function UploadFile($files)
     $files = !is_array($files) ? [$files] : $files;
     try {
         //验证
-        validate(['imgFile' => ['fileSize' => 10240000, 'fileExt' => 'xlsx,xls,pdf,zip,rar,7z,doc,docx']])->check(['imgFile' => $files]);
+        validate(['imgFile' => ['fileSize' => 5*1024*1024, 'fileExt' => 'xlsx,xls,pdf,zip,rar,7z,doc,docx']])->check
+        (['imgFile' => $files]);
 
         foreach ($files as $file) {
-//            $url = Filesystem::disk('public')->putFile('files/' . date("Ymd"), $file, function () use ($file) {
-//                return str_replace('.' . $file->getOriginalExtension(), '', $file->getOriginalName() . "_" . date('YmdHis'));
-//            });
-//            $name = str_replace('.' . $file->getOriginalExtension(), '', $file->getOriginalName());
-//            $temp = ["url" => $url, "name" => $name];
-
-
             //文件存放路径
             $root = config('filesystem.disks.public.root') . DIRECTORY_SEPARATOR;
             $url = 'files' . DIRECTORY_SEPARATOR . date("Ymd") . DIRECTORY_SEPARATOR;
@@ -264,15 +258,9 @@ function UploadVideo($files)
     $files = !is_array($files) ? [$files] : $files;
     try {
         //验证
-        validate(['videoFile' => ['fileSize' => 10240000, 'fileExt' => 'mp4,mp3,avi']])->check(['videoFile' => $files]);
+        validate(['videoFile' => ['fileSize' =>  5*1024*1024,  'fileExt' => 'mp4,mp3,avi']])->check(['videoFile' => $files]);
 
         foreach ($files as $file) {
-//            $url = Filesystem::disk('public')->putFile('video/' . date("Ymd"), $file, function () use ($file) {
-//                return str_replace('.' . $file->getOriginalExtension(), '', $file->getOriginalName() . "_" . date('YmdHis'));
-//            });
-//            $name = str_replace('.' . $file->getOriginalExtension(), '', $file->getOriginalName());
-//            $temp = ["url" => $url, "name" => $name];
-
             //文件存放路径
             $root = config('filesystem.disks.public.root') . DIRECTORY_SEPARATOR;
             $url = 'video' . DIRECTORY_SEPARATOR . date("Ymd") . DIRECTORY_SEPARATOR;

+ 2 - 0
app/event.php

@@ -14,6 +14,8 @@ return [
         'LogWrite' => [],
         'ProcessOrder' => [\app\bbc\listener\ProcessOrder::class],
         'GoodOff' => [\app\bbc\listener\GoodOffine::class],
+        'thdata' => [\app\admin\listener\ThData::class],
+     
     ],
 
     'subscribe' => [