上门前提醒

This commit is contained in:
xman 2025-06-02 18:37:32 +08:00
parent c1ac4bf315
commit c5cd79edd5
14 changed files with 958 additions and 15 deletions

View File

@ -2,6 +2,8 @@
namespace app\admin\behavior; namespace app\admin\behavior;
use app\admin\model\OrderDispatch;
use app\common\Logic\NoticeLogic;
use think\Exception; use think\Exception;
use think\Lang; use think\Lang;
@ -28,7 +30,24 @@ class OrderDispatchLog
'admin_user' => $dispatch->admin_user??'sys', 'admin_user' => $dispatch->admin_user??'sys',
]; ];
\app\admin\model\OrderDispatchLog::create($data); \app\admin\model\OrderDispatchLog::create($data);
//(new \app\admin\model\OrderDispatchLog())->cre($data);
if($dispatch->status == OrderDispatch::STATUS_TOGET)
{
$alibaba_dyvms = config('alibaba_dyvms');
if($alibaba_dyvms['status']){
$data = [
'order_id' => $dispatch->order_id,
'dispatch_id' => $dispatch->id,
'type' => 1,
'outid' => md5(time().rand(1000,9999).rand(1000,9999)),
'craate_time' => date('Y-m-d H:i:s'),
'status' => $alibaba_dyvms['sync']?1:0
];
$service = new NoticeLogic();
$service->dispatchNotice($dispatch,$data);
}
}
}catch (Exception $exception){ }catch (Exception $exception){
} }

View File

@ -257,6 +257,8 @@ class Aftersale extends Backend
if($params['handle_type'] == 1 && $params['status'] == 2){ //处理完成,重新计算利润 if($params['handle_type'] == 1 && $params['status'] == 2){ //处理完成,重新计算利润
$row->refund_status = 1;
$row->save();
$order = Order::get($row->order_id); $order = Order::get($row->order_id);
//重新计算订单利润 //重新计算订单利润
$orderLogic = new OrderLogic(); $orderLogic = new OrderLogic();

View File

@ -0,0 +1,278 @@
<?php
namespace app\admin\controller\aftersales;
use app\admin\model\Admin;
use app\admin\model\Message;
use app\admin\model\Order;
use app\common\controller\Backend;
use app\common\Logic\OrderLogic;
use Exception;
use think\Db;
use think\exception\DbException;
use think\exception\PDOException;
use think\exception\ValidateException;
/**
* 待退款列表
*
* @icon fa fa-circle-o
*/
class Aftersale2 extends Backend
{
/**
* Aftersale模型对象
* @var \app\admin\model\Aftersale
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\Aftersale;
$this->view->assign("statusList", $this->model->getStatusList());
$this->view->assign("handleTypeList", $this->model->getHandleTypeList());
$this->view->assign("fromList", $this->model->getFromList());
$this->view->assign("refundTypeList", $this->model->getRefundTypeList());
$this->view->assign("typeList", $this->model->getTypeList());
$this->view->assign("workerRefundEntryList", $this->model->getWorkerRefundEntryList());
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
$from = $this->request->param('from',1);
$man_id = $this->request->param('man_id');
//如果发送的来源是Selectpage则转发到Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$builder = $this->model
->where('refund_status','=',1)
->with(['order'])
->where($where);
if($from == 2){
//$builder->where('refund_amount','>',0);
//$builder->where('status','<>',-1);
$builder->where('fa_aftersale.dispatch_admin_id',$man_id ?: 0);
}
if($from == 3){
//$builder->where('refund_amount','>',0);
//$builder->where('status','<>',-1);
$builder->where('fa_aftersale.worker_id',$man_id ?: 0);
}
$list = $builder->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
}
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
return $this->view->fetch();
}
/**
* 添加
*
* @return string
* @throws \think\Exception
*/
public function add($ids = null)
{
if (false === $this->request->isPost()) {
if ($ids){
$order = model('order')->get($ids);
$this->view->assign('order',$order);
}else{
$order_id = $this->request->param('order_id');
if(empty($order_id)){
$this->error('请选择订单');
}
$order = Order::get($order_id);
if(empty($order)){
$this->error('订单不存在');
}
$this->assign('order',$order);
}
return $this->view->fetch();
}
$params = $this->request->post('row/a');
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$params = $this->preExcludeFields($params);
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException()->validate($validate);
}
$order = Order::get($params['order_id'],['dispatch']);
if(empty($order)){
$this->error('订单不存在');
}
/* if($order->status != Order::STATUS_FINISHED){
$this->error('订单不是完成状态,不可创建售后');
}*/
if(\app\admin\model\Aftersale::where('order_id',$params['order_id'])->find()){
$this->error('订单已存在售后信息,不可重复创建');
}
$params['admin_id'] = $this->auth->id;
$params['admin_user'] = $this->auth->nickname;
if(!empty($order->dispatch)){
$params['worker_id'] = $order->dispatch->worker_id ?? 0;
$params['worker_name'] = $order->dispatch->worker_name ?? '';
}
$params['status'] = 1;
if($params['type'] == 1){
$params['refund_amount'] = bcadd($params['company_refund_amount'] ?? 0,$params['worker_refund_amount']??0,2);
}else{
unset($params['company_refund_amount']);
unset($params['worker_refund_amount']);
}
$params['dispatch_admin_id'] = $order->dispatch_admin_id ?? 0;
$params['dispatch_admin_user'] = $order->dispatch_admin_user ?? '';
Message::create([
'to_id' => $params['dispatch_admin_id'],
'type' => 1,
'title' => '售后申请通知',
'content' => '【售后申请通知】您有一条售后申请待处理,请前往订单售后界面进行处理!'
]);
$result = $this->model->allowField(true)->save($params);
$order->aftersale_id = $this->model->id;
$order->status = Order::STATUS_AFTERSALE;
$order->save();
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
throw $e;
// $this->error($e->getMessage());
}
if ($result === false) {
$this->error(__('No rows were inserted'));
}
$this->success();
}
/**
* 编辑
*
* @param $ids
* @return string
* @throws DbException
* @throws \think\Exception
*/
public function edit($ids = null)
{
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
if (false === $this->request->isPost()) {
$order = Order::get($row->order_id);
if(empty($order)){
$this->error('订单不存在');
}
$this->view->assign('order',$order);
$this->view->assign('row', $row);
return $this->view->fetch();
}
$params = $this->request->post('row/a');
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$params = $this->preExcludeFields($params);
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException()->validate($validate);
}
$params['handle_admin_id'] = $this->auth->id;
$params['handle_admin_user'] = $this->auth->nickname;
if($params['handle_type'] == 1){
$params['refund_amount'] = bcadd($params['company_refund_amount'],$params['worker_refund_amount'],2);
}else{
unset($params['company_refund_amount']);
unset($params['worker_refund_amount']);
}
if(empty($params['company_refund_time'])){
$params['company_refund_time'] = date('Y-m-d H:i:s');
}
if(empty($params['worker_refund_time'])){
$params['worker_refund_time'] = date('Y-m-d H:i:s');
}
$result = $row->allowField(true)->save($params);
if($params['handle_type'] == 1 && $params['status'] == 2){ //处理完成,重新计算利润
$order = Order::get($row->order_id);
//重新计算订单利润
$orderLogic = new OrderLogic();
$orderLogic->recacle($order,$row);
}
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
$this->success();
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace app\admin\model;
use fast\Tree;
use think\Model;
class TtsLog extends Model
{
// 表名
protected $name = 'tts_logs';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
protected $dateFormat = 'Y-m-d H:i:s';
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
}

View File

@ -0,0 +1,94 @@
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('订单编号')}:</label>
<div class="col-xs-12 col-sm-8">
{if isset($order)}
<input id="c-order_sn" disabled data-rule="required" value="{$order.order_no}" class="form-control" type="text" >
<input id="c-order_id" value="{$order.id}" style="display: none" class="form-control" name="row[order_id]" type="text" >
{else /}value3
<input id="c-order_no" readonly data-rule="required" class="form-control" type="text" value="{$order.order_no}">
<input type="hidden" name="row[order_id]" value="{$order.id}">
{/if}
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">客户姓名:</label>
<div class="col-xs-12 col-sm-8">
<input data-field="order_no" readonly class="form-control" type="text" value="{$order.customer|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">客户姓名:</label>
<div class="col-xs-12 col-sm-8">
<input data-field="order_no" readonly class="form-control" type="text" value="{$order.tel|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">异常类型:</label>
<div class="col-xs-12 col-sm-8">
<select data-live-search="true" title="请选择" data-rule="required" name="row[type]" class="form-control">
<option value="1">退款</option>
<option value="2">返修</option>
<option value="3">其它</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Customer_appeal')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea class="form-control" id="c-customer_appeal" name="row[customer_appeal]" data-rule="required" placeholder="客户诉求"></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Customer_qrcode')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-customer_qrcode" class="form-control" size="50" name="row[customer_qrcode]" type="text" value="">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-customer_qrcode" class="btn btn-danger faupload" data-input-id="c-customer_qrcode" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple=false data-preview-id="p-customer_qrcode"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-customer_qrcode" class="btn btn-primary fachoose" data-input-id="c-customer_qrcode" data-mimetype="image/*" data-multiple=false><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-customer_qrcode"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-customer_qrcode"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Images')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-images" class="form-control" size="50" name="row[images]" type="text">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-images" class="btn btn-danger faupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-images"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-images"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Remark')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-remark" class="form-control" name="row[remark]" placeholder="备注"></textarea>
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
</div>
</div>
</form>

View File

@ -0,0 +1,197 @@
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('订单编号')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-order_id" data-field="order_no" data-rule="required" class="form-control" readonly type="text" value="{$order.order_no|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">客户姓名:</label>
<div class="col-xs-12 col-sm-8">
<input data-field="order_no" data-rule="required" class="form-control" readonly type="text" value="{$order.customer|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">客户电话:</label>
<div class="col-xs-12 col-sm-8">
<input data-field="order_no" data-rule="required" class="form-control" readonly type="text" value="{$order.tel|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">请求售后类型:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-type" class="form-control" readonly type="text" value="{$row.type_text|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('From')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-from" data-rule="required" class="form-control selectpicker" name="row[from]">
{foreach name="fromList" item="vo"}
<option value="{$key}" {in name="key" value="$row.from"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Handle_type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-handle_type" data-rule="required" class="form-control selectpicker" name="row[handle_type]">
{foreach name="handleTypeList" item="vo"}
<option value="{$key}" {in name="key" value="$row.handle_type"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Company_refund_amount')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-company_refund_amount" data-rule="required" min="0" class="form-control" step="0.01" name="row[company_refund_amount]" type="number" value="{$row.company_refund_amount|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Worker_refund_amount')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-worker_refund_amount" data-rule="required" min="0" class="form-control" step="0.01" name="row[worker_refund_amount]" type="number" value="{$row.worker_refund_amount|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Refund_type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-refund_type" data-rule="required" class="form-control selectpicker" name="row[refund_type]">
{foreach name="refundTypeList" item="vo"}
<option value="{$key}" {in name="key" value="$row.refund_type"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Worker_refund_entry')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-worker_refund_entry" data-rule="required" class="form-control selectpicker" name="row[worker_refund_entry]">
{foreach name="workerRefundEntryList" item="vo"}
<option value="{$key}" {in name="key" value="$row.worker_refund_entry"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<!-- <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Refund_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-refund_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[refund_time]" type="text" value="{$row.refund_time}">
</div>
</div>-->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Company_refund_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-company_refund_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[company_refund_time]" type="text" value="{$row.company_refund_time}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Worker_refund_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-worker_refund_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[worker_refund_time]" type="text" value="{$row.worker_refund_time}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Customer_appeal')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea class="form-control" id="c-customer_appeal" name="row[customer_appeal]" data-rule="required" placeholder="客户诉求">{$row.customer_appeal|htmlentities}</textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Customer_qrcode')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-customer_qrcode" class="form-control" size="50" name="row[customer_qrcode]" type="text" value="{$row.customer_qrcode|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-customer_qrcode" class="btn btn-danger faupload" data-input-id="c-customer_qrcode" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple=false data-preview-id="p-customer_qrcode"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-customer_qrcode" class="btn btn-primary fachoose" data-input-id="c-customer_qrcode" data-mimetype="image/*" data-multiple=false><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-customer_qrcode"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-customer_qrcode"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Images')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-images" class="form-control" size="50" name="row[images]" type="text" value="{$row.images|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-images" class="btn btn-danger faupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-images"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-images"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Remark')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-remark" class="form-control" name="row[remark]" >{$row.remark|htmlentities}</textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Star')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-star" data-rule="required" min="1" max="5" step="1" class="form-control" name="row[star]" type="number" value="{$row.star|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="statusList" item="vo"}
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
{if condition='$row.status eq 1'}
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
</div>
</div>
{/if}
</form>

View File

@ -0,0 +1,46 @@
<div class="panel panel-default panel-intro">
<div class="panel-heading">
{:build_heading(null,FALSE)}
<ul class="nav nav-tabs" data-field="status">
<li class="{:$Think.get.status === null ? 'active' : ''}"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li>
{foreach name="statusList" item="vo"}
<li class="{:$Think.get.status === (string)$key ? 'active' : ''}"><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>
{/foreach}
</ul>
</div>
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('aftersales/aftersale/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('aftersales/aftersale/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('aftersales/aftersale/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
-->
<!-- <div class="dropdown btn-group {:$auth->check('aftersales/aftersale/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
{foreach name="statusList" item="vo"}
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:" data-params="status={$key}">{:__('Set status to ' . $key)}</a></li>
{/foreach}
</ul>
</div>-->
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('aftersales/aftersale/edit')}"
data-operate-del="{:$auth->check('aftersales/aftersale/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>

View File

@ -2,6 +2,8 @@
namespace app\common\Logic; namespace app\common\Logic;
use AlibabaCloud\SDK\Dyvmsapi\V20170525\Models\SingleCallByTtsResponse;
use app\common\model\OrderDispatch;
use app\common\services\alibaba\DyvmsService; use app\common\services\alibaba\DyvmsService;
use think\Exception; use think\Exception;
@ -11,25 +13,81 @@ use think\Exception;
class NoticeLogic class NoticeLogic
{ {
const TTS_DISPATCH1 ='TTS_313465270'; //手动派单通知
const TTS_DISPATCH2 ='TTS_313485240'; //手动派单通知
const TTS_OVER_FINISHED = 'TTS_315365191'; //完成时间已过
const TTS_GOGOGO = 'TTS_313570203'; //上门前一小时打电话通知师傅
public function __construct($types = []) public function __construct($types = [])
{ {
} }
public function callIt($log)
{
$dispatch = OrderDispatch::get($log->dispatch_id);
//1=派单2=提前通知3=超时通知
$ttsCode = null;
$dispatch->tts_check_time = date('Y-m-d H:i:s',time()+5*60);
if($log->type == 1)
{
$dispatch->tts_notice = 1;
if($dispatch->type == 1){
$ttsCode = self::TTS_DISPATCH1;
$dispatch->save();
}else{
$ttsCode = self::TTS_DISPATCH2;
}
}elseif($log->type == 2)
{
$dispatch->tts_notice = 2;
$ttsCode = self::TTS_GOGOGO;
}elseif($log->type == 3){
$dispatch->tts_notice = 3;
$ttsCode = self::TTS_OVER_FINISHED;
}
if(empty($ttsCode)){
$log->status = -1;
$log->content = 'TTSID为空';
$log->save();
}
try {
$reponse = DyvmsService::getInstance()->call($dispatch->worker_tel, $ttsCode, md5(time()));
if($reponse->statusCode == 200 && $reponse->body->code == 'OK'){
$log->status = 1;
$log->callId = $reponse->body->callId;
$log->save();
}else{
$log->status = -1;
$log->content = $reponse->body->message;
$log->save();
}
}catch (Exception $exception){
$log->status = -1;
$log->content = $exception->getMessage();
$log->save();
}
}
/** /**
* 派单通知 * 派单通知
* @return void * @return SingleCallByTtsResponse|array
*/ */
public function dispatchNotice($dispatch,$type) public function dispatchNotice($dispatch): array|SingleCallByTtsResponse
{ {
$ttsCode = ''; if($dispatch->type == 1){
$outId = ''; $ttsCode = self::TTS_DISPATCH1;
try { }else{
$reponse = DyvmsService::getInstance()->call($dispatch->worker_tel, $ttsCode, $outId); $ttsCode = self::TTS_DISPATCH2;
}catch (Exception $exception){
dump($exception->getMessage());
} }
try {
$reponse = DyvmsService::getInstance()->call($dispatch->worker_tel, $ttsCode, md5(time()));
}catch (Exception $exception){
throw $exception;
}
return $reponse;
} }

View File

@ -6,6 +6,8 @@ use app\admin\model\Message;
use app\admin\model\OrderDispatch; use app\admin\model\OrderDispatch;
use app\admin\model\OrderDispatchRecord; use app\admin\model\OrderDispatchRecord;
use app\admin\model\TtsLog;
use app\common\Logic\NoticeLogic;
use think\console\Command; use think\console\Command;
use think\console\Input; use think\console\Input;
use think\console\Output; use think\console\Output;
@ -19,7 +21,6 @@ class CheckOrdeRecordCommand extends Command
} }
protected function execute(Input $input, Output $output){ protected function execute(Input $input, Output $output){
$Model = new OrderDispatchRecord(); $Model = new OrderDispatchRecord();
$now = date('Y-m-d H:i:s'); //创建三十分名以上未接的任务 $now = date('Y-m-d H:i:s'); //创建三十分名以上未接的任务

View File

@ -0,0 +1,59 @@
<?php
namespace app\common\command;
use app\admin\controller\SendMailLogic;
use app\admin\model\Message;
use app\admin\model\OrderDispatch;
use app\admin\model\OrderDispatchRecord;
use app\admin\model\TtsLog;
use app\common\Logic\NoticeLogic;
use think\console\Command;
use think\console\Input;
use think\console\Output;
class CheckSmsPlantCommand extends Command
{
protected function configure()
{
$this->setName('check:dispatch-sms-plant')
->setDescription('dispatch已预约任务短信提醒每小时执行一次');
}
protected function execute(Input $input, Output $output){
$Model = new OrderDispatch();
$now = date('Y-m-d H:i:s'); //两小时通知
$afterTwoHours = date('Y-m-d H:i:s', strtotime('+2 hours'));
$logic = new SendMailLogic();
//$Model->where('need_notice',1)
$Model->where('status','=',OrderDispatch::STATUS_PLANIT)
->where('plan_time','between',[$now,$afterTwoHours])
->where('notice_num','<',3)
->chunk(100, function ($list)use ($logic) {
$ids = [];
$logs = [];
foreach ($list as $item) {
$ids[] = $item->id;
//修改状态
/* $logs[] = [
'dispatch_id' => $item->id,
'order_id'=>$item->order_id,
'type' => 2,
'outid' => md5(time().rand(1000,9999).rand(1000,9999)),
'create_time' => date('Y-m-d H:i:s'),
'status' => 0,
'update_time' => date('Y-m-d H:i:s')
];
(new TtsLog())->insertAll($logs);*/
SendMailLogic::sendToWorker($item->worker_tel);
}
if(!empty($ids)){
OrderDispatch::whereIn('id',$ids)->update(['notice_num'=>3,'notice_time'=>date('Y-m-d H:i:s')]);
}
});
$output->info('OVER');
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace app\common\command;
use app\admin\model\Message;
use app\admin\model\OrderDispatch;
use app\admin\model\OrderDispatchRecord;
use app\admin\model\TtsLog;
use app\common\Logic\NoticeLogic;
use think\console\Command;
use think\console\Input;
use think\console\Output;
class CheckTTSPlantCommand extends Command
{
protected function configure()
{
$this->setName('check:dispatch-tts-plant')
->setDescription('dispatch已预约任务语音提醒每小时执行一次');
}
protected function execute(Input $input, Output $output){
$Model = new OrderDispatch();
$now = date('Y-m-d H:i:s'); //两小时通知
$afterTwoHours = date('Y-m-d H:i:s', strtotime('+1 hours'));
//$Model->where('need_notice',1)
$Model->where('status','=',OrderDispatch::STATUS_PLANIT)
->where('plan_time','between',[$now,$afterTwoHours])
->where('tts_notice','<',2)
->chunk(100, function ($list) {
$ids = [];
$logs = [];
foreach ($list as $item) {
$ids[] = $item->id;
//修改状态
$logs[] = [
'dispatch_id' => $item->id,
'order_id'=>$item->order_id,
'type' => 2,
'outid' => md5(time().rand(1000,9999).rand(1000,9999)),
'create_time' => date('Y-m-d H:i:s'),
'status' => 0,
'update_time' => date('Y-m-d H:i:s')
];
(new TtsLog())->insertAll($logs);
}
if(!empty($ids)){
OrderDispatch::whereIn('id',$ids)->update(['tts_notice'=>2,'tts_check_time'=>date('Y-m-d H:i:s')]);
}
});
$output->info('OVER');
}
}

View File

@ -17,7 +17,7 @@ class DyvmsService
// 私有构造函数,防止外部直接实例化 // 私有构造函数,防止外部直接实例化
private function __construct($options = []) private function __construct($options = [])
{ {
$config = Env::get('alibaba_dyvms'); $config = \config('alibaba_dyvms');
if (!empty($options)) { if (!empty($options)) {
$config = array_merge($config, $options); $config = array_merge($config, $options);
} }
@ -39,7 +39,7 @@ class DyvmsService
} }
// 防止反序列化 // 防止反序列化
private function __wakeup() public function __wakeup()
{ {
} }

View File

@ -2,11 +2,15 @@
return [ return [
'accessKeyId' => '', 'accessKeyId' => 'LTAI5t87F5mAkaXVKfLcmnrB',
'accessKeySecret' => '', 'accessKeySecret' => 'fk7KgdqRdJUS6Jc99TlB6mNLKorrsD',
'regionId' => '', //可用区ID 'regionId' => 'cn-chengdu', //可用区ID
'calledShowNumber' => '', //专属号码 'calledShowNumber' => '', //专属号码
'sync' => true, //同步
'status' => true, //true启用0关闭
]; ];

View File

@ -0,0 +1,104 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'aftersales/aftersale2/index' + location.search,
add_url: 'aftersales/aftersale2/add',
edit_url: 'aftersales/aftersale2/edit',
// del_url: 'aftersales/aftersale/del',
multi_url: 'aftersales/aftersale2/multi',
import_url: 'aftersales/aftersale2/import',
table: 'aftersale',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
fixedColumns: true,
fixedRightNumber: 1,
columns: [
[
// {checkbox: true},
{field: 'id', title: __('Id')},
// {field: 'order_id', title: __('Order_id')},
{field: 'order.order_no', title: __('Order.order_no'), operate: '='},
{field: 'order.customer', title: __('Order.customer'), operate: false},
{field: 'order.tel', title: __('Order.tel'), operate: '='},
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),
//"3":__('Status 3'),
"-1":__('Status -1')}, formatter: Table.api.formatter.status},
{field: 'handle_type', title: __('Handle_type'), searchList: {"1":__('Handle_type 1'),"2":__('Handle_type 2'),"3":__('Handle_type 3'),"4":__('Handle_type 4')}, formatter: Table.api.formatter.normal},
{field: 'from', title: __('From'), searchList: {"1":__('From 1'),"2":__('From 2'),"3":__('From 3')}, formatter: Table.api.formatter.normal},
{field: 'refund_amount', title: __('Refund_amount'), operate:false},
{field: 'company_refund_amount', title: __('Company_refund_amount'), operate:false},
{field: 'worker_refund_amount', title: __('Worker_refund_amount'), operate:false},
{field: 'refund_type', title: __('Refund_type'), searchList: {"0":__('Refund_type 0'),"1":__('Refund_type 1'),"2":__('Refund_type 2')}, formatter: Table.api.formatter.normal},
{field: 'worker_refund_entry', title: __('Worker_refund_entry'), searchList: {"0":__('Worker_refund_entry 0'),"1":__('Worker_refund_entry 1')}, formatter: Table.api.formatter.normal},
{field: 'company_refund_time', title: __('Company_refund_time'), operate:false, addclass:'datetimerange', autocomplete:false},
{field: 'worker_refund_time', title: __('Worker_refund_time'), operate:false, addclass:'datetimerange', autocomplete:false},
//{field: 'refund_time', title: __('Refund_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'customer_appeal', title: __('Customer_appeal'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//{field: 'customer_qrcode', title: __('Customer_qrcode'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'customer_qrcode', title: __('Customer_qrcode'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
{field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
{field: 'remark', title: __('Remark'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'dispatch_admin_user', title: __('派单员'), operate: '='},
//{field: 'admin_id', title: __('Admin_id')},
{field: 'admin_user', title: __('Admin_user'), operate: '='},
//{field: 'handle_admin_id', title: __('Handle_admin_id')},
{field: 'handle_admin_user', title: __('Handle_admin_user'), operate: '='},
{field: 'star', title: __('Star'),operate:false},
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'update_time', title: __('Update_time'), operate:false, addclass:'datetimerange', autocomplete:false},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
buttons: [
{
name: 'edit',
text:"处理",
title:"售后处理",
icon: 'fa fa-pencil',
//title: __('Edit'),
extend: 'data-toggle="tooltip" data-container="body"',
classname: 'btn btn-xs btn-success btn-editone',
visible:function(row){
if(row.status === 1){
return true;
}
return false;
}
}
],
}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});