Initial commit: queue workspace
Made-with: Cursor
This commit is contained in:
55
pro_v3.5.1/app/controller/api/v1/activity/CardGift.php
Normal file
55
pro_v3.5.1/app/controller/api/v1/activity/CardGift.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\api\v1\activity;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\activity\card\CardCodeServices;
|
||||
use app\services\activity\card\CardGiftServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
|
||||
/**
|
||||
* 礼品卡
|
||||
* Class CardGift
|
||||
* @package app\api\controller\activity
|
||||
*/
|
||||
class CardGift
|
||||
{
|
||||
|
||||
/**
|
||||
* @var CardGiftServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected CardGiftServices $services;
|
||||
|
||||
public function giftInfo(Request $request, CardCodeServices $codeServices)
|
||||
{
|
||||
[$card_number, $card_pwd] = $request->postMore([
|
||||
['card_number', ''],
|
||||
['card_pwd', ''],
|
||||
], true);
|
||||
if (!$card_number || !$card_pwd) return app('json')->fail('请输入卡密');
|
||||
return app('json')->success($codeServices->verifyGiftCode($card_number, $card_pwd));
|
||||
}
|
||||
|
||||
public function receive(Request $request, CardCodeServices $codeServices)
|
||||
{
|
||||
[$card_number, $card_pwd, $product] = $request->postMore([
|
||||
['card_number', ''],
|
||||
['card_pwd', ''],
|
||||
['product', []]
|
||||
], true);
|
||||
if (!$card_number || !$card_pwd) return app('json')->fail('请输入卡密');
|
||||
$data = $codeServices->receiveGiftCode($card_number, $card_pwd, $product, (int)$request->uid());
|
||||
return app('json')->success($data['type'] == 1 ? '领取成功' : $data['data']);
|
||||
}
|
||||
}
|
||||
116
pro_v3.5.1/app/controller/api/v1/activity/HolidayGift.php
Normal file
116
pro_v3.5.1/app/controller/api/v1/activity/HolidayGift.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\controller\api\v1\activity;
|
||||
|
||||
use app\services\activity\bargain\StoreBargainServices;
|
||||
use app\services\activity\holiday\HolidayGiftServices;
|
||||
use app\services\activity\holiday\HolidayGiftRecordServices;
|
||||
use app\services\activity\holiday\HolidayGiftPushServices;
|
||||
use app\Request;
|
||||
use app\services\user\UserServices;
|
||||
use think\annotation\Inject;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 节日有礼控制器
|
||||
* Class HolidayGiftController
|
||||
* @package app\api\controller\v1\activity
|
||||
*/
|
||||
class HolidayGift
|
||||
{
|
||||
/**
|
||||
* @var HolidayGiftServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected HolidayGiftServices $services;
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户可领取的节日有礼列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getList(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
if (!$uid) {
|
||||
return app('json')->success([]);
|
||||
}
|
||||
|
||||
// 获取活动中的节日有礼
|
||||
$where = [
|
||||
'status' => 1,
|
||||
'is_del' => 0,
|
||||
];
|
||||
$list = $this->services->getActiveHolidayGift($where);
|
||||
if (!$list) {
|
||||
return app('json')->success([]);
|
||||
}
|
||||
$holidayGiftPushServices = app()->make(HolidayGiftPushServices::class);
|
||||
// 过滤不符合条件的活动
|
||||
$result = [];
|
||||
foreach ($list as $item) {
|
||||
//检查提前推送是否在日期内
|
||||
if (!$holidayGiftPushServices->checkAdvancePush($item, false, $uid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 检查用户是否符合条件
|
||||
if (!$this->services->checkUserCondition($uid, $item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 检查是否在推送时段内
|
||||
if (!$this->services->checkPushTimeRange($item)) {
|
||||
continue;
|
||||
}
|
||||
//检查推送频次是否推送过
|
||||
if (!$this->services->checkPopupAdCondition($uid, $item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 添加到结果中
|
||||
$result[] = [
|
||||
'id' => $item['id'],
|
||||
'name' => $item['name'],
|
||||
'gift_type' => $item['gift_type'],
|
||||
'push_channel' => $item['push_channel'],
|
||||
'show_page' => $item['show_page'],
|
||||
'push_frequency' => $item['push_frequency'],
|
||||
'wechat_image' => $item['wechat_image'],
|
||||
'end_time' => $item['end_time'],
|
||||
'end_time_format' => date('Y-m-d H:i:s', $item['end_time'])
|
||||
];
|
||||
}
|
||||
|
||||
return app('json')->success(['list' => $result]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推送记录
|
||||
* @return void
|
||||
* User: liusl
|
||||
* DateTime: 2025/7/21 15:27
|
||||
*/
|
||||
public function record(Request $request, HolidayGiftPushServices $services)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
[$ids] = $request->postMore([['ids', '']], true);
|
||||
if (!$ids || !$uid) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
$ids = explode(',', $ids);
|
||||
$data = [
|
||||
'push_type' => 3,
|
||||
'status' => 1
|
||||
];
|
||||
$result = $services->saveGiftPush($ids, $uid, $data);
|
||||
return app('json')->success($result ? '推送成功' : '推送失败');
|
||||
}
|
||||
}
|
||||
326
pro_v3.5.1/app/controller/api/v1/activity/StoreBargain.php
Normal file
326
pro_v3.5.1/app/controller/api/v1/activity/StoreBargain.php
Normal file
@@ -0,0 +1,326 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\api\v1\activity;
|
||||
|
||||
use app\jobs\activity\StoreBargainJob;
|
||||
use app\services\activity\bargain\StoreBargainServices;
|
||||
use app\services\activity\bargain\StoreBargainUserHelpServices;
|
||||
use app\services\activity\bargain\StoreBargainUserServices;
|
||||
use app\Request;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\other\QrcodeServices;
|
||||
use app\services\user\UserServices;
|
||||
use app\services\wechat\WechatServices;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 砍价商品类
|
||||
* Class StoreBargain
|
||||
* @package app\api\controller\activity
|
||||
*/
|
||||
class StoreBargain
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreBargainServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreBargainServices $services;
|
||||
|
||||
/**
|
||||
* 砍价列表顶部图
|
||||
* @return mixed
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
$lovely = sys_data('routine_lovely') ?? [];//banner图
|
||||
$info = $lovely[2] ?? [];
|
||||
return app('json')->successful($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价商品列表
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function lst()
|
||||
{
|
||||
$bargainList = $this->services->getBargainList();
|
||||
return app('json')->successful(get_thumb_water($bargainList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价详情和当前登录人信息
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
* @throws DataNotFoundException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function detail(Request $request, $id)
|
||||
{
|
||||
$data = $this->services->getBargain((int)$request->uid(), (int)$id);
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价 观看/分享/参与次数
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function share(Request $request)
|
||||
{
|
||||
[$bargainId] = $request->postMore([['bargainId', 0]], true);
|
||||
if (!$bargainId) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
$data['lookCount'] = $this->services->sum([], 'look');// 观看人数
|
||||
/** @var StoreBargainUserHelpServices $bargainUserHelpService */
|
||||
$bargainUserHelpService = app()->make(StoreBargainUserHelpServices::class);
|
||||
$data['userCount'] = $bargainUserHelpService->count([]);// 参与人数
|
||||
/** @var StoreOrderServices $orderServices */
|
||||
$orderServices = app()->make(StoreOrderServices::class);
|
||||
$data['payCount'] = $orderServices->count(['activity_id' => $bargainId, 'type' => 2]);
|
||||
$data['shareCount'] = $this->services->sum([], 'share');// 分享人数
|
||||
//增加分享次数
|
||||
StoreBargainJob::dispatchDo('setBargainCount', [$bargainId, 'share']);
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价开启
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function start(Request $request)
|
||||
{
|
||||
[$bargainId] = $request->postMore([
|
||||
['bargainId', 0]
|
||||
], true);
|
||||
$bargainId = (int)$bargainId;
|
||||
if (!$bargainId) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
if ((int)sys_config('bargain_subscribe') && request()->isWechat()) {
|
||||
/** @var WechatServices $wechat */
|
||||
$wechat = app()->make(WechatServices::class);
|
||||
$subscribe = $wechat->get(['uid' => $uid, 'subscribe' => 1]);
|
||||
if (!$subscribe) {
|
||||
$url = '';
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$url = $qrcodeService->getTemporaryQrcode('bargain-' . $bargainId . '-' . $uid, $uid)->url;
|
||||
return app('json')->successful('请先关注公众号', ['code' => 'subscribe', 'url' => $url]);
|
||||
}
|
||||
}
|
||||
|
||||
$code = $this->services->setBargain($uid, $bargainId);
|
||||
return app('json')->status($code, '参与成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价 帮助好友砍价
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
* @throws DataNotFoundException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function help(Request $request)
|
||||
{
|
||||
[$bargainId, $bargainUserUid] = $request->postMore([
|
||||
['bargainId', 0],
|
||||
['bargainUserUid', 0]
|
||||
], true);
|
||||
$bargainId = (int)$bargainId;
|
||||
$bargainUserUid = (int)$bargainUserUid;
|
||||
if (!$bargainId || !$bargainUserUid) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
if ((int)sys_config('bargain_subscribe') && request()->isWechat()) {
|
||||
/** @var WechatServices $wechat */
|
||||
$wechat = app()->make(WechatServices::class);
|
||||
$subscribe = $wechat->get(['uid' => $uid, 'subscribe' => 1]);
|
||||
if (!$subscribe) {
|
||||
$url = '';
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$url = $qrcodeService->getTemporaryQrcode('bargain-' . $bargainId . '-' . $bargainUserUid, $bargainUserUid)->url;
|
||||
return app('json')->successful('请先关注公众号', ['code' => 'subscribe', 'url' => $url]);
|
||||
}
|
||||
}
|
||||
|
||||
$code = $this->services->setHelpBargain($uid, $bargainId, $bargainUserUid);
|
||||
return app('json')->status($code, '砍价成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价 砍掉金额
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function help_price(Request $request)
|
||||
{
|
||||
[$bargainId, $bargainUserUid] = $request->postMore([
|
||||
['bargainId', 0],
|
||||
['bargainUserUid', 0]
|
||||
], true);
|
||||
$bargainId = (int)$bargainId;
|
||||
$bargainUserUid = (int)$bargainUserUid;
|
||||
if (!$bargainId || !$bargainUserUid) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
/** @var StoreBargainUserHelpServices $bargainUserHelp */
|
||||
$bargainUserHelp = app()->make(StoreBargainUserHelpServices::class);
|
||||
$price = $bargainUserHelp->getPrice($uid, $bargainId, $bargainUserUid);
|
||||
return app('json')->successful($price);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价 砍价帮总人数、剩余金额、进度条、已经砍掉的价格
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function help_count(Request $request)
|
||||
{
|
||||
[$bargainId, $bargainUserUid] = $request->postMore([
|
||||
['bargainId', 0],
|
||||
['bargainUserUid', 0]
|
||||
], true);
|
||||
$bargainId = (int)$bargainId;
|
||||
$bargainUserUid = (int)$bargainUserUid;
|
||||
if (!$bargainId || !$bargainUserUid) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
/** @var StoreBargainUserServices $bargainUserService */
|
||||
$bargainUserService = app()->make(StoreBargainUserServices::class);
|
||||
$data = $bargainUserService->helpCount((int)$request->uid(), $bargainId, $bargainUserUid);
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 砍价 砍价帮
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function help_list(Request $request)
|
||||
{
|
||||
[$bargainId, $bargainUserUid] = $request->postMore([
|
||||
['bargainId', 0],
|
||||
['bargainUserUid', 0]
|
||||
], true);
|
||||
$bargainId = (int)$bargainId;
|
||||
$bargainUserUid = (int)$bargainUserUid;
|
||||
if (!$bargainId || !$bargainUserUid) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
|
||||
/** @var StoreBargainUserServices $bargainUser */
|
||||
$bargainUser = app()->make(StoreBargainUserServices::class);
|
||||
$bargainUserTableId = $bargainUser->getBargainUserTableId($bargainId, $bargainUserUid);
|
||||
|
||||
/** @var StoreBargainUserHelpServices $bargainUserHelp */
|
||||
$bargainUserHelp = app()->make(StoreBargainUserHelpServices::class);
|
||||
[$page, $limit] = $this->services->getPageValue();
|
||||
$storeBargainUserHelp = $bargainUserHelp->getHelpList($bargainUserTableId, $page, $limit);
|
||||
return app('json')->successful($storeBargainUserHelp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价 开启砍价用户信息
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function start_user(Request $request)
|
||||
{
|
||||
[$bargainId, $bargainUserUid] = $request->postMore([
|
||||
['bargainId', 0],
|
||||
['bargainUserUid', 0]
|
||||
], true);
|
||||
$bargainId = (int)$bargainId;
|
||||
$bargainUserUid = (int)$bargainUserUid;
|
||||
if (!$bargainId || !$bargainUserUid) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
/** @var UserServices $userServices */
|
||||
$userServices = app()->make(UserServices::class);
|
||||
$userInfo = $userServices->getUserCacheInfo((int)$bargainUserUid);
|
||||
if (!$userInfo) {
|
||||
return app('json')->fail('用户信息获取失败');
|
||||
}
|
||||
return app('json')->successful(['nickname' => $userInfo['nickname'], 'avatar' => $userInfo['avatar']]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 砍价列表(已参与)
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function user_list(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
/** @var StoreBargainUserServices $bargainUser */
|
||||
$bargainUser = app()->make(StoreBargainUserServices::class);
|
||||
$bargainUser->editBargainUserStatus($uid);// 判断过期砍价活动
|
||||
$list = $bargainUser->getBargainUserAll($uid);
|
||||
if (count($list)) return app('json')->successful(get_thumb_water($list));
|
||||
else return app('json')->successful([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价取消
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function user_cancel(Request $request)
|
||||
{
|
||||
[$bargainId] = $request->postMore([['bargainId', 0]], true);
|
||||
if (!$bargainId) return app('json')->fail('参数错误');
|
||||
/** @var StoreBargainUserServices $bargainUser */
|
||||
$bargainUser = app()->make(StoreBargainUserServices::class);
|
||||
$res = $bargainUser->cancelBargain($bargainId, (int)$request->uid());
|
||||
if ($res) return app('json')->successful('取消成功');
|
||||
else return app('json')->successful('取消失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分享海报信息
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function posterInfo(Request $request, $bargainId)
|
||||
{
|
||||
return app('json')->success($this->services->posterInfo((int)$bargainId, $request->user()));
|
||||
}
|
||||
}
|
||||
180
pro_v3.5.1/app/controller/api/v1/activity/StoreCombination.php
Normal file
180
pro_v3.5.1/app/controller/api/v1/activity/StoreCombination.php
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\api\v1\activity;
|
||||
|
||||
use app\Request;
|
||||
use app\services\activity\combination\StoreCombinationServices;
|
||||
use app\services\activity\combination\StorePinkServices;
|
||||
use app\services\other\QrcodeServices;
|
||||
use app\services\user\UserServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 拼团类
|
||||
* Class StoreCombination
|
||||
* @package app\api\controller\activity
|
||||
*/
|
||||
class StoreCombination
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreCombinationServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreCombinationServices $services;
|
||||
|
||||
/**
|
||||
* 拼团列表
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function lst()
|
||||
{
|
||||
$list = $this->services->getCombinationList();
|
||||
return app('json')->successful(get_thumb_water($list, 'mid'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拼团商品详情
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail(Request $request, $id)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
$data = $this->services->combinationDetail($uid, $id);
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品海报二维码
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2022/11/14
|
||||
*/
|
||||
public function detailCode(Request $request)
|
||||
{
|
||||
$id = $request->get('id/d', 0);
|
||||
$uid = $request->uid();
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
if (($configData['share_qrcode'] ?? 0) && request()->isWechat()) {
|
||||
$storeInfo['code_base'] = $qrcodeService->getTemporaryQrcode('combination-' . $id . '-' . $uid, $uid)->url;
|
||||
} else {
|
||||
$storeInfo['code_base'] = $qrcodeService->getWechatQrcodePath($id . '_product_combination_detail_wap.jpg', '/pages/activity/goods_details/index?type=3id=' . $id . '&spid=' . $uid);
|
||||
}
|
||||
return app('json')->success($storeInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团 开团
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function pinkInfo(Request $request, $id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
$data = $this->services->getPinkInfo((int)$request->uid(), (int)$id);
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团 取消开团
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function remove(Request $request)
|
||||
{
|
||||
[$id, $cid] = $request->postMore([
|
||||
['id', 0],
|
||||
['cid', 0],
|
||||
], true);
|
||||
if (!$id || !$cid) return app('json')->fail('缺少参数');
|
||||
/** @var StorePinkServices $pinkService */
|
||||
$pinkService = app()->make(StorePinkServices::class);
|
||||
$pinkService->removePink((int)$request->uid(), $cid, $id);
|
||||
return app('json')->successful('取消成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团海报详情
|
||||
* @param Request $request
|
||||
* @param StorePinkServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function posterInfo(Request $request, StorePinkServices $services, $id)
|
||||
{
|
||||
return app('json')->success($services->posterInfo((int)$id, $request->user()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团小程序二维码
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function code(Request $request, $id)
|
||||
{
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$uid = (int)$request->uid();
|
||||
$name = 'combination_' . $id . '_' . $uid . '.jpg';
|
||||
$url = $qrcodeService->getRoutineQrcodePath($id, $uid, 3, $name);
|
||||
if ($url) {
|
||||
return app('json')->success(['code' => $url]);
|
||||
} else {
|
||||
return app('json')->success(['code' => '']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团列表轮播图
|
||||
*/
|
||||
public function banner_list()
|
||||
{
|
||||
$banner = sys_data('combination_banner') ?? [];
|
||||
return app('json')->success($banner);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团数据
|
||||
* @return mixed
|
||||
*/
|
||||
public function pink(Request $request, StorePinkServices $pink, UserServices $user)
|
||||
{
|
||||
[$type] = $request->getMore([
|
||||
['type', 1],
|
||||
], true);
|
||||
$where = ['is_refund' => 0];
|
||||
if ($type == 1) {
|
||||
$where['status'] = 2;
|
||||
}
|
||||
$data['pink_count'] = $pink->getCount($where);
|
||||
$uids = array_flip($pink->getColumn($where, 'uid'));
|
||||
if (count($uids)) {
|
||||
mt_srand();
|
||||
$uids = array_rand($uids, count($uids) < 3 ? count($uids) : 3);
|
||||
}
|
||||
$data['avatars'] = $uids ? $user->getColumn(is_array($uids) ? [['uid', 'in', $uids]] : ['uid' => $uids], 'avatar') : [];
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
}
|
||||
120
pro_v3.5.1/app/controller/api/v1/activity/StoreCoupons.php
Normal file
120
pro_v3.5.1/app/controller/api/v1/activity/StoreCoupons.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\api\v1\activity;
|
||||
|
||||
use app\Request;
|
||||
use app\services\activity\coupon\StoreCouponIssueServices;
|
||||
use app\services\activity\coupon\StoreCouponUserServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 优惠券类
|
||||
* Class StoreCoupons
|
||||
* @package app\api\controller\store
|
||||
*/
|
||||
class StoreCoupons
|
||||
{
|
||||
/**
|
||||
* @var StoreCouponIssueServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreCouponIssueServices $services;
|
||||
|
||||
/**
|
||||
* 可领取优惠券列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function lst(Request $request)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
[['type', 'd'], ''],
|
||||
[['product_id', 'd'], 0],
|
||||
[['brand_id', 'd'], 0],
|
||||
]);
|
||||
if ($request->getFromType() == 'pc') $where['type'] = '';
|
||||
return app('json')->successful($this->services->getIssueCouponList((int)$request->uid(), $where)['list']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 领取优惠券
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function receive(Request $request)
|
||||
{
|
||||
[$couponId] = $request->getMore([
|
||||
['couponId', 0]
|
||||
], true);
|
||||
$couponId = (int)$couponId;
|
||||
if (!$couponId) {
|
||||
return app('json')->fail('参数错误!');
|
||||
}
|
||||
$info = $this->services->get($couponId);
|
||||
if ($info['receive_type'] != 1) {
|
||||
return app('json')->fail('该优惠券不能领取');
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
$coupon = $this->services->issueUserCoupon($uid, $couponId, false);
|
||||
if ($coupon) {
|
||||
$coupon = $coupon->toArray();
|
||||
return app('json')->success('领取成功', $coupon);
|
||||
}
|
||||
return app('json')->fail('领取失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的优惠券数量
|
||||
* @param Request $request
|
||||
* @param StoreCouponUserServices $storeCouponUserService
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function userCount(Request $request, StoreCouponUserServices $storeCouponUserService)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful($storeCouponUserService->getUserCounponNum($uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户已领取优惠券
|
||||
* @param Request $request
|
||||
* @param $types
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function user(Request $request, StoreCouponUserServices $storeCouponUserService, $types)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
[$type] = $request->getMore([
|
||||
['type', 0],
|
||||
], true);
|
||||
return app('json')->successful($storeCouponUserService->getUserCounpon($uid, $types, $type));
|
||||
}
|
||||
|
||||
/**
|
||||
* 优惠券 订单获取
|
||||
* @param Request $request
|
||||
* @param $price
|
||||
* @return mixed
|
||||
*/
|
||||
public function order(Request $request, StoreCouponIssueServices $service, $cartId, $new)
|
||||
{
|
||||
[$shipping_type, $storeId] = $request->getMore([
|
||||
['shipping_type', 1],
|
||||
['store_id', 0],
|
||||
], true);
|
||||
return app('json')->successful($service->beUseableCouponList((int)$request->uid(), $cartId, !!$new, (int)$shipping_type));
|
||||
}
|
||||
}
|
||||
37
pro_v3.5.1/app/controller/api/v1/activity/StoreDiscounts.php
Normal file
37
pro_v3.5.1/app/controller/api/v1/activity/StoreDiscounts.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\controller\api\v1\activity;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\activity\discounts\StoreDiscountsServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 优惠套餐控制器
|
||||
* Class StoreDiscounts
|
||||
* @package app\controller\api\v1\activity
|
||||
*/
|
||||
class StoreDiscounts
|
||||
{
|
||||
/**
|
||||
* @var StoreDiscountsServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreDiscountsServices $services;
|
||||
|
||||
/**
|
||||
* 获取优惠商品列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
[$product_id] = $request->postMore([
|
||||
['product_id', 0]
|
||||
], true);
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful($this->services->getDiscounts((int)$product_id, $uid));
|
||||
}
|
||||
}
|
||||
99
pro_v3.5.1/app/controller/api/v1/activity/StoreIntegral.php
Normal file
99
pro_v3.5.1/app/controller/api/v1/activity/StoreIntegral.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\api\v1\activity;
|
||||
|
||||
use app\Request;
|
||||
use app\services\activity\integral\StoreIntegralCategoryServices;
|
||||
use app\services\activity\integral\StoreIntegralServices;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 积分商城
|
||||
* Class StoreIntegral
|
||||
* @package app\api\controller\activity
|
||||
*/
|
||||
class StoreIntegral
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreIntegralServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreIntegralServices $services;
|
||||
|
||||
/**
|
||||
* 积分商城首页数据
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws DbException
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$data['banner'] = sys_data('integral_shop_banner') ?? [];// 积分商城banner
|
||||
$where = ['is_show' => 1];
|
||||
$where['is_host'] = 1;
|
||||
$list = $this->services->getIntegralList($where);
|
||||
$data['list'] = get_thumb_water($list);
|
||||
$userInfo = $request->user()->toArray();
|
||||
$data['integral'] = $userInfo['integral'] ?? 0;
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function lst(Request $request)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['store_name', ''],
|
||||
['priceOrder', ''],
|
||||
['salesOrder', ''],
|
||||
['range', ''],
|
||||
]);
|
||||
$where['is_show'] = 1;
|
||||
$list = $this->services->getIntegralList($where);
|
||||
return app('json')->successful(get_thumb_water($list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分商品详情
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function detail(Request $request, $id)
|
||||
{
|
||||
$data = $this->services->integralDetail((int)$request->uid(), $id);
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
* @param StoreIntegralCategoryServices $services
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2023/11/14 10:14
|
||||
*/
|
||||
public function category(StoreIntegralCategoryServices $services)
|
||||
{
|
||||
return app('json')->successful($services->getTreeList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\api\v1\activity;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\activity\integral\StoreIntegralOrderServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 积分订单
|
||||
* Class StoreIntegralController
|
||||
* @package app\api\controller\activity
|
||||
*/
|
||||
class StoreIntegralOrder
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreIntegralOrderServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreIntegralOrderServices $services;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
* @param Request $request
|
||||
* @param $uni
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail(Request $request, $uni)
|
||||
{
|
||||
if (!strlen(trim($uni))) return app('json')->fail('参数错误');
|
||||
$order = $this->services->getOne(['order_id' => $uni, 'is_del' => 0]);
|
||||
if (!$order) return app('json')->fail('订单不存在');
|
||||
$order = $order->toArray();
|
||||
if (!$order['paid']) return app('json')->fail('订单未支付,无法查看');
|
||||
$orderData = $this->services->tidyOrder($order);
|
||||
return app('json')->successful('ok', $orderData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function lst(Request $request)
|
||||
{
|
||||
$where['uid'] = $request->uid();
|
||||
$where['paid'] = 1;
|
||||
$where['is_del'] = 0;
|
||||
$where['is_system_del'] = 0;
|
||||
$where['type'] = 4;
|
||||
$list = $this->services->getOrderApiList($where);
|
||||
return app('json')->successful($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单删除
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function del(Request $request, StoreOrderServices $storeOrderServices)
|
||||
{
|
||||
[$order_id] = $request->postMore([
|
||||
['order_id', ''],
|
||||
], true);
|
||||
if (!$order_id) return app('json')->fail('参数错误!');
|
||||
$res = $storeOrderServices->removeOrder($order_id, (int)$request->uid());
|
||||
if ($res) {
|
||||
return app('json')->successful();
|
||||
} else {
|
||||
return app('json')->fail('删除失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
196
pro_v3.5.1/app/controller/api/v1/activity/StoreNewcomer.php
Normal file
196
pro_v3.5.1/app/controller/api/v1/activity/StoreNewcomer.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\api\v1\activity;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\activity\coupon\StoreCouponUserServices;
|
||||
use app\services\activity\newcomer\StoreNewcomerServices;
|
||||
use app\services\other\CacheServices;
|
||||
use app\services\user\UserServices;
|
||||
use crmeb\services\SystemConfigService;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 新人商品类
|
||||
* Class StoreNewcomer
|
||||
* @package app\api\controller\activity
|
||||
*/
|
||||
class StoreNewcomer
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreNewcomerServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreNewcomerServices $services;
|
||||
|
||||
/**
|
||||
* 新人大礼包弹窗
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getGift(Request $request)
|
||||
{
|
||||
$data = [];
|
||||
$uid = (int)$request->uid();
|
||||
/** @var UserServices $userServices */
|
||||
$userServices = app()->make(UserServices::class);
|
||||
$userInfo = $userServices->getUserCacheInfo($uid);
|
||||
//新用户
|
||||
if ($userInfo && $userInfo['add_time'] == $userInfo['last_time'] && $this->services->checkUserNewcomer($uid, $userInfo)) {
|
||||
$data = SystemConfigService::more([
|
||||
'newcomer_limit_status',
|
||||
'newcomer_limit_time',
|
||||
'register_integral_status',
|
||||
'register_give_integral',
|
||||
'register_money_status',
|
||||
'register_give_money',
|
||||
'register_coupon_status',
|
||||
'register_give_coupon',
|
||||
'first_order_status',
|
||||
'first_order_discount',
|
||||
'first_order_discount_limit',
|
||||
'register_price_status'
|
||||
]);
|
||||
$data['product_count'] = 0;
|
||||
if ($data['register_price_status']) {
|
||||
/** @var StoreNewcomerServices $newcomerServices */
|
||||
$newcomerServices = app()->make(StoreNewcomerServices::class);
|
||||
$data['product_count'] = $newcomerServices->count(['is_del' => 0]);
|
||||
}
|
||||
$ids = $data['register_give_coupon'] ?? [];
|
||||
$data['register_give_coupon'] = [];
|
||||
if ($data['register_coupon_status'] && $ids) {
|
||||
/** @var StoreCouponUserServices $couponServices */
|
||||
$couponServices = app()->make(StoreCouponUserServices::class);
|
||||
$coupon = $couponServices->getList(['cid' => $ids, 'uid' => $uid]);
|
||||
if ($coupon) $coupon = $couponServices->tidyCouponList($coupon);
|
||||
$data['register_give_coupon'] = $coupon;
|
||||
}
|
||||
if (!$data['first_order_status']) {
|
||||
$data['first_order_discount'] = 0;
|
||||
}
|
||||
if (!$data['register_integral_status']) {
|
||||
$data['register_give_integral'] = 0;
|
||||
}
|
||||
if (!$data['register_money_status']) {
|
||||
$data['register_give_money'] = 0;
|
||||
}
|
||||
$data['coupon_count'] = count($data['register_give_coupon']);
|
||||
}
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新人礼信息
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function getInfo(Request $request)
|
||||
{
|
||||
$data = [];
|
||||
$uid = (int)$request->uid();
|
||||
/** @var UserServices $userServices */
|
||||
$userServices = app()->make(UserServices::class);
|
||||
$userInfo = $userServices->getUserInfo($uid);
|
||||
$status = sys_config('newcomer_status');
|
||||
if ($userInfo && $status) {
|
||||
$data = SystemConfigService::more([
|
||||
'newcomer_limit_status',
|
||||
'newcomer_limit_time',
|
||||
'register_integral_status',
|
||||
'register_give_integral',
|
||||
'register_money_status',
|
||||
'register_give_money',
|
||||
'register_coupon_status',
|
||||
'register_give_coupon',
|
||||
'first_order_status',
|
||||
'first_order_discount',
|
||||
'first_order_discount_limit',
|
||||
'register_price_status'
|
||||
]);
|
||||
$data['product_count'] = 0;
|
||||
if ($data['register_price_status']) {
|
||||
/** @var StoreNewcomerServices $newcomerServices */
|
||||
$newcomerServices = app()->make(StoreNewcomerServices::class);
|
||||
$data['product_count'] = $newcomerServices->count(['is_del' => 0]);
|
||||
}
|
||||
/** @var CacheServices $cache */
|
||||
$cache = app()->make(CacheServices::class);
|
||||
$data['newcomer_agreement'] = $cache->getDbCache('newcomer_agreement', '');
|
||||
$ids = $data['register_give_coupon'] ?? [];
|
||||
$data['register_give_coupon'] = [];
|
||||
if ($data['register_coupon_status'] && $ids) {
|
||||
/** @var StoreCouponUserServices $couponServices */
|
||||
$couponServices = app()->make(StoreCouponUserServices::class);
|
||||
$coupon = $couponServices->getList(['cid' => $ids, 'uid' => $uid]);
|
||||
if ($coupon) $coupon = $couponServices->tidyCouponList($coupon);
|
||||
$data['register_give_coupon'] = $coupon;
|
||||
}
|
||||
$data['coupon_count'] = count($data['register_give_coupon']);
|
||||
|
||||
$data['last_time'] = 0;
|
||||
if ($data['newcomer_limit_status'] && $data['newcomer_limit_time']) {
|
||||
$data['last_time'] = bcadd((string)$userInfo['add_time'], bcmul((string)$data['newcomer_limit_time'], '86400'));
|
||||
}
|
||||
|
||||
if (!$data['first_order_status']) {
|
||||
$data['first_order_discount'] = 0;
|
||||
}
|
||||
if (!$data['register_integral_status']) {
|
||||
$data['register_give_integral'] = 0;
|
||||
}
|
||||
if (!$data['register_money_status']) {
|
||||
$data['register_give_money'] = 0;
|
||||
}
|
||||
}
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新人商品列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function lst(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
$data = [];
|
||||
//新用户
|
||||
if ($this->services->checkUserNewcomer($uid)) {
|
||||
$data = $this->services->getCustomerProduct([], 'id,type,product_id,relation_id,product_type,price', ['product' => function ($query) {
|
||||
$query->field('id,image,store_name,stock,sales,ot_price');
|
||||
}]);
|
||||
}
|
||||
return app('json')->successful(get_thumb_water($data, 'mid'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新人商品详情
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail(Request $request, $id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
$uid = (int)$request->uid();
|
||||
$data = $this->services->newcomerDetail($uid, (int)$id);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
}
|
||||
179
pro_v3.5.1/app/controller/api/v1/activity/StoreSeckill.php
Normal file
179
pro_v3.5.1/app/controller/api/v1/activity/StoreSeckill.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\api\v1\activity;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\activity\seckill\StoreSeckillServices;
|
||||
use app\services\activity\seckill\StoreSeckillTimeServices;
|
||||
use app\services\other\QrcodeServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
|
||||
/**
|
||||
* 秒杀商品类
|
||||
* Class StoreSeckill
|
||||
* @package app\api\controller\activity
|
||||
*/
|
||||
class StoreSeckill
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreSeckillServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreSeckillServices $services;
|
||||
|
||||
/**
|
||||
* 秒杀商品时间区间
|
||||
* @param StoreSeckillTimeServices $seckillTimeServices
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index(StoreSeckillTimeServices $seckillTimeServices)
|
||||
{
|
||||
$seckillTime = $seckillTimeServices->time_list();
|
||||
$seckillTimeIndex = -1;
|
||||
$timeCount = count($seckillTime);//总数
|
||||
$unTimeCunt = 0;//即将开始
|
||||
if ($timeCount) {
|
||||
$today = date('Y-m-d');
|
||||
$currentHour = date('Hi');
|
||||
foreach ($seckillTime as $key => &$value) {
|
||||
$start = str_replace(':', '', $value['start_time']);
|
||||
$end = str_replace(':', '', $value['end_time']);
|
||||
if ($currentHour >= $start && $currentHour <= $end) {
|
||||
$value['state'] = '疯抢中';
|
||||
$value['status'] = 1;
|
||||
if ($seckillTimeIndex == -1) $seckillTimeIndex = $key;
|
||||
} else if ($currentHour < $start) {
|
||||
$value['state'] = '即将开始';
|
||||
$value['status'] = 2;
|
||||
$unTimeCunt += 1;
|
||||
} else if ($currentHour >= $end) {
|
||||
$value['state'] = '已结束';
|
||||
$value['status'] = 0;
|
||||
}
|
||||
$value['time'] = $value['start_time'];
|
||||
$value['stop'] = strtotime($today. ' '. $value['end_time']);
|
||||
}
|
||||
//有时间段但是都不在抢购中
|
||||
if ($seckillTimeIndex == -1 && $currentHour <= (int)$seckillTime[$timeCount - 1]['time'] ?? 0) {
|
||||
if ($currentHour < (int)$seckillTime[0]['time'] ?? 0) {//当前时间
|
||||
$seckillTimeIndex = 0;
|
||||
} elseif ($unTimeCunt) {//存在未开始的
|
||||
foreach ($seckillTime as $key => $item) {
|
||||
if ($item['status'] == 2) {
|
||||
$seckillTimeIndex = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$seckillTimeIndex = $timeCount - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
$data['lovely'] = sys_config('seckill_header_banner');
|
||||
if (strstr($data['lovely'], 'http') === false && strlen(trim($data['lovely']))) $data['lovely'] = sys_config('site_url') . $data['lovely'];
|
||||
$data['lovely'] = str_replace('\\', '/', $data['lovely']);
|
||||
$data['seckillTime'] = $seckillTime;
|
||||
$data['seckillTimeIndex'] = $seckillTimeIndex;
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 秒杀商品列表
|
||||
* @param $time
|
||||
* @return \think\Response
|
||||
* @throws \ReflectionException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function lst($time)
|
||||
{
|
||||
if (!$time) return app('json')->fail('参数错误');
|
||||
$seckillInfo = $this->services->getListByTime((int)$time);
|
||||
return app('json')->successful(get_thumb_water($seckillInfo, 'mid'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 秒杀商品详情
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail(Request $request, $id)
|
||||
{
|
||||
[$time_id, $time, $status] = $request->getMore([
|
||||
['time_id', 0],
|
||||
['time', 0],
|
||||
['status', 0],
|
||||
], true);
|
||||
$this->services->setItem('time_id', $time_id)->setItem('time', $time)->setItem('status', $status);
|
||||
$data = $this->services->seckillDetail((int)$request->uid(), $id);
|
||||
$this->services->reset();
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取秒杀小程序二维码
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function code(Request $request, $id, $stop_time = '')
|
||||
{
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$uid = (int)$request->uid();
|
||||
|
||||
$name = 'seckill_' . $id . '_' . $uid . '.jpg';
|
||||
if ($stop_time) {
|
||||
$name = $stop_time . $name;
|
||||
}
|
||||
$url = $qrcodeService->getRoutineQrcodePath($id, $uid, 1, $name);
|
||||
if ($url) {
|
||||
return app('json')->success(['code' => $url]);
|
||||
} else {
|
||||
return app('json')->success(['code' => '']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2022/11/2
|
||||
*/
|
||||
public function detailCode(Request $request, $id)
|
||||
{
|
||||
$uid = $request->uid();
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$time = $request->param('time', '');
|
||||
$status = $request->param('status', '');
|
||||
if (($configData['share_qrcode'] ?? 0) && request()->isWechat()) {
|
||||
$storeInfo['code_base'] = $qrcodeService->getTemporaryQrcode('seckill-' . $id . '-' . $uid . '-' . $time . '-' . $status, $uid)->url;
|
||||
} else {
|
||||
$storeInfo['code_base'] = $qrcodeService->getWechatQrcodePath($id . '_product_seckill_detail_wap.jpg', '/pages/activity/goods_details/index?type=1&id=' . $id . '&spid=' . $uid . '&time=' . $time . '&status=' . $status);
|
||||
}
|
||||
|
||||
return app('json')->success($storeInfo);
|
||||
}
|
||||
}
|
||||
244
pro_v3.5.1/app/controller/api/v1/activity/Video.php
Normal file
244
pro_v3.5.1/app/controller/api/v1/activity/Video.php
Normal file
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\api\v1\activity;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\activity\video\VideoCommentServices;
|
||||
use app\services\activity\video\VideoServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
use app\services\user\UserRelationServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
|
||||
/**
|
||||
* 短视频类
|
||||
* Class Video
|
||||
* @package app\api\controller\activity
|
||||
*/
|
||||
class Video
|
||||
{
|
||||
/**
|
||||
* @var VideoServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected VideoServices $services;
|
||||
|
||||
/**
|
||||
* 获取短视频列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function list(Request $request)
|
||||
{
|
||||
[$order_type, $id] = $request->getMore([
|
||||
['order_type', ''],
|
||||
['id', 0]
|
||||
], true);
|
||||
return app('json')->success($this->services->getVideoList((int)$request->uid(), '*', (int)$order_type, (int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 短视频详情
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function info($id)
|
||||
{
|
||||
if (!(int)$id) return app('json')->fail('缺少参数');
|
||||
$data = [];
|
||||
// $data['videoInfo'] = $this->services->get((int)$id);
|
||||
$data['recommend'] = $this->services->getRecommend((int)$id);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取短视频评价列表
|
||||
* @param Request $request
|
||||
* @param VideoCommentServices $commentServices
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function commentList(Request $request, VideoCommentServices $commentServices, $id)
|
||||
{
|
||||
if (!(int)$id) return app('json')->fail('缺少参数');
|
||||
return app('json')->success($commentServices->getVideoCommentList((int)$request->uid(), (int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取短视频评价回复列表
|
||||
* @param Request $request
|
||||
* @param VideoCommentServices $commentServices
|
||||
* @param $pid
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function commentReplyList(Request $request, VideoCommentServices $commentServices, $pid)
|
||||
{
|
||||
if (!(int)$pid) return app('json')->fail('缺少参数');
|
||||
return app('json')->success($commentServices->getVideoCommentList((int)$request->uid(), 0, (int)$pid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 短视频关联商品
|
||||
* @param Request $request
|
||||
* @param StoreProductServices $productServices
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function productList(Request $request, StoreProductServices $productServices, $id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
$video = $this->services->getVideoInfo((int)$id);
|
||||
$list = [];
|
||||
$count = 0;
|
||||
if ($video['product_id']) {
|
||||
$ids = is_string($video['product_id']) ? explode(',', $video['product_id']) : $video['product_id'];
|
||||
$where = ['ids' => $ids];
|
||||
$list = $productServices->getGoodsList($where, (int)$request->uid());
|
||||
$newList = [];
|
||||
foreach ($list as $key => $item) {
|
||||
$item['promotions'] = !isset($item['promotions']) || !$item['promotions'] ? (object)[] : $item['promotions'];
|
||||
if ($item['relation_id'] && $item['type'] == 1) {
|
||||
$item['store_id'] = $item['relation_id'];
|
||||
} else {
|
||||
$item['store_id'] = 0;
|
||||
}
|
||||
$newList[$key] = $item;
|
||||
}
|
||||
$where['is_verify'] = 1;
|
||||
$where['is_show'] = 1;
|
||||
$where['is_del'] = 0;
|
||||
$count = $productServices->getCount($where);
|
||||
$list = get_thumb_water($newList, 'small');
|
||||
}
|
||||
return app('json')->success(compact('list', 'count'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 短视频点赞、收藏、分享(再次点击取消)
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @param $type
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function relation(Request $request, $id, $type = 'like')
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
if (!in_array($type, ['like', 'collect', 'share'])) {
|
||||
return app('json')->fail('类型错误');
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
$this->services->userRelationVideo($uid, $id, $type);
|
||||
return app('json')->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存评价
|
||||
* @param Request $request
|
||||
* @param VideoCommentServices $commentServices
|
||||
* @param $video_id
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function saveComment(Request $request, VideoCommentServices $commentServices, $id, $pid = 0)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
[$content] = $request->getMore([
|
||||
['content', '']
|
||||
], true);
|
||||
if (!$content) {
|
||||
return app('json')->fail('请输入评论内容');
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
$comment = $commentServices->saveComment($uid, (int)$id, (int)$pid, ['content' => $content, 'ip' => $request->ip()]);
|
||||
return app('json')->success('评价成功', $comment->toArray());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 评论点赞(再次点击取消)
|
||||
* @param Request $request
|
||||
* @param UserRelationServices $userRelationServices
|
||||
* @param $id
|
||||
* @param $type
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function commentRelation(Request $request, UserRelationServices $userRelationServices, VideoCommentServices $commentServices, $id, $type = 'like')
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
if (!in_array($type, ['like', 'collect', 'share'])) {
|
||||
return app('json')->fail('类型错误');
|
||||
}
|
||||
$comment = $commentServices->get($id);
|
||||
if (!$comment) {
|
||||
return app('json')->fail('评论不存在或已删除');
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
$data = ['uid' => $uid, 'relation_id' => $id, 'category' => UserRelationServices::CATEGORY_VIDEO_COMMENT, 'type' => $type];
|
||||
|
||||
$relation = $userRelationServices->get($data);
|
||||
if ($relation) {//取消
|
||||
$userRelationServices->delete($relation['id']);
|
||||
$commentServices->bcDec($id, $type . '_num', 1);
|
||||
$status = 0;
|
||||
} else {
|
||||
$data['add_time'] = time();
|
||||
$userRelationServices->save($data);
|
||||
$commentServices->bcInc($id, $type . '_num', 1);
|
||||
$status = 1;
|
||||
}
|
||||
return app('json')->success(($status == 1 ? '取消' : '') . (UserRelationServices::TYPE_NAME[$type] ?? '收藏') . '成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤销评价
|
||||
* @param Request $request
|
||||
* @param VideoCommentServices $commentServices
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function commentDelete(Request $request, VideoCommentServices $commentServices, $id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
$comment = $commentServices->get($id);
|
||||
if (!$comment) {
|
||||
return app('json')->fail('评论不存在或已删除');
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
if ($comment['uid'] != $uid) {
|
||||
return app('json')->fail('只能撤销自己的评价');
|
||||
}
|
||||
$commentServices->update($id, ['is_del' => 1]);
|
||||
$this->services->bcDec($comment['video_id'], 'comment_num', 1);
|
||||
return app('json')->success('撤销成功');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user