Explorar el Código

wesmiler 报恩寺项目提交

wesmiler hace 4 años
padre
commit
782ce08099
Se han modificado 1 ficheros con 10 adiciones y 8 borrados
  1. 10 8
      app/Services/EnshrineService.php

+ 10 - 8
app/Services/EnshrineService.php

@@ -519,6 +519,7 @@ class EnshrineService extends BaseService
             return message($msg, false, ['show'=> true,'time'=> $enshrineTime,'hour'=> $hour,'minute'=> $minute]);
         }
 
+        $total = intval($goodsInfo->price*$num);
         \DB::beginTransaction();
         $data = [
             'source_id'=> $enshrineId,
@@ -528,7 +529,7 @@ class EnshrineService extends BaseService
             'order_sn'=> get_order_num('F'),
             'num'=> $num,
             'price'=> $goodsInfo->price,
-            'total'=> ($goodsInfo->price*$num),
+            'total'=> $total,
             'gd_name'=> isset($params['gd_name'])? $params['gd_name'] : '',
             'pay_at'=> date('Y-m-d H:i:s'),
             'remark'=> isset($params['remark'])? $params['remark'] : '',
@@ -542,13 +543,13 @@ class EnshrineService extends BaseService
         }
 
         // 扣款奖励处理
-        if($goodsInfo->price>0){
+        if($total>0){
 
-            if($memberInfo->coupon < $goodsInfo->price){
+            if($memberInfo->coupon < $total){
                 return message("账户花灯券不足,请先充值", false, [],10003);
             }
 
-            if(!MemberModel::where(['id'=> $userId, 'mark'=> 1])->decrement('coupon', $goodsInfo->price)){
+            if(!MemberModel::where(['id'=> $userId, 'mark'=> 1])->decrement('coupon', $total)){
                 \DB::rollBack();
                 return message("更新花灯券账户失败", false);
             }
@@ -559,7 +560,7 @@ class EnshrineService extends BaseService
                 'type'=> 1,
                 'coin_type'=> 1,
                 'pay_type'=> 1,
-                'money'=> $goodsInfo->price,
+                'money'=> $total,
                 'change_type'=> 2,
                 'balance'=> $memberInfo->coupon,
                 'create_time'=> time(),
@@ -575,8 +576,9 @@ class EnshrineService extends BaseService
         // 奖励
         $giveGd = ConfigService::make()->getConfigByCode('enshrine_give_gd');
         $giveGd = $giveGd? $giveGd : 0;
-        if($giveGd>0){
-            if(!MemberModel::where(['id'=> $userId, 'mark'=> 1])->increment('merits_num', $giveGd)){
+        $totalGd = $giveGd*$num;
+        if($totalGd>0){
+            if(!MemberModel::where(['id'=> $userId, 'mark'=> 1])->increment('merits_num', $totalGd)){
                 \DB::rollBack();
                 return message("更新功德账户失败", false);
             }
@@ -587,7 +589,7 @@ class EnshrineService extends BaseService
                 'type'=> 3,
                 'coin_type'=> 4,
                 'pay_type'=> 4,
-                'money'=> $giveGd,
+                'money'=> $totalGd,
                 'change_type'=> 1,
                 'balance'=> $memberInfo->merits_num,
                 'create_time'=> time(),