diff --git a/app/common/dao/store/StoreActivityUserDao.php b/app/common/dao/store/StoreActivityUserDao.php index 4da6b6d1..2d6b8686 100644 --- a/app/common/dao/store/StoreActivityUserDao.php +++ b/app/common/dao/store/StoreActivityUserDao.php @@ -157,4 +157,27 @@ class StoreActivityUserDao extends BaseDao return ['amount' => $userConsumption['coupon_price'], 'end_time' => $userConsumption['end_time']]; } + /** + * 红包获取记录 + * @param int $userId + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function record(int $userId) + { + $consumption = StoreConsumption::select()->toArray(); + $record = StoreConsumptionUser::where('uid', $userId) + ->whereIn('coupon_id', array_column($consumption, 'coupon_id')) + ->where('status', '>=', StoreConsumptionUser::STATUS_UNUSED) + ->field('coupon_price,order_amount,create_time') + ->select()->toArray(); + $totalAmount = 0; + foreach ($record as $item) { + $totalAmount = bcadd($totalAmount, $item['coupon_price'], 2); + } + return ['total_amount' => $totalAmount, 'record' => $record]; + } + } diff --git a/app/common/model/store/consumption/StoreConsumptionDetail.php b/app/common/model/store/consumption/StoreConsumptionDetail.php new file mode 100644 index 00000000..a5ac6de4 --- /dev/null +++ b/app/common/model/store/consumption/StoreConsumptionDetail.php @@ -0,0 +1,20 @@ +success($result); } + /** + * 红包获取记录 + * @param StoreActivityUserDao $dao + * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function record(StoreActivityUserDao $dao) + { + $userId = $this->request->uid(); + $result = $dao->record($userId); + return app('json')->success($result); + } + } \ No newline at end of file