- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明 Made-with: Cursor
88 lines
2.6 KiB
PHP
88 lines
2.6 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Author: ScottPan Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\controller\api\v2\activity;
|
|
|
|
use app\services\activity\coupon\StoreCouponIssueServices;
|
|
use app\services\order\StoreOrderServices;use app\services\product\product\StoreProductCouponServices;
|
|
use think\annotation\Inject;
|
|
use think\exception\ValidateException;use think\Request;
|
|
|
|
/**
|
|
* 优惠券
|
|
* Class StoreCoupons
|
|
* @package app\controller\api\v2\store
|
|
*/
|
|
class StoreCoupons
|
|
{
|
|
|
|
/**
|
|
* @var StoreCouponIssueServices
|
|
*/
|
|
#[Inject]
|
|
protected StoreCouponIssueServices $services;
|
|
|
|
/**
|
|
* 可领取优惠券列表
|
|
* @param \app\Request $request
|
|
* @return mixed
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function lst(Request $request)
|
|
{
|
|
$where = $request->getMore([
|
|
[['type', 'd'], ''],
|
|
[['product_id', 'd'], 0],
|
|
[['brand_id', 'd'], 0],
|
|
['defaultOrder', ''],
|
|
['timeOrder', ''],
|
|
['priceOrder', '']
|
|
]);
|
|
return app('json')->successful($this->services->getIssueCouponList((int)$request->uid(), $where, '*', true));
|
|
}
|
|
|
|
/**
|
|
* 获取新人券
|
|
* @return mixed
|
|
*/
|
|
public function getNewCoupon(Request $request)
|
|
{
|
|
$userInfo = $request->user();
|
|
$data = [];
|
|
/** @var StoreCouponIssueServices $couponService */
|
|
$couponService = app()->make(StoreCouponIssueServices::class);
|
|
$data['list'] = $couponService->getNewCoupon();
|
|
$data['image'] = '';
|
|
if ($userInfo->add_time === $userInfo->last_time) {
|
|
$data['show'] = 1;
|
|
} else {
|
|
$data['show'] = 0;
|
|
}
|
|
//会员领取优惠券
|
|
//$couponService->sendMemberCoupon($userInfo->uid);
|
|
return app('json')->success($data);
|
|
}
|
|
|
|
/**
|
|
* 获取每日新增的优惠券
|
|
* @param Request $request
|
|
* @param StoreCouponIssueServices $couponIssueServices
|
|
* @return \think\Response
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function getTodayCoupon(Request $request, StoreCouponIssueServices $couponIssueServices)
|
|
{
|
|
$uid = 0;
|
|
if ($request->hasMacro('uid')) $uid = (int)$request->uid();
|
|
$data['list'] = $couponIssueServices->getTodayCoupon($uid);
|
|
$data['image'] = '';
|
|
return app('json')->success($data);
|
|
}
|
|
}
|