whitefang 1 год назад
Родитель
Сommit
2b7c3eac51
2 измененных файлов с 15 добавлено и 11 удалено
  1. 14 11
      app/common/logic/EffectiveLogic.php
  2. 1 0
      app/common/logic/PaymentLogic.php

+ 14 - 11
app/common/logic/EffectiveLogic.php

@@ -15,16 +15,19 @@ class EffectiveLogic extends BaseLogic
     {
         $orderGoods = OrderGoods::whereIn('sn',RechargeOrder::where('work_id',$work->id)->column('sn'))->findOrEmpty();
         $effective =  EffectiveCategory::with('effectiveRule')->where('goods_category_id',$orderGoods->goods_category_id)->findOrEmpty();
-        OrderEffectiveLog::create([
-            'effective_id' => $effective->effectiveRule->id,
-            'sn' => $orderGoods['sn'],
-            'user_id' => $work['user_id'],
-            'work_id' => $work->work_id,
-            'goods_id' => $orderGoods->goods_id,
-            'effective_unit' => $effective->effectiveRule->effective_unit,
-            'effective_num' => $effective->effectiveRule->effective_num,
-            'remark' => $effective->effectiveRule->remark,
-            'end_effective_time' =>  date("Y-m-d H:i:s",EffectiveRules::formatEndEffectiveTime(time() ,$effective->effectiveRule->effective_num,$effective->effectiveRule->effective_unit)),
-        ]);
+        if(!$effective->isEmpty()){
+            OrderEffectiveLog::create([
+                'effective_id' => $effective->effectiveRule->id,
+                'sn' => $orderGoods['sn'],
+                'user_id' => $work['user_id'],
+                'work_id' => $work->work_id,
+                'goods_id' => $orderGoods->goods_id,
+                'effective_unit' => $effective->effectiveRule->effective_unit,
+                'effective_num' => $effective->effectiveRule->effective_num,
+                'remark' => $effective->effectiveRule->remark,
+                'end_effective_time' =>  date("Y-m-d H:i:s",EffectiveRules::formatEndEffectiveTime(time() ,$effective->effectiveRule->effective_num,$effective->effectiveRule->effective_unit)),
+            ]);
+        }
+
     }
 }

+ 1 - 0
app/common/logic/PaymentLogic.php

@@ -17,6 +17,7 @@ namespace app\common\logic;
 
 use app\common\enum\PayEnum;
 use app\common\enum\YesNoEnum;
+use app\common\model\effective\EffectiveCategory;
 use app\common\model\pay\PayWay;
 use app\common\model\recharge\RechargeOrder;
 use app\common\model\user\User;