Browse Source

细节优化

wufeng 2 years ago
parent
commit
9c803d2fe9

+ 3 - 3
app/admin/controller/After.php

@@ -1365,9 +1365,9 @@ 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['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);

+ 26 - 15
app/admin/controller/OrderOutChild.php

@@ -84,36 +84,49 @@ class OrderOutChild extends Base
         if ($param['order_type'] != '') $where[] = ['a.order_type', '=', $param['order_type']];
         if ($param['relaComNo'] != '') $where[] = ['a.companyNo', '=', $param['relaComNo']];
 
+        $condition = '';
         //只有level2的账号过滤数据权限
         if ($this->level == 2) {
 
-            //如果是供应商负责人,根据供应商筛选
+            //库管只能看到库存品订单,供应商负责人只能看到非库存品订单
+
+            //是否是仓库管理员
+            $tmp = Db::name('warehouse_info')->field('id')->where(['is_del' => 0, 'contactor' => $this->uid])->findOrEmpty();
+
+            //库管看到所有的库存品发货申请单
+            if (!empty($tmp)) $condition .= " a.order_type=1 AND c.contactor=" . $this->uid;
+            else {
+                $role = $this->checkDataShare();
+                if (!empty($role[DataGroupModel::$type_全部])) {
+                    if ($condition != '') $condition .= " or ";
+                    $condition .= " a.apply_id in (" . implode(',', $role[DataGroupModel::$type_全部]) . ")";
+                }
+            }
             $person_supplier = Db::connect('mysql_sys')
                 ->name('supplier')
                 ->where(['is_del' => 0, 'personid' => $this->uid])
                 ->column('code');
-
-            if (!empty($person_supplier)) $where[] = ['a.supplierNo', 'in', $person_supplier];//"b.supNo in ('" . implode('\',\'', $person_supplier) . "')";
-            else {
-                //不是供应商负责人,根据数据权限筛选申请人
-                $role = $this->checkDataShare();
-                if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['a.apply_id', 'in', $role[DataGroupModel::$type_全部]];// " a.apply_id in (" . implode(',', $role[DataGroupModel::$type_全部]) . ")";
+            if ($person_supplier) {
+                if ($condition != '') $condition .= " or ";
+                $condition .= "(a.order_type<>1 and a.supplierNo in ('" . implode('\',\'', $person_supplier) . "'))";
             }
         }
 
-            $count = Db::name('order_out_child')
+        $count = Db::name('order_out_child')
             ->alias('a')
-            ->leftJoin('warehouse_info c','c.wsm_code=a.wsm_code AND c.is_del=0')
+            ->leftJoin('warehouse_info c', 'c.wsm_code=a.wsm_code AND c.is_del=0')
             ->where($where)
+            ->where($condition)
             ->count('a.id');
 
         $list = Db::name('order_out_child')
             ->alias('a')
             ->field('a.*,c.supplierNo wsm_supplierNo,c.supplierName wsm_supplierName,c.name wsm_name,c.contactor_name')
-            ->leftJoin('warehouse_info c','c.wsm_code=a.wsm_code AND c.is_del=0')
+            ->leftJoin('warehouse_info c', 'c.wsm_code=a.wsm_code AND c.is_del=0')
             ->order(['a.addtime' => 'desc', 'a.id' => 'desc'])
             ->page($param['page'], $param['size'])
             ->where($where)
+            ->where($condition)
             ->select()
             ->toArray();
 
@@ -121,13 +134,11 @@ class OrderOutChild extends Base
         $company_name = get_company_name_by_uid($all_apply_id);
 
         //校验是否开通了供应商账号
-        $supp_account = checkHasAccountBySupplierNos(array_unique(array_column($list,'supplierNo')));
+        $supp_account = checkHasAccountBySupplierNos(array_unique(array_column($list, 'supplierNo')));
 
         $data = [];
         foreach ($list as $value) {
-
             $value['company_name'] = $company_name[$value['apply_id']] ?? '';
-
             $value['has_account'] = (int)isset($supp_account[$value['supplierNo']]);
             $data[] = $value;
         }
@@ -313,7 +324,7 @@ class OrderOutChild extends Base
         $info = Db::name('order_out_child')
             ->alias('a')
             ->field('a.*,b.name wsm_name')
-            ->leftJoin('warehouse_info b','b.wsm_code=a.wsm_code')
+            ->leftJoin('warehouse_info b', 'b.wsm_code=a.wsm_code')
             ->where(['a.is_del' => 0, 'a.outChildCode' => $outChildCode])
             ->findOrEmpty();
 
@@ -359,7 +370,7 @@ class OrderOutChild extends Base
         $is_reurn = Db::name("sale_return")
             ->field('id,orderCode')
             ->where(['orderCode' => array_column($child, 'orderCode'), 'is_del' => 0])
-            ->where("status", "in", [1, 2, 3, 7,8, 9, 10,11,12])
+            ->where("status", "in", [1, 2, 3, 7, 8, 9, 10, 11, 12])
             ->findOrEmpty();
         if (!empty($is_reurn)) return json_show(1004, $is_reurn['orderCode'] . "存在退货未处理完成");
 

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

@@ -716,12 +716,12 @@ class Sale extends Base
                             $status = 0;
                         } else {
                             if (($goodStock_num - $num) < 0) throw new Exception("非库存品可用库存不足");
-                            $goodStock_num = -$num;
+                            $goodStock_num -= $num;
                             $status = 1;
                         }
                     } else {
                         if ($goodStock_num == 0 || ($goodStock_num - $num) < 0) throw new Exception("库存品可用库存不足");
-                        $goodStock_num = -$num;
+                        $goodStock_num -= $num;
                         $status = 1;
                     }
 
@@ -2134,8 +2134,8 @@ class Sale extends Base
         $all_createrid = array_column($list,'apply_id');
         $item = get_company_name_by_uid($all_createrid);
 
-        $userCommon = \app\admin\common\User::getIns();
-        $names = $userCommon->handle('getCodeAndName',['code'=>array_merge(array_column($list,'customer_code'),array_column($list,'supplierNo'))]);
+//        $userCommon = \app\admin\common\User::getIns();
+//        $names = $userCommon->handle('getCodeAndName',['code'=>array_merge(array_column($list,'customer_code'),array_column($list,'supplierNo'))]);
 
         $data = [];
         foreach ($list as $value) {

+ 1 - 1
app/common.php

@@ -1525,7 +1525,7 @@ if(!function_exists("cgd_sale_return")){
 	}
 }
 
-//采购单未操作确认或入库时判断销售单是否存在正进行中的退货
+//离职交接数据
 if(!function_exists("resign_hand_user")){
 	/**
 	* @param $uid