本帖最后由 liusonglin 于 2020-7-14 18:52 编辑
文件地址:app\models\user\WechatUser.php
208行
public static function userTakeOrderGiveCoupon($uid, $total_price) { $couponIds = StoreCouponIssue::where('status', 1) ->where('is_full_give', 1) ->where('is_del', 0) ->where('start_time','<=',time()) ->where('end_time','>=',time()) ->where('status',1) ->column('id,cid,full_reduction,remain_count,is_permanent'); if ($couponIds) { $couponIssueIds = StoreCouponIssueUser::where('uid', $uid) ->whereIn('issue_coupon_id', array_column($couponIds, 'id')) ->column('issue_coupon_id'); foreach ($couponIds as $couponId) if ($couponId && !in_array($couponId['id'], $couponIssueIds)) if ($total_price >= $couponId['full_reduction'] && (!$couponId['is_permanent'] || $couponId['remain_count'] >= 1)) { StoreCouponUser::addUserCoupon($uid, $couponId['cid']); StoreCouponIssueUser::addUserIssue($uid, $couponId['id']); StoreCouponIssue::where('id', $couponId['id'])->update(['remain_count' => $couponId['remain_count'] - 1]); } } }