From 4d7fa19afb8bfa4aaa072d4a5c23327f419f366b Mon Sep 17 00:00:00 2001 From: tang <28718949@qq.com> Date: Mon, 15 Jan 2024 16:52:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=BE=E7=BA=A6=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/Signing.php | 15 +++ modules/admin/models/ThemeCustomiseForm.php | 40 +++--- modules/admin/views/theme/customise.php | 15 ++- modules/api/controllers/SigningController.php | 123 ++++++++++++++++++ modules/api/models/SigningForm.php | 103 +++++++++++++++ 5 files changed, 279 insertions(+), 17 deletions(-) create mode 100644 models/Signing.php create mode 100644 modules/api/controllers/SigningController.php create mode 100644 modules/api/models/SigningForm.php diff --git a/models/Signing.php b/models/Signing.php new file mode 100644 index 0000000..fe3cb10 --- /dev/null +++ b/models/Signing.php @@ -0,0 +1,15 @@ + '域名', 'siteName' => '站点名称', 'siteShortName' => '站点简称', - 'siteDomain' => '站点域名', - 'siteWapDomain' => '移动站点域名', + 'siteDomain' => '站点域名', + 'siteWapDomain' => '移动站点域名', 'siteBriefIntro' => '一句话介绍站点', 'siteDescription' => '站点描述', 'siteKeywords' => '站点关键词', @@ -88,20 +93,23 @@ class ThemeCustomiseForm extends AdminModel 'siteEmail' => '站点联系邮箱', 'sitePostcode' => '站点联系邮编', 'siteCompanyIntro' => '公司介绍', + 'siteSigning' => '签约须知', + 'siteSigningType' => '签约类型', ]; } - + public function save() { - if($this->validate()){ + if ($this->validate()) { $attrs = $this->attributes; - foreach ($attrs as $key => $value){ - if(empty($value)) + + foreach ($attrs as $key => $value) { + if (empty($value)) continue; $key = Utils::hump2underline($key); $key = strtoupper($key); $f = Option::setOption($key, $value, $this->cx_mch_id); - if(!$f){ + if (!$f) { return [ 'code' => 1, 'msg' => $key . '保存失败' @@ -114,7 +122,7 @@ class ThemeCustomiseForm extends AdminModel ]; } else { return $this->getModelError(); - } + } } - + } \ No newline at end of file diff --git a/modules/admin/views/theme/customise.php b/modules/admin/views/theme/customise.php index 133f229..fc11a92 100644 --- a/modules/admin/views/theme/customise.php +++ b/modules/admin/views/theme/customise.php @@ -136,7 +136,20 @@ $this->params['breadcrumbs'][] = $this->title;
- + +
+ +
+ +
+
+
+ +
+ "> +
+
多个用|隔开
+
diff --git a/modules/api/controllers/SigningController.php b/modules/api/controllers/SigningController.php new file mode 100644 index 0000000..e3927ce --- /dev/null +++ b/modules/api/controllers/SigningController.php @@ -0,0 +1,123 @@ +responseHandler(['data' => explode('|', $type)]); + } + + /** + * showdoc + * @catalog 签约订单 + * @title 签约协议 + * @description 本接口用于签约订单 + * @method get + * @url /api/signing/signing + * @return {"code":0,"msg":"ok","data":[]} + + * @remark + */ + public function actionSigning() + { + $type = SiteHelper::getCustomiseOptionByKey("siteSigning", "hump"); + + return $this->responseHandler(['data' => $type]); + } + + /** + * showdoc + * @catalog 签约订单 + * @title 签约 + * @description 本接口用于签约订单 + * @method post + * @url /api/signing/signing-add + * @param goods_hub_id 必选 int 签约商品id + * @param company_name 必选 string 公司名称 + * @param brand_name 必选 string 品牌名称 + * @param product 必选 string 主营产品 + * @param type 必选 int 业务类型 + * @param number 必选 int 签约年限 + * @param remark 必选 int 备注 + * @return {"code":0,"msg":"ok","data":[]} + + * @remark + */ + public function actionSigningAdd() + { + if (!\Yii::$app->request->isPost) { + $data = $this->invaildRequest(); + return $this->responseHandler($data); + } + + $signingForm = new SigningForm(); + + $signingForm->attributes = \Yii::$app->request->post(); + + return $signingForm->add(); + + } + + /** + * showdoc + * @catalog 签约订单 + * @title 签约 + * @description 本接口用于签约订单 + * @method get + * @url /api/signing/signing-detail + * @param order_no 必选 int 订单号 + * @return {"code":0,"msg":"ok","data":[]} + + * @remark + */ + + public function actionSigningDetail() + { + $orderNo = \Yii::$app->request->get('order_no'); + + $signingForm = new SigningForm(); + + return $signingForm->orderDetail($orderNo); + } + + /** + * showdoc + * @catalog 签约订单 + * @title 签约列表 + * @description 本接口用于签约订单 + * @method get + * @url /api/signing/signing-list + * @param status 可选 int 订单状态 + * @return {"code":0,"msg":"ok","data":[]} + + * @remark + */ + public function actionSigningList() + { + $signingForm = new SigningForm(); + + $status = \Yii::$app->request->get('status'); + + return $signingForm->orderList($status); + } + +} \ No newline at end of file diff --git a/modules/api/models/SigningForm.php b/modules/api/models/SigningForm.php new file mode 100644 index 0000000..971752e --- /dev/null +++ b/modules/api/models/SigningForm.php @@ -0,0 +1,103 @@ +validate()) { + return $this->getModelError(); + } + + $goods = GoodsHub::findOne($this->goods_hub_id); + + if (!$goods) { + return $this->apiReturnError('商品id异常'); + } + + $signing = new Signing(); + + $signing->order_no = $this->orderNo(); + $signing->user_id = \Yii::$app->user->identity->id; + $signing->goods_hub_id = $this->goods_hub_id; + $signing->moy = $goods->original_price * $this->number; + $signing->company_name = $this->company_name; + $signing->brand_name = $this->brand_name; + $signing->product = $this->product; + $signing->type = $this->type; + $signing->number = $this->number; + $signing->remark = $this->remark; + $signing->create_time = time(); + + return $signing->save(); + + } + + + private function orderNo() + { + $orderNo = mt_rand(100000000000, 99999999999); + + if (Signing::find()->where('order_no', $orderNo)->count()) { + return $this->orderNo(); + } + return $orderNo; + } + + + public function orderDetail($orderNo) + { + $order = Signing::find()->where('order_no', $orderNo) + ->where('user_id', \Yii::$app->user->identity->id)->one()->toArray(); + + if (!$order) { + return $this->apiReturnError('订单号错误'); + } + + $order['goods'] = GoodsHub::findOne($order['goods_hub_id']); + + return $this->apiReturnSuccess('success', $order); + } + + public function orderList($status) + { + + $query = Signing::find()->where('user_id', \Yii::$app->user->identity->id); + + if ($status) { + $query->where('status', $status); + } + + $pagination = new Pagination(['totalCount' => $query->count(), 'defaultPageSize' => 2]); + + $models = $query->offset($pagination->offset)->limit($pagination->limit)->all(); + + return $this->apiReturnSuccess('success', $models); + } +} \ No newline at end of file