diff --git a/crmeb/app/adminapi/controller/v1/marketing/lottery/LuckLottery.php b/crmeb/app/adminapi/controller/v1/marketing/lottery/LuckLottery.php index 86e4b3417..439394773 100644 --- a/crmeb/app/adminapi/controller/v1/marketing/lottery/LuckLottery.php +++ b/crmeb/app/adminapi/controller/v1/marketing/lottery/LuckLottery.php @@ -85,6 +85,9 @@ class LuckLottery extends AuthController /** * 添加抽奖 * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function add() { diff --git a/crmeb/app/api/controller/v2/activity/LuckLotteryController.php b/crmeb/app/api/controller/v2/activity/LuckLotteryController.php index dde6e1a3f..1623d7568 100644 --- a/crmeb/app/api/controller/v2/activity/LuckLotteryController.php +++ b/crmeb/app/api/controller/v2/activity/LuckLotteryController.php @@ -102,7 +102,11 @@ class LuckLotteryController /** * 领取奖品 * @param Request $request + * @param LuckLotteryRecordServices $lotteryRecordServices * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function lotteryReceive(Request $request, LuckLotteryRecordServices $lotteryRecordServices) { @@ -125,6 +129,9 @@ class LuckLotteryController * @param Request $request * @param LuckLotteryRecordServices $lotteryRecordServices * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function lotteryRecord(Request $request, LuckLotteryRecordServices $lotteryRecordServices) { diff --git a/crmeb/app/services/activity/coupon/StoreCouponIssueServices.php b/crmeb/app/services/activity/coupon/StoreCouponIssueServices.php index 8a88619d5..269a45384 100644 --- a/crmeb/app/services/activity/coupon/StoreCouponIssueServices.php +++ b/crmeb/app/services/activity/coupon/StoreCouponIssueServices.php @@ -365,30 +365,13 @@ class StoreCouponIssueServices extends BaseServices $issueCouponInfo = $this->dao->getInfo((int)$id); $uid = $user->uid; if (!$issueCouponInfo) throw new ApiException(400516); - /** @var MemberRightServices $memberRightService */ - $memberRightService = app()->make(MemberRightServices::class); - if ($issueCouponInfo->receive_type == 4 && (!$user->is_money_level || !$memberRightService->getMemberRightStatus("coupon"))) { - if (!$user->is_money_level) throw new ApiException(400097); - if (!$memberRightService->getMemberRightStatus("coupon")) throw new ApiException(400098); - } /** @var StoreCouponIssueUserServices $issueUserService */ $issueUserService = app()->make(StoreCouponIssueUserServices::class); - if ($is_receive) { - $alreadyReceived = $issueUserService->count(['uid' => $uid, 'issue_coupon_id' => $id]); - if ($alreadyReceived >= $issueCouponInfo['receive_limit']) { - throw new ApiException(400518); - } - } /** @var StoreCouponUserServices $couponUserService */ $couponUserService = app()->make(StoreCouponUserServices::class); - if ($issueCouponInfo->remain_count <= 0 && !$issueCouponInfo->is_permanent) throw new ApiException(400518); $this->transaction(function () use ($issueUserService, $uid, $id, $couponUserService, $issueCouponInfo) { $issueUserService->save(['uid' => $uid, 'issue_coupon_id' => $id, 'add_time' => time()]); - $couponUserService->addUserCoupon($uid, $issueCouponInfo, "get"); - if ($issueCouponInfo['total_count'] > 0) { - $issueCouponInfo['remain_count'] -= 1; - $issueCouponInfo->save(); - } + $couponUserService->addUserCoupon($uid, $issueCouponInfo, "send"); }); } @@ -429,6 +412,9 @@ class StoreCouponIssueServices extends BaseServices * @param int $uid * @param $types * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function getUserCouponList(int $uid, $types) { @@ -512,6 +498,9 @@ class StoreCouponIssueServices extends BaseServices * 获取单个优惠券类型 * @param array $where * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function getOne(array $where) { @@ -538,6 +527,8 @@ class StoreCouponIssueServices extends BaseServices /** * 给会员发放优惠券 * @param $uid + * @param int $couponId + * @return bool * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException diff --git a/crmeb/app/services/activity/lottery/LuckLotteryRecordServices.php b/crmeb/app/services/activity/lottery/LuckLotteryRecordServices.php index 28cd0ad82..3f4d9ac1e 100644 --- a/crmeb/app/services/activity/lottery/LuckLotteryRecordServices.php +++ b/crmeb/app/services/activity/lottery/LuckLotteryRecordServices.php @@ -46,6 +46,9 @@ class LuckLotteryRecordServices extends BaseServices * 获取抽奖记录列表 * @param array $where * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function getList(array $where) { @@ -108,7 +111,11 @@ class LuckLotteryRecordServices extends BaseServices * 写入中奖纪录 * @param int $uid * @param array $prize + * @param array $userInfo * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function insertPrizeRecord(int $uid, array $prize, array $userInfo = []) { @@ -218,13 +225,6 @@ class LuckLotteryRecordServices extends BaseServices throw new ApiException(410053); } break; - case 7: - //TODO 未完善 - break; - case 8: - break; - case 9: - break; } $this->dao->update($lottery_record_id, $data, 'id'); }); @@ -272,7 +272,11 @@ class LuckLotteryRecordServices extends BaseServices /** * 获取中奖记录 * @param int $uid + * @param array $where * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function getRecord(int $uid, $where = []) { diff --git a/crmeb/app/services/activity/lottery/LuckLotteryServices.php b/crmeb/app/services/activity/lottery/LuckLotteryServices.php index 9a23637f1..a5114ede3 100644 --- a/crmeb/app/services/activity/lottery/LuckLotteryServices.php +++ b/crmeb/app/services/activity/lottery/LuckLotteryServices.php @@ -154,7 +154,6 @@ class LuckLotteryServices extends BaseServices } $lottery = $lottery->toArray(); if (isset($lottery['prize']) && $lottery['prize']) { - $products = $coupons = []; $product_ids = array_unique(array_column($lottery['prize'], 'product_id')); $coupon_ids = array_unique(array_column($lottery['prize'], 'coupon_id')); /** @var StoreProductServices $productServices */ @@ -173,6 +172,9 @@ class LuckLotteryServices extends BaseServices } } } + foreach ($lottery['user_level'] as &$item) { + $item = (int)$item; + } /** @var UserLabelServices $userLabelServices */ $userLabelServices = app()->make(UserLabelServices::class); $lottery['user_label'] = !empty($lottery['user_label']) ? $userLabelServices->getLabelList(['ids' => $lottery['user_label']], ['id', 'label_name']) : []; @@ -183,6 +185,9 @@ class LuckLotteryServices extends BaseServices * 添加抽奖活动以及奖品 * @param array $data * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function add(array $data) {