其余文件
This commit is contained in:
24
app/shopapi/config/route.php
Normal file
24
app/shopapi/config/route.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
return [
|
||||
'middleware' => [
|
||||
app\shopapi\http\middleware\Login::class,//登录验证
|
||||
],
|
||||
];
|
||||
67
app/shopapi/controller/Account.php
Normal file
67
app/shopapi/controller/Account.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\common\basics\ShopApi;
|
||||
use app\shopapi\logic\LoginLogic;
|
||||
use app\common\server\JsonServer;
|
||||
use app\shopapi\validate\LoginValidate;
|
||||
|
||||
/**
|
||||
* 商家移动端账号登录
|
||||
* Class Account
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class Account extends ShopApi
|
||||
{
|
||||
|
||||
public $like_not_need_login = ['login'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 账号密码登录
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2021/11/9 16:21
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
(new LoginValidate())->goCheck();
|
||||
$result = LoginLogic::accountLogin($post);
|
||||
return JsonServer::success('登录成功', $result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 退出登录
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2021/11/9 15:49
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
LoginLogic::logout($this->admin_id, $this->client);
|
||||
return JsonServer::success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
40
app/shopapi/controller/Config.php
Normal file
40
app/shopapi/controller/Config.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\common\basics\ShopApi;
|
||||
use app\common\server\ConfigServer;
|
||||
use app\common\server\JsonServer;
|
||||
|
||||
class Config extends ShopApi
|
||||
{
|
||||
public $like_not_need_login = ["getPolicyAgreement"];
|
||||
|
||||
public function getPolicyAgreement()
|
||||
{
|
||||
$config = [
|
||||
1 => ConfigServer::get('policy', 'service',''),
|
||||
2 => ConfigServer::get('policy', 'privacy', ''),
|
||||
3 => ConfigServer::get('policy', 'after_sale', '')
|
||||
];
|
||||
|
||||
return JsonServer::success('', $config);
|
||||
}
|
||||
}
|
||||
96
app/shopapi/controller/Goods.php
Normal file
96
app/shopapi/controller/Goods.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\common\basics\ShopApi;
|
||||
use app\common\server\JsonServer;
|
||||
use app\shopapi\logic\GoodsLogic;
|
||||
|
||||
/**
|
||||
* 商品管理
|
||||
*/
|
||||
class Goods extends ShopApi {
|
||||
/**
|
||||
* @notes 商品列表
|
||||
* @return \think\response\Json
|
||||
* @author Tab
|
||||
* @date 2021/11/10 11:16
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
$params['page_no'] = $this->page_no;
|
||||
$params['page_size'] = $this->page_size;
|
||||
$params['shop_id'] = $this->shop_id;
|
||||
|
||||
$result = (new GoodsLogic())->lists($params);
|
||||
return JsonServer::success('', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 操作
|
||||
* @return \think\response\Json
|
||||
* @author Tab
|
||||
* @date 2021/11/10 11:22
|
||||
*/
|
||||
public function operation()
|
||||
{
|
||||
if ($this->request->isAjax() || !$this->request->isPost()) {
|
||||
return JsonServer::error("请求方式错误");
|
||||
}
|
||||
|
||||
$result = (new GoodsLogic())->operation($this->shop_id, $this->request->post());
|
||||
if($result){
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
return JsonServer::error(GoodsLogic::getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 商品详情
|
||||
* @return \think\response\Json
|
||||
* @author Tab
|
||||
* @date 2021/11/10 14:17
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$result = (new GoodsLogic())->detail($this->request->get('id'));
|
||||
return JsonServer::success('', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 商品编辑
|
||||
* @return \think\response\Json
|
||||
* @author Tab
|
||||
* @date 2021/11/10 15:23
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
if ($this->request->isAjax() || !$this->request->isPost()) {
|
||||
return JsonServer::error("请求方式错误");
|
||||
}
|
||||
|
||||
$result = (new GoodsLogic())->edit($this->request->post());
|
||||
if($result){
|
||||
return JsonServer::success('编辑成功');
|
||||
}
|
||||
return JsonServer::error(GoodsLogic::getError());
|
||||
}
|
||||
}
|
||||
61
app/shopapi/controller/Index.php
Normal file
61
app/shopapi/controller/Index.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\common\basics\ShopApi;
|
||||
use app\shopapi\logic\IndexLogic;
|
||||
use app\common\server\JsonServer;
|
||||
|
||||
/**
|
||||
* 商家移动端账号登录
|
||||
* Class Account
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class Index extends ShopApi
|
||||
{
|
||||
|
||||
public $like_not_need_login = ['config','copyright'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 基础配置
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2021/11/13 17:12
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
return JsonServer::success('', IndexLogic::config());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 版权资质
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/22 11:10 上午
|
||||
*/
|
||||
public function copyright()
|
||||
{
|
||||
$shop_id = $this->shop_id;
|
||||
$result = IndexLogic::copyright($shop_id);
|
||||
return JsonServer::success('',$result);
|
||||
|
||||
}
|
||||
}
|
||||
239
app/shopapi/controller/Order.php
Normal file
239
app/shopapi/controller/Order.php
Normal file
@ -0,0 +1,239 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
|
||||
use app\common\basics\ShopApi;
|
||||
use app\common\server\JsonServer;
|
||||
use app\shopapi\validate\VirtualDeliveryValidate;
|
||||
use app\shopapi\logic\OrderLogic;
|
||||
use app\shopapi\validate\OrderValidate;
|
||||
|
||||
/**
|
||||
* 商家移动端订单管理控制器
|
||||
* Class Order
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class Order extends ShopApi
|
||||
{
|
||||
/**
|
||||
* @notes 订单列表
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2021/11/10 3:14 下午
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$result = OrderLogic::lists($get, $this->page_no, $this->page_size, $this->shop_id);
|
||||
return JsonServer::success('获取成功', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单详情
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2021/11/10 4:16 下午
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$get['shop_id'] = $this->shop_id;
|
||||
(new OrderValidate())->goCheck('detail', $get);
|
||||
$result = OrderLogic::detail($get['id']);
|
||||
return JsonServer::success('获取成功', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 取消订单
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2021/11/10 5:06 下午
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$post['shop_id'] = $this->shop_id;
|
||||
(new OrderValidate())->goCheck('cancel', $post);
|
||||
$result = OrderLogic::cancel($post['id'],$this->admin_id);
|
||||
if (true !== $result) {
|
||||
return JsonServer::error($result);
|
||||
}
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除订单
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2021/11/10 5:37 下午
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$post['shop_id'] = $this->shop_id;
|
||||
(new OrderValidate())->goCheck('del', $post);
|
||||
OrderLogic::del($post['id'],$this->admin_id);
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 修改地址
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2021/11/10 6:36 下午
|
||||
*/
|
||||
public function editAddress()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$post['shop_id'] = $this->shop_id;
|
||||
(new OrderValidate())->goCheck('editAddress', $post);
|
||||
OrderLogic::editAddress($post);
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取地址详情
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2021/11/13 11:41 上午
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$get['shop_id'] = $this->shop_id;
|
||||
(new OrderValidate())->goCheck('getAddress', $get);
|
||||
$result = OrderLogic::getAddress($get['id']);
|
||||
return JsonServer::success('获取成功', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 发货
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2021/11/11 10:27 上午
|
||||
*/
|
||||
public function delivery()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$post['shop_id'] = $this->shop_id;
|
||||
(new OrderValidate())->goCheck('delivery', $post);
|
||||
$result = OrderLogic::delivery($post,$this->admin_id);
|
||||
if (true !== $result) {
|
||||
return JsonServer::error($result);
|
||||
}
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取物流公司列表
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2021/11/13 11:46 上午
|
||||
*/
|
||||
public function getExpress()
|
||||
{
|
||||
return JsonServer::success('获取成功', OrderLogic::getExpress());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 确认收货
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2021/11/11 10:56 上午
|
||||
*/
|
||||
public function confirm()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$post['shop_id'] = $this->shop_id;
|
||||
(new OrderValidate())->goCheck('confirm', $post);
|
||||
OrderLogic::confirm($post['id'],$this->admin_id);
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 查看物流
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2021/11/11 11:35 上午
|
||||
*/
|
||||
public function logistics()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$get['shop_id'] = $this->shop_id;
|
||||
(new OrderValidate())->goCheck('logistics', $get);
|
||||
$result = OrderLogic::logistics($get['id']);
|
||||
return JsonServer::success('获取成功', $result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 虚拟发货
|
||||
* @return \think\response\Json|void
|
||||
* @author 段誉
|
||||
* @date 2022/4/20 17:53
|
||||
*/
|
||||
public function virtualDelivery()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
(new VirtualDeliveryValidate())->goCheck();
|
||||
$result = OrderLogic::virtualDelivery($post, $this->admin_id);
|
||||
if (false == $result) {
|
||||
return JsonServer::error(OrderLogic::getError() ?: '发货失败');
|
||||
}
|
||||
return JsonServer::success('发货成功');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 确认付款
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2024/7/19 下午6:33
|
||||
*/
|
||||
public function confirmPay()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
if (!isset($post['order_id']) || empty($post['order_id'])) {
|
||||
return JsonServer::error('参数缺失');
|
||||
}
|
||||
$result = OrderLogic::confirmPay($post['order_id'], $this->admin_id);
|
||||
if(true !== $result) {
|
||||
return JsonServer::error($result);
|
||||
}
|
||||
return JsonServer::success('确认成功');
|
||||
}
|
||||
}
|
||||
184
app/shopapi/controller/Shop.php
Normal file
184
app/shopapi/controller/Shop.php
Normal file
@ -0,0 +1,184 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\shopapi\controller;
|
||||
use app\common\basics\ShopApi;
|
||||
use app\common\server\JsonServer;
|
||||
use app\shop\validate\BankValidate;
|
||||
use app\shopapi\{
|
||||
logic\ShopLogic,
|
||||
validate\ShopDataSetValidate,
|
||||
validate\ShopWithdrawValidate,
|
||||
validate\AdminPasswordValidate
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 商家控制器
|
||||
* Class Shop
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class Shop extends ShopApi{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商家可提现余额
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2021/11/10 16:16
|
||||
*/
|
||||
public function getShopInfo(){
|
||||
$shop = (new ShopLogic)->getShopInfo($this->shop_id);
|
||||
return JsonServer::success('', $shop);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取提现信息
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2021/11/10 16:30
|
||||
*/
|
||||
public function getWithdrawInfo(){
|
||||
$result = (new ShopLogic)->getWithdrawInfo($this->shop_id);
|
||||
return JsonServer::success('', $result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 提现操作
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2021/11/10 17:03
|
||||
*/
|
||||
public function withdraw(){
|
||||
$post = $this->request->post();
|
||||
$post['shop_id'] = $this->shop_id;
|
||||
(new ShopWithdrawValidate())->goCheck('',$post);
|
||||
$result = (new ShopLogic)->withdraw($post);
|
||||
if(true === $result){
|
||||
return JsonServer::success('提现成功');
|
||||
}
|
||||
return JsonServer::error($result );
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 提现记录
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DbException
|
||||
* @author cjhao
|
||||
* @date 2021/11/10 17:11
|
||||
*/
|
||||
public function withdrawLog(){
|
||||
$list = (new ShopLogic)->withdrawLog($this->shop_id,$this->page_no,$this->page_size);
|
||||
return JsonServer::success('', $list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加账户
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DbException
|
||||
* @author cjhao
|
||||
* @date 2021/11/10 18:26
|
||||
*/
|
||||
public function addBank(){
|
||||
(new BankValidate())->goCheck('add');
|
||||
$post = $this->request->post();
|
||||
$post['shop_id'] = $this->shop_id;
|
||||
(new ShopLogic)->addBank($post);
|
||||
return JsonServer::success('添加成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取银行卡
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2021/11/11 15:47
|
||||
*/
|
||||
public function getBank(){
|
||||
(new BankValidate())->goCheck('id');
|
||||
$id= $this->request->get('id');
|
||||
$data= (new ShopLogic)->getBank($id,$this->shop_id);
|
||||
return JsonServer::success('',$data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑银行卡
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2021/11/10 18:40
|
||||
*/
|
||||
public function editBank(){
|
||||
(new BankValidate())->goCheck('edit');
|
||||
$post = $this->request->post();
|
||||
$post['shop_id'] = $this->shop_id;
|
||||
(new ShopLogic)->editBank($post);
|
||||
return JsonServer::success('编辑成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除银行卡
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2021/11/10 18:42
|
||||
*/
|
||||
public function delBank(){
|
||||
(new BankValidate())->goCheck('id');
|
||||
$id = $this->request->post('id');
|
||||
(new ShopLogic)->delBank($id,$this->shop_id);
|
||||
return JsonServer::success('删除成功');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置商家信息
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2021/11/11 10:40
|
||||
*/
|
||||
public function shopSet(){
|
||||
$post = $this->request->post();
|
||||
(new ShopDataSetValidate())->goCheck('',['dataset'=>$post]);
|
||||
(new ShopLogic)->shopSet($post,$this->shop_id);
|
||||
return JsonServer::success('设置成功');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 修改密码接口
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2021/11/11 16:11
|
||||
*/
|
||||
public function changePwd(){
|
||||
$post = $this->request->post();
|
||||
$post['admin_id'] = $this->admin_id;
|
||||
(new AdminPasswordValidate())->goCheck('', $post);
|
||||
$res = (new ShopLogic)->updatePassword($post, $this->shop_id);
|
||||
if(true === $res){
|
||||
return JsonServer::success('密码修改成功');
|
||||
}
|
||||
return JsonServer::error($res);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
80
app/shopapi/controller/Statistics.php
Normal file
80
app/shopapi/controller/Statistics.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\shopapi\controller;
|
||||
use app\common\basics\ShopApi;
|
||||
use app\common\server\JsonServer;
|
||||
use app\shopapi\logic\StatisticsLogic;
|
||||
|
||||
/**
|
||||
* 数据逻辑层
|
||||
* Class Statistics
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class Statistics extends ShopApi{
|
||||
|
||||
/**
|
||||
* @notes 工作台
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2021/11/11 15:14
|
||||
*/
|
||||
public function workbench(){
|
||||
$data = (new StatisticsLogic)->workbench($this->shop_id);
|
||||
return JsonServer::success('',$data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 交易分析
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2021/11/11 14:37
|
||||
*/
|
||||
public function trading(){
|
||||
$data = (new StatisticsLogic)->trading($this->shop_id);
|
||||
return JsonServer::success('',$data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 商品分析接口
|
||||
* @param int $shop_id
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2021/11/11 14:38
|
||||
*/
|
||||
public function goodslist()
|
||||
{
|
||||
$data = (new StatisticsLogic())->goodslist($this->shop_id);
|
||||
return JsonServer::success('',$data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 访问分析
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2021/11/11 14:43
|
||||
*/
|
||||
public function visit()
|
||||
{
|
||||
$data = (new StatisticsLogic())->visit($this->shop_id);
|
||||
return JsonServer::success('',$data);
|
||||
|
||||
}
|
||||
}
|
||||
43
app/shopapi/controller/Test.php
Normal file
43
app/shopapi/controller/Test.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
use app\common\basics\ShopApi;
|
||||
use app\shopapi\logic\LoginLogic;
|
||||
use app\common\server\JsonServer;
|
||||
use app\shopapi\validate\LoginValidate;
|
||||
|
||||
/**
|
||||
* 商家移动端账号登录
|
||||
* Class Account
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class Test extends ShopApi
|
||||
{
|
||||
|
||||
public $like_not_need_login = ['login'];
|
||||
|
||||
|
||||
public function test()
|
||||
{
|
||||
dd($this->shop_id);
|
||||
}
|
||||
|
||||
}
|
||||
86
app/shopapi/controller/Verification.php
Normal file
86
app/shopapi/controller/Verification.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\controller;
|
||||
|
||||
|
||||
use app\common\basics\ShopApi;
|
||||
use app\common\server\JsonServer;
|
||||
use app\shopapi\logic\VerificationLogic;
|
||||
use app\shopapi\validate\VerificationValidate;
|
||||
use app\shopapi\logic\OrderLogic;
|
||||
|
||||
/**
|
||||
* 自提核销
|
||||
* Class Verification
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class Verification extends ShopApi
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 核销订单
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 17:13
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = VerificationLogic::lists($params, $this->page_no, $this->page_size, $this->shop_id);
|
||||
return JsonServer::success('获取成功', $result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 订单详情
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 18:08
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
(new VerificationValidate())->goCheck('detail', ['shop_id' => $this->shop_id]);
|
||||
$result = VerificationLogic::detail($params, $this->shop_id);
|
||||
return JsonServer::success('', $result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 核销订单
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 17:11
|
||||
*/
|
||||
public function confirm()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
(new VerificationValidate())->goCheck('confirm', ['shop_id' => $this->shop_id]);
|
||||
$result = VerificationLogic::verification($params, $this->shop);
|
||||
if(false === $result) {
|
||||
return JsonServer::error(OrderLogic::getError() ?: '操作失败');
|
||||
}
|
||||
return JsonServer::success('操作成功');
|
||||
}
|
||||
|
||||
}
|
||||
115
app/shopapi/http/middleware/Login.php
Normal file
115
app/shopapi/http/middleware/Login.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\http\middleware;
|
||||
|
||||
|
||||
use app\common\model\shop\ShopAdmin;
|
||||
use app\shopapi\validate\TokenValidate;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
class Login
|
||||
{
|
||||
/**
|
||||
* 登录验证
|
||||
* @param $request
|
||||
* @param \Closure $next
|
||||
* @return mixed|\think\response\Redirect
|
||||
*/
|
||||
public function handle($request, \Closure $next)
|
||||
{
|
||||
//允许跨域调用
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header("Access-Control-Allow-Headers: Authorization, Sec-Fetch-Mode, DNT, X-Mx-ReqToken, Keep-Alive, User-Agent, If-Match, If-None-Match, If-Unmodified-Since, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Accept-Language, Origin, Accept-Encoding,Access-Token,token");
|
||||
header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE');
|
||||
header('Access-Control-Max-Age: 1728000');
|
||||
header('Access-Control-Allow-Credentials:true');
|
||||
|
||||
if (strtoupper($request->method()) == "OPTIONS") {
|
||||
return response();
|
||||
}
|
||||
|
||||
// 过滤前后空格
|
||||
$request->filter(['trim']);
|
||||
|
||||
$token = $request->header('token');
|
||||
|
||||
// 无需登录
|
||||
if (empty($token) && $this->isNotNeedLogin($request)) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
|
||||
//token验证,并生成缓存
|
||||
$validateError = '';
|
||||
try {
|
||||
validate(TokenValidate::class)->check(['token' => $token]);
|
||||
$adminInfo = (new ShopAdmin())->alias('a')
|
||||
->join('shop_session ss', 'a.id=ss.admin_id')
|
||||
->join('shop s', 's.id = a.shop_id')
|
||||
->where(['ss.token' => $token])
|
||||
->field('a.*,ss.token,ss.client,s.name as shop_name')
|
||||
->hidden(['password'])
|
||||
->findOrEmpty();
|
||||
$adminInfo = $adminInfo ? $adminInfo->toArray() : [];
|
||||
// 设置缓存
|
||||
cache($token, $adminInfo);
|
||||
// 设置用户信息
|
||||
$request->admin_info = $adminInfo;
|
||||
return $next($request);
|
||||
} catch (ValidateException $e) {
|
||||
$validateError = $e->getError();
|
||||
}
|
||||
|
||||
//无需要登录,带token的情况
|
||||
if ($this->isNotNeedLogin($request) && $token) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
//登录失败
|
||||
$result = array(
|
||||
'code' => -1,
|
||||
'show' => 1,
|
||||
'msg' => $validateError,
|
||||
'data' => []
|
||||
);
|
||||
return json($result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 是否需要登录
|
||||
* @param $request
|
||||
* @return bool // false-需要; true-不需要
|
||||
* @author 段誉
|
||||
* @date 2021/11/10 11:10
|
||||
*/
|
||||
private function isNotNeedLogin($request)
|
||||
{
|
||||
$controllerObj = invoke('\\app\\shopapi\\controller\\' . $request->controller());
|
||||
$data = $controllerObj->like_not_need_login;
|
||||
if (empty($data)) {
|
||||
return false;
|
||||
}
|
||||
return in_array($request->action(), $data);
|
||||
}
|
||||
|
||||
}
|
||||
473
app/shopapi/logic/GoodsLogic.php
Normal file
473
app/shopapi/logic/GoodsLogic.php
Normal file
@ -0,0 +1,473 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\logic;
|
||||
|
||||
use app\common\basics\Logic;
|
||||
use app\common\enum\GoodsEnum;
|
||||
use app\common\enum\ShopEnum;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\goods\GoodsItem;
|
||||
use app\common\model\goods\GoodsSpec;
|
||||
use app\common\server\ConfigServer;
|
||||
use app\common\server\UrlServer;
|
||||
use think\facade\Db;
|
||||
|
||||
class GoodsLogic extends Logic
|
||||
{
|
||||
/**
|
||||
* @notes 商品列表
|
||||
* @param $params
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author Tab
|
||||
* @date 2021/11/10 11:16
|
||||
*/
|
||||
public function lists($params)
|
||||
{
|
||||
// 组装条件
|
||||
$field = $this->assemblyField();
|
||||
$where = $this->assemblyWhere($params);
|
||||
$order = $this->assemblyOrder();
|
||||
|
||||
$lists = Goods::field($field)
|
||||
->where($where)
|
||||
->page($params['page_no'], $params['page_size'])
|
||||
->order($order)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$count = Goods::where($where)->count();
|
||||
|
||||
$lists = $this->formatLists($lists);
|
||||
|
||||
$more = is_more($count, $params['page_no'], $params['page_size']);
|
||||
$btns = $this->btns($params);
|
||||
$data = [
|
||||
'lists' => $lists,
|
||||
'page_no' => $params['page_no'],
|
||||
'page_size' => $params['page_size'],
|
||||
'count' => $count,
|
||||
'more' => $more,
|
||||
'btns' => $btns,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 字段
|
||||
* @return string[]
|
||||
* @author Tab
|
||||
* @date 2021/11/10 11:04
|
||||
*/
|
||||
public function assemblyField()
|
||||
{
|
||||
return [
|
||||
"id",
|
||||
"name",
|
||||
"image",
|
||||
"min_price",
|
||||
"max_price",
|
||||
"stock",
|
||||
"sales_actual",
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @param $params
|
||||
* @return array[]
|
||||
* @author Tab
|
||||
* @date 2021/11/10 10:47
|
||||
*/
|
||||
public function assemblyWhere($params)
|
||||
{
|
||||
// 商家
|
||||
$where = [
|
||||
['shop_id', '=', $params['shop_id']]
|
||||
];
|
||||
// 商品名称
|
||||
if(isset($params['name']) && trim($params['name'])) {
|
||||
$where[] = ['name','like','%'.trim($params['name']).'%'];
|
||||
}
|
||||
// 商品类型 - 默认销售中
|
||||
$type = !empty($params['type']) ? (int)$params['type'] : GoodsEnum::SALES;
|
||||
|
||||
switch ($type) {
|
||||
case GoodsEnum::SALES:
|
||||
$where[] = ['status', '=', GoodsEnum::STATUS_SHELVES];//上架
|
||||
$where[] = ['del', '=', GoodsEnum::DEL_NORMAL];
|
||||
$where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过
|
||||
$where[] = ['stock','exp', Db::raw('>stock_warn')];
|
||||
break;
|
||||
case GoodsEnum::WAREHOUSE:
|
||||
$where[] = ['status', '=', GoodsEnum::STATUS_SOLD_OUT];//下架
|
||||
$where[] = ['del', '=', GoodsEnum::DEL_NORMAL];
|
||||
$where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过
|
||||
break;
|
||||
case GoodsEnum::WARNING:
|
||||
$where[] = ['status', '=', GoodsEnum::STATUS_SHELVES];//上架
|
||||
$where[] = ['del', '=', GoodsEnum::DEL_NORMAL];
|
||||
$where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过
|
||||
$where[] = ['stock','exp', Db::raw('<=stock_warn')];
|
||||
break;
|
||||
case GoodsEnum::RECYCLE_BIN:
|
||||
$where[] = ['del', '=', GoodsEnum::DEL_RECYCLE];
|
||||
$where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过
|
||||
break;
|
||||
case GoodsEnum::WAIT_AUDIT:
|
||||
$where[] = ['del', '<>', GoodsEnum::DEL_TRUE];
|
||||
$where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_STAY];
|
||||
break;
|
||||
case GoodsEnum::UNPASS_AUDIT:
|
||||
$where[] = ['del', '<>', GoodsEnum::DEL_TRUE];
|
||||
$where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_REFUSE];
|
||||
break;
|
||||
default:
|
||||
$where[] = ['del', '=', GoodsEnum::DEL_NORMAL];
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 排序
|
||||
* @return string[]
|
||||
* @author Tab
|
||||
* @date 2021/11/10 10:47
|
||||
*/
|
||||
public function assemblyOrder()
|
||||
{
|
||||
return [
|
||||
'sort' => 'asc',
|
||||
'id' => 'desc'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 格式化
|
||||
* @param $lists
|
||||
* @return mixed
|
||||
* @author Tab
|
||||
* @date 2021/11/10 11:06
|
||||
*/
|
||||
public function formatLists($lists)
|
||||
{
|
||||
if (empty($lists)) {
|
||||
return $lists;
|
||||
}
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$minPrice = floor($item["min_price"] * 100);
|
||||
$maxPrice = floor($item["max_price"] * 100);
|
||||
$item['price'] = $minPrice == $maxPrice ? "¥" . clearZero($item["min_price"]) : "¥" . clearZero($item["min_price"]) . " ~ " . clearZero($item["max_price"]);
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 操作
|
||||
* @param $shopId
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author Tab
|
||||
* @date 2021/11/10 14:08
|
||||
*/
|
||||
public function operation($shopId, $params)
|
||||
{
|
||||
try {
|
||||
if (empty($params['action'])) {
|
||||
throw new \Exception("请选择操作");
|
||||
}
|
||||
|
||||
$goods = Goods::where([
|
||||
'shop_id' => $shopId,
|
||||
'id' => $params['id']
|
||||
])->findOrEmpty();
|
||||
if ($goods->isEmpty()) {
|
||||
throw new \Exception("商品不存在");
|
||||
}
|
||||
|
||||
switch ($params['action']) {
|
||||
case "delete":
|
||||
$this->delete($goods);
|
||||
break;
|
||||
case "recycle":
|
||||
$this->recycle($goods);
|
||||
break;
|
||||
case "on_shelf":
|
||||
$this->onShelf($goods);
|
||||
break;
|
||||
case "off_shelf":
|
||||
$this->offShelf($goods);
|
||||
break;
|
||||
case "warehouse":
|
||||
$this->warehouse($goods);
|
||||
break;
|
||||
default:
|
||||
throw new \Exception("无效的操作");
|
||||
}
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除商品
|
||||
* @param $goods
|
||||
* @author Tab
|
||||
* @date 2021/11/10 11:58
|
||||
*/
|
||||
public function delete($goods)
|
||||
{
|
||||
$goods->del = GoodsEnum::DEL_TRUE;
|
||||
$goods->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 放入回收站
|
||||
* @param $goods
|
||||
* @author Tab
|
||||
* @date 2021/11/10 11:58
|
||||
*/
|
||||
public function recycle($goods)
|
||||
{
|
||||
$goods->del = GoodsEnum::DEL_RECYCLE;
|
||||
$goods->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 上架
|
||||
* @param $goods
|
||||
* @throws \Exception
|
||||
* @author Tab
|
||||
* @date 2021/11/10 12:01
|
||||
*/
|
||||
public function onShelf($goods)
|
||||
{
|
||||
if ($goods->stock <= 0) {
|
||||
throw new \Exception("库存不足不允许上架");
|
||||
}
|
||||
$goods->status = GoodsEnum::STATUS_SHELVES;
|
||||
$goods->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 下架
|
||||
* @param $goods
|
||||
* @author Tab
|
||||
* @date 2021/11/10 14:04
|
||||
*/
|
||||
public function offShelf($goods)
|
||||
{
|
||||
$goods->status = GoodsEnum::STATUS_SOLD_OUT;
|
||||
$goods->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 放入仓库
|
||||
* @param $goods
|
||||
* @author Tab
|
||||
* @date 2021/11/10 14:07
|
||||
*/
|
||||
public function warehouse($goods)
|
||||
{
|
||||
$goods->status = GoodsEnum::STATUS_SOLD_OUT;
|
||||
$goods->del = GoodsEnum::DEL_NORMAL;
|
||||
$goods->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 商品详情
|
||||
* @param $id
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author Tab
|
||||
* @date 2021/11/10 15:14
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
$goodsDetail = Goods::with(['goods_image', 'goods_item', 'shop'])
|
||||
->field('id,type,code,name,spec_type,image,video,remark,content,market_price,min_price,max_price,stock,sales_actual,shop_id')
|
||||
->where('id', $id)
|
||||
->findOrEmpty();
|
||||
|
||||
if ($goodsDetail->isEmpty()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$goodsDetail = $goodsDetail->toArray();
|
||||
|
||||
// 轮播图添加域名
|
||||
foreach($goodsDetail['goods_image'] as &$item) {
|
||||
$item['uri'] = empty($item['uri']) ? '' : UrlServer::getFileUrl($item['uri']);
|
||||
}
|
||||
|
||||
// 规格项及规格值信息
|
||||
$goodsDetail['goods_spec'] = GoodsSpec::with('spec_value')
|
||||
->where('goods_id', $goodsDetail['id'])->select()->toArray();
|
||||
|
||||
return $goodsDetail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 商品编辑
|
||||
* @param $shopId
|
||||
* @param $params
|
||||
* @author Tab
|
||||
* @date 2021/11/10 15:24
|
||||
*/
|
||||
public function edit($params)
|
||||
{
|
||||
try {
|
||||
$updateData = $this->checkParams($params);
|
||||
(new GoodsItem())->saveAll($updateData['itemData']);
|
||||
Goods::update($updateData['goodsData']);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 参数校验
|
||||
* @param $params
|
||||
* @throws \Exception
|
||||
* @author Tab
|
||||
* @date 2021/11/10 15:48
|
||||
*/
|
||||
public function checkParams($params)
|
||||
{
|
||||
$goodsStock = 0;
|
||||
$itemId = 0;
|
||||
$updateData = [];
|
||||
|
||||
$max_price = 0;
|
||||
$min_price = 0;
|
||||
$market_price = 0;
|
||||
|
||||
if (!isset($params['items']) || !is_array($params['items'])) {
|
||||
throw new \Exception("参数缺失或格式有误");
|
||||
}
|
||||
foreach($params['items'] as $item) {
|
||||
if (!is_array($item)) {
|
||||
throw new \Exception("参数格式错误");
|
||||
}
|
||||
if (!isset($item['id']) || !isset($item['price']) || !isset($item['stock']) || !isset($item['market_price']) || !isset($item['chengben_price'])) {
|
||||
throw new \Exception("参数缺失");
|
||||
}
|
||||
if ($item['price'] <= 0 || $item['market_price'] <= 0 || $item['chengben_price'] <= 0 || $item['stock'] <= 0) {
|
||||
throw new \Exception("价格及库存均不能为负数和零");
|
||||
}
|
||||
if ($item['market_price'] < $item['price']) {
|
||||
throw new \Exception("市场价不能低于售价");
|
||||
}
|
||||
// 重新赋值作用:避免$item字段过多时修改了不该修改的字段
|
||||
$temp['id'] = $item['id'];
|
||||
$temp['price'] = $item['price'];
|
||||
$temp['market_price'] = $item['market_price'];
|
||||
$temp['chengben_price'] = $item['chengben_price'];
|
||||
$temp['stock'] = $item['stock'];
|
||||
// 规格数据
|
||||
$updateData[] = $temp;
|
||||
|
||||
// 主表库存
|
||||
$goodsStock += $item['stock'];
|
||||
$itemId = $item['id'];
|
||||
|
||||
// 最高价
|
||||
if ($item['price'] > $max_price) {
|
||||
$max_price = $item['price'];
|
||||
}
|
||||
|
||||
if ($min_price == 0) {
|
||||
$min_price = $item['price'];
|
||||
$market_price = $item['market_price'];
|
||||
}
|
||||
|
||||
//最低价
|
||||
if ($item['price'] < $min_price) {
|
||||
$min_price = $item['price'];
|
||||
$market_price = $item['market_price'];
|
||||
}
|
||||
}
|
||||
|
||||
// 商品id
|
||||
$goodsId = (new GoodsItem())->where(['id' => $itemId])->value('goods_id');
|
||||
|
||||
// 商品更新库存
|
||||
$goodsData = [
|
||||
'id' => $goodsId,
|
||||
'stock' => $goodsStock,
|
||||
'max_price' => $max_price,
|
||||
'min_price' => $min_price,
|
||||
'market_price' => $market_price,
|
||||
];
|
||||
|
||||
return ['itemData' => $updateData, 'goodsData' => $goodsData];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 按钮显示与隐藏
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author Tab
|
||||
* @date 2021/11/12 17:59
|
||||
*/
|
||||
public function btns($params)
|
||||
{
|
||||
$recycleBtn = $editBtn = $offShelfBtn = $onShelfBtn = $deleteBtn = $warehouseBtn = false;
|
||||
// 商品类型 - 默认销售中
|
||||
$type = !empty($params['type']) ? (int)$params['type'] : GoodsEnum::SALES;
|
||||
|
||||
switch ($type) {
|
||||
case GoodsEnum::SALES:
|
||||
case GoodsEnum::WARNING:
|
||||
$recycleBtn = $editBtn = $offShelfBtn = true;
|
||||
break;
|
||||
case GoodsEnum::WAREHOUSE:
|
||||
$recycleBtn = $editBtn = $onShelfBtn = true;
|
||||
break;
|
||||
case GoodsEnum::RECYCLE_BIN:
|
||||
$deleteBtn = $warehouseBtn = true;
|
||||
break;
|
||||
case GoodsEnum::WAIT_AUDIT:
|
||||
case GoodsEnum::UNPASS_AUDIT:
|
||||
$deleteBtn = $editBtn = true;
|
||||
break;
|
||||
}
|
||||
return [
|
||||
"recycle_btn" => $recycleBtn,
|
||||
"edit_btn" => $editBtn,
|
||||
"off_shelf_btn" => $offShelfBtn,
|
||||
"on_shelf_btn" => $onShelfBtn,
|
||||
"delete_btn" => $deleteBtn,
|
||||
"warehouse_btn" => $warehouseBtn,
|
||||
];
|
||||
}
|
||||
}
|
||||
70
app/shopapi/logic/IndexLogic.php
Normal file
70
app/shopapi/logic/IndexLogic.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\logic;
|
||||
|
||||
use app\common\basics\Logic;
|
||||
use app\common\model\shop\Shop;
|
||||
use app\common\server\ConfigServer;
|
||||
use app\common\server\UrlServer;
|
||||
|
||||
/**
|
||||
* 商家移动端管理员默认配置
|
||||
* Class LoginLogic
|
||||
* @package app\shopapi\logic
|
||||
*/
|
||||
class IndexLogic extends Logic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 配置信息
|
||||
* @return array
|
||||
* @author 段誉
|
||||
* @date 2021/11/13 17:13
|
||||
*/
|
||||
public static function config()
|
||||
{
|
||||
$config = [
|
||||
'platform_name' => ConfigServer::get('website', 'name'),
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 版权资质
|
||||
* @param $shop_id
|
||||
* @return mixed
|
||||
* @author ljj
|
||||
* @date 2022/2/22 11:10 上午
|
||||
*/
|
||||
public static function copyright($shop_id)
|
||||
{
|
||||
$result = Shop::where('id',$shop_id)->json(['other_qualifications'],true)->field('business_license,other_qualifications')->findOrEmpty()->toArray();
|
||||
$business_license = $result['business_license'] ? UrlServer::getFileUrl($result['business_license']) : '';
|
||||
foreach ($result['other_qualifications'] as &$val) {
|
||||
$other_qualifications[] = UrlServer::getFileUrl($val);
|
||||
}
|
||||
if (!empty($business_license)) {
|
||||
array_unshift($other_qualifications,$business_license);
|
||||
}
|
||||
|
||||
return $other_qualifications;
|
||||
}
|
||||
|
||||
}
|
||||
158
app/shopapi/logic/LoginLogic.php
Normal file
158
app/shopapi/logic/LoginLogic.php
Normal file
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\logic;
|
||||
|
||||
use app\common\basics\Logic;
|
||||
use app\common\model\shop\ShopAdmin;
|
||||
use app\common\model\ShopSession;
|
||||
use app\common\model\ShopSession as SessionModel;
|
||||
use app\common\server\UrlServer;
|
||||
use think\facade\Config;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* 商家移动端管理员登录逻辑
|
||||
* Class LoginLogic
|
||||
* @package app\shopapi\logic
|
||||
*/
|
||||
class LoginLogic extends Logic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 账号密码登录
|
||||
* @param $params
|
||||
* @return mixed
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2021/11/9 16:37
|
||||
*/
|
||||
public static function accountLogin($params)
|
||||
{
|
||||
$adminModel = new ShopAdmin();
|
||||
|
||||
$admin = $adminModel->alias('a')
|
||||
->join('shop s', 's.id = a.shop_id')
|
||||
->field(['a.id', 'a.account', 'a.name', 'role_id', 'shop_id', 's.name' => 'shop_name', 's.logo' => 'shop_logo'])
|
||||
->where(['a.account' => $params['account'], 'a.del' => 0])
|
||||
->findOrEmpty()->toArray();
|
||||
|
||||
$admin['shop_logo'] = UrlServer::getFileUrl($admin['shop_logo']);
|
||||
$admin['token'] = self::createSession($admin['id'], $params['client']);
|
||||
|
||||
//登录信息更新
|
||||
$adminModel->where(['account' => $params['account']])->update([
|
||||
'login_ip' => request()->ip(),
|
||||
'login_time' => time()
|
||||
]);
|
||||
return $admin;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 退出登录
|
||||
* @param $user_id
|
||||
* @param $client
|
||||
* @return SessionModel
|
||||
* @author 段誉
|
||||
* @date 2021/11/9 16:37
|
||||
*/
|
||||
public static function logout($user_id, $client)
|
||||
{
|
||||
$time = time();
|
||||
$token = (new ShopSession())
|
||||
->where(['admin_id' => $user_id, 'client' => $client])
|
||||
->value('token');
|
||||
|
||||
Cache::delete($token);
|
||||
|
||||
return (new ShopSession())
|
||||
->where(['admin_id' => $user_id, 'client' => $client])
|
||||
->update(['update_time' => $time, 'expire_time' => $time]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 创建会话
|
||||
* @param $admin_id
|
||||
* @param $client
|
||||
* @return string
|
||||
* @author 段誉
|
||||
* @date 2021/11/9 16:38
|
||||
*/
|
||||
public static function createSession($admin_id, $client)
|
||||
{
|
||||
//清除之前缓存
|
||||
$token = SessionModel::where(['admin_id' => $admin_id, 'client' => $client])
|
||||
->value('token');
|
||||
if ($token) {
|
||||
Cache::delete($token);
|
||||
}
|
||||
|
||||
$result = SessionModel::where(['admin_id' => $admin_id, 'client' => $client])
|
||||
->findOrEmpty();
|
||||
|
||||
$time = time();
|
||||
$expire_time = $time + Config::get('project.token_expire_time');
|
||||
|
||||
// 新token
|
||||
$token = md5($admin_id . $client . $time);
|
||||
|
||||
$shop_amdin = ShopAdmin::where(['id' => $admin_id])->findOrEmpty();
|
||||
|
||||
$data = [
|
||||
'shop_id' => $shop_amdin['shop_id'],
|
||||
'admin_id' => $admin_id,
|
||||
'token' => $token,
|
||||
'client' => $client,
|
||||
'update_time' => $time,
|
||||
'expire_time' => $expire_time,
|
||||
];
|
||||
|
||||
if ($result->isEmpty()) {
|
||||
SessionModel::create($data);
|
||||
} else {
|
||||
SessionModel::where(['admin_id' => $admin_id, 'client' => $client])
|
||||
->update($data);
|
||||
}
|
||||
|
||||
//更新登录信息
|
||||
$login_ip = request()->ip();
|
||||
ShopAdmin::where(['id' => $admin_id])
|
||||
->update(['login_time' => $time, 'login_ip' => $login_ip]);
|
||||
|
||||
// 获取最新的用户信息
|
||||
$admin_info = ShopAdmin::alias('a')
|
||||
->join('shop_session s', 'a.id=s.admin_id')
|
||||
->where(['s.token' => $token])
|
||||
->field('a.*,s.token,s.client')
|
||||
->find();
|
||||
$admin_info = $admin_info ? $admin_info->toArray() : [];
|
||||
|
||||
//创建新的缓存
|
||||
$ttl = 0 + Config::get('project.token_expire_time');
|
||||
Cache::set($token, $admin_info, $ttl);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
511
app/shopapi/logic/OrderLogic.php
Normal file
511
app/shopapi/logic/OrderLogic.php
Normal file
@ -0,0 +1,511 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\logic;
|
||||
|
||||
|
||||
use app\common\basics\Logic;
|
||||
use app\common\enum\NoticeEnum;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\OrderLogEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\TeamEnum;
|
||||
use app\common\logic\GoodsVirtualLogic;
|
||||
use app\common\logic\OrderLogLogic;
|
||||
use app\common\logic\OrderRefundLogic;
|
||||
use app\common\logic\PayNotifyLogic;
|
||||
use app\common\model\Delivery;
|
||||
use app\common\model\DevRegion;
|
||||
use app\common\model\distribution\DistributionOrderGoods;
|
||||
use app\common\model\Express;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\team\TeamFound;
|
||||
use app\common\model\team\TeamJoin;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 商家移动端订单管理逻辑层
|
||||
* Class OrderLogic
|
||||
* @package app\shopapi\logic
|
||||
*/
|
||||
class OrderLogic extends Logic
|
||||
{
|
||||
/**
|
||||
* @notes 订单列表
|
||||
* @param $get
|
||||
* @param $page_no
|
||||
* @param $page_size
|
||||
* @param $shop_id
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2021/11/10 3:13 下午
|
||||
*/
|
||||
public static function lists($get, $page_no, $page_size, $shop_id)
|
||||
{
|
||||
$get['type'] = $get['type'] ?? 'all';
|
||||
$where[] = ['o.shop_id', '=', $shop_id];
|
||||
$where[] = ['o.del', '=', 0];
|
||||
$where[] = ['o.delete', '=', 0];
|
||||
//订单状态
|
||||
if (isset($get['type']) && !empty($get['type'])) {
|
||||
switch ($get['type']) {
|
||||
case 'pay':
|
||||
$where[] = ['o.order_status', '=', 0];
|
||||
break;
|
||||
case 'delivery':
|
||||
$where[] = ['o.order_status', '=', 1];
|
||||
break;
|
||||
case 'receiving':
|
||||
$where[] = ['o.order_status', '=', 2];
|
||||
break;
|
||||
case 'finish':
|
||||
$where[] = ['o.order_status', '=', 3];
|
||||
break;
|
||||
case 'close':
|
||||
$where[] = ['o.order_status', '=', 4];
|
||||
break;
|
||||
}
|
||||
}
|
||||
//订单商品名称
|
||||
if (isset($get['goods_name']) && !empty($get['goods_name'])) {
|
||||
$where[] = ['og.goods_name', 'like', '%'.$get['goods_name'].'%'];
|
||||
}
|
||||
|
||||
$count = Order::alias('o')
|
||||
->join('order_goods og', 'og.order_id = o.id')
|
||||
->where($where)
|
||||
->group('o.id')
|
||||
->count();
|
||||
|
||||
$lists = Order::alias('o')
|
||||
->join('order_goods og', 'og.order_id = o.id')
|
||||
->where($where)
|
||||
->with(['order_goods'])
|
||||
->field('o.id,o.order_type,o.order_sn,o.order_status,o.pay_status,o.shipping_status,o.order_amount,o.create_time,o.delivery_type, o.verification_status,o.pay_way')
|
||||
->append(['is_team_success','shop_cancel_btn','edit_address_btn','to_ship_btn','take_btn','delivery_btn','del_btn','content_btn', 'to_verification_btn'])
|
||||
->page($page_no, $page_size)
|
||||
->order('o.id desc')
|
||||
->group('o.id')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
// 订单状态描述
|
||||
if ($item['order_status'] == OrderEnum::ORDER_STATUS_DELIVERY
|
||||
&& $item['delivery_type'] == OrderEnum::DELIVERY_TYPE_SELF
|
||||
&& $item['pay_status'] == PayEnum::ISPAID) {
|
||||
$item['order_status_text'] = '待取货';
|
||||
} else {
|
||||
$item['order_status_text'] = OrderEnum::getOrderStatus($item['order_status']);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'list' => $lists,
|
||||
'page' => $page_no,
|
||||
'size' => $page_size,
|
||||
'count' => $count,
|
||||
'more' => is_more($count, $page_no, $page_size)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单详情
|
||||
* @param $id
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2021/11/10 4:15 下午
|
||||
*/
|
||||
public static function detail($id)
|
||||
{
|
||||
$result = Order::where('id',$id)
|
||||
->field('id,user_id,order_sn,order_type,order_source,order_status,pay_status,pay_time,shipping_status,pay_way,order_amount,goods_price,shipping_price,discount_amount,member_amount,create_time,consignee,mobile,province,city,district,address,user_remark,delivery_type,delivery_content,pay_way')
|
||||
->with(['order_goods','user', 'invoice'])
|
||||
->append(['is_team_success','shop_cancel_btn','edit_address_btn','to_ship_btn','take_btn','delivery_btn','del_btn','order_status_text','pay_way_text','delivery_address','order_type_text','order_source_text','pay_status_text'])
|
||||
->find()
|
||||
->toArray();
|
||||
|
||||
$result['pay_time'] = $result['pay_time'] ? date('Y-m-d H:i:s', $result['pay_time']) : '-';
|
||||
|
||||
// 虚拟商品 发货内容
|
||||
if ($result['delivery_type'] != OrderEnum::DELIVERY_TYPE_VIRTUAL || $result['shipping_status'] != OrderEnum::SHIPPING_FINISH) {
|
||||
$result['delivery_content'] = '';
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 取消订单
|
||||
* @param $id
|
||||
* @param $admin_id
|
||||
* @return bool|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2021/11/10 5:06 下午
|
||||
*/
|
||||
public static function cancel($id,$admin_id)
|
||||
{
|
||||
$order = Order::where(['id' => $id], ['orderGoods'])->find()->toArray();
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 如果是拼团订单
|
||||
if ($order['order_type'] == OrderEnum::TEAM_ORDER) {
|
||||
$time = time();
|
||||
$team_id = (new TeamJoin())->where(['order_id' => $order['id']])->value('team_id');
|
||||
$teamJoin = (new TeamJoin())->alias('TJ')
|
||||
->field(['TJ.*,O.order_sn,O.order_status,O.pay_status,O.refund_status,O.order_amount'])
|
||||
->where(['team_id' => $team_id])
|
||||
->join('order O', 'O.id=TJ.order_id')
|
||||
->select()->toArray();
|
||||
|
||||
TeamFound::update(['status' => TeamEnum::TEAM_STATUS_FAIL, 'team_end_time' => $time], ['id' => $team_id]);
|
||||
foreach ($teamJoin as $item) {
|
||||
TeamJoin::update(['status' => TeamEnum::TEAM_STATUS_FAIL, 'update_time' => $time], ['id' => $item['id']]);
|
||||
OrderRefundLogic::cancelOrder($item['order_id'], OrderLogEnum::TYPE_USER); //取消订单
|
||||
|
||||
if ($item['pay_status'] == PayEnum::ISPAID) {
|
||||
$order = (new Order())->findOrEmpty($item['order_id'])->toArray();
|
||||
OrderRefundLogic::cancelOrderRefundUpdate($order); //更新订单状态
|
||||
OrderRefundLogic::refund($order, $order['order_amount'], $order['order_amount']); //订单退款
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
//取消订单
|
||||
OrderRefundLogic::cancelOrder($id, OrderLogEnum::TYPE_SHOP, $admin_id);
|
||||
//已支付的订单,取消,退款
|
||||
if ($order['pay_status'] == PayEnum::ISPAID) {
|
||||
//更新订单状态
|
||||
OrderRefundLogic::cancelOrderRefundUpdate($order);
|
||||
//订单退款
|
||||
OrderRefundLogic::refund($order, $order['order_amount'], $order['order_amount']);
|
||||
}
|
||||
}
|
||||
|
||||
// 查找对应的分销订单置为失效状态
|
||||
if ($order['pay_status'] == PayEnum::ISPAID) {
|
||||
DistributionOrderGoods::where('order_id', $id)->update(['status' => 3]);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
//增加退款失败记录
|
||||
if ($order['pay_status'] == PayEnum::ISPAID) {
|
||||
OrderRefundLogic::addErrorRefund($order, $e->getMessage());
|
||||
}
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除订单
|
||||
* @param $id
|
||||
* @param $admin_id
|
||||
* @author ljj
|
||||
* @date 2021/11/10 5:37 下午
|
||||
*/
|
||||
public static function del($id,$admin_id)
|
||||
{
|
||||
Order::update(['delete'=>1,'update_time'=>time()], ['id'=>$id]);
|
||||
|
||||
//订单日志
|
||||
OrderLogLogic::record(
|
||||
OrderLogEnum::TYPE_SHOP,
|
||||
OrderLogEnum::SHOP_DEL_ORDER,
|
||||
$id,
|
||||
$admin_id,
|
||||
OrderLogEnum::SHOP_DEL_ORDER
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 修改地址
|
||||
* @param $post
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2021/11/10 6:35 下午
|
||||
*/
|
||||
public static function editAddress($post)
|
||||
{
|
||||
Order::update(
|
||||
[
|
||||
'consignee'=>$post['consignee'],
|
||||
'province'=>$post['province'],
|
||||
'city'=>$post['city'],
|
||||
'district'=>$post['district'],
|
||||
'address'=>$post['address'],
|
||||
'mobile'=>$post['mobile'],
|
||||
'update_time' => time(),
|
||||
], ['id'=>$post['id']]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取地址详情
|
||||
* @param $id
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2021/11/13 11:41 上午
|
||||
*/
|
||||
public static function getAddress($id)
|
||||
{
|
||||
$result = Order::where('id',$id)
|
||||
->field('consignee,province,city,district,address,mobile')
|
||||
->find()
|
||||
->toArray();
|
||||
$result['region'] = DevRegion::where('id', 'in', $result['province'].','.$result['city'].','.$result['district'])->order('id','asc')->column('name');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 发货
|
||||
* @param $post
|
||||
* @param $admin_id
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2021/11/11 10:27 上午
|
||||
*/
|
||||
public static function delivery($post, $admin_id)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$order = Order::where(['id' => $post['id']], ['order_goods'])->find();
|
||||
|
||||
if ($order['shipping_status'] == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//添加发货单
|
||||
$delivery_data = [
|
||||
'order_id' => $post['id'],
|
||||
'order_sn' => $order['order_sn'],
|
||||
'user_id' => $order['user_id'],
|
||||
'admin_id' => $admin_id,
|
||||
'consignee' => $order['consignee'],
|
||||
'mobile' => $order['mobile'],
|
||||
'province' => $order['province'],
|
||||
'city' => $order['city'],
|
||||
'district' => $order['district'],
|
||||
'address' => $order['address'],
|
||||
'invoice_no' => $post['invoice_no'] ?? '',
|
||||
'send_type' => $post['send_type'],
|
||||
'create_time' => time(),
|
||||
];
|
||||
//配送方式->快递配送
|
||||
if ($post['send_type'] == 1) {
|
||||
$shipping = Express::where('id', $post['shipping_id'])->find();
|
||||
$delivery_data['shipping_id'] = $post['shipping_id'];
|
||||
$delivery_data['shipping_name'] = $shipping['name'];
|
||||
$delivery_data['shipping_status'] = 1;
|
||||
}
|
||||
$delivery = Delivery::create($delivery_data);
|
||||
|
||||
|
||||
//更新订单下商品的发货状态
|
||||
$order->update_time = time();
|
||||
$order->shipping_time = time();
|
||||
$order->shipping_status = 1;
|
||||
$order->order_status = Order::STATUS_WAIT_RECEIVE;
|
||||
$order->delivery_id = $delivery->id;
|
||||
$order->save();
|
||||
|
||||
//订单日志
|
||||
OrderLogLogic::record(
|
||||
OrderLogEnum::TYPE_SHOP,
|
||||
OrderLogEnum::SHOP_DELIVERY_ORDER,
|
||||
$post['id'],
|
||||
$admin_id,
|
||||
OrderLogEnum::SHOP_DELIVERY_ORDER
|
||||
);
|
||||
|
||||
//通知用户发货
|
||||
if (!empty($order['mobile'])) {
|
||||
event('Notice', [
|
||||
'scene' => NoticeEnum::ORDER_DELIVERY_NOTICE,
|
||||
'mobile' => $order['mobile'],
|
||||
'params' => [
|
||||
'order_id' => $order['id'],
|
||||
'user_id' => $order['user_id'],
|
||||
'shipping_name' => $delivery_data['shipping_name'] ?? '无需快递',
|
||||
'invoice_no' => $post['invoice_no'] ?? '-',
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取物流公司列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2021/11/13 11:46 上午
|
||||
*/
|
||||
public static function getExpress()
|
||||
{
|
||||
return Express::where('del',0)->field('id,name')->select()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 确认收货
|
||||
* @param $id
|
||||
* @param $admin_id
|
||||
* @author ljj
|
||||
* @date 2021/11/11 10:55 上午
|
||||
*/
|
||||
public static function confirm($id, $admin_id)
|
||||
{
|
||||
Order::update(
|
||||
[
|
||||
'order_status' => Order::STATUS_FINISH,
|
||||
'confirm_take_time' => time(),
|
||||
'update_time' => time(),
|
||||
], ['id'=>$id]);
|
||||
|
||||
//订单日志
|
||||
OrderLogLogic::record(
|
||||
OrderLogEnum::TYPE_SHOP,
|
||||
OrderLogEnum::SHOP_CONFIRM_ORDER,
|
||||
$id,
|
||||
$admin_id,
|
||||
OrderLogEnum::SHOP_CONFIRM_ORDER
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 查看物流
|
||||
* @param $id
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2021/11/11 11:34 上午
|
||||
*/
|
||||
public static function logistics($id)
|
||||
{
|
||||
return Delivery::where('order_id',$id)
|
||||
->field('shipping_name,invoice_no')
|
||||
->find()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 虚拟发货
|
||||
* @param $post
|
||||
* @param $admin_id
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2022/4/20 17:56
|
||||
*/
|
||||
public static function virtualDelivery($post, $admin_id)
|
||||
{
|
||||
try {
|
||||
$order_id = $post['order_id'];
|
||||
$order = Order::with(['order_goods'])->where(['del' => 0, 'id' => $order_id])->find();
|
||||
|
||||
// 更新发货订单信息
|
||||
$result = GoodsVirtualLogic::shopSelfDelivery($order_id, $post['delivery_content']);
|
||||
if (true !== $result) {
|
||||
throw new \Exception($result);
|
||||
}
|
||||
|
||||
//订单日志
|
||||
OrderLogLogic::record(
|
||||
OrderLogEnum::TYPE_SHOP,
|
||||
OrderLogEnum::SHOP_DELIVERY_ORDER,
|
||||
$order_id,
|
||||
$admin_id,
|
||||
OrderLogEnum::SHOP_DELIVERY_ORDER
|
||||
);
|
||||
|
||||
//通知用户发货
|
||||
if (!empty($order['mobile'])) {
|
||||
event('Notice', [
|
||||
'scene' => NoticeEnum::ORDER_DELIVERY_NOTICE,
|
||||
'mobile' => $order['mobile'],
|
||||
'params' => [
|
||||
'order_id' => $order['id'],
|
||||
'user_id' => $order['user_id'],
|
||||
'shipping_name' => '无需快递',
|
||||
'invoice_no' => '-',
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 确认付款
|
||||
* @param $order_id
|
||||
* @param $adminInfo
|
||||
* @return string|true
|
||||
* @author ljj
|
||||
* @date 2024/7/19 下午6:32
|
||||
*/
|
||||
public static function confirmPay($order_id, $adminInfo)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$order = Order::where(['id' => $order_id])->findOrEmpty()->toArray();
|
||||
$result = PayNotifyLogic::handle('order', $order['order_sn']);
|
||||
if (true !== $result) {
|
||||
throw new \Exception($result);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
303
app/shopapi/logic/ShopLogic.php
Normal file
303
app/shopapi/logic/ShopLogic.php
Normal file
@ -0,0 +1,303 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\shopapi\logic;
|
||||
use app\admin\controller\activity_area\Area;
|
||||
use app\common\enum\NoticeEnum;
|
||||
use app\common\enum\WithdrawalEnum;
|
||||
use app\common\model\shop\Shop;
|
||||
use app\common\model\shop\ShopAccountLog;
|
||||
use app\common\model\shop\ShopAdmin;
|
||||
use app\common\model\shop\ShopBank;
|
||||
use app\common\model\shop\ShopCategory;
|
||||
use app\common\model\shop\ShopWithdrawal;
|
||||
use app\common\server\AreaServer;
|
||||
use app\common\server\ConfigServer;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 商家逻辑层
|
||||
* Class ShopLogic
|
||||
* @package app\shopapi\logic
|
||||
*/
|
||||
class ShopLogic{
|
||||
|
||||
/**
|
||||
* @notes 获取商家可提现余额
|
||||
* @param $shop_id
|
||||
* @return mixed
|
||||
* @author cjhao
|
||||
* @date 2021/11/10 16:15
|
||||
*/
|
||||
public function getShopInfo(int $shop_id){
|
||||
$shop = Shop::where(['id'=>$shop_id])
|
||||
->field("id,cid,name,logo,is_run,wallet,score,nickname,mobile,intro,
|
||||
run_start_time,run_end_time,weekdays,province_id,city_id,district_id,address,refund_address,open_invoice,spec_invoice")
|
||||
->find()->toArray();
|
||||
|
||||
$shop['run_start_time'] = date('H:i',$shop['run_start_time']);
|
||||
$shop['run_end_time'] = date('H:i',$shop['run_end_time']);
|
||||
|
||||
|
||||
$shop['province_name'] = '';
|
||||
$shop['city_name'] = '';
|
||||
$shop['district_name'] = '';
|
||||
|
||||
$shop['province_id'] && $shop['province_name'] = AreaServer::getAddress($shop['province_id']);
|
||||
$shop['city_id'] && $shop['city_name'] = AreaServer::getAddress($shop['city_id']);
|
||||
$shop['district_id'] && $shop['district_name'] = AreaServer::getAddress($shop['district_id']);
|
||||
|
||||
$shop['refund_address']['province_name'] = !empty($shop['refund_address']['province_id']) ? AreaServer::getAddress($shop['refund_address']['province_id']) : '';
|
||||
$shop['refund_address']['city_name'] = !empty($shop['refund_address']['city_id']) ? AreaServer::getAddress($shop['refund_address']['city_id']) : '';
|
||||
$shop['refund_address']['district_name'] = !empty($shop['refund_address']['district_id']) ? AreaServer::getAddress($shop['refund_address']['district_id']) : '';
|
||||
|
||||
$shop['cate_name'] = ShopCategory::where('id', $shop['cid'])->value('name');
|
||||
|
||||
return $shop;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取提现信息
|
||||
* @param int $shop_id
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2021/11/10 16:30
|
||||
*/
|
||||
public function getWithdrawInfo(int $shop_id){
|
||||
$wallet = Shop::where(['id'=>$shop_id])
|
||||
->value("wallet");
|
||||
|
||||
$min_withdrawal_money = ConfigServer::get('shop_withdrawal', 'min_withdrawal_money', 0);
|
||||
$max_withdrawal_money = ConfigServer::get('shop_withdrawal', 'max_withdrawal_money', 0);
|
||||
$withdrawal_service_charge = ConfigServer::get('shop_withdrawal', 'withdrawal_service_charge', 0);
|
||||
|
||||
$bank_list = ShopBank::where(['shop_id'=>$shop_id,'del'=>0])
|
||||
->field('id,name,branch,nickname,account')
|
||||
->select()->toArray();
|
||||
return [
|
||||
'wallet' => $wallet,
|
||||
'min_withdrawal_money' => $min_withdrawal_money,
|
||||
'max_withdrawal_money' => $max_withdrawal_money,
|
||||
'withdrawal_service_charge' => $withdrawal_service_charge,
|
||||
'bank_list' => $bank_list,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 提现金额
|
||||
* @param array $post
|
||||
* @return bool|string
|
||||
* @author cjhao
|
||||
* @date 2021/11/10 16:56
|
||||
*/
|
||||
public function withdraw(array $post){
|
||||
Db::startTrans();
|
||||
try {
|
||||
$shop_id = $post['shop_id'];
|
||||
// 1、获取提现条件
|
||||
$withdrawal_service_charge = ConfigServer::get('shop_withdrawal', 'withdrawal_service_charge', 0);
|
||||
|
||||
// 2、获取商家信息
|
||||
$shop = (new Shop())->findOrEmpty($shop_id)->toArray();
|
||||
|
||||
// 4、获取商家提现手续费
|
||||
$poundage_amount = 0;
|
||||
if ($withdrawal_service_charge > 0) {
|
||||
$proportion = $withdrawal_service_charge / 100;
|
||||
$poundage_amount = $post['money'] * $proportion;
|
||||
$poundage_amount = $poundage_amount <= 0 ? 0 : $poundage_amount;
|
||||
}
|
||||
|
||||
// 5、创建申请记录
|
||||
$withdrawal = ShopWithdrawal::create([
|
||||
'sn' => createSn('shop_withdrawal', 'sn'),
|
||||
'bank_id' => $post['bank_id'],
|
||||
'shop_id' => $shop_id,
|
||||
'apply_amount' => floatval($post['money']),
|
||||
'left_amount' => $post['money'] - $poundage_amount,
|
||||
'poundage_amount' => $poundage_amount,
|
||||
'poundage_ratio' => $withdrawal_service_charge,
|
||||
'status' => WithdrawalEnum::APPLY_STATUS
|
||||
]);
|
||||
// 6、扣除商家可提现金额
|
||||
Shop::update([
|
||||
'wallet' => ['dec', floatval($post['money'])],
|
||||
'update_time' => time()
|
||||
], ['id' => $shop_id]);
|
||||
|
||||
$left_amount = Shop::where(['id' => $shop_id])->value('wallet');
|
||||
// 7、增加提现流水记录(待提现)
|
||||
$logType = ShopAccountLog::withdrawal_stay_money;
|
||||
ShopAccountLog::decData($shop_id, $logType, $post['money'], $left_amount, [
|
||||
'source_id' => $withdrawal['id'],
|
||||
'source_sn' => $withdrawal['sn'],
|
||||
'remark' => '商家提现'
|
||||
]);
|
||||
|
||||
$platform_contacts = ConfigServer::get('website_platform', 'platform_mobile');
|
||||
if (!empty($platform_contacts)) {
|
||||
event('Notice', [
|
||||
'scene' => NoticeEnum::SHOP_WITHDRAWAL_NOTICE_PLATFORM,
|
||||
'mobile' => $platform_contacts,
|
||||
'params' => [
|
||||
'shop_withdrawal_sn' => $withdrawal['sn'],
|
||||
'shop_name' => $shop['name'],
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 提现记录
|
||||
* @param $shop_id
|
||||
* @param $page_no
|
||||
* @param $page_size
|
||||
* @return array
|
||||
* @throws \think\db\exception\DbException
|
||||
* @author cjhao
|
||||
* @date 2021/11/10 17:10
|
||||
*/
|
||||
public function withdrawLog(int $shop_id,int $page_no,int $page_size){
|
||||
$lists = ShopWithdrawal::alias('SW')
|
||||
->join('shop_account_log SCL','SW.sn = SCL.source_sn')
|
||||
->where(['SW.shop_id'=>$shop_id,'source_type'=>[ShopAccountLog::withdrawal_stay_money,ShopAccountLog::withdrawal_dec_money,ShopAccountLog::withdrawal_fail_money]])
|
||||
->field("SCL.id,SCL.change_amount,SCL.left_amount,status,SCL.create_time")
|
||||
->paginate([
|
||||
'page' => $page_no,
|
||||
'list_rows' => $page_size,
|
||||
'var_page' => 'page'
|
||||
])->toArray();
|
||||
|
||||
return ['count' => $lists['total'], 'lists' => $lists['data']];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加银行账户
|
||||
* @param $post
|
||||
* @return bool
|
||||
* @author cjhao
|
||||
* @date 2021/11/10 18:30
|
||||
*/
|
||||
public function addBank(array $post){
|
||||
$shop_bank = new ShopBank();
|
||||
$shop_bank->shop_id = $post['shop_id'];
|
||||
$shop_bank->name = $post['name'];
|
||||
$shop_bank->branch = $post['branch'];
|
||||
$shop_bank->nickname = $post['nickname'];
|
||||
$shop_bank->account = $post['account'];
|
||||
$shop_bank->save();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取银行卡
|
||||
* @param int $id
|
||||
* @param int $shop_id
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2021/11/11 15:46
|
||||
*/
|
||||
public function getBank(int $id,int $shop_id){
|
||||
$shop_bank = ShopBank::where(['id'=>$id,'shop_id'=>$shop_id])
|
||||
->field('id,name,branch,nickname,account')
|
||||
->findOrEmpty()->toArray();
|
||||
return $shop_bank;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑银行账户
|
||||
* @param $post
|
||||
* @return bool
|
||||
* @author cjhao
|
||||
* @date 2021/11/10 18:38
|
||||
*/
|
||||
public function editBank(array $post){
|
||||
ShopBank::update([
|
||||
'name' => $post['name'],
|
||||
'branch' => $post['branch'],
|
||||
'nickname' => $post['nickname'],
|
||||
'account' => $post['account'],
|
||||
'del' => 0
|
||||
], ['id'=>$post['id']]);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除银行卡
|
||||
* @param $id
|
||||
* @param $shop_id
|
||||
* @return bool
|
||||
* @author cjhao
|
||||
* @date 2021/11/10 18:42
|
||||
*/
|
||||
public function delBank(int $id,int $shop_id){
|
||||
ShopBank::where(['id'=>$id,'shop_id'=>$shop_id])->delete();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更新商家信息
|
||||
* @param array $post
|
||||
* @param int $shop_id
|
||||
* @return Shop
|
||||
* @author cjhao
|
||||
* @date 2021/11/11 11:34
|
||||
*/
|
||||
public function shopSet(array $post,int $shop_id){
|
||||
if(isset($post['refund_address'])){
|
||||
$post['refund_address'] = json_encode($post['refund_address'],JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
return Shop::update($post,['id'=>$shop_id]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 修改密码
|
||||
* @param $password
|
||||
* @param $admin_id
|
||||
* @param $shop_id
|
||||
* @return bool
|
||||
* @author cjhao
|
||||
* @date 2021/11/11 16:03
|
||||
*/
|
||||
public function updatePassword(array $post,int $shop_id)
|
||||
{
|
||||
try {
|
||||
$admin = ShopAdmin::where(['id' => $post['admin_id'], 'shop_id' => $shop_id])->find();
|
||||
$admin->password = generatePassword($post['password'], $admin['salt']);
|
||||
$admin->save();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
263
app/shopapi/logic/StatisticsLogic.php
Normal file
263
app/shopapi/logic/StatisticsLogic.php
Normal file
@ -0,0 +1,263 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\shopapi\logic;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\VerificationEnum;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\shop\Shop;
|
||||
use app\common\server\UrlServer;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 数据逻辑层
|
||||
* Class StatisticsLogic
|
||||
* @package app\shopapi\logic
|
||||
*/
|
||||
class StatisticsLogic{
|
||||
|
||||
/**
|
||||
* @notes 工作台
|
||||
* @param int $shop_id
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2021/11/11 15:23
|
||||
*/
|
||||
public function workbench(int $shop_id){
|
||||
//头部数据统计
|
||||
$where = [];
|
||||
$where[] = ['pay_status', '>', PayEnum::UNPAID];
|
||||
$where[] = ['shop_id','=',$shop_id];
|
||||
|
||||
//成交笔数
|
||||
$order_num = Db::name('order')
|
||||
->where($where)
|
||||
->whereDay('create_time')
|
||||
->count('id');
|
||||
|
||||
//销售金额
|
||||
$order_amount = Db::name('order')
|
||||
->where($where)
|
||||
->whereDay('create_time')
|
||||
->sum('order_amount') ?? 0;
|
||||
|
||||
//进店人数
|
||||
$shop_user = Db::name('shop_stat')
|
||||
->where(['shop_id'=>$shop_id])
|
||||
->whereDay('create_time')
|
||||
->group(['ip'])
|
||||
->count('id');
|
||||
|
||||
//当前时间戳
|
||||
$start_t = time();
|
||||
//echarts图表数据
|
||||
$echarts_order_amount = [];
|
||||
$echarts_user_pv = [];
|
||||
$dates = [];
|
||||
for ($i = 7; $i >= 1; $i--) {
|
||||
$where_start = strtotime("- ".$i."day", $start_t);
|
||||
$dates[] = date('m-d',$where_start);
|
||||
$start_now = strtotime(date('Y-m-d',$where_start));
|
||||
$end_now = strtotime(date('Y-m-d 23:59:59',$where_start));
|
||||
$amount = Db::name('order')
|
||||
->where([['shop_id','=',$shop_id],['create_time','between',[$start_now, $end_now]],['pay_status','>',PayEnum::UNPAID]])
|
||||
->sum('order_amount');
|
||||
$pv = Db::name('shop_stat')
|
||||
->where([['shop_id','=',$shop_id],['create_time','between',[$start_now, $end_now]]])
|
||||
->group('ip')
|
||||
->count('id');
|
||||
$echarts_order_amount[] = sprintf("%.2f",substr(sprintf("%.3f", $amount), 0, -2));
|
||||
$echarts_user_pv[] = $pv;
|
||||
}
|
||||
|
||||
$self_order_num = Order::where([
|
||||
'delivery_type' => OrderEnum::DELIVERY_TYPE_SELF,
|
||||
'pay_status' => PayEnum::ISPAID,
|
||||
'shop_id' => $shop_id
|
||||
])->count();
|
||||
$is_verification = Order::where([
|
||||
'delivery_type' => OrderEnum::DELIVERY_TYPE_SELF,
|
||||
'pay_status' => PayEnum::ISPAID,
|
||||
'verification_status' => OrderEnum::NOT_WRITTEN_OFF,
|
||||
'shop_id' => $shop_id
|
||||
])->count();
|
||||
$no_verification = Order::where([
|
||||
'delivery_type' => OrderEnum::DELIVERY_TYPE_SELF,
|
||||
'pay_status' => PayEnum::ISPAID,
|
||||
'verification_status' => OrderEnum::WRITTEN_OFF,
|
||||
'shop_id' => $shop_id
|
||||
])->count();
|
||||
|
||||
return [
|
||||
'now' => date('Y-m-d H:i:s', time()),
|
||||
'shop_name' => Shop::where(['id'=>$shop_id])->value('name'),
|
||||
'order_num' => $order_num,
|
||||
'order_amount' => $order_amount,
|
||||
'shop_user' => $shop_user,
|
||||
'self_order' => $self_order_num,
|
||||
'is_verification' => $is_verification,
|
||||
'no_verification' => $no_verification,
|
||||
'echarts_order_amount' => $echarts_order_amount,
|
||||
'echarts_user_visit' => $echarts_user_pv,
|
||||
'dates' => $dates,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 交易接口
|
||||
* @param int $shop_id
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2021/11/11 14:39
|
||||
*/
|
||||
public function trading(int $shop_id){
|
||||
//获取今天的时间戳
|
||||
$today = strtotime('today');
|
||||
//近七天的开始日期
|
||||
$start_time = $today - 86400 * 7;
|
||||
//近七天的结束日期
|
||||
$end_time = $today - 1;
|
||||
|
||||
$order_num = Db::name('order')
|
||||
->where([['pay_status', '>', PayEnum::UNPAID],['shop_id', '=', $shop_id]])
|
||||
->whereDay('create_time')
|
||||
->count('id');
|
||||
$order_amount = Db::name('order')
|
||||
->where([['pay_status', '>', PayEnum::UNPAID],['shop_id', '=', $shop_id]])
|
||||
->whereDay('create_time')
|
||||
->sum('order_amount') ?? 0;
|
||||
|
||||
//当前时间戳
|
||||
$start_t = time();
|
||||
//echarts图表数据
|
||||
$echarts_order_num_add = [];
|
||||
$echarts_order_amount_add = [];
|
||||
$dates = [];
|
||||
for ($i = 7; $i >= 1; $i--) {
|
||||
$where_start = strtotime("- " . $i . "day", $start_t);
|
||||
$dates[] = date('m-d', $where_start);
|
||||
$start_now = strtotime(date('Y-m-d', $where_start));
|
||||
$end_now = strtotime(date('Y-m-d 23:59:59', $where_start));
|
||||
|
||||
$order_num_add = Db::name('order')
|
||||
->where([['create_time', 'between', [$start_now, $end_now]], ['pay_status', '>', PayEnum::UNPAID],['shop_id', '=', $shop_id]])
|
||||
->count('id');
|
||||
$order_amount_add = Db::name('order')
|
||||
->where([['create_time', 'between', [$start_now, $end_now]], ['pay_status', '>', PayEnum::UNPAID],['shop_id', '=', $shop_id]])
|
||||
->sum('order_amount') ?? 0;
|
||||
|
||||
$echarts_order_num_add[] = $order_num_add;
|
||||
$echarts_order_amount_add[] = sprintf("%.2f",substr(sprintf("%.3f", $order_amount_add), 0, -2));
|
||||
}
|
||||
|
||||
return [
|
||||
'order_num' => $order_num,
|
||||
'order_amount' => '¥'.number_format($order_amount,2),
|
||||
'echarts_order_num_add' => $echarts_order_num_add,
|
||||
'echarts_order_amount_add' => $echarts_order_amount_add,
|
||||
'days' => $dates,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 商品分析
|
||||
* @param int $shop_id
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2021/11/11 15:09
|
||||
*/
|
||||
public function goodslist(int $shop_id){
|
||||
// 商品列表
|
||||
$goods_count = Db::name('order')->alias('o')
|
||||
->join('order_goods og', 'og.order_id = o.id')
|
||||
->join('shop s', 's.id = o.shop_id')
|
||||
->where([['o.pay_status', '=', 1],['o.shop_id', '=', $shop_id]])
|
||||
->group('og.goods_id')
|
||||
->count();
|
||||
|
||||
$goods_list = Db::name('order')->alias('o')
|
||||
->join('order_goods og', 'og.order_id = o.id')
|
||||
->join('shop s', 's.id = o.shop_id')
|
||||
->where([['o.pay_status', '=', 1],['o.shop_id', '=', $shop_id]])
|
||||
->group('og.goods_id')
|
||||
->limit(20)
|
||||
->order('sales_volume desc')
|
||||
->column('s.id,s.logo,s.type,s.name,o.shop_id,count(o.id) as sales_volume,sum(o.order_amount) as sales_price,og.image,og.goods_name');
|
||||
|
||||
foreach ($goods_list as $k => $item) {
|
||||
$goods_list[$k]['number'] = $k + 1;
|
||||
$goods_list[$k]['sales_price'] = '¥' . number_format($item['sales_price'], 2);
|
||||
$goods_list[$k]['goods_image'] = UrlServer::getFileUrl($item['image']);
|
||||
$goods_list[$k]['logo'] = UrlServer::getFileUrl($item['logo']);
|
||||
|
||||
if ($item['type'] == 1) {
|
||||
$goods_list[$k]['type_desc'] = '官方自营';
|
||||
} else {
|
||||
$goods_list[$k]['type_desc'] = '入驻商家';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $goods_count, 'lists' => $goods_list];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 访问分析
|
||||
* @param int $shop_id
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2021/11/11 15:09
|
||||
*/
|
||||
public function visit(int $shop_id){
|
||||
|
||||
//获取今天的时间戳
|
||||
$today = strtotime('today');
|
||||
//近七天的开始日期
|
||||
$start_time = $today - 86400 * 7;
|
||||
//近七天的结束日期
|
||||
$end_time = $today - 1;
|
||||
|
||||
$user_count = Db::name('shop_stat')
|
||||
->where([['create_time', 'between', [$start_time, $end_time]],['shop_id', '=', $shop_id]])
|
||||
->count('id');
|
||||
//当前时间戳
|
||||
$start_t = time();
|
||||
//echarts图表数据
|
||||
$echarts_add = [];
|
||||
$dates = [];
|
||||
for ($i = 7; $i >= 1; $i--) {
|
||||
$where_start = strtotime("- " . $i . "day", $start_t);
|
||||
$dates[] = date('m-d', $where_start);
|
||||
$start_now = strtotime(date('Y-m-d', $where_start));
|
||||
$end_now = strtotime(date('Y-m-d 23:59:59', $where_start));
|
||||
|
||||
$add = Db::name('shop_stat')
|
||||
->where([['create_time', 'between', [$start_now, $end_now]],['shop_id', '=', $shop_id]])
|
||||
->count('id');
|
||||
$echarts_add[] = $add;
|
||||
}
|
||||
|
||||
return [
|
||||
'user_count' => $user_count,
|
||||
'echarts_add' => $echarts_add,
|
||||
'days' => $dates,
|
||||
];
|
||||
}
|
||||
}
|
||||
174
app/shopapi/logic/VerificationLogic.php
Normal file
174
app/shopapi/logic/VerificationLogic.php
Normal file
@ -0,0 +1,174 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\logic;
|
||||
|
||||
|
||||
use app\common\basics\Logic;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\OrderLogEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\VerificationEnum;
|
||||
use app\common\logic\OrderLogLogic;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\order\Verification;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 自提核销逻辑
|
||||
* Class VerificationLogic
|
||||
* @package app\shopapi\logic
|
||||
*/
|
||||
class VerificationLogic extends Logic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 核销订单列表
|
||||
* @param $params
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 17:40
|
||||
*/
|
||||
public static function lists($params, $pageNo, $pageSize, $shopId)
|
||||
{
|
||||
$where[] = ['delivery_type', '=', OrderEnum::DELIVERY_TYPE_SELF];
|
||||
$where[] = ['pay_status', '=', PayEnum::ISPAID];
|
||||
$where[] = ['shop_id', '=', $shopId];
|
||||
|
||||
$verificationStatus = 0;
|
||||
if (isset($params['status'])) {
|
||||
$verificationStatus = $params['status'];
|
||||
}
|
||||
$where[] = ['verification_status', '=', $verificationStatus];
|
||||
|
||||
$lists = Order::field('id,address,verification_status,consignee,verification_status')
|
||||
->with(['order_goods' => function ($query) {
|
||||
$query->field('order_id,image,goods_name,goods_num,spec_value');
|
||||
}])
|
||||
->where($where)
|
||||
->append(['verification_status_text'])
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$count = Order::where($where)->count();
|
||||
|
||||
return [
|
||||
'list' => $lists,
|
||||
'page' => $pageNo,
|
||||
'size' => $pageSize,
|
||||
'count' => $count,
|
||||
'more' => is_more($count, $pageNo, $pageSize)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 订单详情
|
||||
* @param $params
|
||||
* @param $shopId
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 18:08
|
||||
*/
|
||||
public static function detail($params, $shopId)
|
||||
{
|
||||
$detail = Order::where('pickup_code',$params['pickup_code'])
|
||||
->where('shop_id', $shopId)
|
||||
->with([
|
||||
'user',
|
||||
'order_goods' => function ($query) {
|
||||
$query->field('order_id,image,goods_name,goods_num,spec_value');
|
||||
}
|
||||
])
|
||||
->append(['verification_status_text'])
|
||||
->field('id,address,verification_status,consignee,verification_status,consignee,mobile')
|
||||
->find()
|
||||
->toArray();
|
||||
|
||||
$detail['show_verification_nickname'] = $detail['consignee'] ? : ($detail['user']['nickname'] ?? '');
|
||||
$detail['show_verification_mobile'] = $detail['mobile'] ? : ($detail['user']['mobile'] ?? '');
|
||||
|
||||
if ($detail['show_verification_mobile']) {
|
||||
$detail['show_verification_mobile'] = substr_replace($detail['show_verification_mobile'], '****', 3, 4);
|
||||
}
|
||||
|
||||
return $detail;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 核销订单
|
||||
* @param $params
|
||||
* @param $adminInfo
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 17:11
|
||||
*/
|
||||
public static function verification($params, $adminInfo)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$order = Order::find($params['id']);
|
||||
|
||||
//添加核销记录
|
||||
Verification::create([
|
||||
'order_id' => $order['id'],
|
||||
'shop_id' => $order['shop_id'],
|
||||
'handle_id' => $adminInfo['id'],
|
||||
'verification_scene' => VerificationEnum::TYPE_SHOP,
|
||||
'snapshot' => json_encode([
|
||||
'sn' => $adminInfo['account'],
|
||||
'name' => $adminInfo['name']
|
||||
]),
|
||||
]);
|
||||
|
||||
//更新订单状态
|
||||
$order->order_status = OrderEnum::ORDER_STATUS_COMPLETE;
|
||||
$order->verification_status = OrderEnum::WRITTEN_OFF;
|
||||
$order->confirm_take_time = time();
|
||||
$order->save();
|
||||
|
||||
//订单日志
|
||||
OrderLogLogic::record(
|
||||
OrderLogEnum::TYPE_SHOP,
|
||||
OrderLogEnum::SHOP_VERIFICATION,
|
||||
$order['id'],
|
||||
$adminInfo['id'],
|
||||
OrderLogEnum::SHOP_VERIFICATION
|
||||
);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
233
app/shopapi/server/UserServer.php
Normal file
233
app/shopapi/server/UserServer.php
Normal file
@ -0,0 +1,233 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\shopapi\server;
|
||||
|
||||
|
||||
use app\api\logic\DistributionLogic;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\Client_;
|
||||
use app\common\model\user\UserAuth;
|
||||
use app\common\server\storage\Driver as StorageDriver;
|
||||
use app\common\server\UrlServer;
|
||||
use app\common\server\ConfigServer;
|
||||
use think\facade\Db;
|
||||
use think\Exception;
|
||||
|
||||
|
||||
class UserServer
|
||||
{
|
||||
|
||||
/**
|
||||
* User: 意象信息科技 lr
|
||||
* Desc: 通过小程序创建用户信息
|
||||
* @param $response
|
||||
* @param $client
|
||||
* @return array|\PDOStatement|string|\think\Model|null
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function createUser($response, $client)
|
||||
{
|
||||
$user_info = [];
|
||||
try {
|
||||
$openid = $response['openid'];
|
||||
$unionid = $response['unionid'] ?? '';
|
||||
$avatar_url = $response['headimgurl'] ?? '';
|
||||
$nickname = $response['nickname'] ?? '';
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
// 获取存储引擎
|
||||
$config = [
|
||||
'default' => ConfigServer::get('storage', 'default', 'local'),
|
||||
'engine' => ConfigServer::get('storage_engine')
|
||||
];
|
||||
|
||||
$time = time(); //创建时间
|
||||
$avatar = ''; //头像路径
|
||||
|
||||
if (empty($avatar_url)) {
|
||||
$avatar = ConfigServer::get('website', 'user_image', '');
|
||||
} else {
|
||||
if ($config['default'] == 'local') {
|
||||
$file_name = md5($openid . $time) . '.jpeg';
|
||||
$avatar = download_file($avatar_url, 'uploads/user/avatar/', $file_name);
|
||||
} else {
|
||||
$avatar = 'uploads/user/avatar/' . md5($openid . $time) . '.jpeg';
|
||||
$StorageDriver = new StorageDriver($config);
|
||||
if (!$StorageDriver->fetch($avatar_url, $avatar)) {
|
||||
throw new Exception( '头像保存失败:'. $StorageDriver->getError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'nickname' => $nickname,
|
||||
'sn' => create_user_sn(),
|
||||
'avatar' => $avatar,
|
||||
'create_time' => $time,
|
||||
'distribution_code' => generate_invite_code(),//分销邀请码
|
||||
'is_distribution' => DistributionLogic::isDistributionMember(),
|
||||
'client' => $client
|
||||
];
|
||||
|
||||
if (empty($nickname)) {
|
||||
$data['nickname'] = '用户'.$data['sn'];
|
||||
}
|
||||
|
||||
$user = User::create($data);
|
||||
$user_id = $user->id;
|
||||
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'openid' => $openid,
|
||||
'create_time' => $time,
|
||||
'unionid' => $unionid,
|
||||
'client' => $client,
|
||||
];
|
||||
|
||||
UserAuth::create($data);
|
||||
|
||||
//生成会员分销扩展表
|
||||
DistributionLogic::createUserDistribution($user_id);
|
||||
|
||||
// 生成分销基础信息表
|
||||
\app\common\logic\DistributionLogic::add($user_id);
|
||||
|
||||
Db::commit();
|
||||
|
||||
$user_info = User::field(['id', 'nickname', 'avatar', 'level', 'disable', 'distribution_code'])
|
||||
->where(['id' => $user_id])
|
||||
->find();
|
||||
if (empty($user_info['avatar'])) {
|
||||
$user_info['avatar'] = UrlServer::getFileUrl(ConfigServer::get('website', 'user_image', ''));
|
||||
} else {
|
||||
$user_info['avatar'] = UrlServer::getFileUrl($user_info['avatar']);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
|
||||
return $user_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
* @param $response
|
||||
* @param $client
|
||||
* @param $user_id
|
||||
* @return array|\PDOStatement|string|\think\Model|null
|
||||
*/
|
||||
public static function updateUser($response, $client, $user_id)
|
||||
{
|
||||
$time = time();
|
||||
try {
|
||||
|
||||
$openid = $response['openid'];
|
||||
$unionid = $response['unionid'] ?? '';
|
||||
$avatar_url = $response['headimgurl'] ?? '';
|
||||
$nickname = $response['nickname'] ?? '';
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
//ios,android
|
||||
if (in_array($client, [Client_::ios, Client_::android])) {
|
||||
UserAuth::where(['openid' => $openid])
|
||||
->update(['client' => $client]);
|
||||
}
|
||||
|
||||
//用户已存在,但是无该端的授权信息,保存数据
|
||||
$user_auth_id = UserAuth::where(['user_id' => $user_id, 'openid' => $openid])
|
||||
->value('id');
|
||||
|
||||
if (empty($user_auth_id)) {
|
||||
$data = [
|
||||
'create_time' => $time,
|
||||
'openid' => $openid,
|
||||
'unionid' => $unionid,
|
||||
'user_id' => $user_id,
|
||||
'client' => $client,
|
||||
];
|
||||
UserAuth::create($data);
|
||||
}
|
||||
|
||||
$user_info = User::alias('u')
|
||||
->field(['u.nickname', 'u.avatar', 'u.level', 'u.id', 'au.unionid'])
|
||||
->join('user_auth au', 'u.id=au.user_id')
|
||||
->where(['au.openid' => $openid])
|
||||
->find();
|
||||
|
||||
//无头像需要更新头像
|
||||
if (empty($user_info['avatar'])) {
|
||||
// 获取存储引擎
|
||||
$config = [
|
||||
'default' => ConfigServer::get('storage', 'default', 'local'),
|
||||
'engine' => ConfigServer::get('storage_engine')
|
||||
];
|
||||
|
||||
$avatar = ''; //头像路径
|
||||
if ($config['default'] == 'local') {
|
||||
$file_name = md5($openid . $time) . '.jpeg';
|
||||
$avatar = download_file($avatar_url, 'uploads/user/avatar/', $file_name);
|
||||
} else {
|
||||
$avatar = 'uploads/user/avatar/' . md5($openid . $time) . '.jpeg';
|
||||
$StorageDriver = new StorageDriver($config);
|
||||
if (!$StorageDriver->fetch($avatar_url, $avatar)) {
|
||||
throw new Exception( '头像保存失败:'. $StorageDriver->getError());
|
||||
}
|
||||
}
|
||||
|
||||
$data['avatar'] = $avatar;
|
||||
$data['update_time'] = $time;
|
||||
$data['nickname'] = $nickname;
|
||||
User::where(['id' => $user_info['id']])
|
||||
->update($data);
|
||||
}
|
||||
|
||||
//之前无unionid需要更新
|
||||
if (empty($user_info['unionid']) && isset($unionid)) {
|
||||
$data = [];
|
||||
$data['unionid'] = $unionid;
|
||||
$data['update_time'] = $time;
|
||||
UserAuth::where(['user_id' => $user_info['id']])
|
||||
->update($data);
|
||||
}
|
||||
|
||||
$user_info = User::where(['id' => $user_info['id']])
|
||||
->field(['id', 'nickname', 'avatar', 'level', 'disable', 'distribution_code'])
|
||||
->find();
|
||||
|
||||
if (empty($user_info['avatar'])) {
|
||||
$user_info['avatar'] = UrlServer::getFileUrl(ConfigServer::get('website', 'user_image', ''));
|
||||
} else {
|
||||
$user_info['avatar'] = UrlServer::getFileUrl($user_info['avatar']);
|
||||
}
|
||||
Db::commit();
|
||||
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
|
||||
return $user_info;
|
||||
}
|
||||
}
|
||||
68
app/shopapi/validate/AdminPasswordValidate.php
Normal file
68
app/shopapi/validate/AdminPasswordValidate.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\validate;
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\shop\ShopAdmin;
|
||||
|
||||
/**
|
||||
* 管理员密码
|
||||
* Class AdminPasswordValidate
|
||||
* @package app\admin\validate
|
||||
*/
|
||||
class AdminPasswordValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'old_password' => 'require|verify',
|
||||
'password' => 'require|length:6,16|confirm',
|
||||
// 'password_confirm' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'old_password.require' => '当前密码不能为空',
|
||||
'old_password.verify' => '当前密码输入不正确',
|
||||
'password.require' => '新密码不能为空',
|
||||
'password.length' => '密码长度必须为6到16位之间',
|
||||
'password.confirm' => '两次密码输入不一致',
|
||||
'password_confirm.require' => '请输入确认密码',
|
||||
];
|
||||
|
||||
/**
|
||||
* 密码验证
|
||||
* @param $old_password
|
||||
* @param $other
|
||||
* @param $data
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
protected function verify($old_password, $other, $data)
|
||||
{
|
||||
$admin = ShopAdmin::find($data['admin_id']);
|
||||
$password = generatePassword($old_password, $admin['salt']);
|
||||
|
||||
if ($password != $admin['password']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
90
app/shopapi/validate/LoginValidate.php
Normal file
90
app/shopapi/validate/LoginValidate.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace app\shopapi\validate;
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\shop\ShopAdmin;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* 商家移动端登录验证
|
||||
* Class LoginValidate
|
||||
* @package app\shopapi\validate
|
||||
*/
|
||||
class LoginValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'client' => 'require|in:1,2,3,4,5,6',
|
||||
'account' => 'require',
|
||||
'password' => 'require|checkPassword',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'password.require' => '请输入密码',
|
||||
'password.checkPassword' => '账号或密码错误',
|
||||
'client.require' => '请输入客户端',
|
||||
'client.in' => '无效的客户端',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验密码
|
||||
* @param $password
|
||||
* @param $other
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2021/11/9 16:02
|
||||
*/
|
||||
protected function checkPassword($password, $other, $data)
|
||||
{
|
||||
if (false === $this->safe()) {
|
||||
$this->message['password.password'] .= ':多次输入错误';
|
||||
return false;
|
||||
}
|
||||
|
||||
$admin_info = (new ShopAdmin())->alias('a')
|
||||
->field('a.*')
|
||||
->join('shop s', 's.id = a.shop_id')
|
||||
->where(['a.account' => $data['account'], 'a.del' => 0])
|
||||
->find();
|
||||
|
||||
if (empty($admin_info)) {
|
||||
$this->safe(true);
|
||||
return '账号不存在';
|
||||
}
|
||||
|
||||
if ($admin_info['disable']) {
|
||||
return '账号被禁用';
|
||||
}
|
||||
|
||||
$password = generatePassword($password, $admin_info['salt']);
|
||||
if ($password != $admin_info['password']) {
|
||||
$this->safe(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 连续30分钟内15次输错密码,无法登录
|
||||
* @param bool $add
|
||||
* @return bool
|
||||
*/
|
||||
protected function safe($add = false)
|
||||
{
|
||||
$cache_name = 'shop_api_login_error_count' . request()->ip();
|
||||
if ($add) {
|
||||
$admin_login_error_count = Cache::get($cache_name);
|
||||
$admin_login_error_count++;
|
||||
Cache::tag('shop_api_login_error_count')->set($cache_name, $admin_login_error_count, 1800);
|
||||
}
|
||||
$count = Cache::get($cache_name);
|
||||
|
||||
if (!empty($count) && $count >= 15) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
242
app/shopapi/validate/OrderValidate.php
Normal file
242
app/shopapi/validate/OrderValidate.php
Normal file
@ -0,0 +1,242 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\validate;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\model\Delivery;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\team\Team;
|
||||
use app\common\model\team\TeamJoin;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 商家移动端订单管理验证器
|
||||
* Class OrderValidate
|
||||
* @package app\shopapi\validate
|
||||
*/
|
||||
class OrderValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkId',
|
||||
'consignee' => 'require',
|
||||
'province' => 'require',
|
||||
'city' => 'require',
|
||||
'district' => 'require',
|
||||
'address' => 'require',
|
||||
'mobile' => [ 'require', 'checkMobile' => [ 'check' => [ 'land', 'hk' ] ] ],
|
||||
'send_type' => 'require|in:1,2',
|
||||
'shipping_id' => 'requireIf:send_type,1',
|
||||
'invoice_no' => 'requireIf:send_type,1',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'consignee.require' => '请填写收件人',
|
||||
'province.require' => '地址参数缺失',
|
||||
'city.require' => '地址参数缺失',
|
||||
'district.require' => '地址参数缺失',
|
||||
'address.require' => '请填写详细',
|
||||
'mobile.require' => '请填写手机号码',
|
||||
'mobile.mobile' => '请填写正确的手机号码',
|
||||
'send_type.require' => '请选择快递方式',
|
||||
'send_type.in' => '快递方式参数错误',
|
||||
'shipping_id.requireIf' => '请选择快递公司',
|
||||
'invoice_no.requireIf' => '请填写快递单号',
|
||||
];
|
||||
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneCancel()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id','checkCancel');
|
||||
}
|
||||
|
||||
public function sceneDel()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id','checkDel');
|
||||
}
|
||||
|
||||
public function sceneEditAddress()
|
||||
{
|
||||
return $this->only(['id','consignee','province','city','district','address','mobile']);
|
||||
}
|
||||
|
||||
public function sceneDelivery()
|
||||
{
|
||||
return $this->only(['id','send_type','shipping_id','invoice_no'])
|
||||
->append('id','checkDelivery');
|
||||
}
|
||||
|
||||
public function sceneConfirm()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id','checkConfirm');
|
||||
}
|
||||
|
||||
public function sceneLogistics()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id','checkLogistics');
|
||||
}
|
||||
|
||||
public function sceneGetAddress()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单是否存在
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2021/11/10 3:25 下午
|
||||
*/
|
||||
public function checkId($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['id'=>$value,'shop_id'=>$data['shop_id'],'del'=>0,'delete'=>0])->findOrEmpty();
|
||||
if ($result->isEmpty()) {
|
||||
return '订单不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单是否可以取消
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2021/11/10 4:38 下午
|
||||
*/
|
||||
public function checkCancel($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['id'=>$value,'shop_id'=>$data['shop_id']])->findOrEmpty();
|
||||
|
||||
if ($result['order_status'] > OrderEnum::ORDER_STATUS_DELIVERY && $result['delivery_type'] != 2) {
|
||||
return '此订单不可取消';
|
||||
}
|
||||
|
||||
if ($result['order_status'] > OrderEnum::ORDER_STATUS_GOODS && $result['delivery_type'] == 2) {
|
||||
return '此订单不可取消';
|
||||
}
|
||||
|
||||
if ($result['order_type'] == OrderEnum::TEAM_ORDER) {
|
||||
$found = Db::name('team_join')->where(['order_id' => $order['id']])->find();
|
||||
if ($found['status'] == Team::STATUS_WAIT_SUCCESS) {
|
||||
return '已支付的拼团订单需要有拼团结果才可以取消';
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单能否删除
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2021/11/10 5:21 下午
|
||||
*/
|
||||
public function checkDel($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['id'=>$value,'shop_id'=>$data['shop_id']])->findOrEmpty();
|
||||
if ($result['order_status'] != OrderEnum::ORDER_STATUS_DOWN) {
|
||||
return '此订单不可删除';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单能否发货
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2021/11/11 10:25 上午
|
||||
*/
|
||||
public function checkDelivery($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['id'=>$value])->findOrEmpty();
|
||||
|
||||
if ($result['shipping_status'] == 1) {
|
||||
return '订单已发货';
|
||||
}
|
||||
if ($result['order_type'] == OrderEnum::TEAM_ORDER) {
|
||||
$join = TeamJoin::where(['order_id' => $result['id']])->findOrEmpty();
|
||||
if ($join['status'] != Team::STATUS_SUCCESS) {
|
||||
return '已支付的拼团订单需要等待拼团成功后才能发货';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单能否确认收货
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2021/11/11 11:22 上午
|
||||
*/
|
||||
public function checkConfirm($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['id'=>$value])->findOrEmpty();
|
||||
|
||||
if ($result['shipping_status'] != 1 || $result['order_status'] != OrderEnum::ORDER_STATUS_GOODS) {
|
||||
return '此订单不允许确认收货';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单是否有物流信息
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2021/11/11 11:34 上午
|
||||
*/
|
||||
public function checkLogistics($value,$rule,$data)
|
||||
{
|
||||
$order = Order::where(['id'=>$value])->findOrEmpty();
|
||||
$delivery = Delivery::where('order_id',$value)->findOrEmpty();
|
||||
|
||||
if (($order['order_status'] != OrderEnum::ORDER_STATUS_GOODS && $order['order_status'] != OrderEnum::ORDER_STATUS_COMPLETE) || $delivery['send_type'] == 2) {
|
||||
return '暂无物流信息';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
180
app/shopapi/validate/ShopDataSetValidate.php
Normal file
180
app/shopapi/validate/ShopDataSetValidate.php
Normal file
@ -0,0 +1,180 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\shopapi\validate;
|
||||
use app\common\basics\Validate;
|
||||
use app\common\enum\ShopEnum;
|
||||
|
||||
/**
|
||||
* 商家信息验证
|
||||
* Class ShopInfoValidate
|
||||
* @package app\shopapi\validate
|
||||
*/
|
||||
class ShopDataSetValidate extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'dataset' => 'require|checkData',
|
||||
];
|
||||
protected $message = [
|
||||
'dataset.require' => '请输入信息',
|
||||
];
|
||||
|
||||
|
||||
protected $allow_fields = [
|
||||
'nickname', //联系人
|
||||
'mobile' => 'checkMobile', //联系电话
|
||||
'intro', //简介
|
||||
'is_run' => 'checkRund', //营业状态
|
||||
'province_id', //省id
|
||||
'city_id', //城市id
|
||||
'district_id', //区id
|
||||
'address', //详情地址
|
||||
'refund_address' => 'checkRefund', //退款地址
|
||||
'weekdays' => 'checkWeekDay', //营业时间
|
||||
'run_start_time' => 'checkTime', //每天营业开始时间
|
||||
'run_end_time' => 'checkTime', //每天营业结束时间
|
||||
'open_invoice', //发票开关 0- 关闭 1-开启
|
||||
'spec_invoice', //是否支持专票 0-不支持 1-支持
|
||||
];
|
||||
|
||||
protected function checkData($dataset,$rule,$data){
|
||||
foreach ($dataset as $field => $value){
|
||||
|
||||
$allow_fields = array_keys($this->allow_fields);
|
||||
if(!in_array($field,$allow_fields)){
|
||||
return '该信息不允许修改';
|
||||
}
|
||||
|
||||
$func = $this->allow_fields[$field] ?? '';
|
||||
if($func){
|
||||
$result = call_user_func([ShopDataSetValidate::class,$func],$data);
|
||||
if(true !== $result){
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//验证手机号码是否正确
|
||||
public function checkMobile($value, $rule, $data){
|
||||
$mobile = $data['mobile'];
|
||||
$check = $this->checkRule($mobile, 'mobile');
|
||||
if(false === $check){
|
||||
return '手机号格式错误';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//验证营业状态是否正确
|
||||
protected function checkRund($data){
|
||||
if(!in_array($data['is_run'],[ShopEnum::SHOP_RUN_CLOSE,ShopEnum::SHOP_RUN_OPEN])){
|
||||
return '营业状态错误';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//验证营业天是否正确
|
||||
protected function checkWeekDay($data){
|
||||
foreach ($data['weekdays'] as $day){
|
||||
if(!in_array($day,[0,1,2,3,4,5,6])){
|
||||
return '工作日错误';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//验证时间是否正确
|
||||
protected function checkTime($data){
|
||||
if(empty($data['run_start_time']) || empty($data['run_end_time'])){
|
||||
return '请选择营业时间';
|
||||
}
|
||||
if($data['run_start_time'] >= $data['run_end_time']){
|
||||
return '营业时间错误';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//验证退款信息
|
||||
protected function checkRefund($data){
|
||||
$refund_address = $data['refund_address'];
|
||||
if(empty($refund_address)){
|
||||
return '请输入退款地址';
|
||||
}
|
||||
|
||||
foreach ($refund_address as $index => $value){
|
||||
switch ($index){
|
||||
case "nickname":
|
||||
if(empty($value)){
|
||||
return '请输入退款联系人';
|
||||
}
|
||||
break;
|
||||
case "mobile":
|
||||
$check = $this->checkRule($value, 'mobile');
|
||||
if(false === $check){
|
||||
return '手机号格式错误';
|
||||
}
|
||||
break;
|
||||
case "province_id":
|
||||
if(empty($value)){
|
||||
return '请选择省份';
|
||||
}
|
||||
break;
|
||||
case "city_id":
|
||||
if(empty($value)){
|
||||
return '请选择城市';
|
||||
}
|
||||
break;
|
||||
case "district_id":
|
||||
if(empty($value)){
|
||||
return '请选择地区';
|
||||
}
|
||||
break;
|
||||
case "address":
|
||||
if(empty($value)){
|
||||
return '请输入详情地址';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
73
app/shopapi/validate/ShopWithdrawValidate.php
Normal file
73
app/shopapi/validate/ShopWithdrawValidate.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\shopapi\validate;
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\shop\Shop;
|
||||
use app\common\model\shop\ShopBank;
|
||||
use app\common\server\ConfigServer;
|
||||
|
||||
/**
|
||||
* 商家提现验证
|
||||
* Class ShopWithdrawValidate
|
||||
* @package app\shopapi\validate
|
||||
*/
|
||||
class ShopWithdrawValidate extends Validate{
|
||||
protected $rule = [
|
||||
'money' => 'require|gt:0|checkMoney',
|
||||
'bank_id' => 'require|checkBank',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'money.require' => '请输入提现金额',
|
||||
'money.gt' => '提现金额必须大于零',
|
||||
'bank_id.require' => '请现在提现账户',
|
||||
];
|
||||
|
||||
//验证提现金额是否满足条件
|
||||
protected function checkMoney($value,$rule,$data){
|
||||
$min_withdrawal_money = ConfigServer::get('shop_withdrawal', 'min_withdrawal_money', 0);
|
||||
$max_withdrawal_money = ConfigServer::get('shop_withdrawal', 'max_withdrawal_money', 0);
|
||||
|
||||
$wallet = Shop::where(['id'=>$data['shop_id']])
|
||||
->value("wallet");
|
||||
|
||||
if($wallet < $value){
|
||||
return '当前账户仅剩:'.$wallet.'元';
|
||||
}
|
||||
if($min_withdrawal_money > $value){
|
||||
return '最低提现金额:'.$min_withdrawal_money.'元';
|
||||
}
|
||||
if($max_withdrawal_money < $value){
|
||||
return '最高提现金额:'.$max_withdrawal_money.'元';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//验证提现账户是否存在
|
||||
protected function checkBank($value,$rule,$data){
|
||||
if(ShopBank::where(['id'=>$value,'shop_id'=>$data['shop_id'],'del'=>0])->find()){
|
||||
return true;
|
||||
}
|
||||
return '账户不存在,请重新选择';
|
||||
}
|
||||
|
||||
}
|
||||
89
app/shopapi/validate/TokenValidate.php
Normal file
89
app/shopapi/validate/TokenValidate.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\validate;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\shop\ShopAdmin;
|
||||
use app\common\model\ShopSession as SessionModel;
|
||||
|
||||
/**
|
||||
* 商家移动端管理员登录token验证
|
||||
* Class TokenValidate
|
||||
* @package app\shopapi\validate
|
||||
*/
|
||||
class TokenValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'token' => 'require|valid|admin',
|
||||
];
|
||||
|
||||
/**
|
||||
* User: 意象信息科技 lr
|
||||
* Desc: token验证
|
||||
* @param $token
|
||||
* @param $other
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
protected function valid($token, $other, $data)
|
||||
{
|
||||
$session = SessionModel::where(['token' => $token])->find();
|
||||
if (empty($session)) {
|
||||
return '会话失效,请重新登录';
|
||||
}
|
||||
if ($session['expire_time'] <= time()) {
|
||||
return '登录超时,请重新登录';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* User: 意象信息科技 lr
|
||||
* Desc 用户验证
|
||||
* @param $token
|
||||
* @param $other
|
||||
* @param $data
|
||||
* @return string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
protected function admin($token, $other, $data)
|
||||
{
|
||||
$admin_id = SessionModel::where(['token' => $token])
|
||||
->value('admin_id');
|
||||
|
||||
$admin_info = ShopAdmin::where(['id' => $admin_id, 'del' => 0])
|
||||
->find();
|
||||
if (empty($admin_info)) {
|
||||
return '用户不存在';
|
||||
}
|
||||
if ($admin_info['disable'] == 1) {
|
||||
return '用户被禁用';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
146
app/shopapi/validate/VerificationValidate.php
Normal file
146
app/shopapi/validate/VerificationValidate.php
Normal file
@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\shopapi\validate;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\TeamEnum;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\team\TeamJoin;
|
||||
|
||||
/**
|
||||
* 自提核销验证
|
||||
* Class VerificationValidate
|
||||
* @package app\shop\validate\order
|
||||
*/
|
||||
class VerificationValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkId',
|
||||
'pickup_code' => 'require|checkPickupCode',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'pickup_code.require' => '请填写核销码',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 订单详情
|
||||
* @return VerificationValidate
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 18:18
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['pickup_code']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 确认核销
|
||||
* @return VerificationValidate
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 18:18
|
||||
*/
|
||||
public function sceneConfirm()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id', 'checkVerification');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验订单
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 14:41
|
||||
*/
|
||||
public function checkId($value, $rule, $data)
|
||||
{
|
||||
$result = Order::where('id', $value)->findOrEmpty();
|
||||
if ($result->isEmpty()) {
|
||||
return '订单不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验订单是否可以提货核销
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 14:42
|
||||
*/
|
||||
public function checkVerification($value, $rule, $data)
|
||||
{
|
||||
$result = Order::where('id', $value)
|
||||
->where('shop_id', $data['shop_id'])
|
||||
->findOrEmpty();
|
||||
if ($result['pay_status'] != PayEnum::ISPAID) {
|
||||
return '订单未支付,不允许核销';
|
||||
}
|
||||
if ($result['delivery_type'] != OrderEnum::DELIVERY_TYPE_SELF) {
|
||||
return '非自提订单,不允许核销';
|
||||
}
|
||||
if ($result['verification_status'] == OrderEnum::WRITTEN_OFF) {
|
||||
return '订单已核销';
|
||||
}
|
||||
if ($result['order_type'] == OrderEnum::TEAM_ORDER) {
|
||||
$teamcheck = TeamJoin::where(['order_id' => $value, 'status' => TeamEnum::TEAM_STATUS_SUCCESS])->findOrEmpty();
|
||||
if ($teamcheck->isEmpty()) {
|
||||
return '拼团成功后才能核销';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 收货码核销
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 18:04
|
||||
*/
|
||||
public function checkPickupCode($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['pickup_code'=>$value, 'shop_id' => $data['shop_id']])->find();
|
||||
if (empty($result)) {
|
||||
return '提货码不正确';
|
||||
}
|
||||
if (!in_array($result['order_status'],[OrderEnum::ORDER_STATUS_DELIVERY,OrderEnum::ORDER_STATUS_GOODS])) {
|
||||
return '订单不允许核销';
|
||||
}
|
||||
if ($result['delivery_type'] != OrderEnum::DELIVERY_TYPE_SELF) {
|
||||
return '不是自提订单,不允许核销';
|
||||
}
|
||||
if ($result['verification_status'] == OrderEnum::WRITTEN_OFF) {
|
||||
return '订单已核销';
|
||||
}
|
||||
if ($result['order_type'] == OrderEnum::TEAM_ORDER){
|
||||
$teamcheck = TeamJoin::where(['order_id' => $result['id'], 'status' => TeamEnum::TEAM_STATUS_SUCCESS])->findOrEmpty();
|
||||
if ($teamcheck->isEmpty()) {
|
||||
return '拼团成功后才能核销';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
52
app/shopapi/validate/VirtualDeliveryValidate.php
Normal file
52
app/shopapi/validate/VirtualDeliveryValidate.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\shopapi\validate;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\order\Order;
|
||||
|
||||
/**
|
||||
* 虚拟发货验证
|
||||
* Class virtualDeliveryValidate
|
||||
* @package app\shop\validate\order
|
||||
*/
|
||||
class VirtualDeliveryValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'order_id' => 'require|checkOrder',
|
||||
'delivery_content' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'order_id.require' => '缺少ID字段',
|
||||
'delivery_content.require' => '请填写发货内容',
|
||||
];
|
||||
|
||||
/**
|
||||
* @notes 校验订单信息
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/4/7 18:26
|
||||
*/
|
||||
protected function checkOrder($value, $rule, $data)
|
||||
{
|
||||
$order = Order::findOrEmpty($value);
|
||||
if ($order->isEmpty()) {
|
||||
return '订单不存在';
|
||||
}
|
||||
|
||||
if ($order['del'] == 1) {
|
||||
return '订单已删除';
|
||||
}
|
||||
|
||||
if ($order['shipping_status'] == 1) {
|
||||
return '此订单已发货';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user