|
|
@@ -15,6 +15,7 @@
|
|
|
namespace app\adminapi\logic\works;
|
|
|
|
|
|
use app\adminapi\logic\user\UserLogic;
|
|
|
+use app\api\logic\UserCouponLogic;
|
|
|
use app\common\enum\ThirdTypeEnum;
|
|
|
use app\common\enum\worker\WorkerAccountLogEnum;
|
|
|
use app\common\logic\ThirdOrderLogic;
|
|
|
@@ -1285,4 +1286,31 @@ class ServiceWorkLogic extends BaseLogic
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 给用户发券
|
|
|
+ */
|
|
|
+ public static function userAddVoucher($params): bool
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $serviceWork = ServiceWork::where('id',$params['id'])->findOrEmpty();
|
|
|
+ if(!$serviceWork->isEmpty()){
|
|
|
+ $codes = [];
|
|
|
+ foreach ($params['coupon_data'] as $coupon_data) {
|
|
|
+ $coupon_data['code'] && $codes[] = $coupon_data['code'];
|
|
|
+ }
|
|
|
+ if($codes){
|
|
|
+ $userCouponLogic = UserCouponLogic::add(['codes'=>$codes,'user_id'=>$serviceWork->user_id]);
|
|
|
+ Log::info('工单中给用户发券:'.$serviceWork->user_id.'--'.json_encode($codes).'--'.json_encode($userCouponLogic));
|
|
|
+ if($userCouponLogic === false) throw new \Exception(UserCouponLogic::getError());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ self::setError($e->getMessage());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|