sth
This commit is contained in:
parent
32db3c801f
commit
8f45a42d84
|
|
@ -172,7 +172,7 @@ class Order extends Backend
|
|||
|
||||
foreach ($list as &$item){
|
||||
$item->aftersale_btn = false;
|
||||
if($item->aftersale_id==0 && $this->auth->check('aftersales/aftersale/add')){ //$item->status == \app\admin\model\Order::STATUS_FINISHED &&
|
||||
if($item->aftersale_id==0 && $this->auth->check('aftersales/aftersale/add') && $item->status == \app\admin\model\Order::STATUS_FINISHED){ //$item->status == \app\admin\model\Order::STATUS_FINISHED &&
|
||||
$item->aftersale_btn = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace app\admin\controller\aftersales;
|
|||
|
||||
use app\admin\model\Order;
|
||||
use app\common\controller\Backend;
|
||||
use app\common\Logic\OrderLogic;
|
||||
use Exception;
|
||||
use think\Db;
|
||||
use think\exception\DbException;
|
||||
|
|
@ -140,7 +141,13 @@ class Aftersale extends Backend
|
|||
$params['worker_name'] = $order->dispatch->worker_name;
|
||||
}
|
||||
$params['status'] = 1;
|
||||
$params['refund_amount'] = bcadd($params['company_refund_amount'],$params['worker_refund_amount'],2);
|
||||
|
||||
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']);
|
||||
}
|
||||
$result = $this->model->allowField(true)->save($params);
|
||||
$order->aftersale_id = $this->model->id;
|
||||
$order->save();
|
||||
|
|
@ -199,7 +206,12 @@ class Aftersale extends Backend
|
|||
}
|
||||
$params['handle_admin_id'] = $this->auth->id;
|
||||
$params['handle_admin_user'] = $this->auth->nickname;
|
||||
$params['refund_amount'] = bcadd($params['company_refund_amount'],$params['worker_refund_amount'],2);
|
||||
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');
|
||||
|
|
@ -209,6 +221,14 @@ class Aftersale extends Backend
|
|||
}
|
||||
|
||||
$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();
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ class Configorder extends Backend
|
|||
'status' => Order::STATUS_AUDITING,
|
||||
'online_amount_last' => $params['online_amount_last'],
|
||||
'offline_amount' => $params['offline_amount'],
|
||||
'refund_amount' => $params['refund_amount'],
|
||||
// 'refund_amount' => $params['refund_amount'],
|
||||
'cost' => $params['cost'],
|
||||
'offline_amount_type'=> $params['offline_amount_type'],
|
||||
'amount_images' => $params['amount_images'],
|
||||
|
|
@ -138,7 +138,7 @@ class Configorder extends Backend
|
|||
$cost = bcadd($params['cost'],$params['material_cost'],2);
|
||||
|
||||
$data['total'] = bcadd($row->online_amount,$last_amount,2);
|
||||
$data['real_amount'] = bcsub($data['total'],$params['refund_amount'],2);
|
||||
$data['real_amount'] = $data['total'];
|
||||
$data['performance'] = bcsub($data['real_amount'],$cost,2);
|
||||
$result = $row->allowField(true)->save($data);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ return [
|
|||
'Discount_amount' => '优惠抵扣',
|
||||
'Real_amount' => '实际收款',
|
||||
'Refund_amount' => '退款金额',
|
||||
'Cost' => '师傅成本',
|
||||
'Cost' => '师傅分成',
|
||||
'Performance' => '预计利润',
|
||||
'Cancel_reason_id' => '取消原因',
|
||||
'Cancel_detail' => '取消详情',
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ return [
|
|||
'Discount_amount' => '优惠抵扣',
|
||||
'Refund_amount' => '退款金额',
|
||||
'Real_amount' => '实际收款',
|
||||
'Cost' => '师傅成本',
|
||||
'Cost' => '师傅分成',
|
||||
'Performance' => '预计利润',
|
||||
'Cancel_reason_id' => '取消原因',
|
||||
'Cancel_detail' => '取消详情',
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ return [
|
|||
'Order.discount_amount' => '优惠抵扣',
|
||||
'Order.refund_amount' => '退款金额',
|
||||
'Order.real_amount' => '实际收款',
|
||||
'Order.cost' => '师傅成本',
|
||||
'Order.cost' => '师傅分成',
|
||||
'Order.performance' => '预计利润',
|
||||
'Order.cancel_reason_id' => '取消原因',
|
||||
'Order.cancel_detail' => '取消详情',
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ return [
|
|||
'Order.discount_amount' => '优惠抵扣',
|
||||
'Order.refund_amount' => '退款金额',
|
||||
'Order.real_amount' => '实际收款',
|
||||
'Order.cost' => '师傅成本',
|
||||
'Order.cost' => '师傅分成',
|
||||
'Order.performance' => '预计利润',
|
||||
'Order.cancel_reason_id' => '取消原因',
|
||||
'Order.cancel_detail' => '取消详情',
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ return [
|
|||
'Discount_amount' => '优惠抵扣',
|
||||
'Refund_amount' => '总退款额',
|
||||
'Real_amount' => '实际收款',
|
||||
'Cost' => '师傅成本',
|
||||
'Cost' => '师傅分成',
|
||||
'Performance' => '预计利润',
|
||||
'Cancel_reason_id' => '取消原因',
|
||||
'Cancel_detail' => '取消详情',
|
||||
|
|
|
|||
|
|
@ -36,7 +36,10 @@ class Aftersale extends Model
|
|||
|
||||
public function getStatusList()
|
||||
{
|
||||
return ['1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3'), '-1' => __('Status -1')];
|
||||
return ['1' => __('Status 1'),
|
||||
'2' => __('Status 2'),
|
||||
//'3' => __('Status 3'),
|
||||
'-1' => __('Status -1')];
|
||||
}
|
||||
|
||||
public function getHandleTypeList()
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ class Order extends Model
|
|||
|
||||
const TAB_REVIEW = 'review'; //回访
|
||||
|
||||
const TAB_VALID = 'valid'; //有效的订单,即除了取消的和草稿
|
||||
|
||||
const STATUS_DRAFT = 0; //草稿
|
||||
const STATUS_DISPATCHING = 10; //待派单
|
||||
const STATUS_DISPATCHED = 20; //已派单
|
||||
|
|
@ -152,6 +154,14 @@ class Order extends Model
|
|||
self::STATUS_CHECKING,
|
||||
self::STATUS_CHECKONCE
|
||||
],
|
||||
self::TAB_VALID => [
|
||||
self::STATUS_DISPATCHING,
|
||||
self::STATUS_DISPATCHED,
|
||||
self::STATUS_CHECKING,
|
||||
self::STATUS_CHECKONCE,
|
||||
self::STATUS_AUDITING,
|
||||
self::STATUS_FINISHED
|
||||
],
|
||||
];
|
||||
return $tabStatus[$tab] ?? [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@
|
|||
<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="0.00">
|
||||
<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="0.00">
|
||||
</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="0.00">
|
||||
<input id="c-worker_refund_amount" data-rule="required" min="0" class="form-control" min="0" step="0.01" name="row[worker_refund_amount]" type="number" value="0.00">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
|
|||
|
|
@ -112,14 +112,12 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<!-- <div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Refund_amount')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-refund_amount" readonly class="form-control" step="0.01" name="row[refund_amount]" type="number" value="{$row.refund_amount|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Real_amount')}:</label>
|
||||
|
|
|
|||
|
|
@ -169,12 +169,12 @@
|
|||
{/if}
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Refund_amount')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-refund_amount" data-rule="required" class="form-control" step="0.01" name="row[refund_amount]" type="number" value="{$row.refund_amount|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group">-->
|
||||
<!-- <label class="control-label col-xs-12 col-sm-2">{:__('Refund_amount')}:</label>-->
|
||||
<!-- <div class="col-xs-12 col-sm-8">-->
|
||||
<!-- <input id="c-refund_amount" data-rule="required" class="form-control" step="0.01" name="row[refund_amount]" type="number" value="{$row.refund_amount|htmlentities}">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace app\common\Logic;
|
||||
|
||||
use app\admin\controller\orders\Dispatch;
|
||||
use app\admin\model\Aftersale;
|
||||
use app\admin\model\Order;
|
||||
use app\admin\model\OrderDispatch;
|
||||
use fast\Auth;
|
||||
|
|
@ -146,4 +147,19 @@ class OrderLogic
|
|||
}
|
||||
}
|
||||
|
||||
public function recacle(Order $order,Aftersale $aftersale)
|
||||
{
|
||||
if($aftersale->handle_type == 1)
|
||||
{
|
||||
$order->refund_amount = $aftersale->company_refund_amount;
|
||||
$order->worker_refund_amount = $aftersale->worker_refund_amount;
|
||||
//平台实际收款要扣减
|
||||
$order->real_amount = bcsub($order->real_amount,$aftersale->company_refund_amount,2);
|
||||
//师傅成本要扣减
|
||||
$order->cost = bcsub($order->cost,$aftersale->worker_refund_amount);
|
||||
$order->performance = bcsub($order->performance,$aftersale->company_refund_amount,2);
|
||||
$order->save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -32,7 +32,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
{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: '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},
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user