diff --git a/frontend/controllers/InsurerController.php b/frontend/controllers/InsurerController.php index 3360495..2bee5f9 100644 --- a/frontend/controllers/InsurerController.php +++ b/frontend/controllers/InsurerController.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); diff --git a/frontend/views/insurer/my-list-info.php b/frontend/views/insurer/my-list-info.php index 5a31651..ddcaa1e 100644 --- a/frontend/views/insurer/my-list-info.php +++ b/frontend/views/insurer/my-list-info.php @@ -195,8 +195,8 @@ use common\models\PriceT; 送单地址 - - + + @@ -213,6 +213,11 @@ use common\models\PriceT; 确认礼品 + gift_status == 1 && $my_id == 1) { ?> + + @@ -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:id?>},function(data) { + parent.layer.msg(data.msg); + window.location.reload(); + }, 'json'); + }, function(){ + // + }); + }); }); endBlock(); ?>