|
@@ -55,7 +55,8 @@ class CouponController extends Curd
|
|
'category' => function ($query) {
|
|
'category' => function ($query) {
|
|
$query->select('category_id', 'category_name');
|
|
$query->select('category_id', 'category_name');
|
|
},
|
|
},
|
|
- 'user'
|
|
|
|
|
|
+ 'user',
|
|
|
|
+ 'detail'
|
|
]);
|
|
]);
|
|
foreach ($where as $column => $value) {
|
|
foreach ($where as $column => $value) {
|
|
if (is_array($value)) {
|
|
if (is_array($value)) {
|
|
@@ -132,6 +133,19 @@ class CouponController extends Curd
|
|
} elseif ($item['coupon_validdate_day']) {
|
|
} elseif ($item['coupon_validdate_day']) {
|
|
$item['coupon_use_time'] = 'day';
|
|
$item['coupon_use_time'] = 'day';
|
|
}
|
|
}
|
|
|
|
+ $item['member_count'] = $item['pending_count'] = $item['used_count'] = 0;
|
|
|
|
+ if (!empty($item['detail'])) {
|
|
|
|
+ foreach ($item['detail'] as $detail) {
|
|
|
|
+ if (!empty($detail['join_coupon_detail_member_id'])){
|
|
|
|
+ $item['member_count'] += 1;
|
|
|
|
+ }
|
|
|
|
+ if ($detail['coupon_detail_status'] == 'PENDING'){
|
|
|
|
+ $item['pending_count'] += 1;
|
|
|
|
+ }elseif ($detail['coupon_detail_status'] == 'USED'){
|
|
|
|
+ $item['used_count'] += 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
return $items;
|
|
return $items;
|
|
@@ -302,12 +316,12 @@ class CouponController extends Curd
|
|
if ($detailCount < $data['coupon_number']) {
|
|
if ($detailCount < $data['coupon_number']) {
|
|
$this->generateCouponDetail($id, $data['coupon_number'] - $detailCount);
|
|
$this->generateCouponDetail($id, $data['coupon_number'] - $detailCount);
|
|
}
|
|
}
|
|
- }else if($originCouponNumber < $data['coupon_number']){
|
|
|
|
|
|
+ } else if ($originCouponNumber < $data['coupon_number']) {
|
|
$this->generateCouponDetail($id, $data['coupon_number'] - $originCouponNumber);
|
|
$this->generateCouponDetail($id, $data['coupon_number'] - $originCouponNumber);
|
|
- }else if($originCouponNumber > $data['coupon_number']){
|
|
|
|
- CouponDetail::where('join_detail_coupon_id',$id)
|
|
|
|
- ->where('join_coupon_detail_member_id','')
|
|
|
|
- ->limit($originCouponNumber-$data['coupon_number'])
|
|
|
|
|
|
+ } else if ($originCouponNumber > $data['coupon_number']) {
|
|
|
|
+ CouponDetail::where('join_detail_coupon_id', $id)
|
|
|
|
+ ->where('join_coupon_detail_member_id', '')
|
|
|
|
+ ->limit($originCouponNumber - $data['coupon_number'])
|
|
->delete();
|
|
->delete();
|
|
}
|
|
}
|
|
Db::commit();
|
|
Db::commit();
|
|
@@ -578,7 +592,7 @@ class CouponController extends Curd
|
|
CouponDetail::insert([
|
|
CouponDetail::insert([
|
|
'coupon_detail_id' => 'CUDT' . str_pad(SysSerial::getSerial(), 6, '0') . random_string(6, 'up'),
|
|
'coupon_detail_id' => 'CUDT' . str_pad(SysSerial::getSerial(), 6, '0') . random_string(6, 'up'),
|
|
'join_detail_coupon_id' => $couponId,
|
|
'join_detail_coupon_id' => $couponId,
|
|
- 'coupon_detail_status' => 'PENDING',
|
|
|
|
|
|
+ 'coupon_detail_status' => 'INIT',
|
|
'coupon_detail_addtimes' => time()
|
|
'coupon_detail_addtimes' => time()
|
|
]);
|
|
]);
|
|
}
|
|
}
|