diff --git a/frontend/controllers/InsurerController.php b/frontend/controllers/InsurerController.php index 3360495..fb20bc7 100644 --- a/frontend/controllers/InsurerController.php +++ b/frontend/controllers/InsurerController.php @@ -3502,6 +3502,47 @@ 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 && $this->my->id == 1) { + $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(); + } + }else { + $result['msg'] = '当前用户无此权限'; + } + return $result; + } + public function getGift($k, $v, $car_no, $order_info, $order_gift_id) { $result = array(); @@ -3516,7 +3557,6 @@ class InsurerController extends BaseController //礼券 if ($gift_info && $gift_info->type_id == 2) { $pinyin_arr = explode(' ', $gift_info->pinyin_name); -// dd($pinyin_arr); $liquan_str = 'ch'; //获取礼券拼音首字母 foreach ($pinyin_arr as $first) { @@ -3534,13 +3574,12 @@ class InsurerController extends BaseController if ($gift_use) { $liquan_str .= sprintf("%04d", $gift_use->gift_shuzi + 1); $new_gift_use->gift_shuzi = $gift_use->gift_shuzi + 1; - $new_gift_use->code = $liquan_str; } else { $liquan_str .= sprintf("%04d", 1); $new_gift_use->gift_shuzi = 1; - $new_gift_use->code = strtoupper($liquan_str); } + $new_gift_use->code = strtoupper($liquan_str); $new_gift_use->op_id = $this->my->id; $new_gift_use->type_id = $v; //礼券ID $new_gift_use->input_date = date('Y-m-d H:i:s'); @@ -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/common/index.php b/frontend/views/common/index.php index 9eb75d2..a4a9689 100644 --- a/frontend/views/common/index.php +++ b/frontend/views/common/index.php @@ -91,6 +91,9 @@ 退出 + + +