feat : coupon
This commit is contained in:
@@ -93,23 +93,18 @@ class HomePopupsService extends BaseService
|
||||
|
||||
$insertData = array_merge($insertData, $copies);
|
||||
|
||||
if ($item['appoint_group'] == CouponCode::DISPENSE_APPOINT_GROUP_ALL_PEOPLE) {
|
||||
$allUpdateData[] = [
|
||||
'id' => $item['id'],
|
||||
'receive_count' => $item['receive_count'] +$item['item_count'],
|
||||
];
|
||||
} else {
|
||||
if ($item['appoint_group'] != CouponCode::DISPENSE_APPOINT_GROUP_ALL_PEOPLE) {
|
||||
$appointUpdateData[] = [
|
||||
'coupon_dispense_id' => $item['id'],
|
||||
'user_id' => $this->userId,
|
||||
];
|
||||
}
|
||||
|
||||
$allUpdateData[] = [
|
||||
'id' => $item['id'],
|
||||
'receive_count' => $item['receive_count'] +$item['item_count'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($allUpdateData)) return;
|
||||
|
||||
@@ -121,7 +116,7 @@ class HomePopupsService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
Db::transaction(function () use($allUpdateData,$appointUpdateData) {
|
||||
Db::transaction(function () use($allUpdateData,$appointUpdateData,$insertData) {
|
||||
$appointUpdateFlag = true;
|
||||
|
||||
if (!empty($appointUpdateData)) {
|
||||
@@ -130,7 +125,9 @@ class HomePopupsService extends BaseService
|
||||
|
||||
$allUpdateFlag = (new CouponDispenseLog)->update($allUpdateData);
|
||||
|
||||
if (!$allUpdateFlag || !$appointUpdateFlag) throw new ErrException('领取失败');
|
||||
$insertFlag = (new UserCoupon)->insert($insertData);
|
||||
|
||||
if (!$allUpdateFlag || !$appointUpdateFlag || !$insertFlag) throw new ErrException('领取失败');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user