Merge branch 'main' of http://git.njrzwl.cn:3000/wangmingchuan/yanzong
commit
16fe953e25
@ -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; |
||||||
|
} |
||||||
|
} |
@ -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, |
||||||
|
], |
||||||
|
]; |
||||||
|
} |
||||||
|
} |
@ -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'); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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); |
||||||
|
} |
||||||
|
} |
@ -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; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
return [ |
||||||
|
//申请入驻类型 |
||||||
|
'store_type' => [ |
||||||
|
'京东店铺','拼多多店铺','苏宁店铺','唯品会店铺','淘宝店铺','天猫店铺','其他平台' |
||||||
|
], |
||||||
|
]; |
Loading…
Reference in new issue