Procházet zdrojové kódy

红包 与原路退回

shish před 4 roky
rodič
revize
1e079331f7

+ 15 - 4
biz-hd/cg/services/CgRefundService.php

@@ -3,6 +3,7 @@
 namespace bizHd\cg\services;
 
 use biz\ghs\classes\GhsClass;
+use biz\hb\classes\HbClass;
 use biz\shop\classes\ShopCapitalClass;
 use biz\shop\classes\ShopClass;
 use biz\wx\classes\WxMessageClass;
@@ -48,7 +49,7 @@ class CgRefundService extends BaseService
         $post['cgId'] = $cg->id;
         $refundPrice = $post['price'] ?? 0;
         if (is_numeric($refundPrice) == false || $refundPrice < 0) {
-            util::fail('退款金额有问题');
+            util::fail('退款金额有问题');
         }
         $post['refundPrice'] = $refundPrice;
 
@@ -58,7 +59,18 @@ class CgRefundService extends BaseService
             util::fail('没有找到门店');
         }
 
-        //--------start-----花材处理逻辑 linqh 2021.6.28------
+        //退款金额和采购单金额一样,有使用红包则原路退回
+        $actPrice = $cg->actPrice ?? 0;
+        if (floatval($actPrice) == floatval($refundPrice)) {
+            $hbId = $cg->hbId ?? 0;
+            if (!empty($hbId)) {
+                $hbInfo = HbClass::getById($hbId, true);
+                $hbInfo->status = HbClass::STATUS_UN_USE;
+                $hbInfo->take = HbClass::TAKE_UN;
+                $hbInfo->save();
+            }
+        }
+
         $ghsItemInfo = $post['product'] ?? '';
         $data = [];
         $data['status'] = CgRefundClass::STATUS_COMPLETE;
@@ -107,7 +119,6 @@ class CgRefundService extends BaseService
             StockRecordClass::addRecordByOrder($orderData, StockRecordClass::STOCK_RECORD_TYPE_REFUND);
 
         }
-        //--------end-----花材处理逻辑 linqh 2021.6.28------
 
         //门店总收入增加
         $currentTotalIncome = bcadd($shop->totalIncome, $refundPrice, 2);
@@ -236,7 +247,7 @@ class CgRefundService extends BaseService
         } elseif ($payWay == dict::getDict('payWay', 'balancePay')) {
 
             //门店余额增加
-            ShopClass::cgRefundAddBalance($shop, $refundPrice, $cgRefund,$ghs);
+            ShopClass::cgRefundAddBalance($shop, $refundPrice, $cgRefund, $ghs);
 
         } else {
             util::fail('支付方式没有找到哦!');

+ 7 - 0
biz/hb/classes/HbClass.php

@@ -10,6 +10,13 @@ class HbClass extends BaseClass
 
     public static $baseFile = '\biz\hb\models\Hb';
 
+    const STATUS_UN_USE = 1;
+    const STATUS_USED = 2;
+    const STATUS_EXPIRE = 3;
+
+    const TAKE_UN = 1;
+    const TAKE_HAS = 2;
+
     public static function getHbList($where)
     {
         $data = self::getList('*', $where, 'addTime DESC');

+ 1 - 1
biz/wx/classes/WxMessageClass.php

@@ -705,7 +705,7 @@ class WxMessageClass extends BaseClass
                 ]
             ];
             $data['miniprogram']['appid'] = $wx['miniAppId'];
-            $data['miniprogram']['pagepath'] = 'pagesClient/member/detail?id=' . $customId;
+            $data['miniprogram']['pagepath'] = 'admin/hb/rechargeList';
             wxUtil::sendTaskInform($data, $wx, $ptStyle);
         }
     }

+ 2 - 2
console/controllers/ShopCouponController.php

@@ -24,8 +24,8 @@ class ShopCouponController extends Controller
         }
         try {
             foreach ($coupons as $coupon) {
-                $couponAr = ShopCouponClass::getById($coupon['id'], true);
-                ShopCouponClass::expire($couponAr);
+                $info = ShopCouponClass::getById($coupon['id'], true);
+                ShopCouponClass::expire($info);
                 $log = "过期的优惠券:{$coupon['id']} json:" . json_encode($coupon);
                 Yii::info($log);
             }