chore: 添加静态资源文件和版本配置文件
添加大量图片、字体、音频等静态资源文件,包括用户界面图片、模板文件和安装界面素材 添加系统版本配置文件(.version)和常量定义文件(.constant) 更新供应商依赖文件,包括Symfony VarDumper组件和相关许可证文件 添加验证码配置文件(captcha.php)和.gitignore规则
This commit is contained in:
199
app/controller/admin/v1/order/DeliveryService.php
Normal file
199
app/controller/admin/v1/order/DeliveryService.php
Normal file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin\v1\order;
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\store\DeliveryServiceServices;
|
||||
use app\services\user\UserServices;
|
||||
use app\services\user\UserWechatuserServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 配送员
|
||||
* Class StoreService
|
||||
* @package app\admin\controller\store
|
||||
*/
|
||||
class DeliveryService extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var DeliveryServiceServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected DeliveryServiceServices $services;
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return $this->success($this->services->getServiceList(['type' => 0, 'is_del' => 0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function create(UserWechatuserServices $services)
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['nickname', ''],
|
||||
['data', '', '', 'time'],
|
||||
['type', '', '', 'user_type'],
|
||||
]);
|
||||
[$list, $count] = $services->getWhereUserList($where, 'u.nickname,u.uid,u.avatar as headimgurl,w.subscribe,w.province,w.country,w.city,w.sex');
|
||||
return $this->success(compact('list', 'count'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加客服表单
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
return $this->success($this->services->create());
|
||||
}
|
||||
|
||||
/*
|
||||
* 保存新建的资源
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['image', ''],
|
||||
['uid', 0],
|
||||
['avatar', ''],
|
||||
['phone', ''],
|
||||
['nickname', ''],
|
||||
['status', 1],
|
||||
]);
|
||||
if ($data['image'] == '') return $this->fail('请选择用户');
|
||||
$data['uid'] = $data['image']['uid'];
|
||||
/** @var UserServices $userService */
|
||||
$userService = app()->make(UserServices::class);
|
||||
$userInfo = $userService->get($data['uid']);
|
||||
if ($data['phone'] == '') {
|
||||
if (!$userInfo['phone']) {
|
||||
return $this->fail('该用户没有绑定手机号,请手动填写');
|
||||
} else {
|
||||
$data['phone'] = $userInfo['phone'];
|
||||
}
|
||||
} else {
|
||||
if (!check_phone($data['phone'])) {
|
||||
return $this->fail('请输入正确的手机号!');
|
||||
}
|
||||
}
|
||||
if ($data['nickname'] == '') $data['nickname'] = $userInfo['nickname'];
|
||||
$data['avatar'] = $data['image']['image'];
|
||||
if ($this->services->count(['uid' => $data['uid'], 'type' => 0, 'is_del' => 0])) {
|
||||
return $this->fail('配送员已存在!');
|
||||
}
|
||||
if ($this->services->count(['phone' => $data['phone'], 'type' => 0, 'is_del' => 0])) {
|
||||
return $this->fail('同一个手机号的配送员只能添加一个!');
|
||||
}
|
||||
unset($data['image']);
|
||||
$data['type'] = 0;
|
||||
$data['add_time'] = time();
|
||||
$res = $this->services->save($data);
|
||||
if ($res) {
|
||||
return $this->success('配送员添加成功');
|
||||
} else {
|
||||
return $this->fail('配送员添加失败,请稍后再试');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return $this->success($this->services->edit((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['avatar', ''],
|
||||
['nickname', ''],
|
||||
['phone', ''],
|
||||
['status', 1],
|
||||
]);
|
||||
$delivery = $this->services->get((int)$id);
|
||||
if (!$delivery) {
|
||||
return $this->fail('数据不存在');
|
||||
}
|
||||
if ($data["nickname"] == '') {
|
||||
return $this->fail("配送员名称不能为空!");
|
||||
}
|
||||
if (!$data['phone']) {
|
||||
return $this->fail("手机号不能为空!");
|
||||
}
|
||||
if (!check_phone($data['phone'])) {
|
||||
return $this->fail('请输入正确的手机号!');
|
||||
}
|
||||
if ($delivery['phone'] != $data['phone'] && $this->services->count(['phone' => $data['phone'], 'type' => 0, 'is_del' => 0])) {
|
||||
return $this->fail('同一个手机号的配送员只能添加一个!');
|
||||
}
|
||||
$this->services->update($id, $data);
|
||||
return $this->success('修改成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$this->services->delete($id))
|
||||
return $this->fail('删除失败,请稍候再试!');
|
||||
else
|
||||
return $this->success('删除成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* @param $id
|
||||
* @param $status
|
||||
* @return mixed
|
||||
*/
|
||||
public function set_status($id, $status)
|
||||
{
|
||||
if ($status == '' || $id == 0) return $this->fail('参数错误');
|
||||
$this->services->update($id, ['status' => $status]);
|
||||
return $this->success($status == 0 ? '关闭成功' : '开启成功');
|
||||
}
|
||||
|
||||
/**
|
||||
*获取所有配送员列表
|
||||
*/
|
||||
public function get_delivery_list()
|
||||
{
|
||||
$data = $this->services->getDeliveryList();
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
}
|
||||
102
app/controller/admin/v1/order/OtherOrder.php
Normal file
102
app/controller/admin/v1/order/OtherOrder.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\controller\admin\v1\order;
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\order\OtherOrderServices;
|
||||
use app\services\other\QrcodeServices;
|
||||
use crmeb\utils\Canvas;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* Class OtherOrder
|
||||
* @package app\controller\admin\v1\order
|
||||
*/
|
||||
class OtherOrder extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var OtherOrderServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected OtherOrderServices $services;
|
||||
|
||||
/**
|
||||
* 线下收银
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function scan_list()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['order_id', ''],
|
||||
['add_time', ''],
|
||||
['name', ''],
|
||||
['page', 1],
|
||||
['limit', 20],
|
||||
]);
|
||||
$data = $this->services->getScanOrderList($where);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取线下二维码
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function offline_scan()
|
||||
{
|
||||
[$type] = $this->request->getMore([
|
||||
['type', 1]
|
||||
], true);
|
||||
//生成h5地址
|
||||
$weixinPage = "/pages/annex/offline_pay/index";
|
||||
$weixinFileName = "wechat_offline_scan.png";
|
||||
/** @var QrcodeServices $QrcodeService */
|
||||
$QrcodeService = app()->make(QrcodeServices::class);
|
||||
$wechatQrcode = $QrcodeService->getWechatQrcodePath($weixinFileName, $weixinPage, false, false);
|
||||
//生成小程序地址
|
||||
$routineQrcode = $QrcodeService->getRoutineQrcodePath(4, 6, 103, $weixinFileName, false);
|
||||
$qrcod = ['wechat' => $wechatQrcode, 'routine' => $routineQrcode];
|
||||
if ($type) {
|
||||
//生成画布
|
||||
$canvas = Canvas::instance();
|
||||
$path = 'uploads/offline/';
|
||||
$imageType = 'jpg';
|
||||
$siteUrl = sys_config('site_url');
|
||||
$canvas->setImageUrl(public_path() . 'statics/qrcode/offlines.jpg')->setImageHeight(730)->setImageWidth(500)->pushImageValue();
|
||||
foreach ($qrcod as $k => $v) {
|
||||
if ($v) {
|
||||
$name = 'offline_' . $k;
|
||||
//再本地接去掉http使用本地绝对路径获取
|
||||
if (strstr($v, $this->request->host(true)) !== false) {
|
||||
$v = str_replace([
|
||||
'https://' . $this->request->host(true) . '/',
|
||||
'http://' . $this->request->host(true) . '/'
|
||||
], public_path(), $v);
|
||||
}
|
||||
$canvas->setImageUrl($v)->setImageHeight(344)->setImageWidth(344)->setImageLeft(76)->setImageTop(120)->pushImageValue();
|
||||
$image = $canvas->setFileName($name)->setImageType($imageType)->setPath($path)->setBackgroundWidth(500)->setBackgroundHeight(720)->starDrawChart();
|
||||
$data[$k] = $image ? $siteUrl . '/' . $image : '';
|
||||
} else {
|
||||
$data[$k] = "";
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
$data = ['wechat' => $wechatQrcode, 'routine' => $routineQrcode];
|
||||
}
|
||||
return $this->success($data);
|
||||
}
|
||||
}
|
||||
222
app/controller/admin/v1/order/RefundOrder.php
Normal file
222
app/controller/admin/v1/order/RefundOrder.php
Normal file
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\admin\v1\order;
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\Request;
|
||||
use app\services\order\StoreOrderRefundServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\user\UserServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
class RefundOrder extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreOrderRefundServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreOrderRefundServices $services;
|
||||
|
||||
/**
|
||||
* 退款订单列表
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getRefundList()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['order_id', ''],
|
||||
['time', ''],
|
||||
['apply_type', ''],
|
||||
['refund_type', ''],
|
||||
['refund_express', ''],
|
||||
['refund_reason', '']
|
||||
]);
|
||||
if ($this->supplierId != 0) {
|
||||
$where['supplier_id'] = $this->supplierId;
|
||||
}
|
||||
return $this->success($this->services->refundList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款表单生成
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function refund($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('Data does not exist!');
|
||||
}
|
||||
return app('json')->success($this->services->refundOrderForm((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单退款
|
||||
* @param Request $request
|
||||
* @param StoreOrderServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update_refund(Request $request, StoreOrderServices $services, $id)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['refund_price', 0],
|
||||
['type', 1],
|
||||
['refuse_reason', '']
|
||||
]);
|
||||
if (!$id) {
|
||||
return app('json')->fail('Data does not exist!');
|
||||
}
|
||||
$data['refund_price'] = sprintf("%.2f", $data['refund_price']);
|
||||
$orderRefund = $this->services->get($id);
|
||||
if (!$orderRefund) {
|
||||
return app('json')->fail('Data does not exist!');
|
||||
}
|
||||
if ($orderRefund['is_cancel'] == 1) {
|
||||
return app('json')->fail('用户已取消申请');
|
||||
}
|
||||
$order = $services->get((int)$orderRefund['store_order_id']);
|
||||
if (!$order) {
|
||||
return app('json')->fail('Data does not exist!');
|
||||
}
|
||||
if (!in_array($orderRefund['refund_type'], [0, 1, 2, 5]) && !($orderRefund['refund_type'] == 4 && $orderRefund['apply_type'] == 3)) {
|
||||
return app('json')->fail('售后订单状态不支持该操作');
|
||||
}
|
||||
if ($data['type'] == 1) {
|
||||
$data['refund_type'] = 6;
|
||||
} else if ($data['type'] == 2) {
|
||||
$data['refund_type'] = 3;
|
||||
}
|
||||
$data['refunded_time'] = time();
|
||||
$type = $data['type'];
|
||||
//拒绝退款
|
||||
if ($type == 2) {
|
||||
$this->services->refuseRefund((int)$id, $data, $orderRefund);
|
||||
return app('json')->successful('修改退款状态成功!');
|
||||
} else {
|
||||
//0元退款
|
||||
if ($orderRefund['refund_price'] == 0) {
|
||||
$refund_price = 0;
|
||||
} else {
|
||||
if (!$data['refund_price']) {
|
||||
return app('json')->fail('请输入退款金额');
|
||||
}
|
||||
if ($orderRefund['refund_price'] == $orderRefund['refunded_price']) {
|
||||
return app('json')->fail('已退完支付金额!不能再退款了');
|
||||
}
|
||||
$refund_price = $data['refund_price'];
|
||||
$data['refunded_price'] = bcadd($data['refund_price'], $orderRefund['refunded_price'], 2);
|
||||
$bj = bccomp((string)$orderRefund['refund_price'], (string)$data['refunded_price'], 2);
|
||||
if ($bj < 0) {
|
||||
return app('json')->fail('退款金额大于支付金额,请修改退款金额');
|
||||
}
|
||||
}
|
||||
|
||||
unset($data['type']);
|
||||
$refund_data['pay_price'] = $order['pay_price'];
|
||||
$refund_data['refund_price'] = $refund_price;
|
||||
if ($order['refund_price'] > 0) {
|
||||
mt_srand();
|
||||
$refund_data['refund_id'] = $order['order_id'] . rand(100, 999);
|
||||
}
|
||||
//修改订单退款状态
|
||||
unset($data['refund_price']);
|
||||
$adminAccount = $this->adminInfo['account'] ?? '';
|
||||
if ($this->services->agreeRefund($id, $refund_data, $adminAccount)) {
|
||||
$this->services->update($id, $data);
|
||||
return app('json')->success('退款成功');
|
||||
}
|
||||
// else {
|
||||
// $this->services->storeProductOrderRefundYFasle((int)$id, $refund_price);
|
||||
// return app('json')->fail('退款失败');
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家同意退货退款
|
||||
* @return mixed
|
||||
*/
|
||||
public function agreeRefund()
|
||||
{
|
||||
[$order_id] = $this->request->getMore([
|
||||
['order_id', '']
|
||||
], true);
|
||||
$this->services->agreeRefundProdcut((int)$order_id);
|
||||
return app('json')->success('操作成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改备注
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function remark($id)
|
||||
{
|
||||
$data = $this->request->postMore([['remark', '']]);
|
||||
if (!$data['remark'])
|
||||
return app('json')->fail('请输入要备注的内容');
|
||||
if (!$id)
|
||||
return app('json')->fail('缺少参数');
|
||||
if (!$order = $this->services->get($id)) {
|
||||
return app('json')->fail('修改的订单不存在!');
|
||||
}
|
||||
$order->remark = $data['remark'];
|
||||
if ($order->save()) {
|
||||
return app('json')->success('备注成功');
|
||||
} else
|
||||
return app('json')->fail('备注失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 售后详情
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function refundDetail($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
$orderInfo = $this->services->refundDetail($id);
|
||||
$userInfo = ['spread_uid' => '', 'spread_name' => '无'];
|
||||
if ($orderInfo['uid']) {
|
||||
/** @var UserServices $services */
|
||||
$services = app()->make(UserServices::class);
|
||||
$userInfo = $services->getUserWithTrashedInfo($orderInfo['uid']);
|
||||
if (!$userInfo) return app('json')->fail('用户信息不存在');
|
||||
$userInfo = $userInfo->hidden(['pwd', 'add_ip', 'last_ip', 'login_type']);
|
||||
$userInfo = $userInfo->toArray();
|
||||
$userInfo['spread_name'] = '无';
|
||||
if ($orderInfo['spread_uid']) {
|
||||
$spreadName = $services->value(['uid' => $orderInfo['spread_uid']], 'nickname');
|
||||
if ($spreadName) {
|
||||
$userInfo['spread_name'] = $orderInfo['uid'] == $orderInfo['spread_uid'] ? $spreadName . '(自购)' : $spreadName;
|
||||
$userInfo['spread_uid'] = $orderInfo['spread_uid'];
|
||||
} else {
|
||||
$userInfo['spread_uid'] = '';
|
||||
}
|
||||
} else {
|
||||
$userInfo['spread_uid'] = '';
|
||||
}
|
||||
}
|
||||
return $this->success(compact('orderInfo', 'userInfo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 售后原因
|
||||
* @return \think\Response
|
||||
* User: liusl
|
||||
* DateTime: 2024/9/7 14:18
|
||||
*/
|
||||
public function refund_reason()
|
||||
{
|
||||
$reason = sys_config('stor_reason') ?: [];//退款理由
|
||||
$reason = str_replace("\r\n", "\n", $reason);//防止不兼容
|
||||
$reason = explode("\n", $reason);
|
||||
return app('json')->successful($reason);
|
||||
}
|
||||
}
|
||||
120
app/controller/admin/v1/order/StoreDeliveryOrder.php
Normal file
120
app/controller/admin/v1/order/StoreDeliveryOrder.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin\v1\order;
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\order\StoreDeliveryOrderServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 配送订单
|
||||
* Class StoreDeliveryOrder
|
||||
* @package app\admin\controller\store
|
||||
*/
|
||||
class StoreDeliveryOrder extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreDeliveryOrderServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreDeliveryOrderServices $services;
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['keyword', ''],
|
||||
['store_id',],
|
||||
['status', ''],
|
||||
['data', '', '', 'time'],
|
||||
['station_type']
|
||||
]);
|
||||
if ($where['store_id']) {
|
||||
$where['type'] = 1;
|
||||
$where['relation_id'] = $where['store_id'];
|
||||
unset($where['store_id']);
|
||||
}
|
||||
return $this->success($this->services->systemPage($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数ID');
|
||||
}
|
||||
$data = $this->services->detail($id);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取取消发单表单
|
||||
* @param int $id 发单ID
|
||||
* @return mixed
|
||||
*/
|
||||
public function cancelForm($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数ID');
|
||||
}
|
||||
return app('json')->success($this->services->cancelForm($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消发单
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function cancel($id)
|
||||
{
|
||||
$reason = $this->request->getMore([
|
||||
['reason', ''],
|
||||
['cancel_reason', '']
|
||||
]);
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数ID');
|
||||
}
|
||||
if (empty($reason['reason']))
|
||||
return app('json')->fail('取消理由不能为空');
|
||||
$this->services->cancel($id, $reason);
|
||||
return app('json')->success('取消成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return app('json')->fail('缺少参数ID');
|
||||
}
|
||||
$this->services->delete((int)$id);
|
||||
return app('json')->success('删除成功');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
55
app/controller/admin/v1/order/StoreOrder.php
Normal file
55
app/controller/admin/v1/order/StoreOrder.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin\v1\order;
|
||||
|
||||
use app\common\controller\Order;
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\order\{
|
||||
StoreOrderServices
|
||||
};
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 订单管理
|
||||
* Class StoreOrder
|
||||
* @package app\controller\admin\v1\order
|
||||
*/
|
||||
class StoreOrder extends AuthController
|
||||
{
|
||||
|
||||
use Order;
|
||||
|
||||
/**
|
||||
* @var StoreOrderServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreOrderServices $services;
|
||||
|
||||
/**
|
||||
* 易联云打印机打印
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function order_print($id)
|
||||
{
|
||||
if (!$id) return app('json')->fail('缺少参数');
|
||||
$order = $this->services->get($id);
|
||||
if (!$order) {
|
||||
return app('json')->fail('订单没有查到,无法打印!');
|
||||
}
|
||||
$res = $this->services->orderPrint((int)$id, 0, 0);
|
||||
if ($res) {
|
||||
return app('json')->success('打印成功');
|
||||
} else {
|
||||
return app('json')->fail('打印失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
149
app/controller/admin/v1/order/StoreOrderInvoice.php
Normal file
149
app/controller/admin/v1/order/StoreOrderInvoice.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin\v1\order;
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\order\StoreOrderInvoiceServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\product\category\StoreProductCategoryServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
use app\services\store\SystemStoreServices;
|
||||
use app\services\user\UserServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 发票管理
|
||||
* Class StoreOrderInvoice
|
||||
* @package app\controller\admin\v1\order
|
||||
*/
|
||||
class StoreOrderInvoice extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StoreOrderInvoiceServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreOrderInvoiceServices $services;
|
||||
|
||||
/**
|
||||
* 获取订单类型数量
|
||||
* @return mixed
|
||||
*/
|
||||
public function chart()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['data', '', '', 'time'],
|
||||
[['type', 'd'], 0],
|
||||
]);
|
||||
$data = $this->services->chart($where);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询发票列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['status', 0],
|
||||
['real_name', ''],
|
||||
['header_type', ''],
|
||||
['type', ''],
|
||||
['data', '', '', 'time'],
|
||||
['field_key', ''],
|
||||
]);
|
||||
return $this->success($this->services->getList($where));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置发票状态
|
||||
* @param string $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function set_invoice($id = '')
|
||||
{
|
||||
if ($id == '') return $this->fail('缺少参数');
|
||||
$data = $this->request->postMore([
|
||||
['is_invoice', 0],
|
||||
['invoice_number', 0],
|
||||
['invoice_amount', 0],
|
||||
['remark', '']
|
||||
]);
|
||||
if ($data['is_invoice'] == 1 && !$data['invoice_number']) {
|
||||
return $this->fail('请填写开票号');
|
||||
}
|
||||
if ($data['invoice_number'] && !preg_match('/^\d{8,20}$/', $data['invoice_number'])) {
|
||||
return $this->fail('请填写正确的开票号');
|
||||
}
|
||||
$this->services->setInvoice((int)$id, $data);
|
||||
return $this->success('设置成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
* @param $id 订单id
|
||||
* @return mixed
|
||||
*/
|
||||
public function orderInfo(StoreProductServices $productServices, StoreOrderServices $orderServices, $id)
|
||||
{
|
||||
if (!$id || !($orderInfo = $orderServices->get($id))) {
|
||||
return $this->fail('订单不存在');
|
||||
}
|
||||
/** @var UserServices $services */
|
||||
$services = app()->make(UserServices::class);
|
||||
$userInfo = $services->get($orderInfo['uid']);
|
||||
if (!$userInfo) {
|
||||
return app('json')->fail('用户信息不存在');
|
||||
}
|
||||
$userInfo = $userInfo->hidden(['pwd', 'add_ip', 'last_ip', 'login_type']);
|
||||
$userInfo['spread_name'] = '';
|
||||
if ($userInfo['spread_uid'])
|
||||
$userInfo['spread_name'] = $services->value(['uid' => $userInfo['spread_uid']], 'nickname');
|
||||
$orderInfo = $orderServices->tidyOrder($orderInfo->toArray(), true, true);
|
||||
//核算优惠金额
|
||||
$vipTruePrice = 0;
|
||||
foreach ($orderInfo['cartInfo'] ?? [] as $cart) {
|
||||
$vipTruePrice = bcadd((string)$vipTruePrice, (string)$cart['vip_sum_truePrice'], 2);
|
||||
}
|
||||
$orderInfo['vip_true_price'] = $vipTruePrice;
|
||||
|
||||
$orderInfo['add_time'] = $orderInfo['_add_time'] ?? '';
|
||||
$cateIds = [];
|
||||
foreach ($orderInfo['cartInfo'] as &$item) {
|
||||
$cateIds = array_merge($cateIds, explode(',', $item['productInfo']['cate_id'] ?? ''));
|
||||
}
|
||||
$cateIds = implode(',', array_unique($cateIds));
|
||||
/** @var StoreProductCategoryServices $categoryService */
|
||||
$categoryService = app()->make(StoreProductCategoryServices::class);
|
||||
$cateList = $categoryService->getCateParentAndChildName($cateIds);
|
||||
foreach ($orderInfo['cartInfo'] as &$item) {
|
||||
$item['class_name'] = '';
|
||||
if (isset($item['productInfo']['cate_id']) && $item['productInfo']['cate_id']) {
|
||||
$cate_name = $categoryService->getCateName(explode(',', $item['productInfo']['cate_id']), $cateList);
|
||||
if ($cate_name) {
|
||||
$item['class_name'] = is_array($cate_name) ? implode(',', $cate_name) : '';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($orderInfo['store_id'] && $orderInfo['shipping_type'] == 2) {
|
||||
/** @var $storeServices */
|
||||
$storeServices = app()->make(SystemStoreServices::class);
|
||||
$orderInfo['_store_name'] = $storeServices->value(['id' => $orderInfo['store_id']], 'name');
|
||||
} else {
|
||||
$orderInfo['_store_name'] = '';
|
||||
}
|
||||
$userInfo = $userInfo->toArray();
|
||||
$invoice = $this->services->getOne(['order_id' => $id]);
|
||||
return app('json')->success(compact('orderInfo', 'userInfo', 'invoice'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user