礼品回退

订单状态回退
dev
zhaocheng 5 years ago
parent c94aec1e44
commit a4349d78fc
  1. 206
      frontend/controllers/InsurerController.php
  2. 50
      frontend/views/insurer/info.php
  3. 18
      frontend/views/insurer/my-list-info.php
  4. 4
      frontend/views/insurer/office-mng-edit.php
  5. 4
      frontend/views/insurer/original-mng-edit.php

@ -131,20 +131,6 @@ class InsurerController extends BaseController
if($order_info->non_id){ if($order_info->non_id){
$nonitems=NonAutoInsurance::findOne(['id'=>$order_info->non_id]); $nonitems=NonAutoInsurance::findOne(['id'=>$order_info->non_id]);
} }
// dd($order_info->non_id);
//快递
// dd($car_info->id);
// $ems_items = EmsT::find()
// ->where(['car_id'=>$car_info->id,'order_id'=>$order_info->id])
// ->orderBy('id ASC')
// ->all();
// $ems_items1=(object)array();
// if(!$ems_items){
// $ems_items1 = ExpressT::find()
// ->where(['car_id'=>$car_info->id,'order_id'=>$order_info->id])
// ->orderBy('id ASC')
// ->all();
// }
//礼品 //礼品
$gift_free_group_items = GiftGroupT::find() $gift_free_group_items = GiftGroupT::find()
->where('is_free=1') ->where('is_free=1')
@ -177,8 +163,6 @@ class InsurerController extends BaseController
return $this->render('info',[ return $this->render('info',[
'order_info'=>$order_info, 'order_info'=>$order_info,
'car_info'=>$car_info, 'car_info'=>$car_info,
// 'ems_items' => $ems_items,
// 'ems_items1' => $ems_items1,
'money_man' => $money_man, 'money_man' => $money_man,
'money_no' => $money_no, 'money_no' => $money_no,
'money_bank' => $money_bank, 'money_bank' => $money_bank,
@ -2381,8 +2365,10 @@ class InsurerController extends BaseController
$limit = $request->get('limit', 10); $limit = $request->get('limit', 10);
$query = OrderT::find() $query = OrderT::find()
->where('status_id>1') ->orderBy('status_id desc,car_no desc,submit_date asc');
->orderBy('car_no desc,submit_date asc'); if($this->my->id > 2){
$query->andWhere('status_id>1');
}
if($id_man != '') { if($id_man != '') {
$query->andWhere(['like','id_man',$id_man]); $query->andWhere(['like','id_man',$id_man]);
} }
@ -2413,13 +2399,11 @@ class InsurerController extends BaseController
if($date3_end != '') { if($date3_end != '') {
$query->andWhere('insurer1_begin_date<=:end_date or insurer2_begin_date<=:end_date', [':end_date'=>$date3_end]); $query->andWhere('insurer1_begin_date<=:end_date or insurer2_begin_date<=:end_date', [':end_date'=>$date3_end]);
} }
if($status > 0) { if($status == 1) {
if($status == 1) { $query->andWhere('status_id>1 and status_id<10');
$query->andWhere('status_id>1 and status_id<10'); }
} if($status == 2) {
if($status == 2) { $query->andWhere('status_id=10');
$query->andWhere('status_id=10');
}
} }
$total = $query->count(); $total = $query->count();
@ -3503,43 +3487,58 @@ class InsurerController extends BaseController
return $result; return $result;
} }
/**
* 礼品状态回退
* @return array
*/
public function actionGiftCancel() public function actionGiftCancel()
{ {
Yii::$app->response->format = Response::FORMAT_JSON; Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request; $request = Yii::$app->request;
$result = array(); $id = $request->post('order_id');
$result['success'] = false; $msg= $request->post('return_msg');
$result['msg'] = '保存失败'; $result = array('success'=>false,'msg'=>'操作成功');
if(!$request->isPost){
if ($request->isPost && $this->my->id == 1) { $result['msg'] = '请求方式错误';
$id = $request->post('order_id', 0); return $result;
}
$order_info = OrderT::findOne($id); if(!$this->my->id == 1){
if (!$order_info) { $result['msg'] = '无此操作权限';
$result['msg'] = '订单不存在'; return $result;
return $result; }
} if ($id < 0) {
$result['msg'] = '订单ID无效';
$tran = OrderT::getDb()->beginTransaction(); return $result;
try { }
// 删除礼品/券库信息 if ($msg == '') {
GiftTicketTUse::deleteAll('order_id=' . $order_info->id); $result['msg'] = '退单理由必须';
// 修改订单礼品/券信息 return $result;
OrderGiftT::updateAll(['gift_src'=>''],['order_id'=>$order_info->id]); }
// 修改订单状态
$order_info->gift_status = 0; $order_info = OrderT::findOne($id);
$order_info->save(); if (!$order_info) {
$result['success'] = true; $result['msg'] = '订单不存在';
$result['msg'] = '保存成功'; return $result;
$tran->commit(); }
} catch (\Exception $e) {
$tran->rollBack(); $tran = OrderT::getDb()->beginTransaction();
$result['msg'] = $e->getMessage(); try {
} // 删除礼品/券库信息
}else { GiftTicketTUse::deleteAll('order_id=' . $order_info->id);
$result['msg'] = '当前用户无此权限'; // 修改订单礼品/券信息
OrderGiftT::updateAll(['gift_src' => ''], ['order_id' => $order_info->id]);
// 修改订单状态
$order_info->gift_status = 0;
$order_info->save();
$this->addLog($order_info->car_id, '回退礼品状态,理由:' . $msg, 1);
$tran->commit();
} catch (\Exception $e) {
$tran->rollBack();
$result['msg'] = '订单不存在';
$result['msg'] = $e->getMessage();
return $result;
} }
$result['success'] = true;
return $result; return $result;
} }
@ -3681,4 +3680,95 @@ class InsurerController extends BaseController
} }
} }
} /**
* 退单操作(超管权限任意状态退单)
* @return array
* @throws \Exception
*/
public function actionSupperReturn()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '操作失败';
if($request->isPost) {
$order_id = $request->post('order_id',0);
$return_remark = $request->post('return_remark');
if ($order_id < 0) {
$result['msg'] = '订单ID无效';
return $result;
}
if($return_remark == ''){
$result['msg'] = '请填写退单理由!';
return $result;
}
$order_info = OrderT::findOne(['id'=>$order_id]);
if(empty($order_info)) {
$result['msg'] = '保单信息不存在!';
return $result;
}
// 订单信息更新
$order_info->return_status_id = $order_info->status_id;
$order_info->lock_id = 0;
$order_info->status_id = 1;
$order_info->return_remark = $return_remark;
$order_info->return_time = time();
$order_info->insurer1_no = '';
$order_info->insurer2_no = '';
$order_info->shangye_src = '';
$order_info->jiaoqiang_src = '';
$order_info->fapiao_src = '';
$order_info->jq_fapiao_src = '';
$order_info->upload_status = 1;
$order_info->payee_id = '';
$order_info->payment_id = '';
$order_info->payer = '';
$order_info->gift_status = 0;
// 车辆信息处理
if ($order_info->car->op2_id > 0) { //续保
$order_info->car->location = 4;
}else {
$order_info->car->location = 2;
$order_info->car->is_xubao = 0;
}
$order_info->car->user_id = $order_info->user_id;
$tran = OrderT::getDb()->beginTransaction();
try {
// 财务处理
CaiwuT::deleteAll(['order_id'=>$order_info->id]);
OrderCaiwuT::deleteAll(['order_id'=>$order_info->id]);
OrderUserT::deleteAll(['order_id'=>$order_info->id]);
// 车辆信息
CarCT::deleteAll(['id' => $order_info->car_id]);
if($order_info->car->op2_id > 0){
$car_db_info = new CarDT(false);
}else {
$car_db_info = new CarBT(false);
}
$car_db_info->id = $order_info->car_id;
$car_db_info->user_id = $order_info->user_id;
// 礼品状态回退
GiftTicketTUse::deleteAll('order_id=' . $order_info->id);
OrderGiftT::updateAll(['gift_src' => ''], ['order_id' => $order_info->id]);
$this->addLog($order_info->car_id,'超管退单,理由是:'.$return_remark,1);
$car_db_info->save();
$order_info->car->save();
$order_info->save();
$tran->commit();
$result['success'] = true;
$result['msg'] = '操作成功';
} catch (\Exception $e) {
$tran->rollBack();
$result['msg'] = '操作失败,' . $e->getMessage();
}
}
return $result;
}
}

@ -234,9 +234,9 @@ use common\models\PriceT;
<tr> <tr>
<th class="bg-warning">送单地址</th> <th class="bg-warning">送单地址</th>
<td colspan="5" class="form-inline"> <td colspan="5" class="form-inline">
<?=$order_info->sendCity->name?> <label><?=$order_info->sendCity?$order_info->sendCity->name:''?></label>
<?=$order_info->sendDistrict->name?> <label><?=$order_info->sendDistrict?$order_info->sendDistrict->name:''?></label>
<?=$order_info->send_address?> <label><?=$order_info->send_address?></label>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -267,7 +267,15 @@ use common\models\PriceT;
</table> </table>
</div> </div>
</div> </div>
<?php if($uid < 2 && $order_info->status_id > 1) {?>
<div class="ibox float-e-margins">
<div class="col-sm-5 col-sm-offset-4">
<button type="button" class="btn btn-primary btn-return" type="button">
<strong>退单</strong>
</button>
</div>
</div>
<?php }?>
</form> </form>
</div> </div>
@ -332,23 +340,27 @@ use common\models\PriceT;
$(function() { $(function() {
searchOps(); searchOps();
searchGifts(); searchGifts();
<?php if($uid < 2 && $order_info->status_id > 1) {?>
layer.config({extend: 'extend/layer.ext.js'});
$('.btn-return').click(function(){ $('.btn-return').click(function(){
var remark = $('#return_remark').val(); layer.prompt({
if(remark === '') { formType: 2,
parent.layer.msg('请输入退回理由'); title: '退单理由',
return; }, function(value, index){
} $.post('/insurer/supper-return',{
$.post('/insurer/return-op',{ order_id:<?=$order_info->id?>,
order_id:<?=$order_info->id?>, return_remark:value,
return_remark:remark, },function(obj){
return_status_id:<?=$order_info->status_id?> layer.alert(obj.msg,function () {
},function(obj){ window.location.reload();
parent.layer.msg(obj.msg); });
if(obj.success) { },'json');
$('.btn-back').click(); layer.close(index);
} });
},'json');
}); });
<?php }?>
$('.btn-cancel').click(function(){ $('.btn-cancel').click(function(){
parent.layer.confirm('是否确认放弃处理?', { parent.layer.confirm('是否确认放弃处理?', {
btn: ['确认','取消'], //按钮 btn: ['确认','取消'], //按钮

@ -351,15 +351,23 @@ use common\models\PriceT;
}); });
}); });
<?php if($order_info->gift_status == 1 && $my_id == 1) { ?> <?php if($order_info->gift_status == 1 && $my_id == 1) { ?>
layer.config({extend: 'extend/layer.ext.js'});
$('.btn-cancel').click(function () { $('.btn-cancel').click(function () {
parent.layer.confirm('此操作将回滚礼品状态,删除已生成礼物记录,确定继续?', { layer.confirm('此操作将回滚礼品状态,删除已生成礼物记录,确定继续?', {
btn: ['确认','取消'], //按钮 btn: ['确认','取消'], //按钮
shade: false //不显示遮罩 shade: false //不显示遮罩
}, function(){ }, function(){
$.post('/insurer/gift-cancel',{order_id:<?=$order_info->id?>},function(data) { layer.prompt({
parent.layer.msg(data.msg); formType: 2,
window.location.reload(); title: '礼品状态回退理由',
}, 'json'); }, function(value, index){
$.post('/insurer/gift-cancel',{order_id:<?=$order_info->id?>,return_msg:value},function(data) {
layer.alert(data.msg,function () {
window.location.reload();
});
}, 'json');
layer.close(index);
});
}, function(){ }, function(){
// //
}); });

@ -195,8 +195,8 @@ use common\models\PriceT;
<tr> <tr>
<th class="bg-warning">送单地址</th> <th class="bg-warning">送单地址</th>
<td colspan="7" class="form-inline"> <td colspan="7" class="form-inline">
<label><?=$order_info->sendCity->name?></label> <label><?=$order_info->sendCity?$order_info->sendCity->name:''?></label>
<label><?=$order_info->sendDistrict->name?></label> <label><?=$order_info->sendDistrict?$order_info->sendDistrict->name:''?></label>
<label><?=$order_info->send_address?></label> <label><?=$order_info->send_address?></label>
</td> </td>
</tr> </tr>

@ -195,8 +195,8 @@ use common\models\PriceT;
<tr> <tr>
<th class="bg-warning">送单地址</th> <th class="bg-warning">送单地址</th>
<td colspan="7" class="form-inline"> <td colspan="7" class="form-inline">
<label><?=$order_info->sendCity->name?></label> <label><?=$order_info->sendCity?$order_info->sendCity->name:''?></label>
<label><?=$order_info->sendDistrict->name?></label> <label><?=$order_info->sendDistrict?$order_info->sendDistrict->name:''?></label>
<label><?=$order_info->send_address?></label> <label><?=$order_info->send_address?></label>
</td> </td>
</tr> </tr>

Loading…
Cancel
Save