瀏覽代碼

拼音方案

shish 5 年之前
父節點
當前提交
00040159e3

+ 1 - 1
app-ghs/controllers/GhsController.php

@@ -15,7 +15,7 @@ class GhsController extends BaseController
     {
         $get = Yii::$app->request->get();
         $name = isset($get['name']) ? $get['name'] : '';
-        $where = ['sjId' => $this->sjId];
+        $where = ['ownSjId' => $this->sjId];
         if (!empty($name)) {
             if (stringUtil::isLetter($name)) {
                 $where['py'] = ['like', $name];

+ 22 - 2
app-hd/controllers/PurchaseController.php

@@ -57,7 +57,15 @@ class PurchaseController extends BaseController
         $orderSn = $get['orderSn'] ?? 0;
         $info = PurchaseClass::getByCondition(['orderSn' => $orderSn]);
         PurchaseClass::valid($info, $this->shopId);
-        PurchaseClass::debt($info);
+        $connection = Yii::$app->db;//事务处理
+        $transaction = $connection->beginTransaction();
+        try {
+            PurchaseClass::debt($info);
+            $transaction->commit();
+        } catch (Exception $e) {
+            $transaction->rollBack();
+            util::fail('支付失败');
+        }
         util::complete();
     }
 
@@ -67,12 +75,24 @@ class PurchaseController extends BaseController
         $get = Yii::$app->request->get();
         $orderSn = $get['orderSn'] ?? 0;
         $password = $get['password'] ?? '';
+        $admin = $this->admin;
+        if (password_verify($password, $admin['payPassword']) == false) {
+            util::fail('密码错误');
+        }
         $info = PurchaseClass::getByCondition(['orderSn' => $orderSn]);
         if (empty($info)) {
             util::fail('没有找到采购单');
         }
         PurchaseClass::valid($info, $this->shopId);
-        purchaseClass::balancePay($info);
+        $connection = Yii::$app->db;//事务处理
+        $transaction = $connection->beginTransaction();
+        try {
+            purchaseClass::balancePay($info);
+            $transaction->commit();
+        } catch (Exception $e) {
+            $transaction->rollBack();
+            util::fail('支付失败');
+        }
         util::complete();
     }
 

+ 8 - 1
app-pt/controllers/TestController.php

@@ -10,6 +10,7 @@ use bizHd\user\services\UserService;
 use bizHd\wx\classes\WxOpenClass;
 use bizHd\wx\services\WxOpenService;
 use common\components\mapUtil;
+use Overtrue\Pinyin\Pinyin;
 use Yii;
 use common\components\wxUtil;
 use common\components\miniUtil;
@@ -17,7 +18,13 @@ use common\components\miniUtil;
 
 class TestController extends PublicController
 {
-	
+
+    public function actionPy()
+    {
+        $pinyin = new Pinyin(); // 默认
+        echo $pinyin->abbr('带着希望去旅行圳未石耒');
+    }
+
     //即时配送
     public function actionGetBindAccount()
     {

+ 88 - 6
biz-hd/purchase/classes/PurchaseClass.php

@@ -3,12 +3,11 @@
 namespace bizHd\purchase\classes;
 
 use biz\ghs\classes\GhsClass;
-use biz\shop\classes\ShopClass;
+use biz\ghs\models\Ghs;
+use biz\shop\models\Shop;
 use bizGhs\admin\classes\AdminClass;
-use bizGhs\custom\classes\CustomClass;
-use biz\sj\classes\MerchantClass;
+use bizGhs\order\classes\OrderClass;
 use common\components\orderSn;
-use common\components\stringUtil;
 use common\components\util;
 use Yii;
 use bizHd\base\classes\BaseClass;
@@ -59,6 +58,7 @@ class PurchaseClass extends BaseClass
         $sjId = $ghs['sjId'] ?? 0;
         $shopId = $ghs['shopId'];
         $getType = $data['getType'];
+        $cgId = $respond['id'] ?? 0;
         $orderData = [
             'prePrice' => 0.01,
             'actPrice' => 0.01,
@@ -67,9 +67,10 @@ class PurchaseClass extends BaseClass
             'product' => $productList,
             'merchantId' => $sjId,
             'sendType' => $getType,
+            'cgId' => $cgId,
         ];
 
-        \bizGhs\order\classes\OrderClass::addOrder($orderData, $shopId, true);
+        OrderClass::addOrder($orderData, $shopId, true);
 
         return $respond;
     }
@@ -130,14 +131,95 @@ class PurchaseClass extends BaseClass
     public static function debt($info)
     {
         if (isset($info['status']) == false || $info['status'] != self::STATUS_UN_PAY) {
-            util::fail('请确认订单状态');
+            util::fail('订单不是待付款状态');
         }
+        $id = $info['id'] ?? 0;
+        $data = [
+            'status' => self::STATUS_UN_SEND,
+            'debt' => 1,
+        ];
+        self::updateById($id, $data);
+
+        $shopId = $info['shopId'] ?? 0;
+        $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
+        if (empty($shop)) {
+            util::fail('没有找到门店');
+        }
+        $actPrice = $info['actPrice'];
+        $shop->totalPurchase = bcadd($shop->totalPurchase, $actPrice, 2);
+        $shop->totalPurchaseOrder += 1;
+        $shop->save();
+        $ghsId = $info['ghsId'] ?? 0;
+        $ghs = Ghs::findBySql('select * from ' . Ghs::tableName() . ' where id = :id for update', ['id' => $ghsId])->one();
+        if (empty($ghs)) {
+            util::fail('没有找到供货商');
+        }
+        $ghs->debt = 2;
+        $ghs->debtAmount = bcadd($ghs->debtAmount, $actPrice, 2);
+        $ghs->debtNum += 1;
+        $ghs->expendAmount = bcadd($ghs->expendAmount, $actPrice, 2);
+        $ghs->expendNum += 1;
+        $ghs->save();
+
+        $cgId = $info['cgId'] ?? 0;
+        $cg = OrderClass::getById($cgId, true);
+        if (empty($cg)) {
+            util::fail('没有找到对应供货商订单');
+        }
+        $cg->status = OrderClass::ORDER_STATUS_UN_SEND;
+        $cg->save();
+        $shopId = $cg->shopId;
+        $actPrice = $cg->actPrice;
+        $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
+        $shop->totalIncome = bcadd($shop->totalIncome, $actPrice, 2);
+        $shop->totalOrderNum += 1;
+        $shop->save();
+
     }
 
     //余额支付 ssh 2021.1.24
     public static function balancePay($info)
     {
+        if (isset($info['status']) == false || $info['status'] != self::STATUS_UN_PAY) {
+            util::fail('订单不是待付款状态');
+        }
+        $id = $info['id'] ?? 0;
+        $data = [
+            'status' => self::STATUS_UN_SEND,
+        ];
+        self::updateById($id, $data);
 
+        $shopId = $info['shopId'] ?? 0;
+        $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
+        if (empty($shop)) {
+            util::fail('没有找到门店');
+        }
+        $actPrice = $info['actPrice'];
+        $shop->totalPurchase = bcadd($shop->totalPurchase, $actPrice, 2);
+        $shop->totalPurchaseOrder += 1;
+        $shop->save();
+        $ghsId = $info['ghsId'] ?? 0;
+        $ghs = Ghs::findBySql('select * from ' . Ghs::tableName() . ' where id = :id for update', ['id' => $ghsId])->one();
+        if (empty($ghs)) {
+            util::fail('没有找到供货商');
+        }
+        $ghs->expendAmount = bcadd($ghs->expendAmount, $actPrice, 2);
+        $ghs->expendNum += 1;
+        $ghs->save();
+
+        $cgId = $info['cgId'] ?? 0;
+        $cg = OrderClass::getById($cgId, true);
+        if (empty($cg)) {
+            util::fail('没有找到对应供货商订单');
+        }
+        $cg->status = OrderClass::ORDER_STATUS_UN_SEND;
+        $cg->save();
+        $shopId = $cg->shopId;
+        $actPrice = $cg->actPrice;
+        $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
+        $shop->totalIncome = bcadd($shop->totalIncome, $actPrice, 2);
+        $shop->totalOrderNum += 1;
+        $shop->save();
     }
 
     //检查采购单

+ 2 - 1
sql.sql

@@ -2257,4 +2257,5 @@ ALTER TABLE `xhGhs` CHANGE `ghsSjId` `sjId` INT(11) NOT NULL DEFAULT '0' COMMENT
 ALTER TABLE `xhGhs` CHANGE `ghsShopId` `shopId` INT(11) NOT NULL DEFAULT '0' COMMENT '供货商门店id';
 ALTER TABLE `xhGhs` DROP COLUMN `ownShopId`;
 ALTER TABLE `xhPurchase` MODIFY `shopId` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '门店ID' AFTER `merchantId`;
-ALTER TABLE `xhGhsPurchaseOrder` MODIFY `shopId` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '门店ID' AFTER `merchantId`;
+ALTER TABLE `xhGhsPurchaseOrder` MODIFY `shopId` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '门店ID' AFTER `merchantId`;
+ALTER TABLE xhGhsOrder ADD cgId INT NOT NULL DEFAULT 0 COMMENT '采购单id' AFTER `id`;