wangmingchuan321@qq.com 1 year ago
commit 16fe953e25
  1. 41
      app/api/controller/Store.php
  2. 49
      app/api/controller/User.php
  3. 60
      app/api/service/Feedback.php
  4. 84
      app/api/service/Store.php
  5. 42
      app/api/validate/store/Store.php
  6. 47
      app/common/enum/ServerEnum.php
  7. 31
      app/common/enum/coupon/TypeCase.php
  8. 31
      app/common/enum/dealer/DealerUserEnum.php
  9. 15
      app/common/model/Coupon.php
  10. 49
      app/common/model/UserFeedback.php
  11. 41
      app/common/model/dealer/User.php
  12. 109
      app/common/model/server/Order.php
  13. 25
      app/common/model/server/Server.php
  14. 32
      app/common/model/store/StoreSettle.php
  15. 91
      app/common/service/server/Order.php
  16. 108
      app/store/controller/Server.php
  17. 41
      app/store/controller/dealer/User.php
  18. 10
      app/store/model/server/Server.php
  19. 8
      config/store.php

@ -12,11 +12,13 @@ declare (strict_types=1);
namespace app\api\controller;
use app\api\service\User as UserService;
use think\response\Json;
use app\api\service\Store as StoreService;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use app\api\validate\store\Store as StoreValidte;
/**
* 商城基础信息
@ -37,4 +39,43 @@ class Store extends Controller
$service = new StoreService;
return $this->renderSuccess($service->data());
}
public function joinStore(): Json
{
// 当前用户信息
$userInfo = UserService::getCurrentLoginUser(true);
$params = $this->request->param();
$validate = new StoreValidte();
// 表单验证
if (!$validate->check($params)) {
return $this->renderError($validate->getError());
}
$service = new StoreService;
$res = $service->joinStore($params, $userInfo->user_id);
if ($res['code'] == 0) {
return $this->renderSuccess('申请成功,请耐心等待');
} else {
return $this->renderError($res['msg']);
}
}
public function getStoreType(): Json
{
return $this->renderSuccess(config('store.store_type'));
}
public function joinData(): Json
{
// 当前用户信息
$userInfo = UserService::getCurrentLoginUser(true);
$service = new StoreService;
return $this->renderSuccess($service->joinData($userInfo->user_id));
}
public function getStore(): Json
{
$service = new StoreService;
return $this->renderSuccess($service->getStore());
}
}

@ -12,11 +12,13 @@ declare (strict_types=1);
namespace app\api\controller;
use app\api\service\Feedback;
use think\response\Json;
use app\api\model\User as UserModel;
use app\api\model\UserCoupon as UserCouponModel;
use app\api\service\User as UserService;
use cores\exception\BaseException;
use app\api\model\user\BalanceLog;
/**
* 用户管理
@ -36,6 +38,14 @@ class User extends Controller
$userInfo = UserService::getCurrentLoginUser(true);
// 获取用户头像和会员等级
$userInfo = UserModel::related($userInfo, ['avatar', 'grade']);
//获取提现次数
$userInfo['finace_count'] = BalanceLog::where(['user_id' => $userInfo->user_id, 'scene' => 50])->count() ?? 0;
//获取用户收入
$userInfo['income'] = BalanceLog::where(['user_id' => $userInfo->user_id])
->whereIn('scene', [10, 30, 40, 60])
->where('money', '>', 0)
->sum('money') ?? 0;
return $this->renderSuccess(compact('userInfo'));
}
@ -87,4 +97,43 @@ class User extends Controller
}
return $this->renderSuccess('恭喜您,信息修改成功');
}
/**
* 提交反馈
*/
public function addFeedback(): Json
{
// 当前用户信息
$userInfo = UserService::getCurrentLoginUser(true);
$params = $this->request->param();
if (empty($params['content']) || (empty($params['store_id']) && $params['object_type'] != 1) || empty($params['type'])) {
return $this->renderError('请补全信息');
}
$userData = [
'user_id' => $userInfo->user_id,
'user_name' => $userInfo->nick_name,
'mobile' => $userInfo->mobile,
];
$service = new Feedback();
$res = $service->addFeedback($params, $userData);
if ($res) {
return $this->renderSuccess('提交成功,请耐心等待');
} else {
return $this->renderError('提交失败');
}
}
//获取反馈列表
public function getFeedBack(): Json
{
$params = $this->request->param();
// 当前用户信息
if (!empty($params['is_my'])) {
$userInfo = UserService::getCurrentLoginUser(true);
$params['user_id'] = $userInfo->user_id;
}
$service = new Feedback();
$list = $service->getFeedback($params);
return $this->renderSuccess(compact('list'));
}
}

@ -0,0 +1,60 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\api\service;
use app\common\model\UserFeedback;
use app\common\service\BaseService;
use cores\exception\BaseException;
/**
* 用户余额充值服务
* Class Recharge
* @package app\api\controller
*/
class Feedback extends BaseService
{
//添加反馈
public function addFeedback($data, $user_data)
{
$addData = [
'user_id' => $user_data['user_id'],
'store_id' => $data['store_id'] ?? 0,
'type' => $data['type'],
'object_type' => $data['object_type'],
'content' => $data['content'],
'user_name' => $user_data['user_name'],
'mobile' => $user_data['mobile'],
'status' => 0,
'created_at' => time(),
];
$model = new UserFeedback();
return $model->insert($addData);
}
//反馈列表
public function getFeedback($params, $listRows = 10)
{
$query = new UserFeedback();
if (!empty($params['is_my']) && !empty($params['user_id'])) {
$query = $query->where(['user_id' => $params['user_id']]);
}
$list = $query->with(['store'])
->order('replay_at desc,created_at desc')
->paginate($listRows)->toArray();
foreach ($list['data'] as $k => $v) {
$list['data'][$k]['store_name'] = !empty($v['store']['store_name']) ? $v['store']['store_name'] : '';
unset($list['data'][$k]['store']);
}
return $list;
}
}

@ -13,11 +13,15 @@ declare (strict_types=1);
namespace app\api\service;
use app\api\model\Store as StoreModel;
use \app\common\model\Store as StoreInfoModel;
use app\api\service\Client as ClientService;
use app\api\service\Setting as SettingService;
use app\api\model\store\Module as StoreModuleModel;
use app\api\model\dealer\Setting as DealerSettingModel;
use app\common\model\store\StoreSettle;
use app\common\service\BaseService;
use think\facade\Db;
use think\Exception;
/**
* 商城基础信息
@ -58,7 +62,8 @@ class Store extends BaseService
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
private function getModules() {
private function getModules()
{
return StoreModuleModel::getModules($this->storeId);
}
@ -108,4 +113,81 @@ class Store extends BaseService
{
return StoreModel::getInfo();
}
//申请入驻
public function joinStore($data, $user_id)
{
$has = Db::query('select * from yoshop_store where user_id = ' . $user_id . ' and status != 2 and is_recycle = 0 and is_delete= 0');
if ($has) {
return ['code' => 1, 'msg' => '请勿重复申请入驻'];
}
//商城主体信息
$addData = [
'store_name' => $data['store_name'],
'user_id' => $user_id,
'sort' => 100,
'create_time' => time(),
'update_time' => time(),
'status' => 0
];
try {
// 新增记录
$model = new \app\admin\model\Store;
$res = $model->insertGetId($addData);
if (!$res) {
throw new Exception($model->getError());
}
//附加资料
$settleData = [
'store_id' => $res,
'store_cat' => $data['store_cat'],
'store_address' => $data['store_address'],
'store_brand' => $data['store_brand'],
'store_settle_type' => $data['store_settle_type'],
'authorize' => $data['authorize'],
'has_tax' => $data['has_tax'],
'user_name' => $data['user_name'],
'user_position' => $data['user_position'],
'user_mobile' => $data['user_mobile'],
'user_wx' => $data['user_wx'],
'user_email' => $data['user_email'],
'store_model' => $data['store_model'],
'send_type' => $data['send_type'],
'has_factory' => $data['has_factory'],
'has_offline' => $data['has_offline'],
'has_online_shop' => $data['has_online_shop'],
'created_at' => time(),
'store_type' => empty($data['has_online_shop']) ? json_encode([]) : json_encode($data['store_type']),
];
$settleModel = new StoreSettle();
if (!$settleModel->insert($settleData)) {
throw new Exception($settleModel->getError());
}
return ['code' => 0, 'msg' => 'success'];
} catch (\Exception $e) {
return ['code' => 1, 'msg' => $e->getMessage()];
}
}
public function joinData($user_id)
{
$storeInfo = Db::query('select * from yoshop_store where user_id = ' . $user_id . ' and and is_recycle = 0 and is_delete= 0');
$settle = [];
if (!empty($storeInfo)) {
$res = Db::query('select * from yoshop_store_settle where store_id = ' . $storeInfo[0]['store_id']);
$settle = $res ? $res[0] : [];
$settle['store_type'] = json_decode($settle['store_type']);
}
return [
'info' => $storeInfo,
'settle' => $settle,
];
}
public function getStore()
{
$storeList = Db::query('select store_id,store_name from yoshop_store where status = 1 and is_recycle = 0 and is_delete= 0');
return $storeList;
}
}

@ -0,0 +1,42 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\api\validate\store;
use think\Validate;
/**
* 验证类:订单提交
* Class Checkout
* @package app\api\validate\order
*/
class Store extends Validate
{
/**
* 验证规则
* @var array
*/
protected $rule = [
'store_name' => ['require'],
'store_cat' => ['require'],
'store_address' => ['require',],
'store_brand' => ['require',],
'user_name' => ['require',],
'user_position' => ['require',],
'user_mobile' => ['require', 'number'],
'user_wx' => ['require',],
'user_email' => ['require',],
'store_model' => ['require',],
'store_type' => ['require',],
];
}

@ -0,0 +1,47 @@
<?php
namespace app\common\enum;
class ServerEnum extends EnumBasics
{
// 待付款
const APPLYPAY = 10;
// 待派单
const APPLYDISPATCH = 20;
// 待服务
const APPLYSERVER = 30;
// 已完成
const COMPLETED = 40;
// 已取消
const CANCELLED = 50;
/**
* 获取枚举数据
* @return array
*/
public static function data(): array
{
return [
self::APPLYPAY => [
'name' => '待付款',
'value' => self::APPLYPAY,
],
self::CANCELLED => [
'name' => '已取消',
'value' => self::CANCELLED,
],
self::APPLYDISPATCH => [
'name' => '待派单',
'value' => self::APPLYDISPATCH,
],
self::APPLYSERVER => [
'name' => '待服务',
'value' => self::APPLYSERVER,
],
self::COMPLETED => [
'name' => '已完成',
'value' => self::COMPLETED,
]
];
}
}

@ -0,0 +1,31 @@
<?php
namespace app\common\enum\coupon;
use app\common\enum\EnumBasics;
class TypeCase extends EnumBasics
{
const SHOP = 10;//商品券
const SERVER = 20;//服务券
/**
* @notes:优惠券类别
* @return array[]
* @author: wanghousheng
*/
public static function data(): array
{
return [
self::SHOP => [
'name' => '商品券',
'value' => self::SHOP
],
self::SERVER => [
'name' => '服务券',
'value' => self::SERVER
]
];
}
}

@ -0,0 +1,31 @@
<?php
namespace app\common\enum\dealer;
use app\common\enum\EnumBasics;
class DealerUserEnum extends EnumBasics
{
//工程师
const ENGINEER = 20;
//普通
const NORMAL = 10;
/**
* 获取枚举数据
* @return array
*/
public static function data(): array
{
return [
self::ENGINEER => [
'name' => '工程师',
'value' => self::ENGINEER,
],
self::NORMAL => [
'name' => '普通',
'value' => self::NORMAL,
],
];
}
}

@ -12,8 +12,9 @@ declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
use app\common\enum\coupon\TypeCase;
use app\common\library\helper;
use cores\BaseModel;
/**
* 优惠券模型
@ -32,7 +33,7 @@ class Coupon extends BaseModel
* 追加字段
* @var array
*/
protected $append = ['state'];
protected $append = ['state', 'coupon_case_text'];
/**
* 优惠券状态 (是否可领取)
@ -54,6 +55,16 @@ class Coupon extends BaseModel
return ['text' => '正常', 'value' => 1];
}
public function getCouponCaseTextAttr($value, $data)
{
// 订单状态
$result = TypeCase::data();
if (!empty($result[$data['coupon_case']]['name'])) {
return $result[$data['coupon_case']]['name'];
}
return '未知';
}
/**
* 获取器:格式化折扣率
* @param $value

@ -0,0 +1,49 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
use think\model\relation\HasOne;
/**
* 用户模型类
* Class User
* @package app\common\model
*/
class UserFeedback extends BaseModel
{
// 定义表名
protected $name = 'user_feedback';
// 定义主键
protected $pk = 'id';
/**
* 关联用户
* @return HasOne
*/
public function user(): HasOne
{
return $this->hasOne('user', 'user_id', 'user_id');
}
/**
* 关联商家
* @return HasOne
*/
public function store(): HasOne
{
return $this->hasOne('store', 'store_id', 'store_id');
}
}

@ -12,8 +12,13 @@ declare (strict_types=1);
namespace app\common\model\dealer;
use cores\BaseModel;
use app\common\enum\dealer\DealerUserEnum;
use app\common\library\helper;
use cores\BaseModel;
use think\Collection;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\model\relation\BelongsTo;
/**
@ -40,7 +45,23 @@ class User extends BaseModel
];
// 追加的字段
protected $append = ['full_money'];
protected $append = ['full_money', 'type_text'];
/**
* @notes:身份标识
* @param $value
* @param $data
* @return mixed
* @author: wanghousheng
*/
public function getTypeTextAttr($value, $data)
{
$result = DealerUserEnum::data();
if (!empty($result[$data['type']]['name'])) {
return $result[$data['type']]['name'];
}
return '未知';
}
/**
* 关联会员记录表
@ -167,4 +188,20 @@ class User extends BaseModel
]);
return true;
}
/**
* @notes:获取工程师分销商
* @return array|Collection|User[]
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public static function getEngineer()
{
return (new static())
->where(['type' => DealerUserEnum::ENGINEER])
->order(['create_time'])
->select();
}
}

@ -0,0 +1,109 @@
<?php
declare (strict_types=1);
namespace app\common\model\server;
use app\common\enum\ServerEnum;
use app\common\model\UploadFile;
use cores\BaseModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasOne;
use think\Paginator;
class Order extends BaseModel
{
// 定义表名
protected $name = 'server_order';
// 定义主键
protected $pk = 'order_id';
/**
* 追加字段
* @var array
*/
protected $append = [
'order_status_text', // 订单状态文字描述
];
public function serve(): BelongsTo
{
return $this->belongsTo(Server::class, 'id', 'server_id');
}
/**
* 获取器:订单状态文字描述
* @param $value
* @param $data
* @return string
*/
public function getOrderStatusTextAttr($value, $data): string
{
// 订单状态
$result = ServerEnum::data();
if (!empty($result[$data['order_status']]['name'])) {
return $result[$data['order_status']]['name'];
}
return '未知';
}
/**
* 图片
* @return HasOne
*/
public function image(): HasOne
{
return $this->hasOne(UploadFile::class, 'file_id', 'server_image_id')
->bind(['server_image' => 'preview_url']);
}
/**
* 关联用户表
* @return BelongsTo
*/
public function user(): BelongsTo
{
$module = self::getCalledModule();
return $this->belongsTo("app\\$module\\model\\User")
->bind(['user_name' => 'nick_name', 'user_mobile' => 'mobile']);
}
public function dealer(): BelongsTo
{
$module = self::getCalledModule();
return $this->belongsTo("app\\$module\\model\\User", 'dealer_id', 'user_id')
->bind(['dealer_name' => 'nick_name', 'dealer_mobile' => 'mobile']);
}
/**
* @notes:服务订单列表
* @param array $where
* @param int $listRows
* @return Paginator
* @author: wanghousheng
*/
public function getList(array $where, int $listRows = 15): Paginator
{
$where = $this->setQueryDefaultValue($where);
return $this->with(['image', 'dealer'])
->alias('a')
->join('user b', 'b.user_id = a.user_id')
->where($where)
->order(['create_time'])
->field('a.*,b.mobile as user_mobile,b.nick_name as user_nick_name')
->paginate($listRows);
}
/**
* @notes:订单详情
* @param $where
* @param array $with
* @return Order|array|null
* @author: wanghousheng
*/
public static function detail($where, array $with = [])
{
return static::get($where, $with);
}
}

@ -74,6 +74,31 @@ class Server extends BaseModel
->paginate($listRows);
}
/**
* 根据商品id集获取服务列表
* @param array $serverIds
* @param null $status
* @return mixed
*/
public function getListByIds(array $serverIds, $status = null)
{
// 筛选条件
$filter = [['server_id', 'in', $serverIds]];
// 商品状态
$status > 0 && $filter[] = ['status', '=', $status];
// 获取商品列表数据
$result = $this->withoutField(['content'])
->with(['image'])
->withJoin(['category' => ['category_id', 'name']])
->where($filter)
->orderRaw('field(server_id, ' . implode(',', $serverIds) . ')')
->select();
if (!empty($result)) {
return $result->toArray();
}
return [];
}
/**
* 文章详情:HTML实体转换回普通字符
* @param $value

@ -0,0 +1,32 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\model\store;
use cores\BaseModel;
use app\common\model\Region as RegionModel;
use think\model\relation\HasOne;
/**
* 商家入驻资料
* Class Shop
* @package app\common\model\store
*/
class StoreSettle extends BaseModel
{
// 定义表名
protected $name = 'store_settle';
// 定义主键
protected $pk = 'id';
}

@ -0,0 +1,91 @@
<?php
declare (strict_types=1);
namespace app\common\service\server;
use app\api\model\dealer\User as DealerUserModel;
use app\common\enum\dealer\DealerUserEnum;
use app\common\enum\order\PayStatus;
use app\common\enum\ServerEnum;
use app\common\model\UserCoupon as UserCouponModel;
use app\common\service\BaseService;
use app\common\service\order\Refund as RefundService;
use cores\exception\BaseException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
class Order extends BaseService
{
/**
* 生成订单号
* @return string
*/
public static function createOrderNo(): string
{
return date('Ymd') . substr(implode('', array_map('ord', str_split(substr(uniqid(), 7, 13)))), 0, 8);
}
/**
* @notes:用户取消订单
* @param array $order
* @return bool
* @throws BaseException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public static function cancelOrder(array $order): bool
{
//未完成 未取消
if (!empty($order['order_status']) && $order['order_status'] != ServerEnum::COMPLETED || $order['order_status'] != ServerEnum::CANCELLED) {
if (!empty($order['coupon_id'])) {
// 回退用户优惠券
$order['coupon_id'] > 0 && UserCouponModel::setIsUse($order['coupon_id'], false);
}
//判断是否已支付
if ($order['pay_status'] == PayStatus::SUCCESS) {
if (!(new RefundService)->handle($order)) {
try {
throwError('执行订单退款失败');
} catch (BaseException $e) {
return false;
}
}
}
//更新订单状态
$model = new \app\common\model\server\Order;
$model->where(['order_id' => $order['order_id']])->save(['order_status' => ServerEnum::CANCELLED]);
return true;
}
return false;
}
/**
* @notes:派单
* @param array $order
* @param int $dealerId
* @return bool
* @author: wanghousheng
*/
public static function dispatchOrders(array $order, int $dealerId): bool
{
//判断该订单是否可以指派
if (!empty($order) && $order['order_status'] == ServerEnum::APPLYDISPATCH) {
//判断指派人员是否是分销工程师
$dealerInfo = DealerUserModel::detail($dealerId, []);
if (!empty($dealerInfo)) {
$dealerInfo = $dealerInfo->toArray();
if ($dealerInfo['type'] == DealerUserEnum::ENGINEER) {
$model = new \app\common\model\server\Order;
$up['dealer_id'] = $dealerId;
$up['order_status'] = ServerEnum::APPLYSERVER;
$model->where(['order_id' => $order['order_id']])->save($up);
return true;
}
}
}
return false;
}
}

@ -1,9 +1,12 @@
<?php
declare (strict_types=1);
namespace app\store\controller;
use app\common\enum\ServerEnum;
use app\store\model\server\Server as ServerModel;
use app\store\model\ServerCategory;
use cores\exception\BaseException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
@ -168,6 +171,19 @@ class Server extends Controller
return $this->renderError('删除失败');
}
/**
* 根据服务ID集获取列表记录
* @param $serverIds
* @return Json
*/
public function listByIds($serverIds): Json
{
// 获取列表记录
$model = new ServerModel();
$list = $model->getListByIds($serverIds);
return $this->renderSuccess(compact('list'));
}
/**
* 修改服务状态(上下架)
* @param array $serverIds 商品id集
@ -182,4 +198,96 @@ class Server extends Controller
}
return $this->renderSuccess('操作成功');
}
/**
* @notes:服务订单列表
* @return Json
* @author: wanghousheng
*/
public function orderList(): Json
{
$model = new \app\common\model\server\Order;
$server_name = $this->request->post('server_name');
$order_no = $this->request->post('order_no');
$order_status = intval($this->request->post('order_status'));
$where = [];
if (!empty($server_name)) {
$where[] = ['a.server_name', 'like', `%$server_name%`];
}
if (!empty($order_no)) {
$where[] = ['a.order_no', '=', $order_no];
}
if ($order_status) {
$where[] = ['a.order_status', '=', $order_status];
}
$user_mobile = $this->request->post('user_mobile');
if ($user_mobile) {
$where[] = ['b.mobile', '=', $user_mobile];
}
$user_nickname = $this->request->post('user_nickname');
if ($user_nickname) {
$where[] = ['b.nick_name', 'like', "%$server_name%"];
}
$list = $model->getList($where);
return $this->renderSuccess(compact('list'));
}
/**
* @notes:订单状态
* @return Json
* @author: wanghousheng
*/
public function OrderStatus(): Json
{
$list = array_values(ServerEnum::data());
return $this->renderSuccess(compact('list'));
}
/**
* @notes:取消服务订单
* @param int $orderId
* @return Json
* @author: wanghousheng
*/
public function cancelOrder(int $orderId): Json
{
$order = \app\common\model\server\Order::detail($orderId);
if (empty($order)) {
return $this->renderError('订单信息不存在');
}
try {
$result = \app\common\service\server\Order::cancelOrder($order->toArray());
if ($result) {
return $this->renderSuccess('操作成功');
}
} catch (BaseException|DataNotFoundException|ModelNotFoundException|DbException $e) {
return $this->renderError($e->getMessage() ?: '取消失败');
}
return $this->renderError('取消失败');
}
/**
* @notes:派单
* @return Json
* @author: wanghousheng
*/
public function dispatchOrders(): Json
{
$data = $this->postForm();
if (empty($data['dealer_id'])) {
return $this->renderError('指派人员不能为空');
}
if (empty($data['order_id'])) {
return $this->renderError('缺少必要参数');
}
$order = \app\common\model\server\Order::detail($data['order_id']);
if (empty($order)) {
return $this->renderError('订单信息不存在');
}
$result = \app\common\service\server\Order::dispatchOrders($order->toArray(), $data['dealer_id']);
if ($result) {
return $this->renderSuccess('操作成功');
}
return $this->renderError('操作失败');
}
}

@ -12,12 +12,16 @@ declare (strict_types=1);
namespace app\store\controller\dealer;
use think\response\Json;
use app\common\enum\dealer\DealerUserEnum;
use app\common\service\qrcode\Poster;
use app\store\controller\Controller;
use app\store\model\dealer\User as UserModel;
use app\store\model\dealer\Referee as RefereeModel;
use app\common\service\qrcode\Poster;
use app\store\model\dealer\User as UserModel;
use cores\exception\BaseException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\response\Json;
/**
* 分销商管理
@ -84,9 +88,9 @@ class User extends Controller
* @param string $channel 渠道
* @return Json
* @throws BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function poster(int $dealerId, string $channel = 'H5'): Json
{
@ -94,4 +98,29 @@ class User extends Controller
$Qrcode = new Poster($model, $channel);
return $this->renderSuccess(['imageUrl' => $Qrcode->getImage()]);
}
/**
* @notes:工程师分销商
* @return Json
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function getEngineer(): Json
{
$list = UserModel::getEngineer();
return $this->renderSuccess(compact('list'));
}
/**
* @notes:分销商身份
* @return Json
* @author: wanghousheng
*/
public function typeList(): Json
{
$list = array_values(DealerUserEnum::data());
return $this->renderSuccess(compact('list'));
}
}

@ -1,11 +1,9 @@
<?php
declare (strict_types=1);
namespace app\store\model\server;
use app\common\model\server\Server as ServerModel;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
class Server extends ServerModel
{
@ -43,11 +41,7 @@ class Server extends ServerModel
*/
public function remove(array $serverId): bool
{
try {
return static::whereIn('server_id', $serverId)->select()->delete();
} catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
return false;
}
return static::whereIn('server_id', $serverId)->delete();
}
/**

@ -0,0 +1,8 @@
<?php
return [
//申请入驻类型
'store_type' => [
'京东店铺','拼多多店铺','苏宁店铺','唯品会店铺','淘宝店铺','天猫店铺','其他平台'
],
];
Loading…
Cancel
Save