|
@@ -114,7 +114,9 @@ class CouponService extends BaseService
|
|
|
if(time()>$endTime){
|
|
|
$item['status'] = 4; // 已过期
|
|
|
}
|
|
|
+ $item['min_price'] = floatval($item['min_price']);
|
|
|
$item['create_time'] = $item['create_time']? datetime($item['create_time'],'Y-m-d H.i.s') : '';
|
|
|
+ $item['end_time_text'] = $item['end_time']? datetime($item['end_time'],'Y-m-d') : '';
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -208,7 +210,7 @@ class CouponService extends BaseService
|
|
|
|
|
|
$query->where('start_time','<=', time())
|
|
|
->where('end_time','>=', time());
|
|
|
- })->count('sid');
|
|
|
+ })->count('id');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -245,7 +247,7 @@ class CouponService extends BaseService
|
|
|
$info = $this->model->where(['id'=> $id,'mark'=>1,'status'=>1])
|
|
|
->where('start_time','<=', time())
|
|
|
->where('end_time','>=', time())
|
|
|
- ->select(['id as coupon_id','name','num','received_num','coupon_type','reduce_price','discount','min_price','expire_day','start_time','end_time','apply_merch_ids'])
|
|
|
+ ->select(['id as coupon_id','merch_id','name','num','received_num','coupon_type','reduce_price','discount','min_price','expire_day','start_time','end_time','apply_merch_ids'])
|
|
|
->first();
|
|
|
$info = $info? $info->toArray() : [];
|
|
|
if(empty($info)){
|
|
@@ -268,6 +270,8 @@ class CouponService extends BaseService
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ unset($info['num']);
|
|
|
+ unset($info['received_num']);
|
|
|
$info['code'] = get_random_code(8, 'DY');
|
|
|
$info['user_id'] = $userId;
|
|
|
$info['create_time'] = time();
|
|
@@ -281,7 +285,7 @@ class CouponService extends BaseService
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if(!$this->model->where(['id'=> $id])->setInc('received_num', 1)){
|
|
|
+ if(!$this->model->where(['id'=> $id])->increment('received_num', 1)){
|
|
|
$this->error = 2907;
|
|
|
DB::rollBack();
|
|
|
return false;
|