wugg 4 ay önce
ebeveyn
işleme
ec1137727c

+ 19 - 2
app/cxinv/controller/Purchease.php

@@ -4,9 +4,26 @@
 namespace app\cxinv\controller;
 
 
-use think\App;class Purchease extends Base{
+use app\cxinv\model\CgdInfo;
+use think\App;
+class Purchease extends Base{
     public function __construct(App $app) {
         parent::__construct($app);
+        $this->model=new CgdInfo();
+    }
+    public function status(){
+      $param= $this->request->param(['id'=>'','status'=>''],'post','trim');
+      $valid= $this->validate($param,[
+          'id|订单编号'=>'require|number',
+          'status|订单状态'=>'require|number|in:0,1,2,3'
+      ]);
+      if($valid!==true) return error($valid);
+      $model= $this->model->findOrEmpty($param['id']);
+      if($model->isEmpty())return error('订单不存在');
+      if($model->status==$param['status']) return error('订单状态已更新');
+      $model->status=$param['status'];
+      $save = $model->save();
+      if($save===false)return error('更新失败');
+      return success('更新成功');
     }
-
 }

+ 2 - 2
app/cxinv/controller/Trade.php

@@ -135,7 +135,7 @@ class Trade extends Base{
         "trade_type"=>"","palt_po"=>"","skuCode"=>"","goodName"=>"","plat_total_lower"=>"",'plat_total_upper'=>'',"com_total_lower"=>"",
         "com_total_upper"=>"","trade_used"=>"","create_start"=>"","create_end"=>"",'customerName'=>''],"post","trim");
         $where=[["is_del","=",0]];
-        if($params['tradNo']!=="")$where[]=["tradNo","like","%".$params['tradNo']."%"];
+        if($params['tradNo']!=="")$where[]=["trade.tradNo","like","%".$params['tradNo']."%"];
         if(!empty($params['status']))$where[]=["status","in",$params['status']];
         if($params['name']!=="")$where[]=["trade_out","like","%".$params['name']."%"];
         if($params['bank']!=="")$where[]=["trade_bank","like","%".$params['bank']."%"];
@@ -279,11 +279,11 @@ class Trade extends Base{
         $this->model->startTrans();
         try{
             $logInfo->each(function($item) use($params){
+                Assoc::CheckTrad($item->logNo,$params['status']);
                 $item->status = $params['status'];
                 $item->remark = $params['remark'];
                 $save=$item->save();
                 if(!$save) throw new \Exception("资金认领信息更新失败");
-                Assoc::CheckTrad($item->logNo,$params['status']);
                 if($params['status']==3){
                     $trade = $this->model->where(["tradNo"=>$item->tradNo,"is_del"=>0])->findOrEmpty();
                     if($trade->used_fee<$item->total_fee) throw new \Exception('资金流水已使用金额不足');