setter
parent
19655f9464
commit
7cf6e9efda
|
@ -67,31 +67,61 @@ class Coupon extends Base
|
|||
'(end_time > NOW()) as sort_weight'];
|
||||
|
||||
$whereMap[] = ['consumer_code', '=', $accountCode];
|
||||
switch ($type) {
|
||||
case 'all':
|
||||
// 全部持有优惠券
|
||||
$sortOrder = ['sort_weight' => 'desc', 'end_time' => 'asc'];
|
||||
break;
|
||||
case 'notUsed':
|
||||
// 未使用(包含已过期)
|
||||
$whereMap[] = ['is_verificated', '=', self::BOOL_FALSE];
|
||||
$sortOrder = ['sort_weight' => 'desc', 'end_time' => 'asc'];
|
||||
break;
|
||||
case 'normal':
|
||||
// 未使用且未过期
|
||||
$whereMap[] = ['is_verificated', '=', self::BOOL_FALSE];
|
||||
$whereMap[] = ['end_time', '< TIME', date('Y-m-d H:i:s')];
|
||||
break;
|
||||
case 'used':
|
||||
// 已使用
|
||||
$whereMap[] = ['is_verificated', '=', self::BOOL_TRUE];
|
||||
$sortOrder = ['verificate_time' => 'desc'];
|
||||
break;
|
||||
}
|
||||
// switch ($type) {
|
||||
// case 'all':
|
||||
// // 全部持有优惠券
|
||||
// $sortOrder = ['sort_weight' => 'desc', 'end_time' => 'asc'];
|
||||
// break;
|
||||
// case 'notUsed':
|
||||
// // 未使用(包含已过期)
|
||||
// $whereMap[] = ['is_verificated', '=', self::BOOL_FALSE];
|
||||
// $sortOrder = ['sort_weight' => 'desc', 'end_time' => 'asc'];
|
||||
// break;
|
||||
// case 'normal':
|
||||
// // 未使用且未过期
|
||||
// $whereMap[] = ['is_verificated', '=', self::BOOL_FALSE];
|
||||
// $whereMap[] = ['end_time', '> TIME', date('Y-m-d H:i:s')];
|
||||
// break;
|
||||
// case 'used':
|
||||
// // 已使用
|
||||
// $whereMap[] = ['is_verificated', '=', self::BOOL_TRUE];
|
||||
// $sortOrder = ['verificate_time' => 'desc'];
|
||||
// break;
|
||||
// }
|
||||
|
||||
$res = CouponRepository::getInstance()->findList($whereMap, $fields, $page, $size,function ($q){
|
||||
return $q->with(["couponMain","scoreModel","business"]);
|
||||
return $q->with(["couponMain","scoreModel","business"])
|
||||
->where(function ($q){
|
||||
$notUsedWhereMap = [];//未过期 未使用
|
||||
$notUsedWhereMap[] = ['is_verificated', '=', self::BOOL_FALSE];
|
||||
$notUsedWhereMap[] = ['end_time', '> TIME', date('Y-m-d H:i:s')];
|
||||
|
||||
$usedWhereMap = [];//已使用 7天内
|
||||
$usedWhereMap[] = ['is_verificated', '=', self::BOOL_TRUE];
|
||||
$usedWhereMap[] = ['verificate_time', '> TIME', date('Y-m-d H:i:s',time() - (7 * 86400)) ];
|
||||
|
||||
$beOverdueWhereMap = [];//未使用 已过期7天内
|
||||
$beOverdueWhereMap[] = ['is_verificated', '=', self::BOOL_FALSE];
|
||||
$beOverdueWhereMap[] = ['end_time', '> TIME', date('Y-m-d H:i:s',time() - (7 * 86400))];;
|
||||
|
||||
|
||||
$q->whereOr(function ($q)use($notUsedWhereMap){
|
||||
$q->where($notUsedWhereMap);
|
||||
})//未使用未过期
|
||||
|
||||
->whereOr(function ($q)use($usedWhereMap){
|
||||
$q->where($usedWhereMap);
|
||||
})//已使用 7天内
|
||||
|
||||
|
||||
->whereOr(function ($q)use($usedWhereMap){
|
||||
$q->where($usedWhereMap);
|
||||
});//已过期
|
||||
})
|
||||
//->fetchSql(true)
|
||||
;
|
||||
}, $sortOrder);
|
||||
|
||||
$time = time();
|
||||
$res['list'] ->each(function ($item) use($time){
|
||||
//重置优惠券名称
|
||||
|
@ -505,7 +535,7 @@ class Coupon extends Base
|
|||
//付款成功才提交!!!!!伪装成功
|
||||
if(true||isset($result['payment_no']) ){
|
||||
Db::commit();
|
||||
return $this->json(0,"优惠券签到使用成功,您获得{$consumerMoney}元红包,已存入您的零钱");
|
||||
return $this->json(0,"优惠券签到使用成功,您获得{$consumerMoney}元红包,已存入您的零钱",["redPacket"=>$consumerMoney]);
|
||||
}
|
||||
//Log::info("企业发起付款失败:" . json_encode($result,JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
|
|
@ -48,7 +48,20 @@ class Dictionary extends Base
|
|||
*/
|
||||
public function getBusinessCircle(): Json
|
||||
{
|
||||
$items = DictionaryRepository::getInstance()->getAllBusinessCircleList();
|
||||
$lng = $this->request->param('lng/f', 0); // 经度 104.752890
|
||||
$lat = $this->request->param('lat/f', 0); // 纬度 31.465040
|
||||
$field = ["*"];
|
||||
$order = [];
|
||||
|
||||
if ($lng && $lat) {
|
||||
$field[] = "abs( (IFNULL(lat,0) - {$lng}) * (IFNULL(lng,0) - {$lat}) ) as square";
|
||||
$order["square"] = "asc";
|
||||
}
|
||||
|
||||
$order["sort"] = "desc";
|
||||
$order["id"] = "desc";
|
||||
|
||||
$items = DictionaryRepository::getInstance()->getAllBusinessCircleList($field,$order);
|
||||
$items->each(function ($item) {
|
||||
$areaText = '';
|
||||
if (!empty($item['province_text'])) {
|
||||
|
|
|
@ -44,11 +44,11 @@ class DictionaryRepository extends Repository
|
|||
/**
|
||||
* 获取所有的商圈数据
|
||||
*/
|
||||
public function getAllBusinessCircleList(array $fields=[])
|
||||
public function getAllBusinessCircleList(array $fields=[],$order = ['sort'=>'desc', 'id'=>'desc'])
|
||||
{
|
||||
try {
|
||||
return BusinessCircle::field($fields)
|
||||
->order(['sort'=>'desc', 'id'=>'asc'])
|
||||
->order($order)
|
||||
->select();
|
||||
} catch (\Exception $e) {
|
||||
return new Collection();
|
||||
|
|
Loading…
Reference in New Issue