礼品取消确认

dev
zhaocheng 5 years ago
parent 7d37714c5f
commit c8a31e44a5
  1. 41
      frontend/controllers/InsurerController.php
  2. 23
      frontend/views/insurer/my-list-info.php

@ -3502,6 +3502,45 @@ class InsurerController extends BaseController
}
return $result;
}
public function actionGiftCancel()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$result = array();
$result['success'] = false;
$result['msg'] = '保存失败';
if ($request->isPost) {
$id = $request->post('order_id', 0);
$order_info = OrderT::findOne($id);
if (!$order_info) {
$result['msg'] = '订单不存在';
return $result;
}
$tran = OrderT::getDb()->beginTransaction();
try {
// 删除礼品/券库信息
GiftTicketTUse::deleteAll('order_id=' . $order_info->id);
// 修改订单礼品/券信息
OrderGiftT::updateAll(['gift_src'=>''],['order_id'=>$order_info->id]);
// 修改订单状态
$order_info->gift_status = 0;
$order_info->save();
$result['success'] = true;
$result['msg'] = '保存成功';
$tran->commit();
} catch (\Exception $e) {
$tran->rollBack();
$result['msg'] = $e->getMessage();
}
}
return $result;
}
public function getGift($k, $v, $car_no, $order_info, $order_gift_id)
{
$result = array();
@ -3565,7 +3604,7 @@ class InsurerController extends BaseController
if ($shiwu_use) {
$new_shiwu->gift_shuzi = $shiwu_use->gift_shuzi + 1;
$new_shiwu->code = sprintf("%04d", $gift_use->gift_shuzi + 1);
$new_shiwu->code = sprintf("%04d", $shiwu_use->gift_shuzi + 1);
} else {
$new_shiwu->gift_shuzi = 1;
$new_shiwu->code = sprintf("%04d", 1);

@ -195,8 +195,8 @@ use common\models\PriceT;
<tr>
<th class="bg-warning">送单地址</th>
<td colspan="5" class="form-inline">
<label><?=$order_info->sendCity->name?></label>
<label><?=$order_info->sendDistrict->name?></label>
<label><?=$order_info->sendCity?$order_info->sendCity->name:''?></label>
<label><?=$order_info->sendDistrict?$order_info->sendDistrict->name:''?></label>
<label><?=$order_info->send_address?></label>
</td>
</tr>
@ -213,6 +213,11 @@ use common\models\PriceT;
<strong>确认礼品</strong>
</button>
<?php } ?>
<?php if($order_info->gift_status == 1 && $my_id == 1) { ?>
<button type="button" class="btn btn-primary btn-cancel" type="button">
<strong>取消确认</strong>
</button>
<?php } ?>
<button type="button" class="btn btn-primary btn-back" type="button">
<strong>返 回</strong>
</button>
@ -345,6 +350,20 @@ use common\models\PriceT;
//
});
});
$('.btn-cancel').click(function () {
parent.layer.confirm('此操作将回滚礼品状态,删除已生成礼物记录,确定继续?', {
btn: ['确认','取消'], //按钮
shade: false //不显示遮罩
}, function(){
$.post('/insurer/gift-cancel',{order_id:<?=$order_info->id?>},function(data) {
parent.layer.msg(data.msg);
window.location.reload();
}, 'json');
}, function(){
//
});
});
});
</script>
<?php $this->endBlock(); ?>

Loading…
Cancel
Save