修改发货管理

This commit is contained in:
邹景立 2021-03-17 17:52:43 +08:00
parent ccf431caae
commit f432ce693d
5 changed files with 127 additions and 6 deletions

View File

@ -7,6 +7,7 @@ use app\data\service\PaymentService;
use app\data\service\ExpressService; use app\data\service\ExpressService;
use app\data\service\UserAdminService; use app\data\service\UserAdminService;
use think\admin\Controller; use think\admin\Controller;
use think\admin\extend\CodeExtend;
use think\exception\HttpResponseException; use think\exception\HttpResponseException;
/** /**
@ -156,6 +157,57 @@ class ShopOrder extends Controller
} }
} }
/**
* 单据凭证支付审核
* @auth true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function audit()
{
if ($this->request->isGet()) {
$this->_form($this->table, '', 'order_no');
} else {
$data = $this->_vali([
'order_no.require' => '订单单号不能为空!',
'status.in:0,1' => '审核状态数值异常!',
'status.require' => '审核状态不能为空!',
'remark.default' => '',
]);
if (empty($data['status'])) {
$data['status'] = 0;
$data['cancel_status'] = 1;
$data['cancel_remark'] = $data['remark'] ?: '后台审核驳回并取消订单';
$data['cancel_datetime'] = date('Y-m-d H:i:s');
} else {
$data['status'] = 4;
$data['payment_code'] = CodeExtend::uniqidDate(20, 'T');
$data['payment_status'] = 1;
$data['payment_remark'] = $data['remark'] ?: '后台审核支付凭证通过';
$data['payment_datetime'] = date('Y-m-d H:i:s');
}
$order = $this->app->db->name($this->table)->where(['order_no' => $data['order_no']])->find();
if (empty($order) || $order['status'] !== 3) $this->error('不允许操作审核!');
// 无需发货时的处理
if ($data['status'] === 4 && empty($order['truck_type'])) $data['status'] = 5;
// 更新订单支付状态
$map = ['status' => 3, 'order_no' => $data['order_no']];
if ($this->app->db->name($this->table)->strict(false)->where($map)->update($data) !== false) {
if (in_array($data['status'], [4, 5])) {
$this->app->event->trigger('ShopOrderPayment', $data['order_no']);
$this->success('订单审核通过成功!');
} else {
$this->app->event->trigger('ShopOrderCancel');
OrderService::instance()->stock($data['order_no']);
$this->success('审核驳回并取消成功!');
}
} else {
$this->error('订单审核失败!');
}
}
}
/** /**
* 清理订单数据 * 清理订单数据
* @auth true * @auth true

View File

@ -53,7 +53,7 @@ class VoucherPaymentService extends PaymentService
if (empty($order)) throw new Exception("订单不存在"); if (empty($order)) throw new Exception("订单不存在");
if ($order['status'] !== 2) throw new Exception("不可发起支付"); if ($order['status'] !== 2) throw new Exception("不可发起支付");
if (empty($paymentImage)) throw new Exception('支付凭证不能为空'); if (empty($paymentImage)) throw new Exception('支付凭证不能为空');
$this->updateOrder($orderNo, CodeExtend::uniqidDate(20), $paymentAmount, '支付凭证', $paymentImage); $this->updateOrder($orderNo, CodeExtend::uniqidDate(20), $paymentAmount, '单据凭证支付', $paymentImage);
return ['info' => '支付凭证上传成功!', 'status' => 1]; return ['info' => '支付凭证上传成功!', 'status' => 1];
} }
} }

View File

@ -0,0 +1,47 @@
<form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
<div class="layui-card-body padding-left-40">
<fieldset class="layui-form-item">
<legend>
<span class="layui-badge layui-bg-cyan">支付单证凭证</span>
<span class="layui-badge think-bg-blue">{$vo.order_no}</span>
<span class="layui-badge think-bg-violet">订单需要支付 {$vo.amount_real+0} </span>
</legend>
<div class="layui-form-item relative block">
<img data-tips-image style="width:auto;height:220px" src="{$vo.payment_image|default=''}" alt="img">
</div>
</fieldset>
<div class="layui-form-item">
<span class="color-green font-w7 label-required-prev">审核操作类型</span>
<span class="color-desc margin-left-5">Audit type</span>
<div class="layui-textarea" style="min-height:auto;padding:10px 0 13px 18px">
{php} $status = 0; {/php}
{foreach [1 => '审核通过并完成订单支付', 0 => '驳回审核并取消订单'] as $k => $v}
{if $k eq $status}
<input checked type="radio" name="status" value='{$k}' title="{$v}">
{else}
<input checked type="radio" name="status" value='{$k}' title="{$v}">
{/if}{/foreach}
</div>
</div>
<label class="layui-form-item relative block">
<span class="color-green font-w7">订单审核描述</span>
<span class="color-desc margin-left-5"></span>
<textarea name="remark" class="layui-textarea" placeholder="请输入订单审核描述">{$vo.remark|default=''}</textarea>
</label>
<div class="hr-line-dashed"></div>
{notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
{notempty name='vo.order_no'}<input type='hidden' value='{$vo.order_no}' name='order_no'>{/notempty}
<div class="layui-form-item text-center">
<button class="layui-btn" type='submit'>审核</button>
<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消吗?" data-close>取消</button>
</div>
</div>
<script>form.render()</script>
</form>

View File

@ -63,17 +63,38 @@
{eq name='vo.status' value='5'}<span class="layui-badge layui-badge-middle layui-bg-green">已发货</span>{/eq} {eq name='vo.status' value='5'}<span class="layui-badge layui-badge-middle layui-bg-green">已发货</span>{/eq}
{eq name='vo.status' value='6'}<span class="layui-badge layui-badge-middle layui-bg-blue">已完成</span>{/eq} {eq name='vo.status' value='6'}<span class="layui-badge layui-badge-middle layui-bg-blue">已完成</span>{/eq}
<div class="inline-block text-middle"> <div class="inline-block text-middle">
订单单号:<b class="color-blue">{$vo.order_no|default=''}</b><br> <div class="sub-strong-blue">
订单总计:<b class="color-blue">{$vo.amount_total+0}</b> <span class="color-blue">{if $vo.amount_express>0}(含邮费{$vo.amount_express+0}元){else}(包邮){/if}</span>已支付 <b class="color-blue">{$vo.payment_amount+0}</b> <br> 订单单号:<b>{$vo.order_no|default=''}</b>
下单时间:{$vo.create_at|format_datetime}<br> <!--{eq name='vo.status' value='3'}-->
<a data-modal="{:url('audit')}?order_no={$vo.order_no}" class="margin-left-5 layui-badge layui-bg-blue">凭证审核</a>
<!--{/eq}-->
</div>
<div class="sub-strong-blue sub-span-blue">
订单总计:<b>{$vo.amount_total+0}</b>
<span>{if $vo.amount_express>0}(含邮费{$vo.amount_express+0}){else}(包邮){/if}</span>
已支付 <b>{$vo.payment_amount+0}</b>
</div>
<div>下单时间:{$vo.create_at|format_datetime}</div>
<!--{notempty name='vo.payment_status'}--> <!--{notempty name='vo.payment_status'}-->
支付时间:{$vo.payment_datetime|format_datetime} {notempty name='vo.payment_name'}<span class="color-blue"> ({$vo.payment_name|default='-'})</span>{/notempty}<br> <div>
支付时间:{$vo.payment_datetime|format_datetime}
{notempty name='vo.payment_name'}
<!--{notempty name='vo.payment_image'}-->
<span data-tips-text="{$vo.payment_remark|default=''}" data-tips-image="{$vo.payment_image}" class="margin-left-5">({$vo.payment_name|default='-'})</span>
<!--{else}-->
<span class="margin-left-5">({$vo.payment_name|default='-'})</span>
<!--{/notempty}-->
{/notempty}
</div>
<!--{else}--> <!--{else}-->
支付状态:<span class="color-desc">还未支付</span> 支付状态:<span class="color-desc">还未支付</span>
<!--{/notempty}--> <!--{/notempty}-->
</div> </div>
</td> </td>
<td class="nowrap"> <td class="nowrap">
{empty name='vo.truck_type'}
无需发货
{else}
<div>收货信息:{$vo.truck.address_name|default='--'}<span class="margin-left-5 color-blue">{$vo.truck.address_phone|default=''}</span></div> <div>收货信息:{$vo.truck.address_name|default='--'}<span class="margin-left-5 color-blue">{$vo.truck.address_phone|default=''}</span></div>
<div>收货地址:{$vo.truck.address_province|default='--'}{$vo.truck.address_city|default=''}{$vo.truck.address_area|default=''}{$vo.truck.address_content|default=''}</div> <div>收货地址:{$vo.truck.address_province|default='--'}{$vo.truck.address_city|default=''}{$vo.truck.address_area|default=''}{$vo.truck.address_content|default=''}</div>
<div>发货状态:<!--{if empty($vo.truck.send_number)}--><span class="layui-badge layui-bg-black">未发货</span><!--{else}--><span class="layui-badge layui-bg-blue">{$vo.truck.company_name|default='--'}</span> <div>发货状态:<!--{if empty($vo.truck.send_number)}--><span class="layui-badge layui-bg-black">未发货</span><!--{else}--><span class="layui-badge layui-bg-blue">{$vo.truck.company_name|default='--'}</span>
@ -91,6 +112,7 @@
<!--{/if}--> <!--{/if}-->
</div> </div>
<div>发货时间:{$vo.truck.send_datetime|default='--'}</div> <div>发货时间:{$vo.truck.send_datetime|default='--'}</div>
{/empty}
</td> </td>
<td class="nowrap"> <td class="nowrap">
{foreach $vo.items as $item} {foreach $vo.items as $item}

View File

@ -25,7 +25,7 @@ return [
// 模板文件名分隔符 // 模板文件名分隔符
'view_depr' => DIRECTORY_SEPARATOR, 'view_depr' => DIRECTORY_SEPARATOR,
// 去除HTML空格换行 // 去除HTML空格换行
'strip_space' => false, 'strip_space' => true,
// 模板缓存配置 // 模板缓存配置
'tpl_cache' => !app()->isDebug(), 'tpl_cache' => !app()->isDebug(),
// 模板引擎普通标签开始标记 // 模板引擎普通标签开始标记