瀏覽代碼

Merge branch 'wugg-dev' of wugg/phpstock into version1.5

wugg 2 年之前
父節點
當前提交
971d1c2607
共有 3 個文件被更改,包括 30 次插入6 次删除
  1. 4 1
      app/admin/controller/Purch.php
  2. 8 5
      app/admin/controller/Purchin.php
  3. 18 0
      app/common.php

+ 4 - 1
app/admin/controller/Purch.php

@@ -637,7 +637,10 @@ class Purch extends Base
         if (empty($cgdNo)) {
             return error_show(1004, "参数cgdNo 不能为空");
         }
-
+		$isreturn = cgd_sale_return($cgdNo);
+        if($isreturn){
+        	return error_show(1005, "销售单存在退货单正在进行");
+        }
         $remark = isset($this->post['remark']) && $this->post['remark'] != "" ? trim($this->post['remark']) : "";
         $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
         if ($status === "") {

+ 8 - 5
app/admin/controller/Purchin.php

@@ -187,9 +187,12 @@ class Purchin extends Base
             return error_show(1005,"未找到采购单数据");
         }
        if($cgdinfo['status']==0){
-           return error_show(1005,"采购单未发货");
+           return error_show(1005,"采购单未确认");
        }
-
+       $isreturn = cgd_sale_return($cgdNo);
+        if($isreturn){
+        	return error_show(1005, "关联销售单存在退货单正在进行");
+        }
        $wsm_in_code = makeNo("CF");
        $bn_code = makeNo("BN");
        $wsminfo = Db::name("warehouse_info")->where(["wsm_code"=>$cgdinfo['wsm_code'],"is_del"=>0])->find();
@@ -373,10 +376,10 @@ class Purchin extends Base
                         if($cgdinfo['send_status']==3 && $cgdinfo['order_type']!=1){
                             $send=Db::name("order_send")->where(["cgdNo"=>$cgdNo,"status"=>1])->column("outCode");
                             if(!empty($send)){
-                                $out =Db::name("order_out")->where(["outCode"=>$send,"status"=>0])->select()->toArray();
+                                $out =Db::name("order_out")->where(["outCode"=>$send,"status"=>0,"is_del"=>0])->select()
+                                ->toArray();
                                 if(!empty($out)){
-                                    $up =Db::name("order_out")->where(["outCode"=>$send,"status"=>0])->update
-                                    (["status"=>1,'wsm_code'=>$cgdinfo['wsm_code'],"updatetime"=>date('Y-m-d H:i:s')]);
+                                    $up =Db::name("order_out")->where(["outCode"=>$send,"status"=>0,"is_del"=>0])->update(["status"=>1,'wsm_code'=>$cgdinfo['wsm_code'],"updatetime"=>date('Y-m-d H:i:s')]);
                                     if($up==false){
                                         Db::rollback();
                                         return error_show(1004,"出库单出库失败");

+ 18 - 0
app/common.php

@@ -1385,4 +1385,22 @@ if (!function_exists('getUserIdsByShare')) {
         return $tmp;
 
     }
+}
+//采购单未操作确认或入库时判断销售单是否存在正进行中的退货
+if(function_exists("cgd_sale_return")){
+	/**
+	* @param $cgdNo
+	 * @return bool
+	* @throws \think\db\exception\DataNotFoundException
+	* @throws \think\db\exception\DbException
+	* @throws \think\db\exception\ModelNotFoundException
+	 */
+	function cgd_sale_return($cgdNo){
+		$order =Db::name("order_num")->alias("a")
+		->leftJoin("sale_return b","a.orderCode=b.orderCode and b.is_del=0")
+		->where("a.cgdNo",$cgdNo)
+		->whereIn("b.status",[1,2,3,4,7])
+		->find()->isExists();
+		return $order;
+	}
 }