chore: 添加静态资源文件和版本配置文件
添加大量图片、字体、音频等静态资源文件,包括用户界面图片、模板文件和安装界面素材 添加系统版本配置文件(.version)和常量定义文件(.constant) 更新供应商依赖文件,包括Symfony VarDumper组件和相关许可证文件 添加验证码配置文件(captcha.php)和.gitignore规则
This commit is contained in:
45
app/controller/api/v1/CityDelivery.php
Normal file
45
app/controller/api/v1/CityDelivery.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\order\StoreDeliveryOrderServices;
|
||||
use \think\facade\Log;
|
||||
|
||||
/**
|
||||
* 同城配送相关回调
|
||||
* Class CityDelivery
|
||||
* @package app\api\controller\v1
|
||||
*/
|
||||
class CityDelivery
|
||||
{
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function notify(Request $request)
|
||||
{
|
||||
try {
|
||||
$params = $request->param();
|
||||
/** @var StoreDeliveryOrderServices $storeDeliveryOrderServices */
|
||||
$storeDeliveryOrderServices = app()->make(StoreDeliveryOrderServices::class);
|
||||
$storeDeliveryOrderServices->notify($params);
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Log::info('同城配送订单回调失败:' . var_export([$e->getMessage(), $e->getFile() . ':' . $e->getLine()], true));
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
85
app/controller/api/v1/Common.php
Normal file
85
app/controller/api/v1/Common.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\controller\api\v1;
|
||||
|
||||
use crmeb\basic\BaseController;
|
||||
|
||||
/**
|
||||
* Class Common
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2022/11/8
|
||||
* @package app\controller\api\v1
|
||||
*/
|
||||
class Common extends BaseController
|
||||
{
|
||||
/**
|
||||
* 获取版权
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCopyright()
|
||||
{
|
||||
try {
|
||||
$copyright = $this->__z6uxyJQ4xYa5ee1mx5();
|
||||
} catch (\Throwable $e) {
|
||||
$copyright = [
|
||||
'copyrightContext' => '',
|
||||
'copyrightImage' => '',
|
||||
];
|
||||
}
|
||||
$copyright['record_No'] = sys_config('record_No');
|
||||
$copyright['version'] = get_crmeb_version();
|
||||
$copyright['routine_contact_type'] = sys_config('routine_contact_type');
|
||||
$copyright['site_name'] = sys_config('site_name', '');
|
||||
$copyright['site_logo'] = sys_config('wap_login_logo', '');
|
||||
$copyright['store_user_agreement'] = (int)sys_config('store_user_agreement');
|
||||
$copyright['routine_auth_type'] = sys_config('routine_auth_type', []);
|
||||
$copyright['wechat_auth_switch'] = (int)in_array(1, $copyright['routine_auth_type']);//微信登录开关
|
||||
$copyright['phone_auth_switch'] = (int)in_array(2, $copyright['routine_auth_type']);//手机号登录开关
|
||||
$copyright['wechat_status'] = sys_config('wechat_appid') && sys_config('wechat_appsecret');
|
||||
$copyright['product_category_level'] = (int)sys_config('product_category_level');//商品分类层级
|
||||
return $this->success($copyright);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录页面获取logo以及版本全新
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLogo()
|
||||
{
|
||||
try {
|
||||
$copyright = $this->__z6uxyJQ4xYa5ee1mx5();
|
||||
} catch (\Throwable $e) {
|
||||
$copyright = [
|
||||
'copyrightContext' => '',
|
||||
'copyrightImage' => '',
|
||||
];
|
||||
}
|
||||
$copyright['record_No'] = sys_config('record_No');
|
||||
$copyright['version'] = get_crmeb_version();
|
||||
$logo = sys_config('wap_login_logo');
|
||||
if (strstr($logo, 'http') === false && $logo) $logo = sys_config('site_url') . $logo;
|
||||
$copyright['site_name'] = sys_config('site_name');
|
||||
$copyright['logo_url'] = str_replace('\\', '/', $logo);
|
||||
$copyright['store_user_agreement'] = (int)sys_config('store_user_agreement');
|
||||
$copyright['routine_auth_type'] = sys_config('routine_auth_type', []);
|
||||
$copyright['wechat_auth_switch'] = (int)in_array(1, $copyright['routine_auth_type']);//微信登录开关
|
||||
$copyright['phone_auth_switch'] = (int)in_array(2, $copyright['routine_auth_type']);//手机号登录开关
|
||||
$copyright['wechat_status'] = sys_config('wechat_appid') && sys_config('wechat_appsecret');
|
||||
$copyright['product_category_level'] = (int)sys_config('product_category_level');//商品分类层级
|
||||
return app('json')->successful($copyright);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
525
app/controller/api/v1/Login.php
Normal file
525
app/controller/api/v1/Login.php
Normal file
@@ -0,0 +1,525 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\wechat\WechatServices as WechatAuthServices;
|
||||
use Psr\SimpleCache\InvalidArgumentException;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\facade\Config;
|
||||
use crmeb\services\CacheService;
|
||||
use app\services\user\LoginServices;
|
||||
use think\exception\ValidateException;
|
||||
use app\validate\api\user\RegisterValidates;
|
||||
use think\Response;
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* Class Login
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class Login
|
||||
{
|
||||
|
||||
/**
|
||||
* @var LoginServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected LoginServices $services;
|
||||
|
||||
/**
|
||||
* H5账号登陆
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws DbException
|
||||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
[$account, $password, $spread_spid] = $request->postMore([
|
||||
'account', 'password', 'spread_spid'
|
||||
], true);
|
||||
if (!$account || !$password) {
|
||||
return app('json')->fail('请输入账号和密码');
|
||||
}
|
||||
validate(\app\validate\api\LoginValidate::class)->check(['account' => $account, 'pwd' => $password]);
|
||||
|
||||
return app('json')->success('登录成功', $this->services->login($account, $password, $spread_spid));
|
||||
}
|
||||
|
||||
/**
|
||||
* apple快捷登陆
|
||||
* @param Request $request
|
||||
* @param WechatAuthServices $services
|
||||
* @return mixed
|
||||
* @throws InvalidArgumentException
|
||||
* @throws DataNotFoundException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function appleLogin(Request $request, WechatAuthServices $services)
|
||||
{
|
||||
[$openId, $phone, $email, $captcha] = $request->postMore([
|
||||
['openId', ''],
|
||||
['phone', ''],
|
||||
['email', ''],
|
||||
['captcha', '']
|
||||
], true);
|
||||
if ($phone) {
|
||||
if (!$captcha) {
|
||||
return app('json')->fail('请输入验证码');
|
||||
}
|
||||
//验证验证码
|
||||
$verifyCode = CacheService::get('code_' . $phone);
|
||||
if (!$verifyCode)
|
||||
return app('json')->fail('请先获取验证码');
|
||||
$verifyCode = substr($verifyCode, 0, 6);
|
||||
if ($verifyCode != $captcha) {
|
||||
CacheService::delete('code_' . $phone);
|
||||
return app('json')->fail('验证码错误');
|
||||
}
|
||||
} else {
|
||||
if (!$openId) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
}
|
||||
$userInfo = [
|
||||
'openId' => $openId,
|
||||
'unionid' => '',
|
||||
'avatarUrl' => sys_config('h5_avatar'),
|
||||
'nickName' => $email
|
||||
];
|
||||
if (!$userInfo['nickName']) {
|
||||
mt_srand();
|
||||
$userInfo['nickname'] = 'wx' . rand(100000, 999999);
|
||||
}
|
||||
$token = $services->appAuth($userInfo, $phone, 'apple');
|
||||
if ($token) {
|
||||
return app('json')->success('登录成功', $token);
|
||||
} else if ($token === false) {
|
||||
return app('json')->success('请绑定手机号', ['isbind' => true]);
|
||||
} else {
|
||||
return app('json')->fail('登陆失败');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
* @param Request $request
|
||||
*/
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$key = trim(ltrim($request->header(Config::get('cookie.token_name')), 'Bearer'));
|
||||
CacheService::redisHandler()->delete(md5($key));
|
||||
return app('json')->success('成功');
|
||||
}
|
||||
|
||||
public function verifyCode()
|
||||
{
|
||||
$unique = password_hash(uniqid(true), PASSWORD_BCRYPT);
|
||||
CacheService::set('sms.key.' . $unique, 0, 300);
|
||||
$time = sys_config('verify_expire_time', 1);
|
||||
return app('json')->success(['key' => $unique, 'expire_time' => $time]);
|
||||
}
|
||||
|
||||
public function captcha(Request $request)
|
||||
{
|
||||
ob_clean();
|
||||
$rep = captcha();
|
||||
$key = app('session')->get('captcha.key');
|
||||
$uni = $request->get('key');
|
||||
if ($uni)
|
||||
CacheService::set('sms.key.cap.' . $uni, $key, 300);
|
||||
|
||||
return $rep;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证验证码是否正确
|
||||
*
|
||||
* @param $uni
|
||||
* @param string $code
|
||||
* @return bool
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
protected function checkCaptcha($uni, string $code): bool
|
||||
{
|
||||
$cacheName = 'sms.key.cap.' . $uni;
|
||||
if (!CacheService::has($cacheName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$key = CacheService::get($cacheName);
|
||||
|
||||
$code = mb_strtolower($code, 'UTF-8');
|
||||
|
||||
$res = password_verify($code, $key);
|
||||
|
||||
if ($res) {
|
||||
CaCacheServiceche::delete($cacheName);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function ajcaptcha(Request $request)
|
||||
{
|
||||
$captchaType = $request->get('captchaType');
|
||||
return app('json')->success(aj_captcha_create($captchaType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 一次验证
|
||||
* @return mixed
|
||||
*/
|
||||
public function ajcheck(Request $request)
|
||||
{
|
||||
[$token, $pointJson, $captchaType] = $request->postMore([
|
||||
['token', ''],
|
||||
['pointJson', ''],
|
||||
['captchaType', ''],
|
||||
], true);
|
||||
try {
|
||||
aj_captcha_check_one($captchaType, $token, $pointJson);
|
||||
return app('json')->success();
|
||||
} catch (\Throwable $e) {
|
||||
return app('json')->fail(400336);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码发送
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function verify(Request $request)
|
||||
{
|
||||
[$phone, $type, $key, $captchaType, $captchaVerification] = $request->postMore([
|
||||
['phone', 0],
|
||||
['type', ''],
|
||||
['key', ''],
|
||||
['captchaType', ''],
|
||||
['captchaVerification', ''],
|
||||
], true);
|
||||
|
||||
$keyName = 'sms.key.' . $key;
|
||||
$nowKey = 'sms.' . date('YmdHi');
|
||||
|
||||
if (!CacheService::has($keyName))
|
||||
return app('json')->make(401, '发送验证码失败,请刷新页面重新获取');
|
||||
|
||||
|
||||
$total = 1;
|
||||
if (CacheService::has($nowKey)) {
|
||||
$total = CacheService::get($nowKey);
|
||||
if ($total > Config::get('sms.maxMinuteCount', 20))
|
||||
return app('json')->success('已发送');
|
||||
}
|
||||
|
||||
//二次验证
|
||||
// try {
|
||||
// aj_captcha_check_two($captchaType, $captchaVerification);
|
||||
// } catch (\Throwable $e) {
|
||||
// return app('json')->fail($e->getError());
|
||||
// }
|
||||
|
||||
try {
|
||||
validate(RegisterValidates::class)->scene('code')->check(['phone' => $phone]);
|
||||
} catch (ValidateException $e) {
|
||||
return app('json')->fail($e->getError());
|
||||
}
|
||||
$time = sys_config('verify_expire_time', 1);
|
||||
$smsCode = $this->services->verify($phone, $type, $time, app()->request->ip());
|
||||
if ($smsCode) {
|
||||
CacheService::set('code_' . $phone, $smsCode, $time * 60);
|
||||
CacheService::set($nowKey, $total, 61);
|
||||
event('sms.sendAfter', [$smsCode, $phone]);
|
||||
return app('json')->success('发送成功');
|
||||
} else {
|
||||
return app('json')->fail('发送失败');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* H5注册新用户
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function register(Request $request)
|
||||
{
|
||||
[$account, $captcha, $password, $spread_spid] = $request->postMore([['account', ''], ['captcha', ''], ['password', ''], ['spread_spid', 0]], true);
|
||||
try {
|
||||
validate(RegisterValidates::class)->scene('register')->check(['account' => $account, 'captcha' => $captcha, 'password' => $password]);
|
||||
} catch (ValidateException $e) {
|
||||
return app('json')->fail($e->getError());
|
||||
}
|
||||
$verifyCode = CacheService::get('code_' . $account);
|
||||
if (!$verifyCode)
|
||||
return app('json')->fail('请先获取验证码');
|
||||
$verifyCode = substr($verifyCode, 0, 6);
|
||||
if ($verifyCode != $captcha)
|
||||
return app('json')->fail('验证码错误');
|
||||
if (strlen(trim($password)) < 6 || strlen(trim($password)) > 16)
|
||||
return app('json')->fail('密码必须是在6到16位之间');
|
||||
if ($password == '123456') return app('json')->fail('密码太过简单,请输入较为复杂的密码');
|
||||
$user_type = $request->getFromType() ? $request->getFromType() : 'h5';
|
||||
$registerStatus = $this->services->register($account, $password, $spread_spid, $user_type);
|
||||
if ($registerStatus) {
|
||||
return app('json')->success('注册成功');
|
||||
}
|
||||
return app('json')->fail('注册失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 密码修改
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function reset(Request $request)
|
||||
{
|
||||
[$account, $captcha, $password] = $request->postMore([['account', ''], ['captcha', ''], ['password', '']], true);
|
||||
try {
|
||||
validate(RegisterValidates::class)->scene('register')->check(['account' => $account, 'captcha' => $captcha, 'password' => $password]);
|
||||
} catch (ValidateException $e) {
|
||||
return app('json')->fail($e->getError());
|
||||
}
|
||||
$verifyCode = CacheService::get('code_' . $account);
|
||||
if (!$verifyCode)
|
||||
return app('json')->fail('请先获取验证码');
|
||||
$verifyCode = substr($verifyCode, 0, 6);
|
||||
if ($verifyCode != $captcha) {
|
||||
return app('json')->fail('验证码错误');
|
||||
}
|
||||
if (strlen(trim($password)) < 6 || strlen(trim($password)) > 16)
|
||||
return app('json')->fail('密码必须是在6到16位之间');
|
||||
if ($password == '123456') return app('json')->fail('密码太过简单,请输入较为复杂的密码');
|
||||
$resetStatus = $this->services->reset($account, $password);
|
||||
if ($resetStatus) return app('json')->success('修改成功');
|
||||
return app('json')->fail('修改失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号登录
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function mobile(Request $request)
|
||||
{
|
||||
[$phone, $captcha, $spread_spid] = $request->postMore([['phone', ''], ['captcha', ''], ['spread_spid', 0]], true);
|
||||
|
||||
//验证手机号
|
||||
try {
|
||||
validate(RegisterValidates::class)->scene('code')->check(['phone' => $phone]);
|
||||
} catch (ValidateException $e) {
|
||||
return app('json')->fail($e->getError());
|
||||
}
|
||||
|
||||
//验证验证码
|
||||
$verifyCode = CacheService::get('code_' . $phone);
|
||||
if (!$verifyCode)
|
||||
return app('json')->fail('请先获取验证码');
|
||||
$verifyCode = substr($verifyCode, 0, 6);
|
||||
if ($verifyCode != $captcha) {
|
||||
return app('json')->fail('验证码错误');
|
||||
}
|
||||
$user_type = $request->getFromType() ? $request->getFromType() : 'h5';
|
||||
$token = $this->services->mobile($phone, $spread_spid, $user_type);
|
||||
if ($token) {
|
||||
CacheService::delete('code_' . $phone);
|
||||
return app('json')->success('登录成功', $token);
|
||||
} else {
|
||||
return app('json')->fail('登录失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* H5切换登陆
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function switch_h5(Request $request)
|
||||
{
|
||||
$from = $request->post('from', 'wechat');
|
||||
$user = $request->user();
|
||||
$token = $this->services->switchAccount($user, $from);
|
||||
if ($token) {
|
||||
$token['userInfo'] = $user;
|
||||
return app('json')->success('登录成功', $token);
|
||||
} else
|
||||
return app('json')->fail('登录失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定手机号
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function binding_phone(Request $request)
|
||||
{
|
||||
[$phone, $captcha, $key] = $request->postMore([
|
||||
['phone', ''],
|
||||
['captcha', ''],
|
||||
['key', '']
|
||||
], true);
|
||||
//验证手机号
|
||||
try {
|
||||
validate(RegisterValidates::class)->scene('code')->check(['phone' => $phone]);
|
||||
} catch (ValidateException $e) {
|
||||
return app('json')->fail($e->getError());
|
||||
}
|
||||
if (!$key) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
if (!$phone) {
|
||||
return app('json')->fail('请输入手机号');
|
||||
}
|
||||
//验证验证码
|
||||
$verifyCode = CacheService::get('code_' . $phone);
|
||||
if (!$verifyCode)
|
||||
return app('json')->fail('请先获取验证码');
|
||||
$verifyCode = substr($verifyCode, 0, 6);
|
||||
if ($verifyCode != $captcha) {
|
||||
CacheService::delete('code_' . $phone);
|
||||
return app('json')->fail('验证码错误');
|
||||
}
|
||||
$re = $this->services->bindind_phone($phone, $key);
|
||||
if ($re) {
|
||||
CacheService::delete('code_' . $phone);
|
||||
return app('json')->success('绑定成功', $re);
|
||||
} else
|
||||
return app('json')->fail('绑定失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定手机号
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function user_binding_phone(Request $request)
|
||||
{
|
||||
[$phone, $captcha, $step] = $request->postMore([
|
||||
['phone', ''],
|
||||
['captcha', ''],
|
||||
['step', 0]
|
||||
], true);
|
||||
|
||||
//验证手机号
|
||||
try {
|
||||
validate(RegisterValidates::class)->scene('code')->check(['phone' => $phone]);
|
||||
} catch (ValidateException $e) {
|
||||
return app('json')->fail($e->getError());
|
||||
}
|
||||
if (!$step) {
|
||||
//验证验证码
|
||||
$verifyCode = CacheService::get('code_' . $phone);
|
||||
if (!$verifyCode)
|
||||
return app('json')->fail('请先获取验证码');
|
||||
$verifyCode = substr($verifyCode, 0, 6);
|
||||
if ($verifyCode != $captcha)
|
||||
return app('json')->fail('验证码错误');
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
$re = $this->services->userBindindPhone($uid, $phone, $step);
|
||||
if ($re) {
|
||||
CacheService::delete('code_' . $phone);
|
||||
return app('json')->success($re['msg'] ?? '绑定成功', $re['data'] ?? []);
|
||||
} else
|
||||
return app('json')->fail('绑定失败');
|
||||
}
|
||||
|
||||
public function update_binding_phone(Request $request)
|
||||
{
|
||||
[$phone, $captcha] = $request->postMore([
|
||||
['phone', ''],
|
||||
['captcha', ''],
|
||||
], true);
|
||||
|
||||
//验证手机号
|
||||
try {
|
||||
validate(RegisterValidates::class)->scene('code')->check(['phone' => $phone]);
|
||||
} catch (ValidateException $e) {
|
||||
return app('json')->fail($e->getError());
|
||||
}
|
||||
//验证验证码
|
||||
$verifyCode = CacheService::get('code_' . $phone);
|
||||
if (!$verifyCode)
|
||||
return app('json')->fail('请先获取验证码');
|
||||
$verifyCode = substr($verifyCode, 0, 6);
|
||||
if ($verifyCode != $captcha)
|
||||
return app('json')->fail('验证码错误');
|
||||
$uid = (int)$request->uid();
|
||||
$re = $this->services->updateBindindPhone($uid, $phone);
|
||||
if ($re) {
|
||||
CacheService::delete('code_' . $phone);
|
||||
return app('json')->success($re['msg'] ?? '修改成功', $re['data'] ?? []);
|
||||
} else
|
||||
return app('json')->fail('修改失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扫描二维码状态
|
||||
* @param string $code
|
||||
* @return mixed
|
||||
*/
|
||||
public function setLoginKey(string $code)
|
||||
{
|
||||
if (!$code) {
|
||||
return app('json')->fail('登录CODE不存在');
|
||||
}
|
||||
$cacheCode = CacheService::get($code);
|
||||
if ($cacheCode === false || $cacheCode === null) {
|
||||
return app('json')->fail('二维码已过期请重新扫描');
|
||||
}
|
||||
CacheService::set($code, '0', 600);
|
||||
return app('json')->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程登录接口
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/10/26 14:48
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function remoteRegister(Request $request)
|
||||
{
|
||||
[$remote_token] = $request->getMore([
|
||||
['remote_token', ''],
|
||||
], true);
|
||||
if ($remote_token == '') return app('json')->success('登录失败', ['get_remote_login_url' => sys_config('get_remote_login_url')]);
|
||||
return app('json')->success('登录成功', $this->services->remoteRegister($remote_token));
|
||||
}
|
||||
}
|
||||
102
app/controller/api/v1/Pay.php
Normal file
102
app/controller/api/v1/Pay.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use crmeb\services\AliPayService;
|
||||
use crmeb\services\wechat\Payment;
|
||||
use EasyWeChat\Kernel\Exceptions\Exception;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
use EasyWeChat\Kernel\Exceptions\RuntimeException;
|
||||
use think\Response;
|
||||
|
||||
/**
|
||||
* 支付相关回调
|
||||
* Class Pay
|
||||
* @package app\api\controller\v1
|
||||
*/
|
||||
class Pay
|
||||
{
|
||||
|
||||
/**
|
||||
* 支付回调
|
||||
* @param string $type
|
||||
* @return string|Response
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws \ReflectionException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function notify(string $type)
|
||||
{
|
||||
switch (urldecode($type)) {
|
||||
case 'alipay':
|
||||
return AliPayService::handleNotify();
|
||||
break;
|
||||
case 'routine':
|
||||
return Payment::instance()->setAccessEnd(Payment::MINI)->handleNotify();
|
||||
break;
|
||||
case 'wechat':
|
||||
return Payment::instance()->setAccessEnd(Payment::WEB)->handleNotify();
|
||||
break;
|
||||
case 'app':
|
||||
return Payment::instance()->setAccessEnd(Payment::APP)->handleNotify();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款回调
|
||||
* @param string $type
|
||||
* @return Response
|
||||
* @throws Exception
|
||||
*/
|
||||
public function refund(string $type)
|
||||
{
|
||||
switch (urldecode($type)) {
|
||||
case 'alipay':
|
||||
|
||||
break;
|
||||
case 'routine':
|
||||
return Payment::instance()->setAccessEnd(Payment::MINI)->handleRefundedNotify();
|
||||
break;
|
||||
case 'wechat':
|
||||
return Payment::instance()->setAccessEnd(Payment::WEB)->handleRefundedNotify();
|
||||
break;
|
||||
case 'app':
|
||||
return Payment::instance()->setAccessEnd(Payment::APP)->handleRefundedNotify();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商户转账回调
|
||||
* @param string $type
|
||||
* @return Response|void
|
||||
* User: liusl
|
||||
* DateTime: 2025/2/14 下午3:06
|
||||
*/
|
||||
public function mchNotify(string $type)
|
||||
{
|
||||
switch (urldecode($type)) {
|
||||
case 'mini':
|
||||
return Payment::instance()->setAccessEnd(Payment::MINI)->handleMchNotify();
|
||||
break;
|
||||
case 'web':
|
||||
return Payment::instance()->setAccessEnd(Payment::WEB)->handleMchNotify();
|
||||
break;
|
||||
case 'app':
|
||||
return Payment::instance()->setAccessEnd(Payment::APP)->handleMchNotify();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
712
app/controller/api/v1/PublicController.php
Normal file
712
app/controller/api/v1/PublicController.php
Normal file
@@ -0,0 +1,712 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use app\services\activity\combination\StorePinkServices;
|
||||
use app\services\agent\PromoterApplyServices;
|
||||
use app\services\diy\DiyServices;
|
||||
use app\services\message\service\StoreServiceServices;
|
||||
use app\services\other\AgreementServices;
|
||||
use app\services\product\product\StoreProductWordsServices;
|
||||
use app\services\store\DeliveryServiceServices;
|
||||
use app\services\other\CacheServices;
|
||||
use app\services\product\category\StoreProductCategoryServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
use app\services\other\ExpressServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\other\SystemCityServices;
|
||||
use app\services\system\AppVersionServices;
|
||||
use app\services\system\attachment\SystemAttachmentServices;
|
||||
use app\services\system\config\SystemConfigServices;
|
||||
use app\services\store\SystemStoreServices;
|
||||
use app\services\user\channel\ChannelMerchantServices;
|
||||
use app\services\user\UserBillServices;
|
||||
use app\services\user\UserInvoiceServices;
|
||||
use app\services\user\UserServices;
|
||||
use app\services\wechat\WechatUserServices;
|
||||
use crmeb\services\SystemConfigService;
|
||||
use Joypack\Tencent\Map\Bundle\Location;
|
||||
use Joypack\Tencent\Map\Bundle\LocationOption;
|
||||
use app\Request;
|
||||
use crmeb\services\CacheService;
|
||||
use crmeb\services\UploadService;
|
||||
|
||||
/**
|
||||
* 公共类
|
||||
* Class PublicController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class PublicController
|
||||
{
|
||||
/**
|
||||
* 主页获取
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \throwable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$uid = $request->hasMacro('uid') ? (int)$request->uid() : 0;
|
||||
$banner = sys_data('routine_home_banner') ?: [];// 首页banner图
|
||||
$menus = sys_data('routine_home_menus') ?: [];// 首页按钮
|
||||
$roll = sys_data('routine_home_roll_news') ?: [];// 首页滚动新闻
|
||||
$activity = sys_data('routine_home_activity', 3) ?: [];// 首页活动区域图片
|
||||
$explosive_money = sys_data('index_categy_images') ?: [];// 首页超值爆款
|
||||
$site_name = sys_config('site_name');
|
||||
$routine_index_page = sys_data('routine_index_page');
|
||||
$info['fastInfo'] = $routine_index_page[0]['fast_info'] ?? '';// 快速选择简介
|
||||
$info['bastInfo'] = $routine_index_page[0]['bast_info'] ?? '';// 精品推荐简介
|
||||
$info['firstInfo'] = $routine_index_page[0]['first_info'] ?? '';// 首发新品简介
|
||||
$info['salesInfo'] = $routine_index_page[0]['sales_info'] ?? '';// 促销单品简介
|
||||
$logoUrl = sys_config('routine_index_logo');// 促销单品简介
|
||||
if (strstr($logoUrl, 'http') === false && $logoUrl) {
|
||||
$logoUrl = sys_config('site_url') . $logoUrl;
|
||||
}
|
||||
$logoUrl = str_replace('\\', '/', $logoUrl);
|
||||
$fastNumber = (int)sys_config('fast_number', 0);// 快速选择分类个数
|
||||
$bastNumber = (int)sys_config('bast_number', 0);// 精品推荐个数
|
||||
$firstNumber = (int)sys_config('first_number', 0);// 首发新品个数
|
||||
$promotionNumber = (int)sys_config('promotion_number', 0);// 首发新品个数
|
||||
|
||||
/** @var StoreProductCategoryServices $categoryService */
|
||||
$categoryService = app()->make(StoreProductCategoryServices::class);
|
||||
$info['fastList'] = $fastNumber ? $categoryService->byIndexList($fastNumber, 'id,cate_name,pid,pic') : [];// 快速选择分类个数
|
||||
/** @var StoreProductServices $storeProductServices */
|
||||
$storeProductServices = app()->make(StoreProductServices::class);
|
||||
$where = ['product_type' => [0, 1, 2, 3]];
|
||||
$info['bastList'] = $bastNumber ? $storeProductServices->getRecommendProduct($uid, $where + ['is_best' => 1], $bastNumber) : [];// 精品推荐个数
|
||||
$info['firstList'] = $firstNumber ? $storeProductServices->getRecommendProduct($uid, $where + ['is_new' => 1], $firstNumber) : [];// 首发新品个数
|
||||
$info['bastBanner'] = sys_data('routine_home_bast_banner') ?? [];// 首页精品推荐图片
|
||||
$benefit = $promotionNumber ? $storeProductServices->getRecommendProduct($uid, $where + ['is_benefit' => 1], $promotionNumber) : [];// 首页促销单品
|
||||
$lovely = sys_data('routine_home_new_banner') ?: [];// 首发新品顶部图
|
||||
$likeInfo = $storeProductServices->getRecommendProduct($uid, $where + ['is_hot' => 1], 3);// 热门榜单 猜你喜欢
|
||||
|
||||
if ($request->uid()) {
|
||||
/** @var WechatUserServices $wechatUserService */
|
||||
$wechatUserService = app()->make(WechatUserServices::class);
|
||||
$subscribe = (bool)$wechatUserService->value(['uid' => $request->uid()], 'subscribe');
|
||||
} else {
|
||||
$subscribe = true;
|
||||
}
|
||||
$newGoodsBananr = sys_config('new_goods_bananr');
|
||||
$tengxun_map_key = sys_config('tengxun_map_key');
|
||||
return app('json')->successful(compact('banner', 'menus', 'roll', 'info', 'activity', 'lovely', 'benefit', 'likeInfo', 'logoUrl', 'site_name', 'subscribe', 'newGoodsBananr', 'tengxun_map_key', 'explosive_money'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分享配置
|
||||
* @return mixed
|
||||
*/
|
||||
public function share()
|
||||
{
|
||||
$data['img'] = sys_config('wechat_share_img');
|
||||
if ($data['img'] && strstr($data['img'], 'http') === false) {
|
||||
$data['img'] = sys_config('site_url') . $data['img'];
|
||||
}
|
||||
$data['img'] = str_replace('\\', '/', $data['img']);
|
||||
$data['title'] = sys_config('wechat_share_title');
|
||||
$data['synopsis'] = sys_config('wechat_share_synopsis');
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取网站配置
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSiteConfig()
|
||||
{
|
||||
$data['record_No'] = sys_config('record_No');
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取个人中心菜单
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function menu_user(Request $request)
|
||||
{
|
||||
$menusInfo = sys_data('routine_my_menus') ?? [];
|
||||
$uid = 0;
|
||||
$userInfo = [];
|
||||
if ($request->hasMacro('user')) $userInfo = $request->user();
|
||||
if ($request->hasMacro('uid')) $uid = (int)$request->uid();
|
||||
|
||||
$vipOpen = sys_config('member_func_status');
|
||||
$brokerageFuncStatus = sys_config('brokerage_func_status');
|
||||
$brokerageType = sys_config('brokerage_page_type');
|
||||
$storeBrokerageApply = sys_config('store_brokerage_apply');
|
||||
$balanceFuncStatus = sys_config('balance_func_status');
|
||||
$vipCard = sys_config('member_card_status', 0);
|
||||
$svipOpen = (bool)sys_config('member_card_status');
|
||||
$isDivisionOpen = (bool)sys_config('division_open');
|
||||
$isDivisionApplyOpen = (bool)sys_config('division_apply_open');
|
||||
$userService = $invoiceStatus = $deliveryUser = $isUserPromoter = $userVerifyStatus = $userOrder = $isStaff = $isDelivery = $isChannel = $isPromoterApply = true;
|
||||
$levelStatus = true;
|
||||
$userDivisionStatus = false;
|
||||
if ($uid && $userInfo) {
|
||||
/** @var StoreServiceServices $storeService */
|
||||
$storeService = app()->make(StoreServiceServices::class);
|
||||
$userService = $storeService->checkoutIsService(['uid' => $uid, 'status' => 1, 'account_status' => 1]);
|
||||
$userOrder = $storeService->checkoutIsService(['uid' => $uid, 'account_status' => 1, 'customer' => 1]);
|
||||
/** @var UserServices $user */
|
||||
$user = app()->make(UserServices::class);
|
||||
/** @var UserInvoiceServices $userInvoice */
|
||||
$userInvoice = app()->make(UserInvoiceServices::class);
|
||||
$invoiceStatus = $userInvoice->invoiceFuncStatus(false);
|
||||
/** @var DeliveryServiceServices $deliveryService */
|
||||
$deliveryService = app()->make(DeliveryServiceServices::class);
|
||||
$deliveryUser = $deliveryService->checkoutIsService($uid);
|
||||
$isUserPromoter = $user->checkUserPromoter($uid, $userInfo);
|
||||
try {
|
||||
$isDelivery = $deliveryService->getDeliveryInfoByUid($uid);
|
||||
} catch (\Throwable $e) {
|
||||
$isDelivery = false;
|
||||
}
|
||||
$levelStatus = (bool)($userInfo['level_status'] ?? 1);
|
||||
if ($userInfo['division_type'] > 0) {
|
||||
$userDivisionStatus = $userInfo['division_status'] == 1 && $userInfo['division_end_time'] > time();
|
||||
} else {
|
||||
$userDivisionStatus = true;
|
||||
}
|
||||
$isChannel = app()->make(ChannelMerchantServices::class)->isChannel($uid);
|
||||
$isPromoterApply = app()->make(PromoterApplyServices::class)->count(['uid' => $uid, 'status' => 1, 'is_del' => 0]);
|
||||
}
|
||||
$auth = [];
|
||||
$auth['/pages/users/user_vip/index'] = !$vipOpen;
|
||||
$auth['/pages/merchant/apply/index'] = $isChannel;
|
||||
$auth['/pages/users/user_spread_user/index'] = !$brokerageFuncStatus || $uid == 0 || !$userDivisionStatus;
|
||||
$auth['/pages/users/agent/apply'] = !$brokerageFuncStatus || !$isUserPromoter || $uid == 0 || !$isDivisionOpen || !$isDivisionApplyOpen || !$userInfo['division_type'] == 0;
|
||||
$auth['/pages/users/distributor/apply'] = !$brokerageFuncStatus || $isUserPromoter || $uid == 0 || !$storeBrokerageApply || $isPromoterApply;
|
||||
$auth['/pages/users/user_money/index'] = !$balanceFuncStatus;
|
||||
$auth['/pages/admin/order/index'] = true;
|
||||
$auth['/pages/admin/order_cancellation/index'] = (!$userService && !$deliveryUser) || $uid == 0;
|
||||
$auth['/pages/users/user_invoice_list/index'] = !$invoiceStatus;
|
||||
$auth['/pages/annex/vip_paid/index'] = !$vipCard || !$svipOpen;
|
||||
$auth['/kefu/mobile_list'] = !$userService || $uid == 0;
|
||||
$auth['/pages/admin/distribution/index'] = $uid == 0 || !$isDelivery;
|
||||
$auth['/pages/store_spread/index'] = true;
|
||||
$auth['/pages/admin/store/index'] = true;
|
||||
$auth['/pages/admin/work/index'] = !$userOrder || $uid == 0;
|
||||
foreach ($menusInfo as $key => &$value) {
|
||||
$value['pic'] = set_file_url($value['pic'] ?? '');
|
||||
$value['url'] = $value['url'] ?? '';
|
||||
if (isset($auth[$value['url']]) && $auth[$value['url']]) {
|
||||
unset($menusInfo[$key]);
|
||||
continue;
|
||||
}
|
||||
if ($value['url'] == '/kefu/mobile_list') {
|
||||
$value['url'] = sys_config('site_url') . $value['url'];
|
||||
if ($request->isRoutine()) {
|
||||
$value['url'] = str_replace('http://', 'https://', $value['url']);
|
||||
}
|
||||
}
|
||||
//用户等级 未激活地址改为激活页面
|
||||
if ($value['url'] == '/pages/users/user_vip/index' && sys_config('level_activate_status') && !$levelStatus) {
|
||||
$value['url'] = '/pages/annex/vip_grade_active/index';
|
||||
}
|
||||
|
||||
if ($value['url'] == '/pages/users/user_spread_user/index') {
|
||||
if ($brokerageType == 2) {
|
||||
$value['url'] = '/pages/users/spreadData/index';
|
||||
}
|
||||
if ($userInfo['division_type'] == 1 && $isDivisionOpen) {
|
||||
$value['name'] = '区域代理';
|
||||
if (!$userDivisionStatus) unset($menusInfo[$key]);
|
||||
} elseif ($userInfo['division_type'] == 2 && $isDivisionOpen) {
|
||||
$value['name'] = '代理商';
|
||||
if (!$userDivisionStatus) unset($menusInfo[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
/** @var SystemConfigServices $systemConfigServices */
|
||||
$systemConfigServices = app()->make(SystemConfigServices::class);
|
||||
$bannerInfo = $systemConfigServices->getSpreadBanner() ?? [];
|
||||
$my_banner = sys_data('routine_my_banner');
|
||||
$routine_contact_type = sys_config('routine_contact_type', 0);
|
||||
/** @var DiyServices $diyServices */
|
||||
$diyServices = app()->make(DiyServices::class);
|
||||
$member = $diyServices->cacheRemember('diy_data_member_4', function () use ($diyServices) {
|
||||
$member = $diyServices->get(['template_name' => 'member', 'type' => 3], ['value', 'status']);
|
||||
$member = $member ? $member->toArray() : [];
|
||||
return $member;
|
||||
});
|
||||
if ($member) {
|
||||
$diy_data = json_decode($member['value'], true);
|
||||
$diy_data = $diy_data ?: $diyServices->member;
|
||||
} else {
|
||||
$diy_data = $diyServices->member;
|
||||
}
|
||||
if (isset($diy_data['merMenu']['list']) && $diy_data['merMenu']['list']) {
|
||||
foreach ($diy_data['merMenu']['list'] as $key => &$item) {
|
||||
if (isset($auth[$item['url']]) && $auth[$item['url']]) {
|
||||
unset($diy_data['merMenu']['list'][$key]);
|
||||
continue;
|
||||
}
|
||||
if ($item['url'] == '/kefu/mobile_list') {
|
||||
$item['url'] = sys_config('site_url') . $item['url'];
|
||||
if ($request->isRoutine()) {
|
||||
$item['url'] = str_replace('http://', 'https://', $item['url']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($diy_data['menu']['list']) && $diy_data['menu']['list']) {
|
||||
foreach ($diy_data['menu']['list'] as $key => &$item) {
|
||||
if (isset($auth[$item['url']]) && $auth[$item['url']]) {
|
||||
unset($diy_data['menu']['list'][$key]);
|
||||
continue;
|
||||
}
|
||||
//用户等级 未激活地址改为激活页面
|
||||
if ($item['url'] == '/pages/users/user_vip/index' && sys_config('level_activate_status') && !$levelStatus) {
|
||||
$item['url'] = '/pages/annex/vip_grade_active/index';
|
||||
}
|
||||
if ($item['url'] == '/pages/users/user_spread_user/index') {
|
||||
if ($brokerageType == 2) {
|
||||
$item['url'] = '/pages/users/spreadData/index';
|
||||
}
|
||||
if ($userInfo['division_type'] == 1 && $isDivisionOpen) {
|
||||
$item['name'] = '区域代理';
|
||||
if (!$userDivisionStatus) unset($diy_data['menu']['list'][$key]);
|
||||
} elseif ($userInfo['division_type'] == 2 && $isDivisionOpen) {
|
||||
$item['name'] = '代理商';
|
||||
if (!$userDivisionStatus) unset($diy_data['menu']['list'][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return app('json')->successful(['routine_my_menus' => array_merge($menusInfo), 'routine_my_banner' => $my_banner, 'routine_spread_banner' => $bannerInfo, 'routine_contact_type' => $routine_contact_type, 'diy_data' => $diy_data]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人中心数据
|
||||
* @param Request $request
|
||||
* @param UserServices $services
|
||||
* @param StoreOrderServices $orderServices
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function menu_user_data(Request $request, UserServices $services, StoreOrderServices $orderServices)
|
||||
{
|
||||
$uid = 0;
|
||||
$userInfo = [];
|
||||
$commission = [];
|
||||
$order = [];
|
||||
$not_pay_order = [];
|
||||
if ($request->hasMacro('user')) $userInfo = $request->user();
|
||||
if ($request->hasMacro('uid')) $uid = $request->uid();
|
||||
if (!$uid && !$userInfo) return app('json')->successful(['commission' => $commission, 'order' => $order, 'not_pay_order' => $not_pay_order]);
|
||||
if ($userInfo['is_promoter']) {
|
||||
$commission['brokerage_price'] = $userInfo['brokerage_price'];
|
||||
$uids = $services->getColumn(['spread_uid' => $uid], 'uid');
|
||||
$commission['number'] = count($uids);
|
||||
$commission['order_num'] = $orderServices->getCount([['uid', 'in', $uids], ['pid', '=', 0], ['paid', '=', 1], ['is_del', '=', 0]]);
|
||||
}
|
||||
/** @var StoreServiceServices $storeService */
|
||||
$storeService = app()->make(StoreServiceServices::class);
|
||||
$userOrder = $storeService->checkoutIsService(['uid' => $uid, 'account_status' => 1, 'status' => 1, 'customer' => 1]);
|
||||
$order['user_order'] = $userOrder;
|
||||
if ($userOrder) {
|
||||
$where = ['pid' => [0, -1], 'paid' => 1, 'is_del' => 0, 'is_system_del' => 0, 'refund_status' => [0, 3]];
|
||||
$order['price'] = $orderServices->together($where, 'pay_price', 'sum');
|
||||
$order['num'] = $orderServices->count($where);
|
||||
$default_where = [
|
||||
'pid' => [0, -1],
|
||||
'status' => 1,
|
||||
'is_system_del' => 0
|
||||
];
|
||||
$order['consignment'] = $orderServices->count($default_where);
|
||||
}
|
||||
$not_pay_order = $orderServices->getUserNotPayOrder($uid);
|
||||
|
||||
return app('json')->successful(['commission' => $commission, 'order' => $order, 'not_pay_order' => $not_pay_order]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索热词:用户搜索记录
|
||||
* @param StoreProductWordsServices $wordsServices
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function hotKeywords(StoreProductWordsServices $wordsServices)
|
||||
{
|
||||
[$page, $limit] = $wordsServices->getPageValue();
|
||||
return app('json')->success($wordsServices->getList(['is_show' => 1, 'is_del' => 0], 'id,name,color,bg_color,border_color,icon', $page, $limit));
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索关键字关联
|
||||
* @param Request $request
|
||||
* @param StoreProductServices $services
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function searchWords(Request $request, StoreProductServices $services)
|
||||
{
|
||||
[$keyword] = $request->getMore([
|
||||
[['keyword', 's'], ''],
|
||||
], true);
|
||||
$list = [];
|
||||
if (!empty($keyword) && $keyword !== '%') {
|
||||
$where = ['is_vip_product' => 0, 'is_verify' => 1, 'pid' => 0, 'is_show' => 1, 'is_del' => 0, 'store_name' => $keyword, 'field_key' => 'store_name'];
|
||||
$list = $services->getSearchList($where, 0, 10, ['id', 'store_name'], 'sort desc,sales desc,id desc', []);
|
||||
}
|
||||
return app('json')->success(compact('keyword', 'list'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 图片上传
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function uploadImage(Request $request, SystemAttachmentServices $services)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['filename', 'file'],
|
||||
]);
|
||||
if (!$data['filename']) return app('json')->fail('参数有误');
|
||||
$uid = (int)$request->uid();
|
||||
if (CacheService::has('start_uploads_' . $uid) && CacheService::get('start_uploads_' . $uid) >= 100) return app('json')->fail('非法操作');
|
||||
$upload = UploadService::init();
|
||||
$info = $upload->to('store/comment')->validate()->move($data['filename']);
|
||||
if ($info === false) {
|
||||
return app('json')->fail($upload->getError());
|
||||
}
|
||||
$res = $upload->getUploadInfo();
|
||||
$services->attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'], 1, (int)sys_config('upload_type', 1), $res['time'], 3);
|
||||
if (CacheService::has('start_uploads_' . $uid))
|
||||
$start_uploads = (int)CacheService::get('start_uploads_' . $uid);
|
||||
else
|
||||
$start_uploads = 0;
|
||||
$start_uploads++;
|
||||
CacheService::set('start_uploads_' . $uid, $start_uploads, 86400);
|
||||
$res['dir'] = path_to_url($res['dir']);
|
||||
if (strpos($res['dir'], 'http') === false) $res['dir'] = sys_config('site_url') . $res['dir'];
|
||||
return app('json')->successful('图片上传成功!', ['name' => $res['name'], 'url' => $res['dir']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传视频
|
||||
* @param Request $request
|
||||
* @param SystemAttachmentServices $services
|
||||
* @return \think\Response
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* User: liusl
|
||||
* DateTime: 2024/8/8 09:49
|
||||
*/
|
||||
public function uploadVideo(Request $request, SystemAttachmentServices $services)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['filename', 'file'],
|
||||
]);
|
||||
if (!$data['filename']) return app('json')->fail('参数有误');
|
||||
$uid = (int)$request->uid();
|
||||
if (CacheService::has('start_uploads_' . $uid) && CacheService::get('start_uploads_' . $uid) >= 100) return app('json')->fail('非法操作');
|
||||
$upload = UploadService::init();
|
||||
$info = $upload->to('store/video')->validate()->move($data['filename']);
|
||||
if ($info === false) {
|
||||
return app('json')->fail($upload->getError());
|
||||
}
|
||||
$res = $upload->getUploadInfo();
|
||||
$services->attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'], 1, (int)sys_config('upload_type', 1), $res['time'], 3, 2);
|
||||
if (CacheService::has('start_uploads_' . $uid))
|
||||
$start_uploads = (int)CacheService::get('start_uploads_' . $uid);
|
||||
else
|
||||
$start_uploads = 0;
|
||||
$start_uploads++;
|
||||
CacheService::set('start_uploads_' . $uid, $start_uploads, 86400);
|
||||
$res['dir'] = path_to_url($res['dir']);
|
||||
if (strpos($res['dir'], 'http') === false) $res['dir'] = sys_config('site_url') . $res['dir'];
|
||||
return app('json')->successful('视频上传成功!', ['name' => $res['name'], 'url' => $res['dir']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 物流公司
|
||||
* @return mixed
|
||||
*/
|
||||
public function logistics(Request $request, ExpressServices $services)
|
||||
{
|
||||
[$status] = $request->getMore([
|
||||
['status', ''],
|
||||
], true);
|
||||
if ($status == 1) $data['status'] = $status;
|
||||
$data['is_show'] = 1;
|
||||
$expressList = $services->expressList($data);
|
||||
return app('json')->successful($expressList ?? []);
|
||||
}
|
||||
|
||||
/**
|
||||
* 反向解析地址
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function geoLbscoder(Request $request)
|
||||
{
|
||||
[$data] = $request->getMore([
|
||||
['location', '']
|
||||
], true);
|
||||
$locationOption = new LocationOption(sys_config('tengxun_map_key'));
|
||||
$data = explode(',', $data);
|
||||
$locationOption->setLocation($data[0] ?? '', $data[1] ?? '');
|
||||
$location = new Location($locationOption);
|
||||
$res = $location->request();
|
||||
if ($res->error) {
|
||||
return app('json')->fail($res->error);
|
||||
}
|
||||
if ($res->status) {
|
||||
return app('json')->fail($res->message);
|
||||
}
|
||||
if (!$res->result) {
|
||||
return app('json')->fail('获取失败');
|
||||
}
|
||||
return app('json')->success($res->result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录用户分享
|
||||
* @param Request $request
|
||||
* @param UserBillServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
public function user_share(Request $request, UserBillServices $services)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful($services->setUserShare($uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图片base64
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_image_base64(Request $request)
|
||||
{
|
||||
[$imageUrl, $codeUrl] = $request->postMore([
|
||||
['image', ''],
|
||||
['code', ''],
|
||||
], true);
|
||||
if ($imageUrl !== '' && !(preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $imageUrl) || strpos($imageUrl, 'https://mp.weixin.qq.com/cgi-bin/showqrcode') !== false || strpos($imageUrl, 'https://thirdwx.qlogo.cn/mmopen') !== false)) {
|
||||
return app('json')->success(['code' => false, 'image' => false]);
|
||||
}
|
||||
if ($codeUrl !== '' && !(preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $codeUrl) || strpos($codeUrl, 'https://mp.weixin.qq.com/cgi-bin/showqrcode') !== false || strpos($imageUrl, 'https://thirdwx.qlogo.cn/mmopen') !== false)) {
|
||||
return app('json')->success(['code' => false, 'image' => false]);
|
||||
}
|
||||
$imageUrlHost = $imageUrl ? (parse_url($imageUrl)['host'] ?? $imageUrl) : $imageUrl;
|
||||
$codeUrlHost = $codeUrl ? (parse_url($codeUrl)['host'] ?? $codeUrl) : $codeUrl;
|
||||
|
||||
/** @var SystemStorageServices $systemStorageServices */
|
||||
$systemStorageServices = app()->make(SystemStorageServices::class);
|
||||
$domainArr = $systemStorageServices->getColumn([], 'domain');
|
||||
$domainArr = array_merge($domainArr, [$request->host()]);
|
||||
$domainArr = array_unique(array_diff($domainArr, ['']));
|
||||
if (count($domainArr)) {
|
||||
$domainArr = array_map(function ($item) {
|
||||
return str_replace(['https://', 'http://'], '', $item);
|
||||
}, $domainArr);
|
||||
}
|
||||
if ($domainArr && (($imageUrlHost && !in_array($imageUrlHost, $domainArr)) || ($codeUrlHost && !in_array($codeUrlHost, $domainArr)))) {
|
||||
return app('json')->success(['code' => false, 'image' => false]);
|
||||
}
|
||||
try {
|
||||
$code = CacheService::get($codeUrl, function () use ($codeUrl) {
|
||||
$codeTmp = $code = $codeUrl ? image_to_base64($codeUrl) : false;
|
||||
if (!$codeTmp) {
|
||||
$codeUrl = explode('?', $codeUrl)[0] ?? $codeUrl;
|
||||
$putCodeUrl = put_image($codeUrl);
|
||||
$code = $putCodeUrl ? image_to_base64(public_path() . $putCodeUrl) : false;
|
||||
$code ?? unlink(public_path() . $putCodeUrl);
|
||||
}
|
||||
return $code;
|
||||
});
|
||||
$image = CacheService::get($imageUrl, function () use ($imageUrl) {
|
||||
$imageTmp = $image = $imageUrl ? image_to_base64($imageUrl) : false;
|
||||
if (!$imageTmp) {
|
||||
$imageUrl = explode('?', $imageUrl)[0] ?? $imageUrl;
|
||||
$putImageUrl = put_image($imageUrl);
|
||||
$image = $putImageUrl ? image_to_base64(public_path() . $putImageUrl) : false;
|
||||
$image ?? unlink(public_path() . $putImageUrl);
|
||||
}
|
||||
return $image;
|
||||
});
|
||||
return app('json')->successful(compact('code', 'image'));
|
||||
} catch (\Exception $e) {
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店列表
|
||||
* @param Request $request
|
||||
* @param SystemStoreServices $services
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function store_list(Request $request, SystemStoreServices $services)
|
||||
{
|
||||
[$latitude, $longitude, $product_id, $is_store] = $request->getMore([
|
||||
['latitude', ''],
|
||||
['longitude', ''],
|
||||
['product_id', 0],
|
||||
['is_store', 1] //前端传值为 1|商城配送 2|门店自提 3|门店配送
|
||||
], true);
|
||||
if (!checkCoordinates($longitude, $latitude)) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
//判断是否门店自提
|
||||
$is_store == 2 ? $is_store = 1 : $is_store = '';
|
||||
$where = ['type' => 0, 'is_store' => $is_store];
|
||||
$data['list'] = $services->getStoreList($where, ['*'], $latitude, $longitude, (int)$product_id);
|
||||
$data['tengxun_map_key'] = sys_config('tengxun_map_key');
|
||||
$data['site_logo'] = sys_config('site_logo');
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找城市数据
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function city_list(Request $request)
|
||||
{
|
||||
/** @var SystemCityServices $systemCity */
|
||||
$systemCity = app()->make(SystemCityServices::class);
|
||||
return app('json')->successful($systemCity->cityList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 复制口令接口
|
||||
* @return mixed
|
||||
*/
|
||||
public function copy_words()
|
||||
{
|
||||
$data['words'] = sys_config('copy_words');
|
||||
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
|
||||
*/
|
||||
public function copy_share_words(Request $request)
|
||||
{
|
||||
[$productId] = $request->getMore([
|
||||
['product_id', ''],
|
||||
], true);
|
||||
/** @var StoreProductServices $productService */
|
||||
$productService = app()->make(StoreProductServices::class);
|
||||
$keyWords['key_words'] = $productService->getProductWords($productId);
|
||||
return app('json')->successful($keyWords);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户协议内容
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUserAgreement(Request $request, $type = 1)
|
||||
{
|
||||
/** @var CacheServices $cache */
|
||||
$cache = app()->make(CacheServices::class);
|
||||
/** @var UserServices $userService */
|
||||
$userService = app()->make(UserServices::class);
|
||||
$content = $cache->getDbCache($type, '');
|
||||
$uid = $request->uid() ?? 0;
|
||||
$userInfo = $userService->getUserCacheInfo($uid);
|
||||
$name = $userInfo['nickname'] ?? '';
|
||||
$avatar = $userInfo['avatar'] ?? '';
|
||||
return app('json')->success(compact('content', 'uid', 'name', 'avatar'));
|
||||
}
|
||||
|
||||
public function getAgreement(Request $request, $type = 1)
|
||||
{
|
||||
/** @var AgreementServices $agreementService */
|
||||
$agreementService = app()->make(AgreementServices::class);
|
||||
$member_explain = $agreementService->getAgreementBytype($type);
|
||||
return app('json')->success(compact('member_explain'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计代码
|
||||
* @return array|string
|
||||
*/
|
||||
public function getScript()
|
||||
{
|
||||
return sys_config('system_statistics', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页开屏广告
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOpenAdv()
|
||||
{
|
||||
/** @var CacheServices $cache */
|
||||
$cache = app()->make(CacheServices::class);
|
||||
$data = $cache->getDbCache('open_adv', '');
|
||||
$data['time'] = (float)($data['time'] ?? 3);
|
||||
$data['interval_time'] = (float)($data['interval_time'] ?? 24);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
public function getVersion()
|
||||
{
|
||||
$version = parse_ini_file(app()->getRootPath() . '.version');
|
||||
return app('json')->success(['version' => $version['version'], 'version_code' => $version['version_code']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统配置信息
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2025/4/15 上午10:39
|
||||
*/
|
||||
public function getConfig(DiyServices $services)
|
||||
{
|
||||
$data = SystemConfigService::more([
|
||||
'system_channel_style',
|
||||
'product_video_status',
|
||||
'store_brokerage_statu',
|
||||
'store_brokerage_price',
|
||||
'brokerage_func_status',
|
||||
'brokerage_apply_phone_verify',
|
||||
'brokerage_apply_explain',
|
||||
'division_apply_phone_verify',
|
||||
'division_apply_explain',
|
||||
'channel_apply_phone_verify',
|
||||
'channel_apply_explain',
|
||||
'supplier_apply_phone_verify',
|
||||
'supplier_apply_explain',
|
||||
'channel_func_status',
|
||||
]);
|
||||
$data['product_detail'] = $services->getProductDetailDiy();
|
||||
$data['product_category'] = $services->getProductCategoryDiy();
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
public function getNewAppVersion($platform)
|
||||
{
|
||||
/** @var AppVersionServices $appService */
|
||||
$appService = app()->make(AppVersionServices::class);
|
||||
return app('json')->success($appService->getNewInfo($platform));
|
||||
}
|
||||
}
|
||||
55
app/controller/api/v1/activity/CardGift.php
Normal file
55
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
app/controller/api/v1/activity/HolidayGift.php
Normal file
116
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
app/controller/api/v1/activity/StoreBargain.php
Normal file
326
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
app/controller/api/v1/activity/StoreCombination.php
Normal file
180
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
app/controller/api/v1/activity/StoreCoupons.php
Normal file
120
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
app/controller/api/v1/activity/StoreDiscounts.php
Normal file
37
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
app/controller/api/v1/activity/StoreIntegral.php
Normal file
99
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());
|
||||
}
|
||||
|
||||
}
|
||||
86
app/controller/api/v1/activity/StoreIntegralOrder.php
Normal file
86
app/controller/api/v1/activity/StoreIntegralOrder.php
Normal file
@@ -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
app/controller/api/v1/activity/StoreNewcomer.php
Normal file
196
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
app/controller/api/v1/activity/StoreSeckill.php
Normal file
179
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
app/controller/api/v1/activity/Video.php
Normal file
244
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('撤销成功');
|
||||
}
|
||||
|
||||
}
|
||||
381
app/controller/api/v1/community/Community.php
Normal file
381
app/controller/api/v1/community/Community.php
Normal file
@@ -0,0 +1,381 @@
|
||||
<?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\community;
|
||||
|
||||
|
||||
use app\services\community\CommunityCacheServices;
|
||||
use app\services\community\CommunityRecordServices;
|
||||
use app\services\community\CommunityServices;
|
||||
use app\Request;
|
||||
use app\services\community\CommunityTopicServices;
|
||||
use app\services\product\product\StoreProductLogServices;
|
||||
use app\services\user\UserRelationServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
|
||||
/**
|
||||
* Class StoreController
|
||||
* @package app\api\controller\v1\store
|
||||
*/
|
||||
class Community
|
||||
{
|
||||
|
||||
/**
|
||||
* @var CommunityServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected CommunityServices $services;
|
||||
|
||||
/**
|
||||
* 获取社区配置
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/8/5 11:55
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$data = [
|
||||
'community_status' => (int)sys_config('community_status', 1),//社区功能
|
||||
'community_comment_status' => (int)sys_config('community_comment_status', 1),//社区评论功能
|
||||
'community_comment_add' => (int)sys_config('community_comment_add', 1),//社区评论新增功能
|
||||
'community_exp_num' => sys_config('community_exp', 1) ? sys_config('community_exp_num') : 0,//社区经验
|
||||
'community_integral_num' => sys_config('community_integral', 1) ? sys_config('community_integral_num') : 0,//社区积分
|
||||
];
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帖子列表
|
||||
*
|
||||
* 本函数通过接收各种筛选条件来获取帖子列表。筛选条件包括话题、关键词、是否关注、
|
||||
* 作者ID、内容类型、开始ID、特定ID列表以及排序方式。排序方式可选最新或最热。
|
||||
* 如果用户未登录或指定的作者ID与登录用户不符,则只返回已发布且已验证的帖子。
|
||||
* 如果用户登录且关注条件被激活,则用登录用户ID作为关注者筛选条件。
|
||||
*
|
||||
* @param Request $request 包含筛选条件的请求对象
|
||||
* @return mixed 返回帖子列表的JSON响应
|
||||
*/
|
||||
public function list(Request $request)
|
||||
{
|
||||
$where = $request->postMore([
|
||||
['topic_id', ''],//话题
|
||||
['keyword', ''],//关键词
|
||||
['is_follow', ''],//是否关注
|
||||
['relation_id', ''],//作者 id
|
||||
['content_type', ''],//内容类型:1:图文2:视频
|
||||
['start_id', ''],//从哪个id开始
|
||||
['ids', ''],//
|
||||
['order', 2],//1最新2最热
|
||||
]);
|
||||
$where['topic_id'] = stringToIntArray($where['topic_id']);
|
||||
$order = $where['order'] == 2 ? 'star desc,add_time desc' : 'add_time desc';
|
||||
unset($where['order']);
|
||||
$where['is_del'] = 0;
|
||||
$uid = $request->uid();
|
||||
// 如果未指定作者ID或指定的作者ID与当前用户不符,则只返回已发布且已验证的帖子
|
||||
if (!$where['relation_id'] || $uid != $where['relation_id']) {
|
||||
$where['status'] = 1;
|
||||
$where['is_verify'] = 1;
|
||||
}
|
||||
//我的关注
|
||||
if ($where['is_follow']) {
|
||||
if (!$uid) {
|
||||
return app('json')->success([]);
|
||||
}
|
||||
$where['is_follow'] = $uid;
|
||||
}
|
||||
|
||||
if ($where['ids']) {
|
||||
$where['id'] = explode(',', $where['ids']);
|
||||
}
|
||||
unset($where['ids']);
|
||||
return app('json')->success($this->services->getApiList($where, $uid, $order));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取话题
|
||||
* @param CommunityTopicServices $services
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* User: liusl
|
||||
* DateTime: 2024/8/5 12:13
|
||||
*/
|
||||
public function getTopic(CommunityTopicServices $services, Request $request)
|
||||
{
|
||||
$where = $request->postMore([
|
||||
['name', ''],//话题名称
|
||||
['is_recommend', ''],//话题推荐
|
||||
['is_community', ''],//是否查帖子条数
|
||||
]);
|
||||
$where['status'] = 1;
|
||||
return app('json')->success($services->getAllTopic($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户商品列表
|
||||
* @param Request $request
|
||||
* @param StoreProductLogServices $services
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* User: liusl
|
||||
* DateTime: 2024/8/6 09:51
|
||||
*/
|
||||
public function getProductList(Request $request, StoreProductLogServices $services, UserRelationServices $userRelationServices)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['type', 'pay'],//已购pay,收藏collect,浏览visit
|
||||
['keyword', ''],
|
||||
]);
|
||||
$uid = $request->uid();
|
||||
$where['uid'] = $uid;
|
||||
if ($where['type'] == 'collect') {
|
||||
$list = $userRelationServices->getUserRelationList($uid, 'product', 'collect');
|
||||
} else {
|
||||
$list = $services->getProduct($where);
|
||||
}
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增编辑社区内容
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/8/7 14:53
|
||||
*/
|
||||
public function communitySave(Request $request)
|
||||
{
|
||||
$data = $this->checkParams($request);
|
||||
$data['relation_id'] = $request->uid();
|
||||
$this->services->saveData($data);
|
||||
return app('json')->success('添加社区内容成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/8/8 10:03
|
||||
*/
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
$data = $this->checkParams($request);
|
||||
if (!$this->services->get($id)) {
|
||||
return app('json')->fail('社区内容不存在');
|
||||
}
|
||||
$this->services->saveData($data, $id);
|
||||
return app('json')->success('提交成功');
|
||||
}
|
||||
|
||||
/**
|
||||
*获取数据
|
||||
* @param Request $request
|
||||
* @return array|\think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/8/8 10:04
|
||||
*/
|
||||
public function checkParams(Request $request)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['content_type', 1],//内容类型1:图文2视频
|
||||
['title', ''],//标题
|
||||
['content', ''],//内容
|
||||
['image', ''],//封面
|
||||
['video_url', ''],//视频地址
|
||||
['slider_image', []],//图集
|
||||
['topic_id', []],//关联话题
|
||||
['topic_name', []],//关联话题
|
||||
['product_id', []],//关联商品
|
||||
]);
|
||||
if ($data['content_type'] == 1) {
|
||||
$data['image'] = $data['slider_image'][0] ?? '';
|
||||
}
|
||||
$data['slider_image'] = json_encode($data['slider_image']);
|
||||
|
||||
//图文视频审核状态
|
||||
if ($data['content_type'] == 1) {
|
||||
$data['is_verify'] = sys_config('community_verify', 1) ? 0 : 1;
|
||||
} else {
|
||||
$data['is_verify'] = sys_config('community_video_verify', 1) ? 0 : 1;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/8/9 11:28
|
||||
*/
|
||||
public function detail($id, Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->success($this->services->getDetail($id, $uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 点赞取消
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/8/13 11:31
|
||||
*/
|
||||
public function setCommunityLike($id, Request $request)
|
||||
{
|
||||
[$status] = $request->postMore([
|
||||
['status', 1]
|
||||
], true);
|
||||
|
||||
$status = $status == 1 ? 1 : 0;
|
||||
$info = $this->services->get($id);
|
||||
if (!$info || $info['is_del'] == 1 || $info['is_verify'] != 1 || $info['status'] != 1)
|
||||
return app('json')->fail('内容不存在');
|
||||
$info = $info->toArray();
|
||||
$uid = (int)$request->uid();
|
||||
$this->services->setCommunityLike($info, $uid, $status);
|
||||
if ($status) {
|
||||
return app('json')->success('点赞成功');
|
||||
} else {
|
||||
return app('json')->success('取消点赞');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 点赞列表
|
||||
* @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/8/24 17:06
|
||||
*/
|
||||
public function communityLikeList(Request $request)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['keyword', '']
|
||||
]);
|
||||
$where['uid'] = (int)$request->uid();
|
||||
return app('json')->success($this->services->getJoinCommunityList($where, $where['uid']));
|
||||
}
|
||||
|
||||
/**
|
||||
* 种草秀
|
||||
* @return void
|
||||
* User: liusl
|
||||
* DateTime: 2024/8/26 16:03
|
||||
*/
|
||||
public function communityElegantList(Request $request)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['product_id', ''],
|
||||
['order', 2],//1最新2最热
|
||||
]);
|
||||
$order = $where['order'] == 2 ? 'c.star desc' : 'c.id desc';
|
||||
unset($where['order']);
|
||||
if (!$where['product_id']) {
|
||||
return app('json')->fail('商品不能为空');
|
||||
}
|
||||
// $where['uid'] = $request->uid();
|
||||
return app('json')->success($this->services->getJoinCommunityList($where, (int)$request->uid(), 'left_id', 0, $order));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分享
|
||||
* @param $id
|
||||
* @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/8/28 14:10
|
||||
*/
|
||||
public function communityShare($id, Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
$this->services->communityShare($id, $uid);
|
||||
return app('json')->success('分享成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param $id
|
||||
* @return void
|
||||
* User: liusl
|
||||
* DateTime: 2024/8/28 14:11
|
||||
*/
|
||||
public function communityDelete($id, Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
$this->services->communityDelete($id, $uid);
|
||||
return app('json')->success('删除成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 浏览
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* User: liusl
|
||||
* DateTime: 2024/9/3 10:46
|
||||
*/
|
||||
public function setBrowse($id, Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
$this->services->setBrowse($id, $uid);
|
||||
return app('json')->success('浏览成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 话题总数
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/9/21 11:24
|
||||
*/
|
||||
public function topicCount($id)
|
||||
{
|
||||
$count = $this->services->topicCount($id);
|
||||
return app('json')->success(compact('count'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息列表
|
||||
* @param Request $request
|
||||
* @param CommunityRecordServices $services
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/12/5 下午3:22
|
||||
*/
|
||||
public function message(Request $request, CommunityRecordServices $services)
|
||||
{
|
||||
[$type] = $request->getMore([
|
||||
['type', '']
|
||||
], true);
|
||||
$uid = (int)$request->uid();
|
||||
$services->update(['uid' => $uid, 'type' => $type], ['is_viewed' => 1]);
|
||||
$list = $services->getList(['uid' => $uid, 'type' => $type]);
|
||||
$isViewed = $services->isViewed($uid);
|
||||
return app('json')->success(compact('list', 'isViewed'));
|
||||
}
|
||||
}
|
||||
129
app/controller/api/v1/community/CommunityComment.php
Normal file
129
app/controller/api/v1/community/CommunityComment.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?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\community;
|
||||
|
||||
|
||||
use app\services\community\CommunityCacheServices;
|
||||
use app\services\community\CommunityCommentServices;
|
||||
use app\services\community\CommunityServices;
|
||||
use app\Request;
|
||||
use app\services\community\CommunityTopicServices;
|
||||
use app\services\product\product\StoreProductLogServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
|
||||
/**
|
||||
* Class StoreController
|
||||
* @package app\api\controller\v1\store
|
||||
*/
|
||||
class CommunityComment
|
||||
{
|
||||
|
||||
/**
|
||||
* @var CommunityCommentServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected CommunityCommentServices $services;
|
||||
|
||||
|
||||
public function list(Request $request)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['community_id', ''],//社区 id
|
||||
['reply_id', ''],//评论id
|
||||
]);
|
||||
if (!$where['community_id']) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
if (!$where['reply_id']) {
|
||||
$where['is_reply'] = 1;
|
||||
}
|
||||
$where['is_del'] = 0;
|
||||
$where['is_verify'] = 1;
|
||||
|
||||
return app('json')->success($this->services->getList($where, '*', [], (int)$request->uid()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @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/8/19 11:03
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
if (!sys_config('community_comment_add'))
|
||||
return app('json')->fail('评论功能未开启');
|
||||
[$community_id, $comment_reply_id, $content] = $request->postMore([
|
||||
['community_id', 0],//社区 id
|
||||
['comment_reply_id', 0],//评论回复id
|
||||
['content', ''],//评论内容
|
||||
], true);
|
||||
$uid = (int)$request->uid();
|
||||
if (empty($content)) {
|
||||
return app('json')->fail('请输入回复内容');
|
||||
}
|
||||
$data['content'] = $content;
|
||||
$data['ip'] = $request->ip();
|
||||
|
||||
$data['is_verify'] = sys_config('community_comment_verify', 0) ? 0 : 1;
|
||||
$data['type'] = 2;
|
||||
$this->services->saveComment((int)$community_id, $data, (int)$comment_reply_id, $uid);
|
||||
$msg = sys_config('community_comment_verify', 1) ? '评论成功,等待审核' : '评论成功';
|
||||
return app('json')->success($msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 点赞,取消点赞
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/8/21 10:28
|
||||
*/
|
||||
public function setCommentLike($id, Request $request)
|
||||
{
|
||||
[$status] = $request->postMore([
|
||||
['status', 1]
|
||||
], true);
|
||||
|
||||
$status = $status == 1 ? 1 : 0;
|
||||
$info = $this->services->get($id);
|
||||
if (!$info || $info['is_del'] == 1 || $info['is_verify'] != 1)
|
||||
return app('json')->fail('内容不存在');
|
||||
$info = $info->toArray();
|
||||
$uid = (int)$request->uid();
|
||||
$this->services->setCommentLike($info, $uid, $status);
|
||||
if ($status) {
|
||||
return app('json')->success('点赞成功');
|
||||
} else {
|
||||
return app('json')->success('取消点赞');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param $id
|
||||
* @return void
|
||||
* User: liusl
|
||||
* DateTime: 2024/8/28 14:37
|
||||
*/
|
||||
public function commentDelete($id, Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
$res = $this->services->commentDelete($id, $uid);
|
||||
return app('json')->success('删除成功');
|
||||
}
|
||||
}
|
||||
160
app/controller/api/v1/community/CommunityUser.php
Normal file
160
app/controller/api/v1/community/CommunityUser.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?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\community;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\community\CommunityServices;
|
||||
use app\services\community\CommunityUserServices;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\Response;
|
||||
|
||||
|
||||
/**
|
||||
* Class CommunityUser
|
||||
* @package app\api\controller\v1\community
|
||||
*/
|
||||
class CommunityUser
|
||||
{
|
||||
|
||||
/**
|
||||
* @var CommunityUserServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected CommunityUserServices $services;
|
||||
|
||||
/**
|
||||
* 用户主页
|
||||
* @param $uid
|
||||
* @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/8/22 16:30
|
||||
*/
|
||||
public function getInfo($authorUid, Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->success($this->services->getInfo($authorUid, $uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改简介
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/8/22 16:30
|
||||
*/
|
||||
public function updateDesc(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
[$desc] = $request->postMore([['desc', '']], true);
|
||||
$info = $this->services->getUserInfo($uid);
|
||||
if (!$info) {
|
||||
return app('json')->fail('用户不存在');
|
||||
}
|
||||
$info->desc = $desc;
|
||||
$info->save();
|
||||
return app('json')->success('修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 关注/取消关注
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/8/22 16:31
|
||||
*/
|
||||
public function setInterest($authorUid, Request $request)
|
||||
{
|
||||
[$status] = $request->postMore([
|
||||
['status', 1]
|
||||
], true);
|
||||
|
||||
$status = $status == 1 ? 1 : 0;
|
||||
$uid = (int)$request->uid();
|
||||
if ($authorUid == $uid) {
|
||||
return app('json')->fail('不能关注自己');
|
||||
}
|
||||
|
||||
$this->services->setInterest($authorUid, $uid, $status);
|
||||
if ($status) {
|
||||
return app('json')->success('关注成功');
|
||||
} else {
|
||||
return app('json')->success('取消成功');
|
||||
}
|
||||
}
|
||||
|
||||
public function follow(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->success($this->services->follow($uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 关注/粉丝列表
|
||||
* @param $type 关注:follow 粉丝:fans
|
||||
* @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/8/26 11:28
|
||||
*/
|
||||
public function followList($type, Request $request)
|
||||
{
|
||||
if (!in_array($type, ['follow', 'fans'])) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->success($this->services->followList($uid, $type));
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的好友
|
||||
* @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/8/26 12:05
|
||||
*/
|
||||
public function userFriend(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->success($this->services->userFriend($uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 推荐
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/8/26 15:18
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function recommendList(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->success($this->services->recommendList($uid));
|
||||
}
|
||||
}
|
||||
197
app/controller/api/v1/diy/Diy.php
Normal file
197
app/controller/api/v1/diy/Diy.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?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\diy;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\activity\coupon\StoreCouponUserServices;
|
||||
use app\services\activity\newcomer\StoreNewcomerServices;
|
||||
use app\services\activity\video\VideoServices;
|
||||
use app\services\diy\DiyServices;
|
||||
use app\services\product\product\StoreProductLogServices;
|
||||
use app\services\product\product\StoreProductRankServices;use app\services\user\level\SystemUserLevelServices;
|
||||
use app\services\user\UserRelationServices;
|
||||
use app\services\user\UserServices;
|
||||
use app\services\user\UserSignServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* Class Diy
|
||||
* @package app\controller\api\v1\diy
|
||||
*/
|
||||
class Diy
|
||||
{
|
||||
/**
|
||||
* @var DiyServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected DiyServices $services;
|
||||
|
||||
/**
|
||||
* 获取页面数据
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getDiy($id = 0)
|
||||
{
|
||||
return app('json')->successful($this->services->getDiyInfo((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取diy缓存版本
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function getDiyVersion($id = 0)
|
||||
{
|
||||
return app('json')->successful(['version' => $this->services->getDiyVersion((int)$id)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取底部导航
|
||||
* @param $template_name
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function getNavigation($template_name = '')
|
||||
{
|
||||
return app('json')->success($this->services->getNavigation((string)$template_name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取diy用户数据
|
||||
* @param Request $request
|
||||
* @param UserServices $userServices
|
||||
* @return mixed
|
||||
*/
|
||||
public function userInfo(Request $request, UserServices $userServices)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
$userInfo = [];
|
||||
if ($uid) {
|
||||
$userInfo = $userServices->getUserInfo($uid, 'uid,nickname,phone,avatar,level,integral,now_money,exp,is_money_level,bar_code');
|
||||
if ($userInfo) {
|
||||
$userInfo = $userInfo->toArray();
|
||||
/** @var StoreCouponUserServices $storeCoupon */
|
||||
$storeCoupon = app()->make(StoreCouponUserServices::class);
|
||||
$userInfo['coupon_num'] = $storeCoupon->getUserValidCouponCount((int)$uid);
|
||||
$userInfo['vip_name'] = '';
|
||||
if ($userInfo['level']) {
|
||||
/** @var SystemUserLevelServices $systemUserLevel */
|
||||
$systemUserLevel = app()->make(SystemUserLevelServices::class);
|
||||
$levelList = $systemUserLevel->getList(['is_del' => 0, 'is_show' => 1], 'id,name,exp_num');
|
||||
$i = 0;
|
||||
foreach ($levelList as &$level) {
|
||||
if ($level['id'] == $userInfo['level']) {
|
||||
$userInfo['vip_name'] = $level['name'];
|
||||
}
|
||||
$level['next_exp_num'] = $levelList[$i + 1]['exp_num'] ?? $level['exp_num'];
|
||||
$i++;
|
||||
}
|
||||
$levelList = array_combine(array_column($levelList,'id'), $levelList);
|
||||
$userInfo['next_exp'] = $levelList[$userInfo['level']]['next_exp_num'] ?? 0;
|
||||
} else {
|
||||
/** @var SystemUserLevelServices $systemUserLevel */
|
||||
$systemUserLevel = app()->make(SystemUserLevelServices::class);
|
||||
$levelList = $systemUserLevel->getList(['is_del' => 0, 'is_show' => 1], 'id,name,exp_num');
|
||||
$userInfo['next_exp'] = $levelList[0]['exp_num'] ?? 0;
|
||||
}
|
||||
/** @var UserRelationServices $productRelation */
|
||||
$productRelation = app()->make(UserRelationServices::class);
|
||||
$collectCategory = sys_config('video_func_status', 1) ? '' : 'product';
|
||||
$userInfo['collectCount'] = $productRelation->getUserCount($uid, 0, 'collect', $collectCategory);
|
||||
/** @var StoreProductLogServices $storeProductLogServices */
|
||||
$storeProductLogServices = app()->make(StoreProductLogServices::class);
|
||||
$userInfo['visit_num'] = $storeProductLogServices->getDistinctCount(['uid' => $uid, 'type' => 'visit'], 'product_id');
|
||||
}
|
||||
}
|
||||
return app('json')->success($userInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取diy短视频
|
||||
* @param Request $request
|
||||
* @param VideoServices $videoServices
|
||||
* @return mixed
|
||||
*/
|
||||
public function videoList(Request $request, VideoServices $videoServices)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->success($videoServices->getDiyVideoList($uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取新人礼商品
|
||||
* @param Request $request
|
||||
* @param StoreNewcomerServices $newcomerServices
|
||||
* @return mixed
|
||||
*/
|
||||
public function newcomerList(Request $request, StoreNewcomerServices $newcomerServices)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['priceOrder', ''],
|
||||
['salesOrder', ''],
|
||||
]);
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->success($newcomerServices->getDiyNewcomerList($uid, $where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页diy签到数据
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function diySign(Request $request, UserSignServices $services)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->successful($services->homeDiysignData($uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品排行榜
|
||||
* @param Request $request
|
||||
* @param StoreProductRankServices $productRankServices
|
||||
* @return \think\Response
|
||||
* @throws \ReflectionException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \throwable
|
||||
*/
|
||||
public function productRank(Request $request, StoreProductRankServices $productRankServices)
|
||||
{
|
||||
[$limit] = $request->getMore([
|
||||
['limit', 3]
|
||||
], true);
|
||||
$uid = 0;
|
||||
if ($request->hasMacro('uid')) $uid = (int)$request->uid();
|
||||
$data = [];
|
||||
$data['sales'] = $productRankServices->getProductRankList($uid, 1, [], $limit);
|
||||
$data['star'] = $productRankServices->getProductRankList($uid, 2, [], $limit);
|
||||
$data['collect'] = $productRankServices->getProductRankList($uid, 3, [], $limit);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 悬浮框
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/9/6 10:17
|
||||
*/
|
||||
public function getSuspendedDiy()
|
||||
{
|
||||
$data = $this->services->getSuspendedDiy();
|
||||
return app('json')->success($data);
|
||||
}
|
||||
}
|
||||
287
app/controller/api/v1/order/OtherOrder.php
Normal file
287
app/controller/api/v1/order/OtherOrder.php
Normal file
@@ -0,0 +1,287 @@
|
||||
<?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\order;
|
||||
|
||||
|
||||
use app\services\order\OtherOrderServices;
|
||||
use app\services\pay\OrderPayServices;
|
||||
use app\services\pay\PayServices;
|
||||
use app\services\pay\YuePayServices;
|
||||
use app\services\user\member\MemberCardServices;
|
||||
use app\services\user\UserServices;
|
||||
use crmeb\services\CacheService;
|
||||
use crmeb\services\SystemConfigService;
|
||||
use app\Request;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* Class OtherOrder
|
||||
* @package app\api\controller\v1\order
|
||||
*/
|
||||
class OtherOrder
|
||||
{
|
||||
/**
|
||||
* @var OtherOrderServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected OtherOrderServices $services;
|
||||
|
||||
/**
|
||||
* 计算会员线下付款金额
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function computed_offline_pay_price(Request $request)
|
||||
{
|
||||
[$pay_price] = $request->getMore([
|
||||
['pay_price', 0]
|
||||
], true);
|
||||
if (!$pay_price || !is_numeric($pay_price)) return app('json')->fail('请输入付款金额');
|
||||
$uid = $request->uid();
|
||||
/** @var UserServices $userService */
|
||||
$userService = app()->make(UserServices::class);
|
||||
//会员线下享受折扣
|
||||
if ($userService->checkUserIsSvip($uid)) {
|
||||
//看是否开启线下享受折扣
|
||||
/** @var MemberCardServices $memberCardService */
|
||||
$memberCardService = app()->make(MemberCardServices::class);
|
||||
$offline_rule_number = $memberCardService->isOpenMemberCardCache('offline');
|
||||
if ($offline_rule_number) {
|
||||
$pay_price = bcmul($pay_price, bcdiv($offline_rule_number, '100', 2), 2);
|
||||
} else {
|
||||
$pay_price = 0;
|
||||
}
|
||||
} else {
|
||||
$pay_price = 0;
|
||||
}
|
||||
return app('json')->successful(['pay_price' => $pay_price]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function create(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
/** @var OtherOrderServices $OtherOrderServices */
|
||||
$OtherOrderServices = app()->make(OtherOrderServices::class);
|
||||
[$payType, $type, $from, $memberType, $price, $money, $quitUrl] = $request->postMore([
|
||||
['pay_type', 'yue'],
|
||||
['type', 0],
|
||||
['from', 'weixin'],
|
||||
['member_type', ''],
|
||||
['price', 0.00],
|
||||
['money', 0.00],
|
||||
['quitUrl', ''],
|
||||
], true);
|
||||
$payType = strtolower($payType);
|
||||
if (in_array($type, [1, 2])) {
|
||||
/** @var MemberCardServices $memberCardService */
|
||||
$memberCardService = app()->make(MemberCardServices::class);
|
||||
$isOpenMember = $memberCardService->isOpenMemberCardCache();
|
||||
if (!$isOpenMember) return app('json')->fail('付费会员功能暂未开启!');
|
||||
}
|
||||
$channelType = $request->user('user_type');
|
||||
$order = $OtherOrderServices->createOrder($uid, $channelType, $memberType, $price, $payType, $type, $money);
|
||||
if ($order === false) return app('json')->fail('支付数据生成失败');
|
||||
$order = $order->toArray();
|
||||
$order_id = $order['order_id'];
|
||||
if($type == 3){
|
||||
$info = compact('order_id');
|
||||
switch ($payType) {
|
||||
case PayServices::WEIXIN_PAY:
|
||||
if ($order['paid']) return app('json')->fail('已支付!');
|
||||
//支付金额为0
|
||||
if (bcsub((string)$order['pay_price'], '0', 2) <= 0) {
|
||||
//创建订单jspay支付
|
||||
$payPriceStatus = $OtherOrderServices->zeroYuanPayment($order);
|
||||
if ($payPriceStatus)//0元支付成功
|
||||
return app('json')->status('success', '微信支付成功', $info);
|
||||
else
|
||||
return app('json')->status('pay_error');
|
||||
} else {
|
||||
/** @var OrderPayServices $payServices */
|
||||
$payServices = app()->make(OrderPayServices::class);
|
||||
$info['jsConfig'] = $payServices->orderPay($order, $from);
|
||||
if ($from == 'weixinh5') {
|
||||
return app('json')->status('wechat_h5_pay', '前往支付', $info);
|
||||
} else {
|
||||
return app('json')->status('wechat_pay', '前往支付', $info);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PayServices::YUE_PAY:
|
||||
/** @var YuePayServices $yueServices */
|
||||
$yueServices = app()->make(YuePayServices::class);
|
||||
$pay = $yueServices->yueOrderPay($order, $uid);
|
||||
if ($pay['status'] === true)
|
||||
return app('json')->status('success', '余额支付成功', $info);
|
||||
else {
|
||||
if (is_array($pay))
|
||||
return app('json')->status($pay['status'], $pay['msg'], $info);
|
||||
else
|
||||
return app('json')->status('pay_error', $pay);
|
||||
}
|
||||
break;
|
||||
case PayServices::ALIPAY_PAY:
|
||||
if (!$quitUrl && ($request->isH5() || $request->isWechat())) {
|
||||
return app('json')->status('pay_error', '请传入支付宝支付回调URL', $info);
|
||||
}
|
||||
//支付金额为0
|
||||
if (bcsub((string)$order['pay_price'], '0', 2) <= 0) {
|
||||
//创建订单jspay支付
|
||||
$payPriceStatus = $OtherOrderServices->zeroYuanPayment($order);
|
||||
if ($payPriceStatus)//0元支付成功
|
||||
return app('json')->status('success', '支付宝支付成功', $info);
|
||||
else
|
||||
return app('json')->status('pay_error');
|
||||
} else {
|
||||
/** @var OrderPayServices $payServices */
|
||||
$payServices = app()->make(OrderPayServices::class);
|
||||
$info['jsConfig'] = $payServices->alipayOrder($order, $quitUrl, $request->isRoutine());
|
||||
$payKey = md5($order['order_id']);
|
||||
CacheService::set($payKey, ['order_id' => $order['order_id'], 'other_pay_type' => true], 300);
|
||||
$info['pay_key'] = $payKey;
|
||||
return app('json')->status(PayServices::ALIPAY_PAY . '_pay', '前往支付', $info);
|
||||
}
|
||||
break;
|
||||
case PayServices::OFFLINE_PAY:
|
||||
return app('json')->status('success', '前往支付', $info);
|
||||
break;
|
||||
default:
|
||||
return app('json')->fail('未知支付方式');
|
||||
}
|
||||
}else{
|
||||
if ($order_id) {
|
||||
return app('json')->successful('订单创建成功', ['order_id' => $order_id]);
|
||||
} else {
|
||||
return app('json')->fail('订单生成失败!');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员订单支付
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \throwable
|
||||
*/
|
||||
public function create_pay(Request $request)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
/** @var OtherOrderServices $OtherOrderServices */
|
||||
$OtherOrderServices = app()->make(OtherOrderServices::class);
|
||||
[$uni, $payType, $from, $quitUrl] = $request->postMore([
|
||||
['uni', ''],
|
||||
['paytype', 'weixin'],
|
||||
['from', 'weixin'],
|
||||
['quitUrl', '']
|
||||
], true);
|
||||
$payType = strtolower($payType);
|
||||
if (!$uni) return app('json')->fail('参数错误!');
|
||||
$order = $OtherOrderServices->getOne(['order_id' => $uni]);
|
||||
if ($order === false) return app('json')->fail('支付数据获取失败');
|
||||
if ($order['pay_type'] != $payType) {
|
||||
$res = $OtherOrderServices->update(['order_id' => $uni], ['pay_type' => $payType]);
|
||||
if (!$res) return app('json')->fail('支付方式修改失败');
|
||||
}
|
||||
$orderInfo = $order->toArray();
|
||||
$order_id = $orderInfo['order_id'];
|
||||
$info = compact('order_id');
|
||||
switch ($payType) {
|
||||
case PayServices::WEIXIN_PAY:
|
||||
if ($orderInfo['paid']) return app('json')->fail('已支付!');
|
||||
//支付金额为0
|
||||
if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
|
||||
//创建订单jspay支付
|
||||
$payPriceStatus = $OtherOrderServices->zeroYuanPayment($orderInfo);
|
||||
if ($payPriceStatus)//0元支付成功
|
||||
return app('json')->status('success', '微信支付成功', $info);
|
||||
else
|
||||
return app('json')->status('pay_error');
|
||||
} else {
|
||||
/** @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::YUE_PAY:
|
||||
/** @var YuePayServices $yueServices */
|
||||
$yueServices = app()->make(YuePayServices::class);
|
||||
$pay = $yueServices->yueOrderPay($orderInfo, $uid);
|
||||
if ($pay['status'] === true)
|
||||
return app('json')->status('success', '余额支付成功', $info);
|
||||
else {
|
||||
if (is_array($pay))
|
||||
return app('json')->status($pay['status'], $pay['msg'], $info);
|
||||
else
|
||||
return app('json')->status('pay_error', $pay);
|
||||
}
|
||||
break;
|
||||
case PayServices::ALIPAY_PAY:
|
||||
if (!$quitUrl && ($request->isH5() || $request->isWechat())) {
|
||||
return app('json')->status('pay_error', '请传入支付宝支付回调URL', $info);
|
||||
}
|
||||
//支付金额为0
|
||||
if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
|
||||
//创建订单jspay支付
|
||||
$payPriceStatus = $OtherOrderServices->zeroYuanPayment($orderInfo);
|
||||
if ($payPriceStatus)//0元支付成功
|
||||
return app('json')->status('success', '支付宝支付成功', $info);
|
||||
else
|
||||
return app('json')->status('pay_error');
|
||||
} else {
|
||||
/** @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;
|
||||
case PayServices::OFFLINE_PAY:
|
||||
return app('json')->status('success', '前往支付', $info);
|
||||
break;
|
||||
default:
|
||||
return app('json')->fail('未知支付方式');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 线下支付方式
|
||||
* @return mixed
|
||||
*/
|
||||
public function pay_type(Request $request)
|
||||
{
|
||||
$payType = SystemConfigService::more(['ali_pay_status', 'pay_weixin_open', 'site_name', 'balance_func_status']);
|
||||
$payType['now_money'] = $request->user('now_money');
|
||||
$payType['offline_pay_status'] = true;
|
||||
$payType['yue_pay_status'] = (int)$payType['balance_func_status'] ? 1 : 0;//余额支付 1 开启 2 关闭
|
||||
unset($payType['balance_func_status']);
|
||||
return app('json')->successful($payType);
|
||||
}
|
||||
}
|
||||
258
app/controller/api/v1/order/StoreCart.php
Normal file
258
app/controller/api/v1/order/StoreCart.php
Normal file
@@ -0,0 +1,258 @@
|
||||
<?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\order;
|
||||
|
||||
use app\Request;
|
||||
use app\services\order\StoreCartServices;
|
||||
use app\services\activity\discounts\StoreDiscountsServices;
|
||||
use crmeb\services\CacheService;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 购物车类
|
||||
* Class StoreCart
|
||||
* @package app\api\controller\store
|
||||
*/
|
||||
class StoreCart
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreCartServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreCartServices $services;
|
||||
|
||||
/**
|
||||
* 购物车 列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function lst(Request $request)
|
||||
{
|
||||
[$status, $latitude, $longitude, $store_id, $is_channel, $is_send_gift] = $request->postMore([
|
||||
['status', 1],//购物车商品状态
|
||||
['latitude', ''],
|
||||
['longitude', ''],
|
||||
['store_id', 0],
|
||||
['is_channel', 0],
|
||||
['is_send_gift', 0],
|
||||
], true);
|
||||
if (!checkCoordinates($longitude, $latitude)) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
$this->services->setItem('latitude', $latitude)->setItem('longitude', $longitude)->setItem('store_id', (int)$store_id)->setItem('status', $status);
|
||||
$result = $this->services->getUserCartList((int)$request->uid(), (int)$status, [], -1, 0, false, $is_channel, (int)$is_send_gift);
|
||||
$this->services->reset();
|
||||
$result['valid'] = $this->services->getReturnCartList($result['valid'], $result['promotions']);
|
||||
unset($result['promotions']);
|
||||
return app('json')->successful($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车 添加
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function add(Request $request)
|
||||
{
|
||||
$where = $request->postMore([
|
||||
['productId', 0],//普通商品编号
|
||||
[['cartNum', 'd'], 1], //购物车数量
|
||||
['uniqueId', ''],//属性唯一值
|
||||
[['new', 'd'], 0],// 1 加入购物车直接购买 0 加入购物车
|
||||
[['is_new', 'd'], 0],// 1 加入购物车直接购买 0 加入购物车
|
||||
[['secKillId', 'd'], 0],//秒杀商品ID
|
||||
[['bargainId', 'd'], 0],//砍价商品ID
|
||||
[['combinationId', 'd'], 0],//拼团商品ID
|
||||
[['storeIntegralId', 'd'], 0],//积分商品ID
|
||||
[['discountId', 'd'], 0],//优惠套餐ID
|
||||
['discountInfos', []],//优惠套餐商品ID
|
||||
[['newcomerId', 'd'], 0],//新人专享商品ID
|
||||
[['luckRecordId', 'd'], 0],//抽奖记录ID
|
||||
[['key', 's'], ''],//直接购买购物车ID 再次累加1
|
||||
[['is_set', 'd'], 0],//1:直接设置购物车数量 0:累加
|
||||
[['is_channel', 'd'], 0],//1:采购商 0:普通
|
||||
[['is_send_gift', 'd'], 0],//1:送礼 0:普通
|
||||
]);
|
||||
if ($where['is_new'] || $where['new']) $new = true;
|
||||
else $new = false;
|
||||
if (!$where['productId'] && !$where['discountId']) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
$type = 0;
|
||||
$uid = (int)$request->uid();
|
||||
$activityId = 0;
|
||||
$this->services->setItem('key', $where['key'] ?? '');
|
||||
$this->services->setItem('is_set', $where['is_set'] ?? 0);
|
||||
if ($where['discountId']) {//套餐商品
|
||||
$type = 5;
|
||||
/** @var StoreDiscountsServices $discountService */
|
||||
$discountService = app()->make(StoreDiscountsServices::class);
|
||||
$discounts = $discountService->get((int)$where['discountId'], ['id', 'is_limit', 'limit_num']);
|
||||
if (!$discounts) {
|
||||
return app('json')->fail('套餐商品未找到!');
|
||||
}
|
||||
//套餐限量
|
||||
if ($discounts['is_limit']) {
|
||||
if ($discounts['limit_num'] <= 0) {
|
||||
return app('json')->fail('套餐限量不足');
|
||||
}
|
||||
if (!CacheService::checkStock(md5($discounts['id']), 1, $type)) {
|
||||
return app('json')->fail('套餐限量不足');
|
||||
}
|
||||
}
|
||||
$cartIds = [];
|
||||
$cartNum = 0;
|
||||
$activityId = (int)$where['discountId'];
|
||||
foreach ($where['discountInfos'] as $info) {
|
||||
[$cartId, $cartNum] = $this->services->setCart($uid, (int)$info['product_id'], 1, $info['unique'], $type, $new, $activityId, (int)$info['id']);
|
||||
$cartIds[] = $cartId;
|
||||
}
|
||||
} else {
|
||||
if ($where['secKillId']) {
|
||||
$type = 1;
|
||||
$activityId = $where['secKillId'];
|
||||
} elseif ($where['bargainId']) {
|
||||
$type = 2;
|
||||
$activityId = $where['bargainId'];
|
||||
} elseif ($where['combinationId']) {
|
||||
$type = 3;
|
||||
$activityId = $where['combinationId'];
|
||||
} elseif ($where['storeIntegralId']) {
|
||||
$type = 4;
|
||||
$activityId = $where['storeIntegralId'];
|
||||
} elseif ($where['newcomerId']) {
|
||||
$type = 7;
|
||||
$activityId = $where['newcomerId'];
|
||||
} elseif ($where['luckRecordId']) {
|
||||
$type = 8;
|
||||
$activityId = $where['luckRecordId'];
|
||||
} elseif ($where['is_send_gift'] == 1) {
|
||||
$type = 10;
|
||||
}
|
||||
[$cartIds, $cartNum] = $this->services->setCart($uid, (int)$where['productId'], (int)$where['cartNum'], $where['uniqueId'], $type, $new, (int)$activityId, 0, $where['is_channel'], $where['is_send_gift']);
|
||||
}
|
||||
$this->services->reset();
|
||||
if (!$cartIds) {
|
||||
return app('json')->fail('添加失败');
|
||||
} else {
|
||||
//更新秒杀详情缓存
|
||||
$this->services->cacheTag('Cart_Nums_' . $uid)->clear();
|
||||
return app('json')->successful('ok', ['cartId' => $cartIds, 'cartNum' => $cartNum]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车 删除商品
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function del(Request $request)
|
||||
{
|
||||
$where = $request->postMore([
|
||||
['ids', ''],//购物车编号
|
||||
]);
|
||||
$where['ids'] = is_array($where['ids']) ? $where['ids'] : stringToIntArray($where['ids']);
|
||||
if (!count($where['ids']))
|
||||
return app('json')->fail('参数错误!');
|
||||
if ($this->services->removeUserCart((int)$request->uid(), $where['ids'])) {
|
||||
$this->services->cacheTag('Cart_Nums_' . $request->uid())->clear();
|
||||
return app('json')->successful();
|
||||
}
|
||||
return app('json')->fail('清除失败!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车 修改商品数量
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function num(Request $request)
|
||||
{
|
||||
$where = $request->postMore([
|
||||
['id', 0],//购物车编号
|
||||
['type', 1],//1购物车 id,2商品 id
|
||||
['number', 0],//购物车编号
|
||||
]);
|
||||
if ($where['type'] == 2) {
|
||||
$where['id'] = $this->services->value(['product_id' => $where['id'], 'is_pay' => 0, 'uid' => $request->uid()], 'id');
|
||||
}
|
||||
unset($where['type']);
|
||||
|
||||
if (!$where['id'] || !$where['number'] || !is_numeric($where['id']) || !is_numeric($where['number'])) return app('json')->fail('参数错误!');
|
||||
$res = $this->services->changeUserCartNum($where['id'], $where['number'], $request->uid());
|
||||
if ($res) {
|
||||
$this->services->cacheTag('Cart_Nums_' . $request->uid())->clear();
|
||||
return app('json')->successful();
|
||||
} else {
|
||||
return app('json')->fail('修改失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车 统计 数量 价格
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function count(Request $request)
|
||||
{
|
||||
[$numType, $store_id, $is_channel] = $request->postMore([
|
||||
['numType', true],//购物车编号
|
||||
['store_id', 0],
|
||||
['is_channel', 0],
|
||||
], true);
|
||||
$uid = (int)$request->uid();
|
||||
return app('json')->success('ok', $this->services->getUserCartCount($uid, $numType, (int)$store_id, (int)$is_channel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车重选
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function reChange(Request $request)
|
||||
{
|
||||
[$cart_id, $product_id, $unique] = $request->postMore([
|
||||
['cart_id', 0],
|
||||
['product_id', 0],
|
||||
['unique', '']
|
||||
], true);
|
||||
$this->services->modifyCart($cart_id, $product_id, $unique);
|
||||
|
||||
$this->services->cacheTag('Cart_Nums_' . $request->uid())->clear();
|
||||
|
||||
return app('json')->success('重选成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算用户购物车商品(优惠活动、最优优惠券)
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function computeCart(Request $request)
|
||||
{
|
||||
[$cartId, $shipping_type, $is_send_gift] = $request->postMore([
|
||||
'cartId',
|
||||
['shipping_type', -1],
|
||||
['is_send_gift', 0],
|
||||
], true);
|
||||
$uid = (int)$request->uid();
|
||||
$result = $this->services->computeUserCart($uid, $cartId, (int)$shipping_type, false, (int)$is_send_gift);
|
||||
return app('json')->success($result);
|
||||
}
|
||||
}
|
||||
1513
app/controller/api/v1/order/StoreOrder.php
Normal file
1513
app/controller/api/v1/order/StoreOrder.php
Normal file
File diff suppressed because it is too large
Load Diff
100
app/controller/api/v1/order/StoreOrderRefund.php
Normal file
100
app/controller/api/v1/order/StoreOrderRefund.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?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\order;
|
||||
|
||||
use app\Request;
|
||||
use app\services\order\StoreOrderRefundServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 售后订单
|
||||
* Class StoreOrderRefundController
|
||||
* @package app\controller\api\v1\order
|
||||
*/
|
||||
class StoreOrderRefund
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreOrderRefundServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreOrderRefundServices $services;
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function lst(Request $request)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
[['search', 's'], '', '', 'real_name'],
|
||||
['refund_type', '', '', 'refundTypes'],
|
||||
['channel', 0],
|
||||
]);
|
||||
$where['uid'] = $request->uid();
|
||||
$list = $this->services->getRefundOrderList($where);
|
||||
return app('json')->successful($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
* @param Request $request
|
||||
* @param $uni
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail(StoreOrderRefundServices $services, Request $request, $uni)
|
||||
{
|
||||
$orderData = $services->refundDetail($uni);
|
||||
return app('json')->successful('ok', $orderData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 取消申请
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function cancelApply(Request $request, $uni)
|
||||
{
|
||||
if (!strlen(trim($uni))) return app('json')->fail('参数错误');
|
||||
$uid = (int)$request->uid();
|
||||
$this->services->cancelApplyRefund($uid, $uni);
|
||||
return app('json')->success('取消成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除已退款和拒绝退款的订单
|
||||
* @param Request $request
|
||||
* @param $uni
|
||||
* @return mixed
|
||||
*/
|
||||
public function delRefundOrder(Request $request, $uni)
|
||||
{
|
||||
if (!strlen(trim($uni))) return app('json')->fail('参数错误');
|
||||
$uid = (int)$request->uid();
|
||||
$this->services->delRefundOrder($uid, $uni);
|
||||
return app('json')->success('删除成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 再次申请
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function againRefundOrder(Request $request, $id)
|
||||
{
|
||||
if (!strlen(trim($id))) return app('json')->fail('参数错误');
|
||||
$uid = (int)$request->uid();
|
||||
$this->services->againRefundOrder($uid, (int)$id);
|
||||
return app('json')->success('申请成功');
|
||||
}
|
||||
}
|
||||
125
app/controller/api/v1/other/Qrcode.php
Normal file
125
app/controller/api/v1/other/Qrcode.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?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\other;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\other\QrcodeServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* Class Login
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class Qrcode
|
||||
{
|
||||
|
||||
/**
|
||||
* @var QrcodeServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected QrcodeServices $services;
|
||||
|
||||
/**
|
||||
* 获取商品、秒杀、砍价、分销等海报二维码
|
||||
* @param Request $request
|
||||
* @param $type
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getQrcode(Request $request, $type, $id)
|
||||
{
|
||||
$id = (int)$id;
|
||||
$uid = $request->hasMacro('user') ? (int)$request->uid() : 0;
|
||||
$user = $request->hasMacro('user') ? $request->user() : [];
|
||||
$is_promoter = $user['is_promoter'] ?? 1;
|
||||
$name = $third_type = $link = '';
|
||||
switch ($type) {
|
||||
case -1://分销
|
||||
$third_type = 'spread-' . $uid;
|
||||
$name = 'spread-' . $uid . '_' . $is_promoter . '.jpg';
|
||||
$link = '/pages/index/index?spid=' . $uid;
|
||||
break;
|
||||
case 0://普通商品
|
||||
$name = 'product_' . $id . '_' . $uid . '_' . $is_promoter . '.jpg';
|
||||
$third_type = 'product-' . $id . '-' . $uid;
|
||||
$link = '/pages/goods_details/index?id=' . $id . '&spid=' . $uid;
|
||||
break;
|
||||
case 1://秒杀
|
||||
$time = $request->param('time', '');
|
||||
$status = $request->param('status', '');
|
||||
$name = 'seckill_' . $id . '_' . $uid . '.jpg';
|
||||
$third_type = 'seckill-' . $id . '-' . $uid . '-' . $time . '-' . $status;
|
||||
$link = '/pages/activity/goods_details/index?type=1&id=' . $id . '&time=' . $time . '&status=' . $status . '&spid=' . $uid;
|
||||
break;
|
||||
case 2://砍价
|
||||
$third_type = 'bargain-' . $id . '-' . $uid;
|
||||
$name = 'bargain_' . $id . '_' . $uid . '_' . $is_promoter . '.jpg';
|
||||
$link = '/pages/activity/goods_bargain_details/index?id=' . $id . '&spid=' . $uid;
|
||||
break;
|
||||
case 3://拼团
|
||||
$third_type = 'combination-' . $id . '-' . $uid;
|
||||
$name = 'combination_' . $id . '_' . $uid . '_' . $is_promoter . '.jpg';
|
||||
$link = '/pages/activity/goods_details/index?type=3&id=' . $id . '&spid=' . $uid;
|
||||
break;
|
||||
case 4://积分
|
||||
$third_type = 'integral-' . $id . '-' . $uid;
|
||||
$name = 'integral_' . $id . '_' . $uid . '_' . $is_promoter . '.jpg';
|
||||
$link = '/pages/activity/goods_details/index?type=4&id=' . $id . '&spid=' . $uid;
|
||||
break;
|
||||
case 6://预售
|
||||
$third_type = 'presale-' . $id . '-' . $uid;
|
||||
$name = 'presale_' . $id . '_' . $uid . '_' . $is_promoter . '.jpg';
|
||||
$link = '/pages/activity/goods_details/index?type=6&id=' . $id . '&spid=' . $uid;
|
||||
break;
|
||||
case 7://新人专享
|
||||
$third_type = 'newcomer-' . $id . '-' . $uid;
|
||||
$name = 'newcomer_' . $id . '_' . $uid . '_' . $is_promoter . '.jpg';
|
||||
$link = '/pages/activity/goods_details/index?type=7&id=' . $id . '&spid=' . $uid;
|
||||
break;
|
||||
case 90://用户码
|
||||
$code = $user['bar_code'];
|
||||
$third_type = 'user-' . $code . '-' . $uid;
|
||||
$name = 'user_' . $code . '_' . $uid . '.jpg';
|
||||
$id = $code;
|
||||
$link = '/pages/admin/order_cancellation/index?auth=3&code=' . $code;
|
||||
break;
|
||||
case 91://核销码
|
||||
$order_id = $request->param('order_id', '');
|
||||
/** @var StoreOrderServices $orderServices */
|
||||
$orderServices = app()->make(StoreOrderServices::class);
|
||||
$code = $orderServices->value(['order_id' => $order_id], 'verify_code');
|
||||
$third_type = 'write-off-' . $code . '-' . $uid;
|
||||
$name = 'write_off_' . $code . '_' . $uid . '.jpg';
|
||||
$id = $code;
|
||||
$link = '/pages/admin/order_cancellation/index?auth=3&code=' . $code;
|
||||
break;
|
||||
}
|
||||
if (sys_config('share_qrcode', 0) && request()->isWechat()) {
|
||||
if ($type == -1 && sys_config('spread_share_forever', 0)) {
|
||||
$wechatUrl = $this->services->getForeverQrcode($third_type, $uid)->url;
|
||||
} else {
|
||||
$wechatUrl = $this->services->getTemporaryQrcode($third_type, $uid)->url;
|
||||
}
|
||||
} else {
|
||||
$wechatUrl = $this->services->getWechatQrcodePath($name, $link);
|
||||
}
|
||||
$routineUrl = $this->services->getRoutineQrcodePath((int)$id, (int)$uid, (int)$type, $name);
|
||||
return app('json')->success(['routineUrl' => $routineUrl, 'wechatUrl' => $wechatUrl, 'site_name' => sys_config('site_name'), 'nickname' => $user['nickname'] ?? '']);
|
||||
}
|
||||
|
||||
}
|
||||
576
app/controller/api/v1/product/StoreProduct.php
Normal file
576
app/controller/api/v1/product/StoreProduct.php
Normal file
@@ -0,0 +1,576 @@
|
||||
<?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\product;
|
||||
|
||||
use app\Request;
|
||||
use app\services\activity\coupon\StoreCouponIssueServices;
|
||||
use app\services\activity\discounts\StoreDiscountsServices;
|
||||
use app\services\activity\promotions\StorePromotionsServices;
|
||||
use app\services\diy\DiyServices;
|
||||
use app\services\other\QrcodeServices;
|
||||
use app\services\product\category\StoreProductCategoryServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
use app\services\system\SystemRecommendServices;
|
||||
use app\services\user\UserServices;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 商品类
|
||||
* Class StoreProduct
|
||||
* @package app\api\controller\store
|
||||
*/
|
||||
class StoreProduct
|
||||
{
|
||||
/**
|
||||
* 商品services
|
||||
* @var StoreProductServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductServices $services;
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function lst(Request $request, StoreProductCategoryServices $services)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
[['sid', 'd'], 0],
|
||||
[['cid', 'd'], 0],
|
||||
[['tid', 'd'], 0],
|
||||
['keyword', '', '', 'store_name'],
|
||||
['priceOrder', ''],
|
||||
['salesOrder', ''],
|
||||
['defaultOrder', ''],
|
||||
[['news', 'd'], 0, '', 'is_new'],
|
||||
[['type', ''], '', '', 'status'],
|
||||
['ids', ''],
|
||||
[['selectId', 'd'], ''],
|
||||
['cate_id', ''],
|
||||
['productId', ''],
|
||||
['brand_id', ''],
|
||||
['promotions_id', 0],
|
||||
['promotions_type', 0],
|
||||
['store_label_id', 0],
|
||||
['store_label_id', 0],
|
||||
['is_channel', '', '', 'is_channel_product'],//是否采购商品
|
||||
['is_general_product', 1],
|
||||
['is_big', 0],//是否大图模式
|
||||
]);
|
||||
if ($where['selectId'] && (!$where['sid'] || !$where['cid'])) {
|
||||
$level = $services->value(['id' => (int)$where['selectId']], 'level') ?? 0;
|
||||
$levelArr = $services->cateField;
|
||||
$where[$levelArr[$level] ?? 'cid'] = $where['selectId'];
|
||||
}
|
||||
$where['ids'] = stringToIntArray($where['ids']);
|
||||
if (!$where['ids']) {
|
||||
unset($where['ids']);
|
||||
}
|
||||
$where['brand_id'] = stringToIntArray($where['brand_id']);
|
||||
$where['store_label_id'] = stringToIntArray($where['store_label_id']);
|
||||
|
||||
$cateId = $where['cate_id'];
|
||||
if ($cateId) {
|
||||
$cateId = is_string($cateId) ? stringToIntArray($where['cate_id']) : $cateId;
|
||||
$cateId = array_merge($cateId, $services->getColumn(['pid' => $cateId], 'id'));
|
||||
$cateId = array_unique(array_diff($cateId, [0]));
|
||||
}
|
||||
$where['cate_id'] = $cateId;
|
||||
|
||||
$type = $where['is_big'] ? 'big' : 'mid';
|
||||
unset($where['is_big']);
|
||||
$field = ['image', 'recommend_image'];
|
||||
if ($where['store_name']) {//搜索
|
||||
$field = ['image'];
|
||||
$where['pid'] = 0;
|
||||
}
|
||||
if ($where['is_channel_product'] == 1) {
|
||||
unset($where['is_general_product']);
|
||||
}
|
||||
$list = $this->services->getGoodsList($where, (int)$request->uid(), (int)$where['promotions_type']);
|
||||
return app('json')->successful(get_thumb_water($list, $type, $field));
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索获取商品品牌列表
|
||||
* @param Request $request
|
||||
* @param StoreProductCategoryServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
public function brand(Request $request, StoreProductCategoryServices $services)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
[['sid', 'd'], 0],
|
||||
[['cid', 'd'], 0],
|
||||
['keyword', '', '', 'store_name'],
|
||||
['priceOrder', ''],
|
||||
['salesOrder', ''],
|
||||
[['news', 'd'], 0, '', 'is_new'],
|
||||
[['type', ''], '', '', 'status'],
|
||||
['ids', ''],
|
||||
['selectId', ''],
|
||||
['productId', '']
|
||||
]);
|
||||
if ($where['selectId'] && (!$where['sid'] || !$where['cid'])) {
|
||||
if ($services->value(['id' => $where['selectId']], 'pid')) {
|
||||
$where['sid'] = $where['selectId'];
|
||||
} else {
|
||||
$where['cid'] = $where['selectId'];
|
||||
}
|
||||
}
|
||||
if ($where['ids'] && is_string($where['ids'])) {
|
||||
$where['ids'] = explode(',', $where['ids']);
|
||||
}
|
||||
if (!$where['ids']) {
|
||||
unset($where['ids']);
|
||||
}
|
||||
$where['type'] = [0, 2];
|
||||
return app('json')->successful($this->services->getBrandList($where, (int)$request->uid()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品搜索页面参数:活动、品牌、标签
|
||||
* @param Request $request
|
||||
* @param StoreProductCategoryServices $services
|
||||
* @return \think\Response
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function searchFilter(Request $request, StoreProductCategoryServices $services)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
[['sid', 'd'], 0],
|
||||
[['cid', 'd'], 0],
|
||||
['keyword', '', '', 'store_name'],
|
||||
[['news', 'd'], 0, '', 'is_new'],
|
||||
[['type', ''], '', '', 'status'],
|
||||
['ids', ''],
|
||||
['selectId', ''],
|
||||
['productId', ''],
|
||||
['promotions_id', 0],
|
||||
['promotions_type', 0],
|
||||
]);
|
||||
if ($where['selectId'] && (!$where['sid'] || !$where['cid'])) {
|
||||
$level = $services->value(['id' => (int)$where['selectId']], 'level') ?? 0;
|
||||
$levelArr = $services->cateField;
|
||||
$where[$levelArr[$level] ?? 'cid'] = $where['selectId'];
|
||||
}
|
||||
if ($where['ids'] && is_string($where['ids'])) {
|
||||
$where['ids'] = stringToIntArray($where['ids']);
|
||||
}
|
||||
if (!$where['ids']) {
|
||||
unset($where['ids']);
|
||||
}
|
||||
return app('json')->successful($this->services->searchFilter((int)$request->uid(), $where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取短链
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
* User: liusl
|
||||
* DateTime: 2024/11/23 下午3:11
|
||||
*/
|
||||
public function shortLink(Request $request, $id)
|
||||
{
|
||||
$id = (int)$id;
|
||||
if (!$id || !$this->services->isValidProduct($id)) {
|
||||
return app('json')->fail('商品不存在或已下架');
|
||||
}
|
||||
$uid = $request->uid() ?? '';
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
return app('json')->successful(['code' => $qrcodeService->getRoutineShortLink($id, (int)$uid)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品分享二维码 推广员
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function code(Request $request, $id)
|
||||
{
|
||||
$id = (int)$id;
|
||||
if (!$id || !$this->services->isValidProduct($id)) {
|
||||
return app('json')->fail('商品不存在或已下架');
|
||||
}
|
||||
$userType = $request->get('user_type', 'wechat');
|
||||
$user = $request->user() ?? [];
|
||||
$uid = $user['uid'] ?? 0;
|
||||
$is_promoter = $user['is_promoter'] ?? 0;
|
||||
try {
|
||||
switch ($userType) {
|
||||
case 'wechat':
|
||||
//公众号
|
||||
$name = $id . '_product_detail_' . $uid . '_is_promoter_' . $is_promoter . '_wap.jpg';
|
||||
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
if (sys_config('share_qrcode', 0) && request()->isWechat()) {
|
||||
$url = $qrcodeService->getTemporaryQrcode('product-' . $id . '-' . $uid, $uid)->url;
|
||||
} else {
|
||||
$url = $qrcodeService->getWechatQrcodePath($name, '/pages/goods_details/index?id=' . $id . '&spread=' . $uid . 'spid=' . $uid);
|
||||
}
|
||||
|
||||
if ($url === false)
|
||||
return app('json')->fail('二维码生成失败');
|
||||
else {
|
||||
// $codeTmp = $code = $url ? image_to_base64($url) : false;
|
||||
// if (!$codeTmp) {
|
||||
// $putCodeUrl = put_image($url);
|
||||
// $code = $putCodeUrl ? image_to_base64(app()->request->domain(true) . '/' . $putCodeUrl) : false;
|
||||
// $code ?? unlink(public_path() . $putCodeUrl);
|
||||
// }
|
||||
return app('json')->successful(['code' => $url]);
|
||||
}
|
||||
break;
|
||||
case 'routine':
|
||||
$name = $id . '_' . $uid . '_' . $is_promoter . '_product.jpg';
|
||||
/** @var QrcodeServices $qrcodeService */
|
||||
$qrcodeService = app()->make(QrcodeServices::class);
|
||||
$url = $qrcodeService->getRoutineQrcodePath($id, (int)$uid, 0, $name);
|
||||
if ($url === false)
|
||||
return app('json')->fail('二维码生成失败');
|
||||
else
|
||||
return app('json')->successful(['code' => $url]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return app('json')->fail($e->getMessage(), [
|
||||
'code' => $e->getCode(),
|
||||
'line' => $e->getLine(),
|
||||
'message' => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品详情
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @param int $type
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail(Request $request, $id, $type = 0)
|
||||
{
|
||||
[$promotions_type, $is_channel_product] = $request->getMore([
|
||||
[['promotions_type', 'd'], 0],
|
||||
['is_channel_product', 0]
|
||||
], true);
|
||||
$data = $this->services->productDetail((int)$request->uid(), (int)$id, (int)$type, (int)$promotions_type, (int)$is_channel_product);
|
||||
return app('json')->successful($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品的详情内容
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2022/11/28
|
||||
*/
|
||||
public function detailContent($id)
|
||||
{
|
||||
$productInfo = $this->services->getCacheProductInfo((int)$id);
|
||||
return app('json')->success(['description' => $productInfo['description'] ?? '']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 推荐商品列表
|
||||
* @param Request $request
|
||||
* @param DiyServices $diyServices
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function recommend(Request $request, DiyServices $diyServices, $id)
|
||||
{
|
||||
$list = [];
|
||||
$diy = $diyServices->getProductDetailDiy();
|
||||
//推荐开启
|
||||
if (isset($diy['showRecommend']) && $diy['showRecommend']) {
|
||||
$num = (int)($diy['recommendNum'] ?? 12);
|
||||
$storeInfo = [];
|
||||
if ($id) {
|
||||
$storeInfo = $this->services->getCacheProductInfo((int)$id);
|
||||
}
|
||||
$uid = $request->uid();
|
||||
$where = [];
|
||||
$where['is_vip_product'] = 0;
|
||||
if ($uid) {
|
||||
$is_vip = $request->user('is_money_level');
|
||||
$where['is_vip_product'] = $is_vip ? -1 : 0;
|
||||
}
|
||||
//推荐
|
||||
if (isset($storeInfo['recommend_list']) && $storeInfo['recommend_list']) {
|
||||
$recommend_list = explode(',', $storeInfo['recommend_list']);
|
||||
$list = get_thumb_water($this->services->getProducts(['ids' => $recommend_list, 'is_del' => 0, 'is_show' => 1] + $where, '', $num, ['couponId']));
|
||||
} else {
|
||||
$list = get_thumb_water($this->services->getProducts(['is_good' => 1, 'is_del' => 0, 'is_show' => 1] + $where, 'rand()', $num, ['couponId']));
|
||||
}
|
||||
}
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品关联活动信息
|
||||
* @param Request $request
|
||||
* @param StoreCouponIssueServices $couponIssueServices
|
||||
* @param StoreDiscountsServices $storeDiscountsServices
|
||||
* @param StorePromotionsServices $storePromotionsServices
|
||||
* @param DiyServices $diyServices
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function activity(Request $request, StoreCouponIssueServices $couponIssueServices, StoreDiscountsServices $storeDiscountsServices, StorePromotionsServices $storePromotionsServices, DiyServices $diyServices, $id)
|
||||
{
|
||||
[$promotions_type, $unique] = $request->getMore([
|
||||
[['promotions_type', 'd'], 0],
|
||||
['unique', '']
|
||||
], true);
|
||||
$storeInfo = [];
|
||||
$id = (int)$id;
|
||||
if ($id) {
|
||||
$storeInfo = $this->services->getCacheProductInfo($id);
|
||||
}
|
||||
$uid = $request->hasMacro('uid') ? (int)$request->uid() : 0;
|
||||
$data = ['activity' => [], 'coupons' => [], 'discounts_products' => [], 'promotions' => [], 'activity_background' => [], 'computed' => ['deduction' => []]];
|
||||
//预售不参与
|
||||
if (!$storeInfo || $storeInfo['is_presale_product']) {
|
||||
return app('json')->success($data);
|
||||
}
|
||||
$diy = $diyServices->getProductDetailDiy();
|
||||
if (isset($diy['showService']) && in_array(0, $diy['showService']))
|
||||
$data['activity'] = $this->services->getActivityList($storeInfo, false);
|
||||
$data['coupons'] = $couponIssueServices->getProductCouponList($uid, $id, 'id,type,coupon_type,coupon_title,coupon_price,use_min_price,coupon_time,start_time,end_time,rule', 20);
|
||||
foreach ($data['coupons'] as $key => $item) {
|
||||
if ($item['use_status'] != 1) {
|
||||
unset($data['coupons'][$key]);
|
||||
}
|
||||
}
|
||||
$data['coupons'] = array_values($data['coupons']);
|
||||
if (isset($diy['showMatch']) && $diy['showMatch']) {
|
||||
$num = (int)($diy['matchNum'] ?? 2);
|
||||
$data['discounts_products'] = $storeDiscountsServices->getDiscounts($id, $uid, $num, 'id,type,title,image,is_limit,limit_num,product_ids');
|
||||
if ($data['discounts_products']) {
|
||||
foreach ($data['discounts_products'] as &$item) {
|
||||
$products = [];
|
||||
if (isset($item['products']) && $item['products']) {
|
||||
foreach ($item['products'] as $product) {
|
||||
$products[] = ['id' => $product['id'] ?? '', 'store_name' => $product['store_name'] ?? $product['title'] ?? '', 'image' => $product['image']];
|
||||
}
|
||||
}
|
||||
$item['products'] = $products;
|
||||
}
|
||||
unset($item);
|
||||
}
|
||||
}
|
||||
if (isset($diy['showService']) && in_array(0, $diy['showService'])) {//商品详情开启活动
|
||||
$promotions_type = $promotions_type ? [(int)$promotions_type] : [1, 2, 3, 4, 6];
|
||||
} else {
|
||||
$promotions_type = $promotions_type ? [(int)$promotions_type] : [6];
|
||||
}
|
||||
$ids = $storeInfo['pid'] ? [$storeInfo['pid']] : [$id];
|
||||
[$promotions, $productRelation] = $storePromotionsServices->getProductsPromotions($ids, $promotions_type, '*', ['giveProducts' => function ($query) {
|
||||
$query->field('promotions_id,product_id,limit_num,surplus_num')->with(['productInfo' => function ($query) {
|
||||
$query->field('id,store_name,image');
|
||||
}]);
|
||||
}, 'giveCoupon' => function ($query) {
|
||||
$query->field('promotions_id,coupon_id,limit_num,surplus_num')->with(['coupon' => function ($query) {
|
||||
$query->field('id,type,coupon_type,coupon_title,coupon_price,use_min_price');
|
||||
}]);
|
||||
}, 'promotions' => function ($query) {
|
||||
$query->field('id,pid,promotions_type,promotions_cate,threshold_type,threshold,discount_type,n_piece_n_discount,discount,give_integral,give_coupon_id,give_product_id,give_product_unique')->with(['giveProducts' => function ($query) {
|
||||
$query->field('promotions_id, product_id,limit_num,surplus_num')->with(['productInfo' => function ($query) {
|
||||
$query->field('id,store_name');
|
||||
}]);
|
||||
}, 'giveCoupon' => function ($query) {
|
||||
$query->field('promotions_id, coupon_id,limit_num,surplus_num')->with(['coupon' => function ($query) {
|
||||
$query->field('id,type,coupon_type,coupon_title,coupon_price,use_min_price');
|
||||
}]);
|
||||
}]);
|
||||
}], 'promotions_type');
|
||||
if ($promotions) {
|
||||
foreach ($promotions as $key => $item) {
|
||||
|
||||
if ($item['promotions_type'] == 6) {
|
||||
$data['activity_background'] = ['id' => $item['id'], 'name' => $item['name'], 'image' => $item['image']];
|
||||
} else {
|
||||
$data['promotions'][] = [
|
||||
'id' => $item['id'],
|
||||
'type' => $item['type'],
|
||||
'title' => $item['title'],
|
||||
'name' => $item['name'],
|
||||
'give_integral' => $item['give_integral'],
|
||||
'promotions_type' => $item['promotions_type'],
|
||||
'threshold_type' => $item['threshold_type'],
|
||||
'threshold' => $item['threshold'],
|
||||
'discount_type' => $item['discount_type'],
|
||||
'discount' => $item['discount'],
|
||||
'desc' => $item['desc'],
|
||||
'start_time' => $item['start_time'] ? date('Y-m-d', $item['start_time']) : '',
|
||||
'stop_time' => $item['stop_time'] ? date('Y-m-d', $item['stop_time']) : '',
|
||||
'giveProducts' => $item['giveProducts'] ?? [],
|
||||
'giveCoupon' => $item['giveCoupon'] ?? []
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
$computed = $this->services->computedProductPayPrice($uid, $id, $unique);
|
||||
$data['computed'] = $computed;
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为你推荐
|
||||
* @param Request $request
|
||||
* @param UserServices $userServices
|
||||
* @return mixed
|
||||
*/
|
||||
public function product_hot(Request $request, UserServices $userServices)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
$vip_user = $userServices->checkUserIsSvip($uid) ? -1 : 0;
|
||||
$where = ['is_show' => 1, 'is_del' => 0, 'is_verify' => 1, 'is_vip_product' => $vip_user];
|
||||
$type = $request->get('type', 0);
|
||||
if ($type == 0) {
|
||||
$where = $where + ['is_hot' => 1];
|
||||
$title = '为您推荐';
|
||||
} else {
|
||||
[$title, $recommendProductIds] = app()->make(SystemRecommendServices::class)->getRecommendProductIds($type, $uid);
|
||||
if (count($recommendProductIds)) {
|
||||
$where = $where + ['ids' => $recommendProductIds];
|
||||
} else {
|
||||
$where = $where + ['is_hot' => 1];
|
||||
}
|
||||
}
|
||||
$list = $this->services->getProducts($where, '', 0, ['couponId']);
|
||||
$count = count($list);
|
||||
$limit = $request->get('limit', 10);
|
||||
$page = $request->get('page', 1);
|
||||
if ($count < $limit && $page == 1) {
|
||||
$where = ['is_show' => 1, 'is_del' => 0, 'is_verify' => 1, 'is_vip_product' => $vip_user, 'is_hot' => 1];
|
||||
$list = array_merge($list, $this->services->getProducts($where, '', 20, ['couponId']));
|
||||
// 用于存储已经处理过的id
|
||||
$seenIds = [];
|
||||
$uniqueData = [];
|
||||
foreach ($list as $item) {
|
||||
$id = $item['id'];
|
||||
if (!isset($seenIds[$id])) {
|
||||
$seenIds[$id] = true;
|
||||
$uniqueData[] = $item;
|
||||
|
||||
// 如果已经取到10个唯一项,提前退出循环
|
||||
if (count($uniqueData) === 10) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$list = $uniqueData;
|
||||
}
|
||||
$list = get_thumb_water($list, 'mid');
|
||||
return app('json')->success(compact('list', 'title'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页推荐不同类型商品的轮播图和商品
|
||||
* @param Request $request
|
||||
* @param $type
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function groom_list(Request $request, $type)
|
||||
{
|
||||
$info['banner'] = [];
|
||||
$info['list'] = [];
|
||||
$uid = (int)$request->uid();
|
||||
$where = [];
|
||||
if ($type == 1) {// 精品推荐
|
||||
$info['banner'] = sys_data('routine_home_bast_banner') ?: [];// 首页精品推荐图片
|
||||
$where['is_best'] = 1;
|
||||
} else if ($type == 2) {// 热门榜单
|
||||
$info['banner'] = sys_data('routine_home_hot_banner') ?: [];// 热门榜单 猜你喜欢推荐图片
|
||||
$where['is_hot'] = 1;
|
||||
} else if ($type == 3) {// 首发新品
|
||||
$info['banner'] = sys_data('routine_home_new_banner') ?: [];// 首发新品推荐图片
|
||||
$where['is_new'] = 1;
|
||||
} else if ($type == 4) {// 促销单品
|
||||
$info['banner'] = sys_data('routine_home_benefit_banner') ?: [];// 促销单品推荐图片
|
||||
$where['is_benefit'] = 1;
|
||||
} else if ($type == 5) {// 会员商品
|
||||
$where['is_vip'] = 1;
|
||||
}
|
||||
$info['list'] = $this->services->getRecommendProduct($uid, $where);
|
||||
return app('json')->successful($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预售列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function presaleList(Request $request)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
[['time_type', 'd'], 0],
|
||||
['limit', 0],
|
||||
]);
|
||||
$uid = (int)$request->uid();
|
||||
$limit = (int)$where['limit'];
|
||||
unset($where['limit']);
|
||||
return app('json')->successful($this->services->getPresaleList($uid, $where, $limit));
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索页面推荐排序商品
|
||||
* @param Request $request
|
||||
* @param $type
|
||||
* @return \think\Response
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws \throwable
|
||||
*/
|
||||
public function searchRecommendList(Request $request, $type)
|
||||
{
|
||||
$uid = 0;
|
||||
if ($request->hasMacro('uid')) $uid = $request->uid();
|
||||
$order = match ((int)$type) {
|
||||
1 => 'sales desc, sort desc, id desc',//销量
|
||||
2 => 'star desc, sort desc, id desc',//评分
|
||||
3 => 'collect desc, sort desc, id desc',//收藏
|
||||
default => 'sales desc, sort desc, id desc',
|
||||
};
|
||||
return app('json')->successful($this->services->getRecommendProduct($uid, [], 8, 'small', $order));
|
||||
}
|
||||
}
|
||||
69
app/controller/api/v1/product/StoreProductCategory.php
Normal file
69
app/controller/api/v1/product/StoreProductCategory.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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\product;
|
||||
|
||||
use app\services\product\category\StoreProductCategoryServices;
|
||||
use think\annotation\Inject;
|
||||
use think\Request;
|
||||
|
||||
/**
|
||||
* Class StoreProductCategory
|
||||
* @package app\api\controller\v1\store
|
||||
*/
|
||||
class StoreProductCategory
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreProductCategoryServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductCategoryServices $services;
|
||||
|
||||
/**
|
||||
* 获取分类列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function category(Request $request)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['pid', 0],
|
||||
]);
|
||||
$category = $this->services->getCategory($where);
|
||||
return app('json')->success($category);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取同级的所有分类
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function levelCategory(Request $request)
|
||||
{
|
||||
[$id] = $request->getMore([
|
||||
['id', 0],
|
||||
], true);
|
||||
if (!$id) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
return app('json')->success($this->services->getLevelCategory((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2022/11/11
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCategoryVersion()
|
||||
{
|
||||
return app('json')->success(['version' => $this->services->getCategoryVersion()]);
|
||||
}
|
||||
}
|
||||
80
app/controller/api/v1/product/StoreProductRank.php
Normal file
80
app/controller/api/v1/product/StoreProductRank.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?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\product;
|
||||
|
||||
use app\Request;
|
||||
use app\services\product\category\StoreProductCategoryServices;
|
||||
use app\services\product\product\StoreProductRankServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 商品榜单
|
||||
* Class StoreProductRank
|
||||
* @package app\api\controller\product
|
||||
*/
|
||||
class StoreProductRank
|
||||
{
|
||||
/**
|
||||
* 商品services
|
||||
* @var StoreProductServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductServices $services;
|
||||
|
||||
|
||||
/**
|
||||
* 获取绑定分类
|
||||
* @param StoreProductCategoryServices $services
|
||||
* @return \think\Response
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function rankCategory(StoreProductCategoryServices $services)
|
||||
{
|
||||
return app('json')->successful($services->getRankCategory());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取榜单列表
|
||||
* @param Request $request
|
||||
* @param StoreProductCategoryServices $services
|
||||
* @param StoreProductRankServices $productRankServices
|
||||
* @param $type
|
||||
* @return \think\Response
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws \throwable
|
||||
*/
|
||||
public function rankList(Request $request, StoreProductCategoryServices $services, StoreProductRankServices $productRankServices,$type)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
[['selectId', 'd'], ''],
|
||||
]);
|
||||
if ($where['selectId']) {
|
||||
$level = $services->value(['id' => (int)$where['selectId']], 'level') ?? 0;
|
||||
$levelArr = $services->cateField;
|
||||
$where[$levelArr[$level] ?? 'cid'] = $where['selectId'];
|
||||
unset($where['selectId']);
|
||||
}
|
||||
$uid = 0;
|
||||
if ($request->hasMacro('uid')) $uid = (int)$request->uid();
|
||||
return app('json')->successful($productRankServices->getProductRankList($uid, (int)$type, $where));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
217
app/controller/api/v1/product/StoreProductReply.php
Normal file
217
app/controller/api/v1/product/StoreProductReply.php
Normal file
@@ -0,0 +1,217 @@
|
||||
<?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\product;
|
||||
|
||||
use app\Request;
|
||||
use app\services\product\product\StoreProductReplyCommentServices;
|
||||
use app\services\product\product\StoreProductReplyServices;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 商品评价类
|
||||
* Class StoreProductReplyController
|
||||
* @package app\api\controller\store
|
||||
*/
|
||||
class StoreProductReply
|
||||
{
|
||||
/**
|
||||
* 商品services
|
||||
* @var StoreProductReplyServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductReplyServices $services;
|
||||
|
||||
|
||||
/**
|
||||
* 商品评价数量和好评度
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function reply_config($id)
|
||||
{
|
||||
/** @var StoreProductReplyServices $replyService */
|
||||
$replyService = app()->make(StoreProductReplyServices::class);
|
||||
$count = $replyService->productReplyCount((int)$id);
|
||||
return app('json')->successful($count);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品评论
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @param $type
|
||||
* @return mixed
|
||||
*/
|
||||
public function reply_list(Request $request, $id)
|
||||
{
|
||||
[$type] = $request->getMore([
|
||||
[['type', 'd'], 0]
|
||||
], true);
|
||||
/** @var StoreProductReplyServices $replyService */
|
||||
$replyService = app()->make(StoreProductReplyServices::class);
|
||||
$list = $replyService->getProductReplyList((int)$id, (int)$type);
|
||||
return app('json')->successful(get_thumb_water($list, 'small', ['pics']));
|
||||
}
|
||||
|
||||
/**
|
||||
* 评价详情
|
||||
* @param StoreProductReplyServices $services
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function replyInfo(StoreProductReplyServices $services, Request $request, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数');
|
||||
}
|
||||
return app('json')->success($services->getReplyInfo((int)$id, (int)$request->uid()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 评论回复列表
|
||||
* @param StoreProductReplyCommentServices $services
|
||||
* @param Request $request
|
||||
* @param $id 评论id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function commentList(StoreProductReplyCommentServices $services, Request $request, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数');
|
||||
}
|
||||
$data = $services->getReplCommenList((int)$id, '', (int)$request->uid(), false);
|
||||
return app('json')->success($data['list']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存评论回复
|
||||
* @param Request $request
|
||||
* @param StoreProductReplyCommentServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function replyComment(Request $request, StoreProductReplyCommentServices $services, $id)
|
||||
{
|
||||
[$content] = $request->postMore([
|
||||
['content', '']
|
||||
], true);
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数');
|
||||
}
|
||||
if (!$content) {
|
||||
return app('json')->fail('缺少回复内容');
|
||||
}
|
||||
$services->saveComment((int)$request->uid(), (int)$id, $content);
|
||||
return app('json')->success('回复成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 回复点赞
|
||||
* @param Request $request
|
||||
* @param StoreProductReplyCommentServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function commentPraise(Request $request, StoreProductReplyCommentServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数');
|
||||
}
|
||||
|
||||
if ($services->commentPraise((int)$id, (int)$request->uid())) {
|
||||
return app('json')->success('点赞成功');
|
||||
} else {
|
||||
return app('json')->fail('点赞失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消回复点赞
|
||||
* @param Request $request
|
||||
* @param StoreProductReplyCommentServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function unCommentPraise(Request $request, StoreProductReplyCommentServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数');
|
||||
}
|
||||
|
||||
if ($services->unCommentPraise((int)$id, (int)$request->uid())) {
|
||||
return app('json')->success('取消点赞成功');
|
||||
} else {
|
||||
return app('json')->fail('取消点赞失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 点赞
|
||||
* @param Request $request
|
||||
* @param StoreProductReplyServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function replyPraise(Request $request, StoreProductReplyServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数');
|
||||
}
|
||||
if ($services->replyPraise((int)$id, (int)$request->uid())) {
|
||||
return app('json')->success('点赞成功');
|
||||
} else {
|
||||
return app('json')->fail('点赞失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消点赞
|
||||
* @param Request $request
|
||||
* @param StoreProductReplyServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function unReplyPraise(Request $request, StoreProductReplyServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数');
|
||||
}
|
||||
if ($services->unReplyPraise((int)$id, (int)$request->uid())) {
|
||||
return app('json')->success('取消点赞成功');
|
||||
} else {
|
||||
return app('json')->fail('取消点赞失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
121
app/controller/api/v1/publics/Article.php
Normal file
121
app/controller/api/v1/publics/Article.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?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\publics;
|
||||
|
||||
use app\Request;
|
||||
use app\services\article\ArticleServices;
|
||||
use app\services\wechat\WechatNewsCategoryServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 文章类
|
||||
* Class Article
|
||||
* @package app\api\controller\publics
|
||||
*/
|
||||
class Article
|
||||
{
|
||||
/**
|
||||
* @var ArticleServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected ArticleServices $services;
|
||||
|
||||
/**
|
||||
* 文章列表
|
||||
* @param WechatNewsCategoryServices $services
|
||||
* @param $cid
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function lst(WechatNewsCategoryServices $services, $cid)
|
||||
{
|
||||
[$page, $limit] = $this->services->getPageValue();
|
||||
$where = ['cid' => $cid];
|
||||
$where['ids'] = $services->getNewIds();
|
||||
$list = $this->services->cidByArticleList($where, $page, $limit, "id,title,image_input,visit,likes,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url");
|
||||
return app('json')->successful($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章点赞 添加、取消
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function userArticleLikes(Request $request, $id)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['status', 0]
|
||||
]);
|
||||
$uid = $request->uid();
|
||||
$info = $this->services->userArticleLikes($id, $where, $uid);
|
||||
return app('json')->successful($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章详情
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function details(Request $request, $id)
|
||||
{
|
||||
$uid = $request->uid();
|
||||
$info = $this->services->getInfo($uid, $id);
|
||||
return app('json')->successful($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取热门文章
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function hot()
|
||||
{
|
||||
[$page, $limit] = $this->services->getPageValue();
|
||||
$list = $this->services->cidByArticleList(['is_hot' => 1], $page, $limit, "id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url");
|
||||
return app('json')->successful($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最新文章
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function new()
|
||||
{
|
||||
[$page, $limit] = $this->services->getPageValue();
|
||||
$list = $this->services->cidByArticleList([], $page, $limit, "id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url");
|
||||
return app('json')->successful($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取顶部banner文章
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function banner()
|
||||
{
|
||||
[$page, $limit] = $this->services->getPageValue();
|
||||
$list = $this->services->cidByArticleList(['is_banner' => 1], $page, $limit, "id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url");
|
||||
return app('json')->successful($list);
|
||||
}
|
||||
}
|
||||
47
app/controller/api/v1/publics/ArticleCategory.php
Normal file
47
app/controller/api/v1/publics/ArticleCategory.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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\publics;
|
||||
|
||||
use app\services\article\ArticleCategoryServices;
|
||||
use crmeb\services\CacheService;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 文章分类类
|
||||
* Class ArticleCategoryController
|
||||
* @package app\api\controller\publics
|
||||
*/
|
||||
class ArticleCategory
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ArticleCategoryServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected ArticleCategoryServices $services;
|
||||
|
||||
/**
|
||||
* 文章分类列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function lst()
|
||||
{
|
||||
$cateInfo = CacheService::get('ARTICLE_CATEGORY', function () {
|
||||
$cateInfo = $this->services->getArticleCategory();
|
||||
array_unshift($cateInfo, ['id' => 0, 'title' => '热门']);
|
||||
return $cateInfo;
|
||||
});
|
||||
return app('json')->successful($cateInfo);
|
||||
}
|
||||
}
|
||||
116
app/controller/api/v1/store/Store.php
Normal file
116
app/controller/api/v1/store/Store.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?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\store;
|
||||
|
||||
|
||||
use app\services\order\StoreOrderStatusServices;
|
||||
use app\services\store\SystemStoreServices;
|
||||
use app\services\store\SystemStoreStaffServices;
|
||||
use app\Request;
|
||||
use think\annotation\Inject;
|
||||
use think\facade\Log;
|
||||
use think\Response;
|
||||
|
||||
/**
|
||||
* Class StoreController
|
||||
* @package app\api\controller\v1\store
|
||||
*/
|
||||
class Store
|
||||
{
|
||||
|
||||
/**
|
||||
* @var SystemStoreServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected SystemStoreServices $services;
|
||||
|
||||
|
||||
/**
|
||||
* 获取门店列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getStoreList(Request $request)
|
||||
{
|
||||
[$store_type, $keywords, $latitude, $longitude] = $request->getMore([
|
||||
['store_type', 1],
|
||||
['keyword', ''],
|
||||
['latitude', ''],
|
||||
['longitude', '']
|
||||
], true);
|
||||
if (!checkCoordinates($longitude, $latitude)) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
$where = ['uid' => (int)$request->uid(), 'store_type' => $store_type, 'keywords' => $keywords];
|
||||
$storeList = [];
|
||||
//开启门店
|
||||
if (sys_config('store_func_status', 1)) {
|
||||
$storeList = $this->services->getNearbyStore($where, $latitude, $longitude, $request->ip());
|
||||
}
|
||||
return app('json')->success($storeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取门店客服列表
|
||||
* @param SystemStoreStaffServices $staffServices
|
||||
* @param $store_id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getCustomerList(SystemStoreStaffServices $staffServices, $store_id)
|
||||
{
|
||||
$customer = [];
|
||||
if ($store_id) {
|
||||
$customer = $staffServices->getCustomerList((int)$store_id, 'id,store_id,staff_name,avatar,customer_phone,customer_url');
|
||||
}
|
||||
return app('json')->success($customer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客服详情
|
||||
* @param SystemStoreStaffServices $staffServices
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getCustomerInfo(SystemStoreStaffServices $staffServices, $id)
|
||||
{
|
||||
$info = [];
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数');
|
||||
}
|
||||
$info = $staffServices->getStaffInfo((int)$id, 'id,store_id,staff_name,avatar,customer_phone,customer_url');
|
||||
if (!$info) {
|
||||
return app('json')->fail('客服不存在');
|
||||
}
|
||||
$info = $info->toArray();
|
||||
$storeInfo = $this->services->getStoreInfo((int)$info['store_id']);
|
||||
$info['store_name'] = $storeInfo['name'] ?? '';
|
||||
$info['address'] = $storeInfo['address'] ?? '';
|
||||
$info['detailed_address'] = $storeInfo['detailed_address'] ?? '';
|
||||
$info['latitude'] = $storeInfo['latitude'] ?? '';
|
||||
$info['longitude'] = $storeInfo['longitude'] ?? '';
|
||||
$info['day_time'] = $storeInfo['day_time'] ?? '';
|
||||
$info['day_start'] = $storeInfo['day_start'] ?? '';
|
||||
$info['day_end'] = $storeInfo['day_end'] ?? '';
|
||||
return app('json')->success($info);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
42
app/controller/api/v1/store/StoreProductCategory.php
Normal file
42
app/controller/api/v1/store/StoreProductCategory.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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\store;
|
||||
|
||||
use app\services\product\category\StoreProductCategoryServices;
|
||||
use think\annotation\Inject;
|
||||
use think\Request;
|
||||
|
||||
/**
|
||||
* Class StoreProductCategory
|
||||
* @package app\api\controller\v1\store
|
||||
*/
|
||||
class StoreProductCategory
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreProductCategoryServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductCategoryServices $services;
|
||||
|
||||
/**
|
||||
* 获取分类列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function category(Request $request)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['pid', 0],
|
||||
]);
|
||||
$category = $this->services->getCategory($where);
|
||||
return app('json')->success($category);
|
||||
}
|
||||
}
|
||||
131
app/controller/api/v1/system/UserApply.php
Normal file
131
app/controller/api/v1/system/UserApply.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?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\system;
|
||||
|
||||
use app\Request;
|
||||
use app\services\supplier\SystemSupplierServices;
|
||||
use app\services\system\admin\SystemAdminServices;
|
||||
use app\services\system\SystemUserApplyServices;
|
||||
use app\validate\api\user\UserApplyValidate;
|
||||
use crmeb\services\CacheService;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
|
||||
/**
|
||||
* 用户申请类
|
||||
* Class UserApplyController
|
||||
* @package app\controller\api\v1\system
|
||||
*/
|
||||
class UserApply
|
||||
{
|
||||
protected $services = NUll;
|
||||
|
||||
/**
|
||||
* UserExtractController constructor.
|
||||
* @param SystemUserApplyServices $services
|
||||
*/
|
||||
public function __construct(SystemUserApplyServices $services)
|
||||
{
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个申请详情
|
||||
* @param Request $request
|
||||
* @param SystemSupplierServices $supplierServices
|
||||
* @param SystemAdminServices $adminServices
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getInfo(Request $request, SystemSupplierServices $supplierServices, SystemAdminServices $adminServices, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数');
|
||||
}
|
||||
$info = $this->services->get((int)$id);
|
||||
if (!$info || $info['uid'] != $request->uid()) {
|
||||
return app('json')->fail('数据不存在');
|
||||
}
|
||||
$info = $info->toArray();
|
||||
$data = ['url' => sys_config('site_url') . '/' . config('admin.supplier_prefix'), 'account' => '', 'pwd' => ''];
|
||||
if ($info['status'] == 1 && $info['relation_id']) {//审核通过
|
||||
$data['account'] = $info['phone'];
|
||||
$supplierInfo = $supplierServices->get(['id' => $info['relation_id']], ['id', 'admin_id']);
|
||||
if ($supplierInfo) {
|
||||
$adminInfo = $adminServices->get(['id' => $supplierInfo['admin_id']], ['id', 'account']);
|
||||
if ($adminInfo) $data['account'] = $adminInfo['account'] ?? '';
|
||||
}
|
||||
$data['pwd'] = substr($info['phone'], -6);
|
||||
}
|
||||
$info['add_time'] = $info['add_time'] ? date('Y-m-d H:i', $info['add_time']) : '';
|
||||
$info['status_time'] = $info['status_time'] ? date('Y-m-d H:i', $info['status_time']) : '';
|
||||
$info = array_merge($info, $data);
|
||||
return app('json')->success($info);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 申请供应商
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function userApply(Request $request, $id)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['name', ''],//用户名称
|
||||
['phone', ''],//手机号
|
||||
['system_name', ''],//供应商名称
|
||||
['captcha', ''],//验证码
|
||||
['images', []],//资质图片
|
||||
]);
|
||||
//验证手机号
|
||||
try {
|
||||
validate(UserApplyValidate::class)->check($data);
|
||||
} catch (ValidateException $e) {
|
||||
return app('json')->fail($e->getError());
|
||||
}
|
||||
$captcha = $data['captcha'];
|
||||
unset($data['captcha']);
|
||||
|
||||
if (sys_config('supplier_apply_phone_verify') == 1) {
|
||||
//验证验证码
|
||||
$verifyCode = CacheService::get('code_' . $data['phone']);
|
||||
if (!$verifyCode)
|
||||
return app('json')->fail('请先获取验证码');
|
||||
$verifyCode = substr($verifyCode, 0, 6);
|
||||
if ($verifyCode != $captcha) {
|
||||
return app('json')->fail('验证码错误');
|
||||
}
|
||||
}
|
||||
|
||||
$res = $this->services->saveApply((int)$id, (int)$request->uid(), $data);
|
||||
if ($res) {
|
||||
CacheService::delete('code_' . $data['phone']);
|
||||
return app('json')->successful('申请成功!', ['id' => $res]);
|
||||
}
|
||||
return app('json')->fail('申请失败!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取申请记录
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function userApplyRecord(Request $request)
|
||||
{
|
||||
return app('json')->success($this->services->getUserApply((int)$request->uid()));
|
||||
}
|
||||
|
||||
}
|
||||
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('设置成功');
|
||||
}
|
||||
}
|
||||
111
app/controller/api/v1/wechat/Routine.php
Normal file
111
app/controller/api/v1/wechat/Routine.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?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\wechat;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\activity\live\LiveRoomServices;
|
||||
use app\services\wechat\RoutineServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 小程序相关
|
||||
* Class Routine
|
||||
* @package app\controller\api\v1\wechat
|
||||
*/
|
||||
class Routine
|
||||
{
|
||||
|
||||
/**
|
||||
* @var RoutineServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected RoutineServices $services;
|
||||
|
||||
/**
|
||||
* 小程序授权登录
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function mp_auth(Request $request)
|
||||
{
|
||||
[$code, $cache_key, $login_type, $spread_spid, $spread_code, $iv, $encryptedData] = $request->postMore([
|
||||
['code', ''],
|
||||
['cache_key', ''],
|
||||
['login_type', ''],
|
||||
['spread_spid', 0],
|
||||
['spread_code', ''],
|
||||
['iv', ''],
|
||||
['encryptedData', ''],
|
||||
], true);
|
||||
$token = $this->services->mp_auth($code, $cache_key, $login_type, $spread_spid, $spread_code, $iv, $encryptedData);
|
||||
if ($token) {
|
||||
if (isset($token['key']) && $token['key']) {
|
||||
return app('json')->successful('授权成功,请绑定手机号', $token);
|
||||
} else {
|
||||
return app('json')->successful('登录成功!', [
|
||||
'userInfo' => $token['userInfo']
|
||||
]);
|
||||
}
|
||||
} else
|
||||
return app('json')->fail('获取用户访问token失败!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取授权logo
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_logo()
|
||||
{
|
||||
$logo = sys_config('wap_login_logo');
|
||||
if (strstr($logo, 'http') === false && $logo) $logo = sys_config('site_url') . $logo;
|
||||
return app('json')->successful(['logo_url' => str_replace('\\', '/', $logo)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序订阅消息id
|
||||
* @return mixed
|
||||
*/
|
||||
public function teml_ids()
|
||||
{
|
||||
return app('json')->success($this->services->temlIds());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序直播列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function live(Request $request, LiveRoomServices $liveRoom)
|
||||
{
|
||||
[$limit] = $request->getMore([
|
||||
['limit', 0],
|
||||
], true);
|
||||
return app('json')->success($liveRoom->userList([], (int)$limit));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取直播回放
|
||||
* @param $id
|
||||
* @param LiveRoomServices $lvieRoom
|
||||
* @return mixed
|
||||
*/
|
||||
public function livePlaybacks($id, LiveRoomServices $lvieRoom)
|
||||
{
|
||||
return app('json')->success($lvieRoom->getPlaybacks((int)$id));
|
||||
}
|
||||
}
|
||||
160
app/controller/api/v1/wechat/Wechat.php
Normal file
160
app/controller/api/v1/wechat/Wechat.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?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\wechat;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\wechat\RoutineServices;
|
||||
use app\services\wechat\WechatServices as WechatAuthServices;
|
||||
use crmeb\services\CacheService;
|
||||
use crmeb\services\wechat\OfficialAccount;
|
||||
use crmeb\services\wechat\Work;
|
||||
use EasyWeChat\Kernel\Exceptions\BadRequestException;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
|
||||
use think\annotation\Inject;
|
||||
use think\Response;
|
||||
|
||||
/**
|
||||
* 微信公众号
|
||||
* Class Wechat
|
||||
* @package app\api\controller\wechat
|
||||
*/
|
||||
class Wechat
|
||||
{
|
||||
/**
|
||||
* @var WechatAuthServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected WechatAuthServices $services;
|
||||
|
||||
/**
|
||||
* 微信公众号服务
|
||||
* @return Response
|
||||
* @throws BadRequestException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws InvalidConfigException
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function serve()
|
||||
{
|
||||
return $this->services->serve();
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信小程序公众号服务
|
||||
* @param RoutineServices $routineServices
|
||||
* @return Response
|
||||
*/
|
||||
public function miniServe(RoutineServices $routineServices)
|
||||
{
|
||||
return $routineServices->serve();
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业微信服务
|
||||
* @return Response
|
||||
* @throws BadRequestException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws InvalidConfigException
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function work()
|
||||
{
|
||||
return $this->services->workServe();
|
||||
}
|
||||
|
||||
/**
|
||||
* 公众号权限配置信息获取
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function config(Request $request)
|
||||
{
|
||||
$url = $request->get('url', '') ?: sys_config('site_url');
|
||||
return app('json')->success($this->services->config($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* 公众号授权登陆
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function auth(Request $request)
|
||||
{
|
||||
[$spread_spid, $login_type] = $request->getMore([
|
||||
[['spread_spid', 'd'], 0],
|
||||
['login_type', ''],
|
||||
], true);
|
||||
$token = $this->services->auth($spread_spid, $login_type);
|
||||
if ($token && isset($token['key'])) {
|
||||
return app('json')->success('授权成功,请绑定手机号', $token);
|
||||
} else if ($token) {
|
||||
return app('json')->success('登录成功', ['userInfo' => $token['userInfo']]);
|
||||
} else
|
||||
return app('json')->fail('登录失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* App微信登陆
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function appAuth(Request $request)
|
||||
{
|
||||
[$userInfo, $phone, $captcha] = $request->postMore([
|
||||
['userInfo', []],
|
||||
['phone', ''],
|
||||
['code', '']
|
||||
], true);
|
||||
if ($phone) {
|
||||
if (!$captcha) {
|
||||
return app('json')->fail('请输入验证码');
|
||||
}
|
||||
//验证验证码
|
||||
$verifyCode = CacheService::get('code_' . $phone);
|
||||
if (!$verifyCode)
|
||||
return app('json')->fail('请先获取验证码');
|
||||
$verifyCode = substr($verifyCode, 0, 6);
|
||||
if ($verifyCode != $captcha) {
|
||||
CacheService::delete('code_' . $phone);
|
||||
return app('json')->fail('验证码错误');
|
||||
}
|
||||
} else {
|
||||
if ((!isset($userInfo['unionId']) || !$userInfo['unionId']) && (!isset($userInfo['openid']) || !$userInfo['openid'])) {
|
||||
return app('json')->fail('参数错误,请重新登录');
|
||||
}
|
||||
}
|
||||
$token = $this->services->appAuth($userInfo, $phone);
|
||||
if ($token) {
|
||||
return app('json')->success('登录成功', $token);
|
||||
} else if ($token === false) {
|
||||
return app('json')->success('登录成功', ['isbind' => true]);
|
||||
} else {
|
||||
return app('json')->fail('登陆失败');
|
||||
}
|
||||
}
|
||||
|
||||
public function follow()
|
||||
{
|
||||
$data = $this->services->follow();
|
||||
if ($data) {
|
||||
return app('json')->success('ok', $data);
|
||||
} else {
|
||||
return app('json')->fail('获取失败');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
67
app/controller/api/v1/work/BaseWork.php
Normal file
67
app/controller/api/v1/work/BaseWork.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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\work;
|
||||
|
||||
/**
|
||||
* Class BaseWork
|
||||
* @package app\controller\api\v1\work
|
||||
*/
|
||||
abstract class BaseWork
|
||||
{
|
||||
|
||||
/**
|
||||
* 客户userid
|
||||
* @var string
|
||||
*/
|
||||
protected $userid;
|
||||
|
||||
/**
|
||||
* 客户详细信息
|
||||
* @var array
|
||||
*/
|
||||
protected $clientInfo;
|
||||
|
||||
/**
|
||||
* @var \think\facade\Request|\think\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* BaseWorkController constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->request = request();
|
||||
$this->clientInfo = $this->request->clientInfo();
|
||||
$this->userid = $this->request->userid();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $msg
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function success($msg, array $data = [])
|
||||
{
|
||||
return app('json')->success($msg, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $msg
|
||||
* @param array|null $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function fail($msg = 'fail', ?array $data = null)
|
||||
{
|
||||
return app('json')->fail($msg, $data);
|
||||
}
|
||||
}
|
||||
39
app/controller/api/v1/work/Client.php
Normal file
39
app/controller/api/v1/work/Client.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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\work;
|
||||
|
||||
|
||||
use app\services\work\WorkClientServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 客户
|
||||
* Class SidebarController
|
||||
* @package app\controller\api\v1\work
|
||||
*/
|
||||
class Client extends BaseWork
|
||||
{
|
||||
|
||||
/**
|
||||
* @var WorkClientServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected WorkClientServices $service;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getClientInfo()
|
||||
{
|
||||
return $this->success($this->service->getClientInfo($this->userid, $this->clientInfo));
|
||||
}
|
||||
}
|
||||
68
app/controller/api/v1/work/GroupChat.php
Normal file
68
app/controller/api/v1/work/GroupChat.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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\work;
|
||||
|
||||
|
||||
use app\services\work\WorkGroupChatMemberServices;
|
||||
use app\services\work\WorkGroupChatServices;
|
||||
use crmeb\services\wechat\config\WorkConfig;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 客户群
|
||||
* Class GroupChatController
|
||||
* @package app\controller\api\v1\work
|
||||
*/
|
||||
class GroupChat extends BaseWork
|
||||
{
|
||||
|
||||
/**
|
||||
* @var WorkGroupChatServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected WorkGroupChatServices $service;
|
||||
|
||||
/**
|
||||
* @param WorkConfig $config
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function getGroupInfo(WorkConfig $config)
|
||||
{
|
||||
$chatId = $this->request->param('chat_id');
|
||||
if (!$chatId) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
$corpId = $config->corpId;
|
||||
return $this->success($this->service->getGroupInfo($chatId, $corpId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取群成员列表
|
||||
* @param WorkGroupChatMemberServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getChatMemberList(WorkGroupChatMemberServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
$name = $this->request->get('name', '');
|
||||
return $this->success($services->getChatMemberList((int)$id, $name));
|
||||
}
|
||||
}
|
||||
216
app/controller/api/v1/work/Order.php
Normal file
216
app/controller/api/v1/work/Order.php
Normal file
@@ -0,0 +1,216 @@
|
||||
<?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\work;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\activity\combination\StorePinkServices;
|
||||
use app\services\activity\coupon\StoreCouponIssueServices;
|
||||
use app\services\message\service\StoreServiceRecordServices;
|
||||
use app\services\order\StoreOrderEconomizeServices;
|
||||
use app\services\order\StoreOrderPromotionsServices;
|
||||
use app\services\order\StoreOrderRefundServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\order\StoreOrderStatusServices;
|
||||
use app\services\store\SystemStoreServices;
|
||||
use app\services\user\UserInvoiceServices;
|
||||
use app\services\user\UserServices;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 订单
|
||||
* Class OrderController
|
||||
* @package app\controller\api\v1\work
|
||||
*/
|
||||
class Order extends BaseWork
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreOrderServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreOrderServices $service;
|
||||
|
||||
/**
|
||||
* 获取订单列表
|
||||
* @param Request $request
|
||||
* @param StoreServiceRecordServices $services
|
||||
* @param StoreOrderRefundServices $storeOrderRefundServices
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function getUserOrderList(Request $request, StoreServiceRecordServices $services, StoreOrderRefundServices $storeOrderRefundServices)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['type', '', '', 'status'],
|
||||
['search', '', '', 'real_name'],
|
||||
]);
|
||||
$uid = $this->clientInfo['uid'] ?? 0;
|
||||
if (!$uid) {
|
||||
return $this->success(['list' => [], 'count' => 0]);
|
||||
}
|
||||
$where['uid'] = $uid;
|
||||
$where['is_del'] = 0;
|
||||
$where['is_system_del'] = 0;
|
||||
$where['refund_type'] = [0, 1, 3, 6];
|
||||
if ($where['status'] == -1) {
|
||||
$list = $storeOrderRefundServices->refundList(['uid' => $where['uid'], 'real_name' => $where['real_name'], 'refund_type' => [0, 1, 2, 4, 5]])['list'] ?? [];
|
||||
} else {
|
||||
$list = $this->service->getOrderApiList($where + ['pid' => 0], ['*'], ['pink', 'invoice']);
|
||||
}
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
* @param StoreOrderEconomizeServices $services
|
||||
* @param StoreOrderPromotionsServices $storeOrderPromotiosServices
|
||||
* @param $id 订单id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function orderInfo(StoreOrderEconomizeServices $services, StoreOrderPromotionsServices $storeOrderPromotiosServices, $id)
|
||||
{
|
||||
if (!$id || !($orderInfo = $this->service->get($id))) {
|
||||
return $this->fail('订单不存在');
|
||||
}
|
||||
$order = $orderInfo->toArray();
|
||||
$order['split'] = [];
|
||||
//门店是否开启 || 门店自提是否开启
|
||||
if (!sys_config('store_func_status', 1) || !sys_config('store_self_mention')) {
|
||||
//关闭门店自提后 订单隐藏门店信息
|
||||
$order['shipping_type'] = 1;
|
||||
}
|
||||
if ($order['verify_code']) {
|
||||
$verify_code = $order['verify_code'];
|
||||
$verify[] = substr($verify_code, 0, 4);
|
||||
$verify[] = substr($verify_code, 4, 4);
|
||||
$verify[] = substr($verify_code, 8);
|
||||
$order['_verify_code'] = implode(' ', $verify);
|
||||
}
|
||||
//收银台订单 用户无信息 手机号
|
||||
if ($order['shipping_type'] == 4 && $order['uid'] && !$order['real_name']) {
|
||||
/** @var UserServices $userServices */
|
||||
$userServices = app()->make(UserServices::class);
|
||||
$userInfo = $userServices->getUserCacheInfo((int)$order['uid']);
|
||||
$order['real_name'] = $userInfo['nickname'];
|
||||
$order['user_phone'] = $userInfo['phone'];
|
||||
}
|
||||
$order['add_time_y'] = date('Y-m-d', $order['add_time']);
|
||||
$order['add_time_h'] = date('H:i:s', $order['add_time']);
|
||||
$order['system_store'] = false;
|
||||
if (!$order['store_id'] && $order['shipping_type'] == 2) {
|
||||
$order['store_id'] = $this->service->value(['pid' => $order['id']], 'store_id');
|
||||
}
|
||||
if ($order['store_id']) {
|
||||
/** @var SystemStoreServices $storeServices */
|
||||
$storeServices = app()->make(SystemStoreServices::class);
|
||||
$order['system_store'] = $storeServices->getStoreDispose($order['store_id']);
|
||||
}
|
||||
$order['mapKey'] = sys_config('tengxun_map_key');
|
||||
$order['yue_pay_status'] = (int)sys_config('balance_func_status') ? (int)1 : (int)2;//余额支付 1 开启 2 关闭
|
||||
$order['pay_weixin_open'] = (int)sys_config('pay_weixin_open') ?? 0;//微信支付 1 开启 0 关闭
|
||||
$order['ali_pay_status'] = (bool)sys_config('ali_pay_status');//支付包支付 1 开启 0 关闭
|
||||
|
||||
$orderData = $this->service->tidyOrder($order, true, true);
|
||||
//核算优惠金额
|
||||
$vipTruePrice = 0;
|
||||
$refund_num = 0;
|
||||
foreach ($orderData['cartInfo'] ?? [] as $key => &$cart) {
|
||||
$vipTruePrice = bcadd((string)$vipTruePrice, (string)$cart['vip_sum_truePrice'], 2);
|
||||
$refund_num = bcadd((string)$refund_num, (string)$cart['refund_num'], 0);
|
||||
}
|
||||
$orderData['vip_true_price'] = $vipTruePrice;
|
||||
$orderData['total_price'] = floatval(bcsub((string)$orderData['total_price'], (string)$vipTruePrice, 2));
|
||||
//优惠活动优惠详情
|
||||
$orderData['promotions_detail'] = $storeOrderPromotiosServices->getOrderPromotionsDetail((int)$order['id']);
|
||||
//同步查询订单商品为查询到 查询缓存信息
|
||||
if (!$orderData['cartInfo']) {
|
||||
$cartGroup = $this->service->getCacheOrderInfo((int)$order['uid'], $order['unique']);
|
||||
$orderData['cartInfo'] = $cartGroup['cartInfo'] ?? [];
|
||||
}
|
||||
|
||||
$economize = $services->get(['order_id' => $order['order_id']], ['postage_price', 'member_price']);
|
||||
if ($economize) {
|
||||
$orderData['postage_price'] = $economize['postage_price'];
|
||||
$orderData['member_price'] = $economize['member_price'];
|
||||
} else {
|
||||
$orderData['postage_price'] = 0;
|
||||
$orderData['member_price'] = 0;
|
||||
}
|
||||
$orderData['routine_contact_type'] = sys_config('routine_contact_type', 0);
|
||||
/** @var UserInvoiceServices $userInvoice */
|
||||
$userInvoice = app()->make(UserInvoiceServices::class);
|
||||
$invoice_func = $userInvoice->invoiceFuncStatus();
|
||||
$orderData['invoice_func'] = $invoice_func['invoice_func'];
|
||||
$orderData['special_invoice'] = $invoice_func['special_invoice'];
|
||||
$orderData['refund_cartInfo'] = [];
|
||||
$orderData['refund_total_num'] = $orderData['total_num'];
|
||||
$orderData['refund_pay_price'] = $orderData['pay_price'];
|
||||
$orderData['is_apply_refund'] = !($refund_num >= $orderData['total_num']) && $this->service->isRefundAvailable((int)$order['id']);
|
||||
$orderData['is_batch_refund'] = count($orderData['cartInfo']) > 1;
|
||||
$orderData['pinkStatus'] = null;
|
||||
if ($orderData['type'] == 3) {
|
||||
/** @var StorePinkServices $pinkService */
|
||||
$pinkService = app()->make(StorePinkServices::class);
|
||||
$orderData['pinkStatus'] = $pinkService->value(['order_id' => $orderData['order_id']], 'status');
|
||||
}
|
||||
|
||||
/** @var StoreOrderStatusServices $statusServices */
|
||||
$statusServices = app()->make(StoreOrderStatusServices::class);
|
||||
$log = $statusServices->getColumn(['oid' => $order['id']], 'change_time', 'change_type');
|
||||
if (isset($log['delivery'])) {
|
||||
$delivery = date('Y-m-d', $log['delivery']);
|
||||
} elseif (isset($log['delivery_goods'])) {
|
||||
$delivery = date('Y-m-d', $log['delivery_goods']);
|
||||
} elseif (isset($log['delivery_fictitious'])) {
|
||||
$delivery = date('Y-m-d', $log['delivery_fictitious']);
|
||||
} else {
|
||||
$delivery = '';
|
||||
}
|
||||
$orderData['order_log'] = [
|
||||
'create' => isset($log['cache_key_create_order']) ? date('Y-m-d', $log['cache_key_create_order']) : '',
|
||||
'pay' => isset($log['pay_success']) ? date('Y-m-d', $log['pay_success']) : '',
|
||||
'delivery' => $delivery,
|
||||
'take' => isset($log['take_delivery']) ? date('Y-m-d', $log['take_delivery']) : '',
|
||||
'complete' => isset($log['check_order_over']) ? date('Y-m-d', $log['check_order_over']) : '',
|
||||
];
|
||||
if ($orderData['give_coupon']) {
|
||||
$couponIds = is_string($orderData['give_coupon']) ? explode(',', $orderData['give_coupon']) : $orderData['give_coupon'];
|
||||
/** @var StoreCouponIssueServices $couponIssueService */
|
||||
$couponIssueService = app()->make(StoreCouponIssueServices::class);
|
||||
$orderData['give_coupon'] = $couponIssueService->getColumn([['id', 'IN', $couponIds]], 'id,coupon_title');
|
||||
}
|
||||
$orderInfo = $orderData;
|
||||
/** @var UserServices $services */
|
||||
$userServices = app()->make(UserServices::class);
|
||||
$userInfo = $userServices->get($orderInfo['uid']);
|
||||
if (!$userInfo) {
|
||||
return $this->fail('用户信息不存在');
|
||||
}
|
||||
$userInfo = $userInfo->hidden(['pwd', 'add_ip', 'last_ip', 'login_type']);
|
||||
$userInfo['spread_name'] = '';
|
||||
if ($userInfo['spread_uid']) {
|
||||
$userInfo['spread_name'] = $userServices->value(['uid' => $userInfo['spread_uid']], 'nickname');
|
||||
}
|
||||
return $this->success(compact('orderInfo', 'userInfo'));
|
||||
}
|
||||
|
||||
}
|
||||
80
app/controller/api/v1/work/Product.php
Normal file
80
app/controller/api/v1/work/Product.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?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\work;
|
||||
|
||||
use app\services\kefu\ProductServices;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* Class ProductController
|
||||
* @package app\controller\api\v1\work
|
||||
*/
|
||||
class Product extends BaseWork
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ProductServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected ProductServices $service;
|
||||
|
||||
/**
|
||||
* 获取用户购买记录
|
||||
* @param string $store_name
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function getCartProductList(string $store_name = '')
|
||||
{
|
||||
$uid = $this->clientInfo['uid'] ?? 0;
|
||||
if (!$uid) {
|
||||
return $this->success([]);
|
||||
}
|
||||
return $this->success(get_thumb_water($this->service->getProductCartList((int)$uid, $store_name)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户浏览记录
|
||||
* @param string $store_name
|
||||
* @return mixed
|
||||
*/
|
||||
public function getVisitProductList(string $store_name = '')
|
||||
{
|
||||
$uid = $this->clientInfo['uid'] ?? 0;
|
||||
if (!$uid) {
|
||||
return $this->success([]);
|
||||
}
|
||||
return $this->success(get_thumb_water($this->service->getVisitProductList((int)$uid, $store_name)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户购买的热销商品
|
||||
* @param string $store_name
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function getProductHotSale(string $store_name = '')
|
||||
{
|
||||
$uid = $this->clientInfo['uid'] ?? 0;
|
||||
if (!$uid) {
|
||||
return $this->success([]);
|
||||
}
|
||||
return $this->success(get_thumb_water($this->service->getProductHotSale((int)$uid, $store_name)));
|
||||
}
|
||||
}
|
||||
49
app/controller/api/v1/work/WorkController.php
Normal file
49
app/controller/api/v1/work/WorkController.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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\work;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use crmeb\services\wechat\Work;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
use think\Response;
|
||||
|
||||
/**
|
||||
* 企业微信
|
||||
* Class WorkController
|
||||
* @package app\controller\api\v1\work
|
||||
*/
|
||||
class WorkController
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取企业微信配置
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function config(Request $request)
|
||||
{
|
||||
return response(['status' => 200, 'msg' => 'ok', 'data' => Work::getJsSDK($request->get('url', ''))], 200, [], 'json');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用配置
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function agentConfig(Request $request)
|
||||
{
|
||||
return response(['status' => 200, 'msg' => 'ok', 'data' => Work::getAgentConfig($request->get('url', ''))], 200, [], 'json');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user