chore: 添加静态资源文件和版本配置文件
添加大量图片、字体、音频等静态资源文件,包括用户界面图片、模板文件和安装界面素材 添加系统版本配置文件(.version)和常量定义文件(.constant) 更新供应商依赖文件,包括Symfony VarDumper组件和相关许可证文件 添加验证码配置文件(captcha.php)和.gitignore规则
This commit is contained in:
110
app/controller/api/v1/user/Channel.php
Normal file
110
app/controller/api/v1/user/Channel.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\api\v1\user;
|
||||
|
||||
use app\Request;
|
||||
use app\services\user\channel\ChannelMerchantServices;
|
||||
use app\validate\api\user\RegisterValidates;
|
||||
use crmeb\services\CacheService;
|
||||
use think\annotation\Inject;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
/**
|
||||
* 采购商控制器
|
||||
* Class Channel
|
||||
* @package app\controller\api\v1\user
|
||||
*/
|
||||
class Channel
|
||||
{
|
||||
/**
|
||||
* @var ChannelMerchantServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected ChannelMerchantServices $services;
|
||||
|
||||
/**
|
||||
* 申请成为采购商
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function apply(Request $request)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['channel_name', ''], // 渠道名称
|
||||
['real_name', ''], // 真实姓名
|
||||
['phone', ''], // 手机号
|
||||
['code', ''], // 验证码
|
||||
['province', ''], // 省市区
|
||||
['address', ''], // 详细地址
|
||||
['remark', ''], // 备注
|
||||
['certificate', ''], // 资质图片
|
||||
['province_ids', []], // 省市区id
|
||||
]);
|
||||
// 验证用户是否已经是采购商
|
||||
$uid = $request->uid();
|
||||
$userInfo = $request->user();
|
||||
if ($userInfo['is_channel'] == 1) {
|
||||
return app('json')->fail('您已经是采购商,请勿重复申请');
|
||||
}
|
||||
$info = $this->services->getChannelInfo(['uid' => $uid, 'is_del' => 0]);
|
||||
if ($info && in_array($info['verify_status'], [0, 1])) {
|
||||
return app('json')->fail('请勿重复申请');
|
||||
}
|
||||
if (!$data['channel_name']) {
|
||||
return app('json')->fail('渠道名称不能为空');
|
||||
}
|
||||
if (!$data['real_name']) {
|
||||
return app('json')->fail('真实姓名不能为空');
|
||||
}
|
||||
//验证手机号
|
||||
try {
|
||||
validate(RegisterValidates::class)->scene('code')->check(['phone' => $data['phone']]);
|
||||
} catch (ValidateException $e) {
|
||||
return app('json')->fail($e->getError());
|
||||
}
|
||||
if (!$data['province']) {
|
||||
return app('json')->fail('省市区不能为空');
|
||||
}
|
||||
if (!$data['address']) {
|
||||
return app('json')->fail('详细地址不能为空');
|
||||
}
|
||||
if (!$data['certificate']) {
|
||||
return app('json')->fail('资质图片不能为空');
|
||||
}
|
||||
if (sys_config('channel_apply_phone_verify') == 1) {
|
||||
//验证验证码
|
||||
$verifyCode = CacheService::get('code_' . $data['phone']);
|
||||
if (!$verifyCode)
|
||||
return app('json')->fail('请先获取验证码');
|
||||
$verifyCode = substr($verifyCode, 0, 6);
|
||||
if ($verifyCode != $data['code']) {
|
||||
return app('json')->fail('验证码错误');
|
||||
}
|
||||
}
|
||||
// 验证手机号是否与用户绑定的一致
|
||||
if ($userInfo['phone'] != $data['phone']) {
|
||||
return app('json')->fail('请使用绑定的手机号申请');
|
||||
}
|
||||
unset($data['code']);
|
||||
$data['uid'] = $uid;
|
||||
// 调用服务处理申请
|
||||
$result = $this->services->apply($data, $info['id'] ?? 0);
|
||||
|
||||
return app('json')->success('申请提交成功,请等待审核');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取申请状态
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function getApplyInfo(Request $request)
|
||||
{
|
||||
$uid = $request->uid();
|
||||
|
||||
// 获取用户最新的申请记录和状态
|
||||
$applyInfo = $this->services->getChannelInfo(['uid' => $uid, 'is_del' => 0]);
|
||||
$applyInfo = $applyInfo ? $applyInfo->toArray() : [];
|
||||
return app('json')->success($applyInfo);
|
||||
}
|
||||
}
|
||||
160
app/controller/api/v1/user/Division.php
Normal file
160
app/controller/api/v1/user/Division.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\api\v1\user;
|
||||
|
||||
use app\Request;
|
||||
use app\services\agent\DivisionApplyServices;
|
||||
use app\services\agent\DivisionServices;
|
||||
use crmeb\services\CacheService;
|
||||
|
||||
class Division
|
||||
{
|
||||
/**
|
||||
* 获取代理商申请信息
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author wuhaotian
|
||||
* @email 442384644@qq.com
|
||||
* @date 2024/8/21
|
||||
*/
|
||||
public function applyInfo(Request $request)
|
||||
{
|
||||
$uid = $request->uid();
|
||||
$data = app()->make(DivisionApplyServices::class)->applyInfo($uid);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 代理商申请
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
* @author wuhaotian
|
||||
* @email 442384644@qq.com
|
||||
* @date 2024/8/21
|
||||
*/
|
||||
public function applyAgent(Request $request, $id)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['division_name', ''],
|
||||
['name', ''],
|
||||
['phone', 0],
|
||||
['code', 0],
|
||||
['division_invite', 0],
|
||||
['images', []]
|
||||
]);
|
||||
$data['uid'] = $request->uid();
|
||||
if (sys_config('division_apply_phone_verify') == 1) {
|
||||
$verifyCode = CacheService::get('code_' . $data['phone']);
|
||||
if ($verifyCode != $data['code']) return app('json')->fail('验证码错误');
|
||||
}
|
||||
if ($data['division_invite'] == 0) return app('json')->fail('邀请码错误');
|
||||
app()->make(DivisionApplyServices::class)->applyAgent($data, $id);
|
||||
return app('json')->success('申请成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 代理商员工列表
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author wuhaotian
|
||||
* @email 442384644@qq.com
|
||||
* @date 2024/8/21
|
||||
*/
|
||||
public function staffList(Request $request)
|
||||
{
|
||||
$where = $request->postMore([
|
||||
['keyword', ''],
|
||||
['start', 0],
|
||||
['stop', 0],
|
||||
]);
|
||||
$where['agent_id'] = $request->uid();
|
||||
$where['division_type'] = 3;
|
||||
$where['is_del'] = 0;
|
||||
return app('json')->success(app()->make(DivisionServices::class)->staffList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置员工提成
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* @author wuhaotian
|
||||
* @email 442384644@qq.com
|
||||
* @date 2024/8/21
|
||||
*/
|
||||
public function staffPercent(Request $request)
|
||||
{
|
||||
[$divisionPercent, $uid] = $request->postMore([
|
||||
['division_percent', ''],
|
||||
['uid', 0],
|
||||
], true);
|
||||
$agentId = $request->uid();
|
||||
if (!$uid) return app('json')->fail('参数错误');
|
||||
app()->make(DivisionServices::class)->staffPercent($uid, $agentId, $divisionPercent);
|
||||
return app('json')->success('设置成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除员工
|
||||
* @param Request $request
|
||||
* @param $uid
|
||||
* @return \think\Response
|
||||
* @author wuhaotian
|
||||
* @email 442384644@qq.com
|
||||
* @date 2024/8/21
|
||||
*/
|
||||
public function delStaff(Request $request, $uid)
|
||||
{
|
||||
$agentId = $request->uid();
|
||||
if (!$uid) return app('json')->fail('参数错误');
|
||||
app()->make(DivisionServices::class)->delStaff($uid, $agentId);
|
||||
return app('json')->success('删除成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 代理商推广码
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author wuhaotian
|
||||
* @email 442384644@qq.com
|
||||
* @date 2024/8/21
|
||||
*/
|
||||
public function agentSpreadCode(Request $request)
|
||||
{
|
||||
return app('json')->success(app()->make(DivisionServices::class)->agentSprsaveDivisionStaffeadCode($request->uid()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 代理商推广
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author wuhaotian
|
||||
* @email 442384644@qq.com
|
||||
* @date 2024/8/21
|
||||
*/
|
||||
public function agentSpread(Request $request)
|
||||
{
|
||||
[$agentId, $agentCode] = $request->postMore([
|
||||
['agent_id', 0],
|
||||
['agent_code', 0],
|
||||
], true);
|
||||
$res = app()->make(DivisionServices::class)->agentSpreadStaff($request->uid(), (int)$agentId, (int)$agentCode);
|
||||
if ($res) {
|
||||
return app('json')->success('绑定成功');
|
||||
} else {
|
||||
return app('json')->fail('无操作');
|
||||
}
|
||||
}
|
||||
}
|
||||
147
app/controller/api/v1/user/MemberCard.php
Normal file
147
app/controller/api/v1/user/MemberCard.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?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\user;
|
||||
|
||||
use app\Request;
|
||||
use app\services\activity\coupon\StoreCouponUserServices;
|
||||
use app\services\order\OtherOrderServices;
|
||||
use app\services\other\AgreementServices;
|
||||
use app\services\user\member\MemberCardServices;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 会员卡
|
||||
* Class MemberCard
|
||||
* @package app\api\controller\v1\user
|
||||
*/
|
||||
class MemberCard
|
||||
{
|
||||
/**
|
||||
* @var MemberCardServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected MemberCardServices $services;
|
||||
|
||||
/**
|
||||
* @var array|string[]
|
||||
*/
|
||||
protected array $channelType = [
|
||||
'weixin' => 'wechat',
|
||||
'weixinh5' => 'weixinh5',
|
||||
'routine' => 'routine',
|
||||
'h5' => 'h5'
|
||||
];
|
||||
|
||||
/**
|
||||
* 会员卡主页数据接口
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
$member_rights = $this->services->getMemberRightsInfo();
|
||||
/** @var AgreementServices $agreementService */
|
||||
$agreementService = app()->make(AgreementServices::class);
|
||||
$member_explain = $agreementService->getAgreementBytype(1);
|
||||
$member_explain = (isset($member_explain['status']) && $member_explain['status'] == 1) ? $member_explain : "";
|
||||
$member_type = $this->services->DoMemberType($uid);
|
||||
/** @var OtherOrderServices $OtherOrderServices */
|
||||
$OtherOrderServices = app()->make(OtherOrderServices::class);
|
||||
$is_get_free = $OtherOrderServices->isCanGetFree($uid);
|
||||
/** @var StoreCouponUserServices $couponUserService */
|
||||
$couponUserService = app()->make(StoreCouponUserServices::class);
|
||||
$coupons = $couponUserService->getMemberCoupon($uid);
|
||||
return app('json')->successful([
|
||||
'member_rights' => $member_rights['member_right'],
|
||||
'is_get_free' => $is_get_free,
|
||||
'member_explain' => $member_explain,
|
||||
'member_type' => $member_type,
|
||||
'member_coupons' => $coupons
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡密领取会员卡
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function draw_member_card(Request $request)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['member_card_code', ''],
|
||||
['member_card_pwd', ''],
|
||||
['from', 'weixin'],
|
||||
]);
|
||||
$data['from'] = strtolower(trim($data['from']));
|
||||
if (!array_key_exists($data['from'], $this->channelType)) return app('json')->fail('非法渠道');
|
||||
$data['from'] = $this->channelType[$data['from']];
|
||||
$uid = (int)$request->uid();
|
||||
$this->services->drawMemberCard($data, $uid);
|
||||
return app('json')->successful("激活成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员券接口
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function memberCouponList(Request $request)
|
||||
{
|
||||
/** @var StoreCouponUserServices $couponUserService */
|
||||
$couponUserService = app()->make(StoreCouponUserServices::class);
|
||||
$coupons = $couponUserService->getMemberCoupon($request->uid());
|
||||
return app('json')->successful($coupons);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算会员天数
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOverdueTime(Request $request)
|
||||
{
|
||||
$params = $request->getMore([
|
||||
['member_type', ''],
|
||||
['vip_day', ''],
|
||||
]);
|
||||
$member_type = $params['member_type'];
|
||||
$vip_day = $params['vip_day'];
|
||||
$user_info = $request->user();
|
||||
if ($member_type == 'ever') {
|
||||
$overdue_time = 0;
|
||||
$is_ever_level = 1;
|
||||
} else {
|
||||
if ($user_info['is_money_level'] == 0) {
|
||||
$overdue_time = bcadd(bcmul($vip_day, 86400, 0), time(), 0);
|
||||
} else {
|
||||
$overdue_time = bcadd(bcmul($vip_day, 86400, 0), $user_info['overdue_time'], 0);
|
||||
}
|
||||
$is_ever_level = 0;
|
||||
}
|
||||
if ($is_ever_level == 1 || $user_info['is_ever_level']) {
|
||||
$res = "永久会员";
|
||||
} else {
|
||||
$res = date('Y-m-d', $overdue_time);
|
||||
}
|
||||
|
||||
return app('json')->successful(['data' => $res]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
48
app/controller/api/v1/user/PromoterApply.php
Normal file
48
app/controller/api/v1/user/PromoterApply.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\api\v1\user;
|
||||
|
||||
use app\Request;
|
||||
use app\services\agent\DivisionApplyServices;
|
||||
use app\services\agent\PromoterApplyServices;
|
||||
use crmeb\services\CacheService;
|
||||
use think\annotation\Inject;
|
||||
|
||||
class PromoterApply
|
||||
{
|
||||
/**
|
||||
* @var PromoterApplyServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected PromoterApplyServices $services;
|
||||
|
||||
|
||||
public function applyInfo(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
$uid = $request->uid();
|
||||
$data = $this->services->applyInfo($uid, $user);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
public function applyPromoter(Request $request, $id)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['uid', 0],
|
||||
['nickname', ''],
|
||||
['real_name', ''],
|
||||
['phone', ''],
|
||||
['code', 0]
|
||||
]);
|
||||
$data['uid'] = $request->uid();
|
||||
$userInfo = $request->user();
|
||||
if (sys_config('brokerage_apply_phone_verify') == 1) {
|
||||
$verifyCode = CacheService::get('code_' . $data['phone']);
|
||||
if ($verifyCode != $data['code']) return app('json')->fail('验证码错误');
|
||||
}
|
||||
unset($data['code']);
|
||||
$data['refusal_reason'] = '';
|
||||
$id = $this->services->applyPromoter($data, $id, $userInfo);
|
||||
return app('json')->success('申请成功', ['id' => $id]);
|
||||
}
|
||||
}
|
||||
192
app/controller/api/v1/user/StoreService.php
Normal file
192
app/controller/api/v1/user/StoreService.php
Normal file
@@ -0,0 +1,192 @@
|
||||
<?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\user;
|
||||
|
||||
use app\validate\api\user\StoreServiceFeedbackValidate;
|
||||
use app\Request;
|
||||
use app\services\message\service\StoreServiceFeedbackServices;
|
||||
use app\services\message\service\StoreServiceLogServices;
|
||||
use app\services\message\service\StoreServiceRecordServices;
|
||||
use app\services\message\service\StoreServiceServices;
|
||||
use app\services\other\CacheServices;
|
||||
use crmeb\services\CacheService;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 客服类
|
||||
* Class StoreService
|
||||
* @package app\api\controller\user
|
||||
*/
|
||||
class StoreService
|
||||
{
|
||||
/**
|
||||
* @var StoreServiceLogServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreServiceLogServices $services;
|
||||
|
||||
/**
|
||||
* 客服列表
|
||||
* @param StoreServiceServices $services
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function lst(StoreServiceServices $services)
|
||||
{
|
||||
$serviceInfoList = $services->getServiceList(['status' => 1]);
|
||||
if (!count($serviceInfoList)) return app('json')->successful([]);
|
||||
return app('json')->successful($serviceInfoList['list']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 客服聊天记录
|
||||
* @param Request $request
|
||||
* @param StoreServiceServices $services
|
||||
* @param StoreServiceRecordServices $recordServices
|
||||
* @return array
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function record(Request $request, StoreServiceServices $services, StoreServiceRecordServices $recordServices)
|
||||
{
|
||||
[$uidTo] = $request->getMore([
|
||||
['uidTo', 0]
|
||||
], true);
|
||||
$serviceInfoList = $services->getServiceList(['status' => 1]);
|
||||
if (!count($serviceInfoList)) return app('json')->fail('暂无客服人员在线,请稍后联系');
|
||||
$uid = (int)$request->uid();
|
||||
$uids = array_column($serviceInfoList['list'], 'uid');
|
||||
if (!$uidTo) {
|
||||
//自己是客服
|
||||
if (in_array($uid, $uids)) {
|
||||
$uids = array_merge(array_diff($uids, [$uid]));
|
||||
if (!$uids) return app('json')->fail('不能和自己聊天');
|
||||
}
|
||||
} else {
|
||||
if (in_array($uid, $uids)) {
|
||||
$uid = $uidTo;
|
||||
}
|
||||
}
|
||||
if (!$uids) {
|
||||
return app('json')->fail('暂无客服人员在线,请稍后联系');
|
||||
}
|
||||
//上次聊天客服优先对话
|
||||
$toUid = $recordServices->value(['user_id' => $uid], 'to_uid');
|
||||
if (!in_array($toUid, $uids)) {
|
||||
$toUid = 0;
|
||||
}
|
||||
if (!$toUid) {
|
||||
mt_srand();
|
||||
$toUid = $uids[array_rand($uids)] ?? 0;
|
||||
}
|
||||
|
||||
if (!$toUid) return app('json')->fail('暂无客服人员在线,请稍后联系');
|
||||
$result = ['serviceList' => [], 'uid' => $toUid];
|
||||
$serviceLogList = $this->services->getChatList(['uid' => $uid], $uid);
|
||||
if (!$serviceLogList) return app('json')->successful($result);
|
||||
$idArr = array_column($serviceLogList, 'id');
|
||||
array_multisort($idArr, SORT_ASC, $serviceLogList);
|
||||
$result['serviceList'] = $serviceLogList;
|
||||
return app('json')->successful($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客服页面广告内容
|
||||
* @return mixed
|
||||
*/
|
||||
public function getKfAdv()
|
||||
{
|
||||
/** @var CacheServices $cache */
|
||||
$cache = app()->make(CacheServices::class);
|
||||
$content = $cache->getDbCache('kf_adv', '');
|
||||
return app('json')->successful(compact('content'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存反馈信息
|
||||
* @param Request $request
|
||||
* @param StoreServiceFeedbackServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
public function saveFeedback(Request $request, StoreServiceFeedbackServices $services)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['rela_name', ''],
|
||||
['phone', ''],
|
||||
['content', ''],
|
||||
]);
|
||||
|
||||
validate(StoreServiceFeedbackValidate::class)->check($data);
|
||||
|
||||
$data['content'] = htmlspecialchars($data['content']);
|
||||
$data['add_time'] = time();
|
||||
$data['uid'] = $request->uid();
|
||||
$services->save($data);
|
||||
return app('json')->success('提交成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 客服反馈页面头部文字
|
||||
* @return mixed
|
||||
*/
|
||||
public function getFeedbackInfo()
|
||||
{
|
||||
return app('json')->success(['feedback' => sys_config('service_feedback')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认登录
|
||||
* @param Request $request
|
||||
* @param StoreServiceServices $services
|
||||
* @param string $code
|
||||
* @return mixed
|
||||
*/
|
||||
public function setLoginCode(Request $request, StoreServiceServices $services, string $code)
|
||||
{
|
||||
if (!$code) {
|
||||
return app('json')->fail('登录CODE不存在');
|
||||
}
|
||||
$cacheCode = CacheService::get($code);
|
||||
if ($cacheCode === false || $cacheCode === null) {
|
||||
return app('json')->fail('二维码已过期请重新扫描');
|
||||
}
|
||||
$userInfo = $services->get(['uid' => $request->uid()]);
|
||||
if (!$userInfo) {
|
||||
return app('json')->fail('您不是客服无法登录');
|
||||
}
|
||||
$userInfo->uniqid = $code;
|
||||
$userInfo->save();
|
||||
CacheService::set($code, '0', 600);
|
||||
return app('json')->success('登录成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前客服和用户的聊天记录
|
||||
* @param StoreServiceRecordServices $services
|
||||
* @param Request $request
|
||||
* @param string $nickname
|
||||
* @param int $is_tourist
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function recordList(StoreServiceRecordServices $services, Request $request, string $nickname = '', $is_tourist = 0)
|
||||
{
|
||||
return app('json')->success($services->getServiceList((int)$request->uid(), $nickname, (int)$is_tourist));
|
||||
}
|
||||
}
|
||||
89
app/controller/api/v1/user/SystemMessage.php
Normal file
89
app/controller/api/v1/user/SystemMessage.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?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\user;
|
||||
|
||||
use app\Request;
|
||||
use app\services\community\CommunityRecordServices;
|
||||
use app\services\message\service\StoreServiceRecordServices;
|
||||
use app\services\message\SystemMessageServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 站内信类
|
||||
* Class SystemMessage
|
||||
* @package app\api\controller\store
|
||||
*/
|
||||
class SystemMessage
|
||||
{
|
||||
|
||||
/**
|
||||
* @var SystemMessageServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected SystemMessageServices $services;
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户消息 站内信+客服消息
|
||||
* @param Request $request
|
||||
* @param StoreServiceRecordServices $services
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function message(Request $request, StoreServiceRecordServices $services, CommunityRecordServices $community)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
$where['is_del'] = 0;
|
||||
$where['uid'] = $uid;
|
||||
$list = $this->services->getMessageList($where, '*', 0, 1);
|
||||
$list = $list[0] ?? [];
|
||||
if ($list) {
|
||||
$list['add_time'] = time_tran($list['add_time']);
|
||||
$list['message_num'] = $this->services->count(['uid' => $uid, 'look' => 0, 'is_del' => 0]);
|
||||
}
|
||||
|
||||
$service = $services->getServiceList($uid);
|
||||
$community = $community->getList(['uid' => $uid], '*', 0, 1);
|
||||
$community = $community[0] ?? [];
|
||||
return app('json')->successful(['system' => $list, 'service' => $service, 'community' => $community]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 站内信列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function message_list(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful($this->services->getMessageSystemList($uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 站内信详情
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail(Request $request, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
app('json')->fail('缺少参数');
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
$where['uid'] = $uid;
|
||||
$where['id'] = $id;
|
||||
return app('json')->successful($this->services->getInfo($where));
|
||||
}
|
||||
}
|
||||
305
app/controller/api/v1/user/User.php
Normal file
305
app/controller/api/v1/user/User.php
Normal file
@@ -0,0 +1,305 @@
|
||||
<?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\user;
|
||||
|
||||
use app\Request;
|
||||
use app\services\product\product\StoreProductLogServices;
|
||||
use app\services\user\UserServices;
|
||||
use app\services\wechat\WechatUserServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 用户类
|
||||
* Class User
|
||||
* @package app\api\controller\store
|
||||
*/
|
||||
class User
|
||||
{
|
||||
|
||||
/**
|
||||
* @var UserServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserServices $services;
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function userInfo(Request $request)
|
||||
{
|
||||
$info = $request->user()->toArray();
|
||||
return app('json')->success($this->services->userInfo($info));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户资金统计
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function balance(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful($this->services->balance($uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人中心
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function user(Request $request)
|
||||
{
|
||||
$user = $request->user()->toArray();
|
||||
return app('json')->success($this->services->personalHome($user, $request->tokenData()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取活动状态
|
||||
* @return mixed
|
||||
*/
|
||||
public function activity()
|
||||
{
|
||||
return app('json')->successful($this->services->activity());
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户修改信息
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function edit(Request $request)
|
||||
{
|
||||
[$avatar, $nickname, $extend_info] = $request->postMore([
|
||||
['avatar', ''],
|
||||
['nickname', ''],
|
||||
['extend_info', []]
|
||||
], true);
|
||||
if (!$avatar && $nickname == '') {
|
||||
return app('json')->fail('请输入昵称或者选择头像');
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
$this->services->saveExtendForm($uid, $extend_info, ['avatar' => $avatar, 'nickname' => $nickname], true);
|
||||
return app('json')->success('修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 推广人排行
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function rank(Request $request)
|
||||
{
|
||||
$data = $request->getMore([
|
||||
['page', ''],
|
||||
['limit', ''],
|
||||
['type', '']
|
||||
]);
|
||||
$data['uid'] = $request->uid();
|
||||
$info = $this->services->getRankList($data);
|
||||
$info['avatar'] = $request->user()['avatar'];
|
||||
$info['nickname'] = $request->user()['nickname'];
|
||||
$info['uid'] = $request->uid();
|
||||
return app('json')->success($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加访问记录
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function set_visit(Request $request)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['url', ''],
|
||||
['stay_time', 0]
|
||||
]);
|
||||
if ($data['url'] == '') return app('json')->fail('未获取页面路径');
|
||||
$data['uid'] = (int)$request->uid();
|
||||
$data['ip'] = $request->ip();
|
||||
if ($this->services->setVisit($data)) {
|
||||
return app('json')->success('添加访问记录成功');
|
||||
} else {
|
||||
return app('json')->fail('添加访问记录失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 静默绑定推广人
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function spread(Request $request)
|
||||
{
|
||||
[$spreadUid, $code] = $request->postMore([
|
||||
['puid', 0],
|
||||
['code', 0]
|
||||
], true);
|
||||
$uid = (int)$request->uid();
|
||||
$this->services->spread($uid, (int)$spreadUid, $code);
|
||||
return app('json')->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 推荐用户
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*
|
||||
* grade == 0 获取一级推荐人
|
||||
* grade == 1 获取二级推荐人
|
||||
*
|
||||
* keyword 会员名称查询
|
||||
*
|
||||
* sort childCount ASC/DESC 团队排序 numberCount ASC/DESC 金额排序 orderCount ASC/DESC 订单排序
|
||||
*/
|
||||
public function spread_people(Request $request)
|
||||
{
|
||||
$spreadInfo = $request->postMore([
|
||||
['grade', 0],
|
||||
['keyword', ''],
|
||||
['sort', ''],
|
||||
['start', 0],
|
||||
['stop', 0],
|
||||
['type', 0],
|
||||
]);
|
||||
if (!in_array($spreadInfo['grade'], [0, 1])) {
|
||||
return app('json')->fail('等级错误');
|
||||
}
|
||||
$spreadInfo['time'] = [$spreadInfo['start'], $spreadInfo['stop']];
|
||||
$uid = $request->uid();
|
||||
return app('json')->successful($this->services->getUserSpreadGrade($uid, $spreadInfo['grade'], $spreadInfo['sort'], $spreadInfo['keyword'], $spreadInfo['time'], $spreadInfo['type']));
|
||||
}
|
||||
|
||||
public function peopleHead()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否关注
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function subscribe(Request $request)
|
||||
{
|
||||
if ($request->uid()) {
|
||||
/** @var WechatUserServices $wechatUserService */
|
||||
$wechatUserService = app()->make(WechatUserServices::class);
|
||||
$subscribe = (bool)$wechatUserService->value(['uid' => $request->uid()], 'subscribe');
|
||||
return app('json')->success(['subscribe' => $subscribe]);
|
||||
} else {
|
||||
return app('json')->success(['subscribe' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户付款code
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function randCode(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
$code = $this->services->getRandCode((int)$uid);
|
||||
return app('json')->success(['code' => $code]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品浏览记录
|
||||
* @param Request $request
|
||||
* @param StoreProductLogServices $services
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function visitList(Request $request, StoreProductLogServices $services)
|
||||
{
|
||||
$where['uid'] = (int)$request->uid();
|
||||
$where['type'] = 'visit';
|
||||
$result = $services->getList($where, 'product_id', 'id,product_id,max(add_time) as add_time');
|
||||
$time_data = [];
|
||||
if ($result['list']) {
|
||||
foreach ($result['list'] as $key => &$item) {
|
||||
$add_time = strtotime($item['add_time']);
|
||||
if (date('Y') == date('Y', $add_time)) {//今年
|
||||
$item['time_key'] = date('m月d日', $add_time);
|
||||
} else {
|
||||
$item['time_key'] = date('Y年m月d日', $add_time);
|
||||
}
|
||||
}
|
||||
$time_data = array_merge(array_unique(array_column($result['list'], 'time_key')));
|
||||
}
|
||||
$result['time'] = $time_data;
|
||||
return app('json')->success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品浏览记录删除
|
||||
* @param Request $request
|
||||
* @param StoreProductLogServices $services
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function visitDelete(Request $request, StoreProductLogServices $services)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
[$ids] = $request->postMore([
|
||||
['ids', []],
|
||||
], true);
|
||||
if ($ids) {
|
||||
$where = ['uid' => $uid, 'product_id' => $ids];
|
||||
$services->update($where, ['delete_time' => date('Y-m-d H:i:s')]);
|
||||
}
|
||||
return app('json')->success('删除成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注销
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function cancelUser(Request $request)
|
||||
{
|
||||
$uid = $request->uid();
|
||||
if (!$uid) return app('json')->fail('用户不存在');
|
||||
event('user.cancelUser', [$uid]);
|
||||
return app('json')->success('注销成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换身份
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2025/4/8 下午3:17
|
||||
*/
|
||||
public function switchIdentity(Request $request)
|
||||
{
|
||||
[$identity] = $request->postMore([
|
||||
['identity', 0],
|
||||
], true);
|
||||
$uid = (int)$request->uid();
|
||||
if (!$uid) return app('json')->fail('用户不存在');
|
||||
$this->services->switchIdentity($uid, (int)$identity);
|
||||
return app('json')->success('切换成功');
|
||||
}
|
||||
}
|
||||
175
app/controller/api/v1/user/UserAddress.php
Normal file
175
app/controller/api/v1/user/UserAddress.php
Normal file
@@ -0,0 +1,175 @@
|
||||
<?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\user;
|
||||
|
||||
use app\Request;
|
||||
use app\services\other\CityAreaServices;
|
||||
use app\services\user\UserAddressServices;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\Exception;
|
||||
|
||||
/**
|
||||
* 用户地址类
|
||||
* Class UserAddress
|
||||
* @package app\api\controller\store
|
||||
*/
|
||||
class UserAddress
|
||||
{
|
||||
|
||||
/**
|
||||
* @var UserAddressServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserAddressServices $services;
|
||||
|
||||
/**
|
||||
* 地址 获取单个
|
||||
* @param Request $request
|
||||
* @param CityAreaServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws ModelNotFoundException|DbException
|
||||
*/
|
||||
public function address(Request $request, CityAreaServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数');
|
||||
}
|
||||
$data = $this->services->address((int)$id);
|
||||
if (!$data) {
|
||||
return app('json')->fail('地址不存在');
|
||||
}
|
||||
if ($data['uid'] != $request->uid()) {
|
||||
return app('json')->fail('地址不存在');
|
||||
}
|
||||
$address = implode('/', [$data['province'] ?? '', $data['city'] ?? '', $data['district'] ?? '', $data['street'] ?? '']);
|
||||
$city = $services->searchCity(compact('address'));
|
||||
if ($city) {
|
||||
$where = [['id', 'in', array_merge([$city['id']], explode('/', trim($city->path, '/')))]];
|
||||
$data['city_list'] = $services->getCityList($where, 'id as value,id,name as label,parent_id as pid');
|
||||
}
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 地址列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function address_list(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful($this->services->getUserAddressList($uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置默认地址
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function address_default_set(Request $request)
|
||||
{
|
||||
[$id] = $request->getMore([['id', 0]], true);
|
||||
if (!$id || !is_numeric($id)) return app('json')->fail('参数错误!');
|
||||
$uid = (int)$request->uid();
|
||||
$res = $this->services->setDefault($uid, (int)$id);
|
||||
if (!$res)
|
||||
return app('json')->fail('地址不存在!');
|
||||
else {
|
||||
$this->services->cacheTag()->clear();
|
||||
return app('json')->successful();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认地址
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function address_default(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
$defaultAddress = $this->services->getUserDefaultAddressCache($uid);
|
||||
if ($defaultAddress) {
|
||||
return app('json')->successful('ok', $defaultAddress);
|
||||
}
|
||||
return app('json')->successful('empty', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 添加地址
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function address_edit(Request $request)
|
||||
{
|
||||
$addressInfo = $request->postMore([
|
||||
['address', []],
|
||||
['is_default', false],
|
||||
['real_name', ''],
|
||||
['post_code', ''],
|
||||
['phone', ''],
|
||||
['detail', ''],
|
||||
[['id', 'd'], 0],
|
||||
[['type', 'd'], 0],
|
||||
['latitude', ''],
|
||||
['longitude', ''],
|
||||
]);
|
||||
if ($addressInfo['latitude'] && $addressInfo['longitude'] && !checkCoordinates($addressInfo['longitude'], $addressInfo['latitude'])) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
if (!isset($addressInfo['address']['province']) || !$addressInfo['address']['province'] || $addressInfo['address']['province'] == '省') return app('json')->fail('收货地址格式错误!');
|
||||
if (!isset($addressInfo['address']['city']) || !$addressInfo['address']['city'] || $addressInfo['address']['city'] == '市') return app('json')->fail('收货地址格式错误!');
|
||||
if (!isset($addressInfo['address']['district']) || !$addressInfo['address']['district'] || $addressInfo['address']['district'] == '区') return app('json')->fail('收货地址格式错误!');
|
||||
if (!isset($addressInfo['address']['city_id']) && $addressInfo['type'] == 0) {
|
||||
return app('json')->fail('收货地址格式错误!请重新选择!');
|
||||
}
|
||||
if (!$addressInfo['detail']) return app('json')->fail('请填写详细地址!');
|
||||
$uid = (int)$request->uid();
|
||||
$addressInfo['upgrade'] = 1;
|
||||
$re = $this->services->editAddress($uid, $addressInfo);
|
||||
if ($re) {
|
||||
return app('json')->success($re['type'] == 'edit' ? $re['msg'] : $re['data']);
|
||||
} else {
|
||||
return app('json')->fail('处理失败');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除地址
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function address_del(Request $request)
|
||||
{
|
||||
[$id] = $request->postMore([
|
||||
['id', 0]
|
||||
], true);
|
||||
if (!$id || !is_numeric($id)) return app('json')->fail('参数错误!');
|
||||
$uid = (int)$request->uid();
|
||||
$re = $this->services->delAddress($uid, (int)$id);
|
||||
if ($re)
|
||||
return app('json')->successful();
|
||||
else
|
||||
return app('json')->fail('删除地址失败!');
|
||||
}
|
||||
}
|
||||
153
app/controller/api/v1/user/UserBill.php
Normal file
153
app/controller/api/v1/user/UserBill.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?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\user;
|
||||
|
||||
use app\Request;
|
||||
use app\services\other\QrcodeServices;
|
||||
use app\services\system\attachment\SystemAttachmentServices;
|
||||
use app\services\system\config\SystemConfigServices;
|
||||
use app\services\user\UserBillServices;
|
||||
use crmeb\services\UploadService;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 账单类
|
||||
* Class UserBill
|
||||
* @package app\api\controller\user
|
||||
*/
|
||||
class UserBill
|
||||
{
|
||||
|
||||
/**
|
||||
* @var UserBillServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserBillServices $services;
|
||||
|
||||
/**
|
||||
* 推广佣金明细
|
||||
* @param Request $request
|
||||
* @param $type 0 全部 1 消费 2 充值 3 返佣 4 提现
|
||||
* @return mixed
|
||||
*/
|
||||
public function spread_commission(Request $request, $type)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful($this->services->getUserBillList($uid, $type));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序二维码
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getRoutineCode(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
$uid = (int)$request->uid();
|
||||
//小程序
|
||||
$name = $uid . '_' . $user['is_promoter'] . '_user_routine.jpg';
|
||||
|
||||
/** @var SystemAttachmentServices $systemAttachment */
|
||||
$systemAttachment = app()->make(SystemAttachmentServices::class);
|
||||
$imageInfo = $systemAttachment->getInfo(['name' => $name]);
|
||||
|
||||
/** @var QrcodeServices $qrCode */
|
||||
$qrCode = app()->make(QrcodeServices::class);
|
||||
$res1 = $qrCode->qrCodeExist($uid, 'spread');
|
||||
|
||||
//图片在,数据库没有数据,删除图片
|
||||
if ($imageInfo && !$res1) {
|
||||
try {
|
||||
$uploadRes = UploadService::init($imageInfo->image_type);
|
||||
if ($imageInfo['image_type'] == 1) {
|
||||
if (strpos($imageInfo['att_dir'], '/') == 0) {
|
||||
$imageInfo['att_dir'] = substr($imageInfo['att_dir'], 1);
|
||||
}
|
||||
if ($imageInfo['att_dir']) $uploadRes->delete(public_path() . $imageInfo['att_dir']);
|
||||
} else {
|
||||
if ($imageInfo['name']) $uploadRes->delete($imageInfo['name']);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
}
|
||||
if (!$imageInfo || !$res1) {
|
||||
/** @var QrcodeServices $qrCode */
|
||||
$qrCode = app()->make(QrcodeServices::class);
|
||||
$resForever = $qrCode->qrCodeForever($user['uid'], 'spread-' . $user['uid']);
|
||||
$id = (int)$resForever['id'];
|
||||
/** @var QrcodeServices $QrcodeService */
|
||||
$QrcodeService = app()->make(QrcodeServices::class);
|
||||
//生成小程序地址
|
||||
$urlCode = $QrcodeService->getRoutineQrcodePath($id, $uid, 99, $name);
|
||||
} else {
|
||||
$urlCode = $imageInfo['att_dir'];
|
||||
if ($imageInfo['image_type'] == 1) $urlCode = sys_config('site_url') . $urlCode;
|
||||
}
|
||||
return app('json')->success(['url' => $urlCode]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取海报详细信息
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSpreadInfo(Request $request)
|
||||
{
|
||||
/** @var SystemConfigServices $systemConfigServices */
|
||||
$systemConfigServices = app()->make(SystemConfigServices::class);
|
||||
$spreadBanner = $systemConfigServices->getSpreadBanner() ?? [];
|
||||
$bannerCount = count($spreadBanner);
|
||||
$routineSpreadBanner = [];
|
||||
if ($bannerCount) {
|
||||
foreach ($spreadBanner as $item) {
|
||||
$routineSpreadBanner[] = ['pic' => $item];
|
||||
}
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
if (sys_config('share_qrcode', 0) && request()->isWechat()) {
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
if (sys_config('spread_share_forever', 0)) {
|
||||
$qrcode = $qrcodeService->getForeverQrcode('spread-' . $uid, $uid)->url;
|
||||
} else {
|
||||
$qrcode = $qrcodeService->getTemporaryQrcode('spread-' . $uid, $uid)->url;
|
||||
}
|
||||
} else {
|
||||
$qrcode = '';
|
||||
}
|
||||
return app('json')->success([
|
||||
'spread' => $routineSpreadBanner,
|
||||
'qrcode' => $qrcode,
|
||||
'nickname' => $request->user('nickname'),
|
||||
'avatar' => $request->user('avatar'),
|
||||
'site_name' => sys_config('site_name')
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分记录
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function integral_list(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
$data = $this->services->getIntegralList($uid);
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
}
|
||||
151
app/controller/api/v1/user/UserBrokerage.php
Normal file
151
app/controller/api/v1/user/UserBrokerage.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?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\user;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\user\UserBrokerageServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 佣金
|
||||
* Class UserBrokerage
|
||||
* @package app\controller\api\v1\user
|
||||
*/
|
||||
class UserBrokerage
|
||||
{
|
||||
|
||||
/**
|
||||
* @var UserBrokerageServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserBrokerageServices $services;
|
||||
|
||||
/**
|
||||
* 推广数据 昨天的佣金 累计提现金额 当前佣金
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function commission(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful($this->services->commission($uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 推广订单
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function spread_order(Request $request)
|
||||
{
|
||||
$orderInfo = $request->postMore([
|
||||
['page', 1],
|
||||
['limit', 20],
|
||||
['category', 'now_money'],
|
||||
['type', 'brokerage'],
|
||||
['start', 0],
|
||||
['stop', 0],
|
||||
['keyword', '']
|
||||
]);
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful($this->services->spread_order($uid, $orderInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单收益明细
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* User: liusl
|
||||
* DateTime: 2024/11/22 上午10:45
|
||||
*/
|
||||
public function order_income(Request $request)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['start', 0],
|
||||
['stop', 0],
|
||||
]);
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful($this->services->orderIncome($uid, $where));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据总览
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/11/23 下午12:11
|
||||
*/
|
||||
public function overview(Request $request)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['start', 0],
|
||||
['stop', 0],
|
||||
]);
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful($this->services->overview($uid, $where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户贡献
|
||||
* @param $type
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* @throws \ReflectionException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* User: liusl
|
||||
* DateTime: 2024/11/23 下午2:18
|
||||
*/
|
||||
public function contribute($type, Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful($this->services->contribute($uid, $type));
|
||||
}
|
||||
|
||||
/**
|
||||
* 推广 佣金/提现 总和
|
||||
* @param Request $request
|
||||
* @param $type 3 佣金 4 提现
|
||||
* @return mixed
|
||||
*/
|
||||
public function spread_count(Request $request, $type)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful(['count' => $this->services->spread_count($uid, $type)]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 佣金排行
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function brokerage_rank(Request $request)
|
||||
{
|
||||
$data = $request->getMore([
|
||||
['page', ''],
|
||||
['limit'],
|
||||
['type']
|
||||
]);
|
||||
$uid = (int)$request->uid();
|
||||
$userInfo = $request->user();
|
||||
$data = $this->services->brokerage_rank($uid, $data['type']);
|
||||
$data['nickname'] = $userInfo['nickname'];
|
||||
$data['avatar'] = $userInfo['avatar'];
|
||||
return app('json')->success($data);
|
||||
}
|
||||
}
|
||||
126
app/controller/api/v1/user/UserCollect.php
Normal file
126
app/controller/api/v1/user/UserCollect.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?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\user;
|
||||
|
||||
use app\Request;
|
||||
use app\services\user\UserRelationServices;
|
||||
use crmeb\services\CacheService;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 用户收藏
|
||||
* Class UserCollect
|
||||
* @package app\api\controller\v1\user
|
||||
*/
|
||||
class UserCollect
|
||||
{
|
||||
|
||||
/**
|
||||
* @var UserRelationServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserRelationServices $services;
|
||||
|
||||
/**
|
||||
* 获取收藏列表
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function collect_user(Request $request)
|
||||
{
|
||||
[$category] = $request->postMore([
|
||||
['category', 'product']
|
||||
], true);
|
||||
$uid = (int)$request->uid();
|
||||
$list = $this->services->getUserRelationList($uid, $category);
|
||||
foreach ($list as &$item) {
|
||||
$item['promotions'] = !isset($item['promotions']) || !$item['promotions'] ? (object)[] : $item['promotions'];
|
||||
}
|
||||
$count = $this->services->getUserCount($uid,0, UserRelationServices::TYPE_COLLECT, $category);
|
||||
return app('json')->successful(compact('list', 'count'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加收藏
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @param $category
|
||||
* @return mixed
|
||||
*/
|
||||
public function collect_add(Request $request)
|
||||
{
|
||||
[$id, $category] = $request->postMore([
|
||||
['id', 0],
|
||||
['category', 'product']
|
||||
], true);
|
||||
if (!$id) return app('json')->fail('参数错误');
|
||||
if(!is_array($id)) $id = [$id];
|
||||
$uid = (int)$request->uid();
|
||||
$res = $this->services->productRelation($uid, $id, 'collect', $category);
|
||||
if (!$res) {
|
||||
return app('json')->fail('添加收藏失败');
|
||||
} else {
|
||||
CacheService::clearTokenAll('relation_' . fmod((float)$request->uid(), (float)10));
|
||||
return app('json')->successful('收藏成功');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消收藏
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function collect_del(Request $request)
|
||||
{
|
||||
[$id, $category] = $request->postMore([
|
||||
['id', 0],
|
||||
['category', 'product']
|
||||
], true);
|
||||
if (!$id) return app('json')->fail('参数错误');
|
||||
if (!is_array($id)) $id = [$id];
|
||||
$uid = (int)$request->uid();
|
||||
$res = $this->services->productRelation($uid, $id, 'collect', $category, true);
|
||||
if (!$res) {
|
||||
return app('json')->fail('取消收藏失败');
|
||||
} else {
|
||||
CacheService::clearTokenAll('relation_' . fmod((float)$request->uid(), (float)10));
|
||||
return app('json')->successful('取消收藏成功');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量收藏
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function collect_all(Request $request)
|
||||
{
|
||||
$collectInfo = $request->postMore([
|
||||
['id', ''],
|
||||
['category', 'product'],
|
||||
]);
|
||||
$collectInfo['id'] = stringToIntArray($collectInfo['id']);
|
||||
if (!count($collectInfo['id'])) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
$productIdS = $collectInfo['id'];
|
||||
$res = $this->services->productRelation($uid, $productIdS, 'collect', $collectInfo['category']);
|
||||
if (!$res) {
|
||||
return app('json')->fail('收藏失败');
|
||||
} else {
|
||||
CacheService::clearTokenAll('relation_' . fmod((float)$request->uid(), (float)10));
|
||||
return app('json')->successful('收藏成功');
|
||||
}
|
||||
}
|
||||
}
|
||||
147
app/controller/api/v1/user/UserExtract.php
Normal file
147
app/controller/api/v1/user/UserExtract.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?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\user;
|
||||
|
||||
use app\Request;
|
||||
use app\services\activity\lottery\LuckLotteryRecordServices;
|
||||
use app\services\user\UserExtractServices;
|
||||
use crmeb\services\wechat\Payment;
|
||||
use think\annotation\Inject;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 提现类
|
||||
* Class UserExtractController
|
||||
* @package app\api\controller\user
|
||||
*/
|
||||
class UserExtract
|
||||
{
|
||||
|
||||
/**
|
||||
* @var UserExtractServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserExtractServices $services;
|
||||
|
||||
/**
|
||||
* 提现银行
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function bank(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful($this->services->bank($uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现申请
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function cash(Request $request)
|
||||
{
|
||||
$extractInfo = $request->postMore([
|
||||
['alipay_code', ''],
|
||||
['extract_type', ''],
|
||||
['money', 0],
|
||||
['name', ''],
|
||||
['bankname', ''],
|
||||
['cardnum', ''],
|
||||
['weixin', ''],
|
||||
['qrcode_url', ''],
|
||||
['channel_type', ''],
|
||||
]);
|
||||
$extractType = Config::get('pay.extractType', []);
|
||||
if (!in_array($extractInfo['extract_type'], $extractType))
|
||||
return app('json')->fail('提现方式不存在');
|
||||
if (!preg_match('/^[0-9]+(.[0-9]{1,2})?$/', (float)$extractInfo['money'])) return app('json')->fail('提现金额输入有误');
|
||||
if (!$extractInfo['cardnum'] == '')
|
||||
if (!preg_match('/^([1-9]{1})(\d{15}|\d{16}|\d{18})$/', $extractInfo['cardnum']))
|
||||
return app('json')->fail('银行卡号输入有误');
|
||||
if ($extractInfo['extract_type'] == 'alipay') {
|
||||
if (!$extractInfo['name']) return app('json')->fail('请输入真实姓名');
|
||||
if (!$extractInfo['alipay_code']) return app('json')->fail('请输入支付宝账号');
|
||||
} else if ($extractInfo['extract_type'] == 'bank') {
|
||||
if (!$extractInfo['cardnum']) return app('json')->fail('请输入银行卡账号');
|
||||
if (!$extractInfo['bankname']) return app('json')->fail('请输入开户行信息');
|
||||
} else if ($extractInfo['extract_type'] == 'weixin' && sys_config('brokerage_type') == 0) {
|
||||
if (!$extractInfo['weixin']) return app('json')->fail('请输入微信账号');
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
if ($this->services->cash($uid, $extractInfo))
|
||||
return app('json')->successful('申请提现成功!');
|
||||
else
|
||||
return app('json')->fail('提现失败');
|
||||
}
|
||||
|
||||
public function detail(Request $request)
|
||||
{
|
||||
[$order_id, $type] = $request->postMore([
|
||||
['order_id', ''],
|
||||
['type', ''],
|
||||
], true);
|
||||
if (!$order_id || !$type) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
|
||||
$info = [];
|
||||
switch ($type) {
|
||||
//提现
|
||||
case 1:
|
||||
$info = $this->services->get(['order_id' => $order_id]);
|
||||
$info = $info ? $info->toArray() : [];
|
||||
if ($info['extract_type'] != 'weixin' || sys_config('pay_wechat_type') != 1) {
|
||||
return app('json')->fail('状态错误,请联系客服管理员');
|
||||
}
|
||||
|
||||
break;
|
||||
case 2:
|
||||
$info = app()->make(LuckLotteryRecordServices::class)->get(['order_id' => $order_id]);
|
||||
$info = $info ? $info->toArray() : [];
|
||||
$prize_info = is_string($info['prize_info']) ? json_decode($info['prize_info'], true) : $info['prize_info'];
|
||||
$info['extract_price'] = $prize_info['num'] ?? '0';
|
||||
if ($info['type'] != 4 || sys_config('pay_wechat_type') != 1) {
|
||||
return app('json')->fail('状态错误,请联系客服管理员');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$res = Payment::instance()->payClient()->queryTransferBills($order_id);
|
||||
if (isset($res['fail_reason']) && $res['fail_reason'] != '') {
|
||||
if ($type == 1) {
|
||||
$this->services->changeFail($info['id'], $info, '提现失败,原因:超时未领取');
|
||||
$this->services->update($info['id'], ['wechat_state' => 'FAIL']);
|
||||
} else {
|
||||
app()->make(LuckLotteryRecordServices::class)->update($info['id'], ['wechat_state' => 'FAIL']);
|
||||
}
|
||||
$info['wechat_state'] = 'FAIL';
|
||||
return app('json')->fail('收款失败,超时未领取');
|
||||
}
|
||||
|
||||
if ($info['wechat_state'] != 'WAIT_USER_CONFIRM') {
|
||||
return app('json')->fail('状态错误,请联系客服管理员');
|
||||
}
|
||||
$info['mchid'] = sys_config('pay_weixin_mchid');
|
||||
$info['wechat_appid'] = sys_config('wechat_appid');
|
||||
return app('json')->successful($info);
|
||||
}
|
||||
|
||||
public function cancel(Request $request, $id)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
if ($this->services->cancel((int)$id, $uid)) {
|
||||
return app('json')->successful('取消提现成功');
|
||||
} else {
|
||||
return app('json')->fail('取消失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
92
app/controller/api/v1/user/UserLevel.php
Normal file
92
app/controller/api/v1/user/UserLevel.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?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\user;
|
||||
|
||||
use app\Request;
|
||||
use app\services\user\level\UserLevelServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 会员等级类
|
||||
* Class UserLevel
|
||||
* @package app\api\controller\user
|
||||
*/
|
||||
class UserLevel
|
||||
{
|
||||
|
||||
/**
|
||||
* @var UserLevelServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserLevelServices $services;
|
||||
|
||||
/**
|
||||
* 检测用户是否可以成为会员
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function detection(Request $request)
|
||||
{
|
||||
return app('json')->successful($this->services->detection((int)$request->uid()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员等级列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function grade(Request $request)
|
||||
{
|
||||
return app('json')->successful(['list' => $this->services->grade((int)$request->uid()), 'task' => ['list' => [], 'task' => []]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员详情
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function userLevelInfo(Request $request)
|
||||
{
|
||||
return app('json')->successful($this->services->getUserLevelInfo((int)$request->uid()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 经验列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function expList(Request $request)
|
||||
{
|
||||
return app('json')->successful($this->services->expList((int)$request->uid()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员卡激活需要的信息
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function activateInfo(Request $request)
|
||||
{
|
||||
return app('json')->successful($this->services->getActivateInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员卡激活
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function activateLevel(Request $request)
|
||||
{
|
||||
$data = $request->post();
|
||||
return app('json')->successful($this->services->userActivatelevel((int)$request->uid(), $data));
|
||||
}
|
||||
|
||||
}
|
||||
142
app/controller/api/v1/user/UserRecharge.php
Normal file
142
app/controller/api/v1/user/UserRecharge.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?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\user;
|
||||
|
||||
use app\Request;
|
||||
use app\services\pay\OrderPayServices;
|
||||
use app\services\pay\PayServices;
|
||||
use app\services\pay\RechargeServices;
|
||||
use app\services\pay\YuePayServices;
|
||||
use app\services\user\UserRechargeServices;
|
||||
use crmeb\services\CacheService;
|
||||
use think\annotation\Inject;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
/**
|
||||
* 充值类
|
||||
* Class UserRecharge
|
||||
* @package app\api\controller\user
|
||||
*/
|
||||
class UserRecharge
|
||||
{
|
||||
/**
|
||||
* @var UserRechargeServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserRechargeServices $services;
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/19
|
||||
*/
|
||||
public function recharge(Request $request)
|
||||
{
|
||||
[$price, $recharId, $type, $from] = $request->postMore([
|
||||
['price', 0],
|
||||
['rechar_id', 0],
|
||||
['type', 0],
|
||||
['from', 'weixin']
|
||||
], true);
|
||||
if (!$price || $price <= 0) return app('json')->fail('充值金额不能为0元!');
|
||||
if (!in_array($type, [0, 1])) return app('json')->fail('充值方式不支持!');
|
||||
if (!in_array($from, ['weixin', 'weixinh5', 'routine'])) return app('json')->fail('充值方式不支持');
|
||||
$storeMinRecharge = sys_config('store_user_min_recharge');
|
||||
if ($price < $storeMinRecharge) return app('json')->fail('充值金额不能低于' . $storeMinRecharge);
|
||||
$uid = (int)$request->uid();
|
||||
$re = $this->services->recharge($uid, $price, $recharId, $type, $from);
|
||||
if ($re) {
|
||||
return app('json')->successful($type == 1 ? '操作成功' : '订单生成成功', ['order_id' => $re['data']['order_id'] ?? '']);
|
||||
}
|
||||
return app('json')->fail('充值订单生产失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值订单支付
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function recharge_pay(Request $request)
|
||||
{
|
||||
[$uni, $payType, $from, $quitUrl] = $request->postMore([
|
||||
['uni', ''],
|
||||
['paytype', 'weixin'],
|
||||
['from', 'weixin'],
|
||||
['quitUrl', '']
|
||||
], true);
|
||||
$info['order_id'] = $uni;
|
||||
$recharge = $this->services->getOne(['order_id' => $uni]);
|
||||
if (!$recharge) {
|
||||
throw new ValidateException('订单失效或者不存在');
|
||||
}
|
||||
if ($recharge['paid'] == 1) {
|
||||
throw new ValidateException('订单已支付');
|
||||
}
|
||||
if (($from == 'routine' ? 'routine' : $payType) != $recharge['recharge_type']) {
|
||||
$res = $this->services->update(['order_id' => $uni], ['recharge_type' => $payType]);
|
||||
if (!$res) {
|
||||
throw new ValidateException('订单支付方式修改失败');
|
||||
}
|
||||
}
|
||||
$orderInfo = $recharge->toArray();
|
||||
$order_id = $orderInfo['order_id'];
|
||||
$info = compact('order_id');
|
||||
$orderInfo['pay_price'] = $recharge['price'];
|
||||
switch ($payType) {
|
||||
case PayServices::WEIXIN_PAY:
|
||||
if ($orderInfo['paid']) return app('json')->fail('已支付!');
|
||||
/** @var OrderPayServices $payServices */
|
||||
$payServices = app()->make(OrderPayServices::class);
|
||||
$info['jsConfig'] = $payServices->orderPay($orderInfo, $from);
|
||||
if ($from == 'weixinh5') {
|
||||
return app('json')->status('wechat_h5_pay', '前往支付', $info);
|
||||
} else {
|
||||
return app('json')->status('wechat_pay', '前往支付', $info);
|
||||
}
|
||||
break;
|
||||
case PayServices::ALIPAY_PAY:
|
||||
if (!$quitUrl && ($request->isH5() || $request->isWechat())) {
|
||||
return app('json')->status('pay_error', '请传入支付宝支付回调URL', $info);
|
||||
}
|
||||
/** @var OrderPayServices $payServices */
|
||||
$payServices = app()->make(OrderPayServices::class);
|
||||
$info['jsConfig'] = $payServices->alipayOrder($orderInfo, $quitUrl, $request->isRoutine());
|
||||
$payKey = md5($orderInfo['order_id']);
|
||||
CacheService::set($payKey, ['order_id' => $orderInfo['order_id'], 'other_pay_type' => true], 300);
|
||||
$info['pay_key'] = $payKey;
|
||||
return app('json')->status(PayServices::ALIPAY_PAY . '_pay', '前往支付', $info);
|
||||
break;
|
||||
default:
|
||||
return app('json')->fail('未知支付方式');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值额度选择
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$rechargeQuota = sys_data('user_recharge_quota') ?? [];
|
||||
$data['recharge_quota'] = $rechargeQuota;
|
||||
$recharge_attention = sys_config('recharge_attention');
|
||||
$recharge_attention = explode("\n", $recharge_attention);
|
||||
$data['recharge_attention'] = $recharge_attention;
|
||||
$data['user_extract_balance_status'] = (int)sys_config('user_extract_balance_status', 1);
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
}
|
||||
155
app/controller/api/v1/user/UserSign.php
Normal file
155
app/controller/api/v1/user/UserSign.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?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\user;
|
||||
|
||||
use app\Request;
|
||||
use app\services\user\member\MemberCardServices;
|
||||
use app\services\user\UserServices;
|
||||
use app\services\user\UserSignServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 用户签到
|
||||
* Class UserSign
|
||||
* @package app\api\controller\v1\user
|
||||
*/
|
||||
class UserSign
|
||||
{
|
||||
/**
|
||||
* @var UserSignServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserSignServices $services;
|
||||
|
||||
|
||||
/**
|
||||
* 签到 配置
|
||||
* @param Request $request
|
||||
* @param UserServices $userServices
|
||||
* @return mixed
|
||||
* @throws \throwable
|
||||
*/
|
||||
public function sign_config(Request $request, UserServices $userServices)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
$signConfig = $this->services->signConfig($uid);
|
||||
//是否是付费会员
|
||||
if ($userServices->checkUserIsSvip($uid)) {
|
||||
//看是否开启签到积分翻倍奖励
|
||||
/** @var MemberCardServices $memberCardService */
|
||||
$memberCardService = app()->make(MemberCardServices::class);
|
||||
$sign_rule_number = $memberCardService->isOpenMemberCardCache('sign');
|
||||
if ($sign_rule_number) {
|
||||
foreach ($signConfig['signList'] as &$value) {
|
||||
$value['point'] = (int)$sign_rule_number * $value['point'];
|
||||
}
|
||||
$signConfig['signData']['sign_point'] = (int)$sign_rule_number * $signConfig['signData']['sign_point'];
|
||||
}
|
||||
}
|
||||
return app('json')->successful($signConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 日历数据
|
||||
* @param Request $request
|
||||
* @param UserServices $userServices
|
||||
* @return mixed
|
||||
* @throws \throwable
|
||||
*/
|
||||
public function sign_calendar(Request $request)
|
||||
{
|
||||
[$time] = $request->getMore([
|
||||
['time', '']
|
||||
], true);
|
||||
$uid = (int)$request->uid();
|
||||
$signCalendar = $this->services->getCalendarDate($uid, $time);
|
||||
return app('json')->successful($signCalendar);
|
||||
}
|
||||
|
||||
/**
|
||||
* 签到 列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function sign_list(Request $request)
|
||||
{
|
||||
[$page, $limit] = $request->getMore([
|
||||
['page', 0],
|
||||
['limit', 0]
|
||||
], true);
|
||||
if (!$limit) return app('json')->successful([]);
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful($this->services->getUserSignList($uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 签到
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function sign_integral(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
$sign = $this->services->sign($uid);
|
||||
if ($sign) {
|
||||
return app('json')->successful('签到成功', $sign);
|
||||
} else {
|
||||
return app('json')->fail('签到失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 签到用户信息
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function sign_user(Request $request)
|
||||
{
|
||||
[$sign, $integral, $all] = $request->postMore([
|
||||
['sign', 0],
|
||||
['integral', 0],
|
||||
['all', 0],
|
||||
], true);
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->success($this->services->signUser($uid, $sign, $integral, $all));
|
||||
}
|
||||
|
||||
/**
|
||||
* 签到列表(年月)
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function sign_month(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful($this->services->getSignMonthList($uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户设置签到提醒
|
||||
* @param Request $request
|
||||
* @param $status
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function sign_remind(Request $request, $status)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
$this->services->setSignRemind($uid, $status);
|
||||
return app('json')->success('设置成功');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user