Explorar o código

采购与销售

shish %!s(int64=5) %!d(string=hai) anos
pai
achega
7fa006030d

+ 0 - 1
app-ghs/controllers/OrderController.php

@@ -97,7 +97,6 @@ class OrderController extends BaseController
         $post['merchantId'] = $this->sjId;
         $post['shopId'] = $shopId;
         $post['payWay'] = $this->isWx == true ? 0 : 1;
-        $post['merchantId'] = $this->sjId;
         $post['fromType'] = 1;
         $post['expressId'] = $post['expressId'] ?? 0;
         $post['clearType'] = $post['clearType'] ?? OrderClass::CLEAR_DEBT;

+ 6 - 4
app-hd/controllers/PurchaseController.php

@@ -35,6 +35,8 @@ class PurchaseController extends BaseController
             $post['shopId'] = $this->shopId;
             $post['shopAdminId'] = $this->shopAdminId;
             $post['ghsId'] = $ghsId;
+            $post['ghsName'] = $ghsInfo['name'] ?? '';
+            $post['ghsAvatar'] = $ghsInfo['avatar'] ?? '';
             $customId = $ghsInfo['customId'] ?? 0;
             $post['customId'] = $customId;
             $shopAdmin = $this->shopAdmin;
@@ -46,9 +48,9 @@ class PurchaseController extends BaseController
             ProductClass::valid($productList, $currentShopId);
             $post['product'] = $productList;
             $post['sendCost'] = isset($post['sendCost']) && is_numeric($post['sendCost']) ? $post['sendCost'] : 0;
-            $respond = PurchaseService::createPurchase($post,$ghsInfo);
-            $orderSn = $respond['orderSn'] ?? '';
-            $actPrice = $respond['actPrice'] ?? '';
+            $respond = PurchaseService::createPurchase($post, $ghsInfo);
+            $orderSn = $respond->orderSn ?? '';
+            $actPrice = $respond->actPrice ?? '';
             $transaction->commit();
             $data = [
                 'orderSn' => $orderSn,
@@ -84,7 +86,7 @@ class PurchaseController extends BaseController
             util::fail('没有找到客户');
         }
         if (isset($custom['debt']) == false || $custom['debt'] == CustomClass::IS_DEBT_NO) {
-            util::fail('您没有延期付款权限');
+            util::fail('您没有延期付款权限,请联系此批发商开通');
         }
         $connection = Yii::$app->db;//事务处理
         $transaction = $connection->beginTransaction();

+ 13 - 4
biz-ghs/order/services/OrderService.php

@@ -6,6 +6,7 @@ use biz\ghs\classes\GhsClass;
 use biz\shop\models\Shop;
 use bizGhs\base\services\BaseService;
 use bizGhs\order\classes\OrderClass;
+use common\components\dict;
 use common\components\util;
 use bizHd\purchase\classes\PurchaseClass;
 use common\components\stringUtil;
@@ -21,6 +22,7 @@ class OrderService extends BaseService
     {
         //供货商销售单
         $return = OrderClass::addOrder($data);
+        $saleId = $return['id'] ?? 0;
 
         $customSjId = $custom['sjId'] ?? 0;
         $customShopId = $custom['shopId'] ?? 0;
@@ -32,8 +34,9 @@ class OrderService extends BaseService
         if (empty($ghs)) {
             util::fail('没有找到供货商');
         }
-        $saleId = $return['id'] ?? 0;
-
+        $ghsName = $ghs['name'] ?? '';
+        $ghsAvatar = $ghs['avatar'] ?? '';
+        $payWay = $data['payWay'] ?? dict::getDict('payWay', 'wxPay');
         //零售采购单
         $purchaseData = [
             'product' => $data['product'],
@@ -45,10 +48,14 @@ class OrderService extends BaseService
             'shopId' => $customShopId,
             'saleId' => $saleId,
             'ghsId' => $ghsId,
+            'ghsName' => $ghsName,
+            'ghsAvatar' => $ghsAvatar,
             'customId' => $customId,
+            'payWay' => $payWay,
+            'status' => PurchaseClass::STATUS_UN_PAY
         ];
         $purchase = PurchaseClass::addPurchase($purchaseData);
-        $purchaseId = $purchase['id'] ?? 0;
+        $purchaseId = $purchase->id ?? 0;
         OrderClass::updateById($saleId, ['purchaseId' => $purchaseId]);
 
         $currentShopId = $data['shopId'] ?? 0;
@@ -56,20 +63,22 @@ class OrderService extends BaseService
         if (empty($shop)) {
             util::fail('没有找到门店');
         }
-        //0正常订单 1欠款
         $debt = $data['debt'] ?? 0;
         if ($debt == 1) {
             //欠款
             OrderClass::staffKdPay($return, 1, $shop);
+            PurchaseClass::debt($purchase);
         } else {
             //已收款
             OrderClass::staffKdPay($return, 2, $shop);
+            PurchaseClass::staffKdPay($purchase);
         }
 
         //自取订单直接完成
         if (isset($data['sendType']) && $data['sendType'] == OrderClass::SEND_TYPE_NO) {
             OrderClass::withoutSend($return);
         }
+
         return $return;
     }
 

+ 0 - 1
biz-hd/admin/services/ShopAdminService.php

@@ -108,7 +108,6 @@ class ShopAdminService extends BaseService
     }
 
     //获取管理员 ssh 2020.4.21
-    // $sensitive true 密码等敏感信息不显示
     public static function getAdminList($where, $sensitive = true)
     {
         $data = ShopAdminClass::getList('*', $where, 'addTime DESC');

+ 8 - 1
biz-hd/purchase/classes/PurchaseClass.php

@@ -123,7 +123,7 @@ class PurchaseClass extends BaseClass
         //采购单5分钟有效期
         $current = time() + 300;
         $data['deadline'] = isset($data['deadline']) ? $data['deadline'] : date("Y-m-d H:i:s", $current);
-        $respond = self::add($data);
+        $respond = self::add($data, true);
         if (isset($data['product']) == false || empty($data['product'])) {
             util::fail('请选择花材');
         }
@@ -220,6 +220,13 @@ class PurchaseClass extends BaseClass
         util::fail('没有权限操作');
     }
 
+    //供货商的员工开单,直接生成采购单 shish 2021.5.8
+    public static function staffKdPay($info)
+    {
+        $payWay = $info->payWay;
+        self::complete($info, $payWay);
+    }
+
     //采购订单支付成功后回调处理流程
     public static function thirdPay($payWay, $orderSn, $totalFee, $attach)
     {

+ 2 - 14
biz-hd/purchase/services/PurchaseService.php

@@ -35,7 +35,7 @@ class PurchaseService extends BaseService
         $customName = $custom['name'] ?? '';
         $customNamePy = $custom['py'] ?? '';
         $customMobile = $custom['mobile'] ?? '';
-        $purchaseId = $respond['id'] ?? 0;
+        $purchaseId = $respond->id ?? 0;
         $shopAdminId = $data['shopAdminId'] ?? 0;
         $shopAdminName = $data['shopAdminName'] ?? '';
         //客户采购时选了自取,则供货商的销售单就是自取
@@ -80,20 +80,8 @@ class PurchaseService extends BaseService
         if (empty($list)) {
             return $list;
         }
-
-        $ghsIds = array_unique(array_filter(array_column($list, 'ghsId')));
-        $ghsInfo = GhsClass::getGhsByIds($ghsIds);
-
-        $adminIds = array_unique(array_filter(array_column($list, 'adminId')));
-        $adminInfo = AdminClass::getAdminByIds($adminIds);
-
         foreach ($list as $key => $val) {
-            $ghsId = $val['ghsId'];
-            $list[$key]['supplierName'] = $ghsInfo[$ghsId]['name'] ?? '';
-            $list[$key]['supplierAvatar'] = $ghsInfo[$ghsId]['logoUrl'] ?? imgUtil::getPrefix() . '/hhb_small.png';
-            $adminId = $val['adminId'] ?? 0;
-            $list[$key]['adminName'] = $adminInfo[$adminId]['name'] ?? '';
-            //$list[$key]['status'] = rand(1, 4);
+            $list[$key]['ghsAvatar'] = imgUtil::groupImg($val['ghsAvatar']);
         }
         return $list;
     }

+ 6 - 1
sql.sql

@@ -2388,4 +2388,9 @@ ALTER TABLE `xhGhsOrder` CHANGE `customAdminId` `customShopAdminId` INT(11) NOT
 ALTER TABLE `xhGhsOrder` ADD customShopAdminName VARCHAR(50) NOT NULL DEFAULT '' COMMENT '客户员工名称' AFTER `customShopAdminId`;
 ALTER TABLE xhGhsOrder MODIFY `customId` INT(11) NOT NULL DEFAULT '0' COMMENT '客户id 对应xhGhsCustom id字段';
 ALTER TABLE xhPurchase ADD customId INT NOT NULL DEFAULT 0 COMMENT '客户id,冗余字段' AFTER `changePrice`;
-ALTER TABLE xhGhsOrder ADD ghsId INT NOT NULL DEFAULT 0 COMMENT '供货商id,冗余字段' AFTER `shopAdminName`;
+ALTER TABLE xhGhsOrder ADD ghsId INT NOT NULL DEFAULT 0 COMMENT '供货商id,冗余字段' AFTER `shopAdminName`;
+ALTER TABLE xhPurchase ADD ghsName VARCHAR(50) NOT NULL DEFAULT '' COMMENT '供货商名称' AFTER `customId`;
+ALTER TABLE xhPurchase ADD ghsAvatar VARCHAR(500) NOT NULL DEFAULT '' COMMENT '供货商头像' AFTER `ghsName`;
+ALTER TABLE xhPurchase DROP COLUMN `ghsInfo`;
+ALTER TABLE xhPurchase MODIFY ghsName VARCHAR(50) NOT NULL DEFAULT '' COMMENT '供货商名称' AFTER `ghsId`;
+ALTER TABLE xhPurchase MODIFY ghsAvatar VARCHAR(500) NOT NULL DEFAULT '' COMMENT '供货商头像' AFTER `ghsName`;