Browse Source

退货及项目生成竞价单进而生成销售订单时,优化台账记录

wufeng 2 years ago
parent
commit
13a73a3695
2 changed files with 38 additions and 14 deletions
  1. 12 6
      app/admin/controller/Reorder.php
  2. 26 8
      app/admin/controller/Sale.php

+ 12 - 6
app/admin/controller/Reorder.php

@@ -106,12 +106,18 @@ class Reorder extends Base
                 ProcessOrder::AddProcess($this->post['token'],$process);
 
                 //维护台账信息
-                Db::name('standing_book')
-                    ->where('orderCode', $ordeCode)
-                    ->update([
-                        "returnGoodCode" => $returnCode,
-                        "updatetime" => date("Y-m-d H:i:s")
-                    ]);
+                $rs = Db::name('standing_book')->where('orderCode', $ordeCode)->order('returnGoodCode')->find();
+                if (!empty($rs)) {
+                    if ($rs['returnGoodCode'] == '') Db::name('standing_book')->where('id', $rs['id'])->update(["returnGoodCode" => $returnCode, "updatetime" => date("Y-m-d H:i:s")]);
+                    else {
+                        unset($rs['id']);
+                        $rs['standBookNo'] = makeNo('IO');
+                        $rs['addtime'] = $rs['updatetime'] = date("Y-m-d H:i:s");
+                        $rs['returnGoodCode'] = $returnCode;
+                        Db::name('standing_book')->insert($rs);
+                    }
+                }
+
                 if($returnadr!=""){
                     $inf=[];
                     foreach ($returnadr as $val){

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

@@ -1291,14 +1291,31 @@ class Sale extends Base
                 if (isset($standing_book_data['companyNo'])) unset($standing_book_data['companyNo']);
                 if (isset($standing_book_data['customer_code'])) unset($standing_book_data['customer_code']);
 
-                if ($key == 0) Db::name('standing_book')->where('projectNo', $plan['projectNo'])->update($standing_book_data);
-                else {
-                    $temp = Db::name('standing_book')->where('projectNo', $plan['projectNo'])->find();
-                    if (!empty($temp)) {
-                        unset($temp['id']);
-                        $temp = array_merge($temp, $standing_book_data);
-                        $temp['standBookNo'] = makeNo('IO');
-                        Db::name('standing_book')->insert($temp);
+
+                //普通商品
+                if ($feedback['data_source'] == 1) {
+                    if ($key == 0) Db::name('standing_book')->where('projectNo', $plan['projectNo'])->update($standing_book_data);
+                    else {
+                        $temp = Db::name('standing_book')->where('projectNo', $plan['projectNo'])->find();
+                        if (!empty($temp)) {
+                            unset($temp['id']);
+                            $temp = array_merge($temp, $standing_book_data);
+                            $temp['standBookNo'] = makeNo('IO');
+                            Db::name('standing_book')->insert($temp);
+                        }
+                    }
+
+                } else {
+                    //项目类竞价单
+                    if ($key == 0) Db::name('standing_book')->where('projectNo', $plan['projectNo'])->where('infoNo', $standing_book_data['infoNo'])->update($standing_book_data);
+                    else {
+                        $temp = Db::name('standing_book')->where('projectNo', $plan['projectNo'])->where('infoNo', $standing_book_data['infoNo'])->find();
+                        if (!empty($temp)) {
+                            unset($temp['id']);
+                            $temp = array_merge($temp, $standing_book_data);
+                            $temp['standBookNo'] = makeNo('IO');
+                            Db::name('standing_book')->insert($temp);
+                        }
                     }
                 }
 
@@ -1447,6 +1464,7 @@ class Sale extends Base
         if($datainfo>0){
             $standing_book_data['sale_id'] = $datainfo;
             $standing_book_data['customer_code']=$datas['customer_code'];
+            $standing_book_data['infoNo']=$goodinfo['infoNo'];
             //修改状态,添加待办
             ActionLog::logAdd($this->post['token'], [
                 "order_code" =>$orderCode,//项目编码