更新:商家个人资料信息中补充返回优惠卷统计数据
parent
b0e754c246
commit
f4c9de618a
|
@ -181,6 +181,8 @@ class User extends Base
|
|||
'reason' => $account['business']['reason'],
|
||||
'balance' => $account['business']['balance'],
|
||||
'enable' => $account['business']['enable'],
|
||||
// 商家优惠卷情况统计
|
||||
'couponCountList' => $busRepo->getCountBusinessOnShelf($account['business']['code'], 29),
|
||||
],
|
||||
"alertMoney"=>config("wechat.balance"),
|
||||
"redPrice"=>CouponRepository::getInstance()->getUserRedPrice( $account['user_code']),
|
||||
|
@ -245,7 +247,7 @@ class User extends Base
|
|||
} catch (ValidateException $e) {
|
||||
return $this->json(4001, $e->getError());
|
||||
} catch (Exception $e) {
|
||||
return $this->json(5001, '服务器繁忙!获取用户个人信息失败');
|
||||
return $this->json(5001, '服务器繁忙!获取用户个人信息失败'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -155,4 +155,54 @@ trait CouponMainTrait
|
|||
->where("on_shelf",CouponMain::on_shelf_on)
|
||||
->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计商家优惠卷情况
|
||||
*
|
||||
* @param $businessCode
|
||||
* @param int $daySize 最近($daySize + 1)天内的领取量, 0表示当日领取量
|
||||
*/
|
||||
public function getCountBusinessOnShelf($businessCode, $daySize = 29)
|
||||
{
|
||||
$whereMap = [
|
||||
['business_code', '=', $businessCode],
|
||||
['on_shelf', '=', CouponMain::on_shelf_on]
|
||||
];
|
||||
|
||||
$totalSize = CouponMain::where($whereMap)->count();
|
||||
$totalCountSize = CouponMain::where($whereMap)->sum('count');
|
||||
$verificationSize = Coupon::alias('c')
|
||||
->leftJoin('coupon_main m', 'c.coupon_id = m.id')
|
||||
->where([
|
||||
['m.business_code', '=', $businessCode],
|
||||
['m.on_shelf', '=', CouponMain::on_shelf_on],
|
||||
['c.is_verificated', '=', Coupon::is_verificated_on]
|
||||
])
|
||||
->count('c.id');
|
||||
$unVerificationSize = $totalCountSize - $verificationSize;
|
||||
$unVerificationSize = $unVerificationSize > 0 ? $unVerificationSize : 0;
|
||||
$lastReceivedSize = Coupon::alias('c')
|
||||
->leftJoin('coupon_main m', 'c.coupon_id = m.id')
|
||||
->where([
|
||||
['m.business_code', '=', $businessCode],
|
||||
])
|
||||
->when($daySize >= 0, function ($q) use ($daySize) {
|
||||
$startDay = date('Y-m-d 00:00:00', strtotime('- '.$daySize.' day'));
|
||||
$q->whereTime('c.received_time', '>=', $startDay);
|
||||
})
|
||||
->count('c.id');
|
||||
|
||||
return [
|
||||
// 发行总次数
|
||||
'totalSize' => $totalSize,
|
||||
// 发行优惠卷总数量
|
||||
'totalCountSize' => $totalCountSize,
|
||||
// 累计已核销数量
|
||||
'verificationSize' => $verificationSize,
|
||||
// 剩余未核销量
|
||||
'unVerificationSize' => $unVerificationSize,
|
||||
// 最近($daySize + 1)天内的领取量
|
||||
'lastReceivedSize' => $lastReceivedSize,
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue