| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- /*
- * @Author: kai
- * @Date: 2021-03-02 09:50:20
- * @LastEditTime: 2021-04-23 13:39:19
- * @LastEditors: Please set LastEditors
- * @Description: In User Settings Edit
- * @FilePath: \admin_php\modules\client\models\v1\order\OrderSubmitPreviewForm.php
- */
- namespace app\modules\client\models\v1\pt\order;
- use app\constants\OptionSetting;
- use app\models\District;
- use app\models\FoodFlag;
- use app\models\Goods;
- use app\models\Md;
- use app\models\Option;
- use app\models\Store;
- use app\utils\Notice\NoticeAction;
- use app\utils\OrderNo;
- use app\utils\Tools;
- use yii\helpers\Json;
- class OrderSubmitPreviewForm extends OrderForm
- {
- public function rules()
- {
- return parent::rules();
- }
- public function search()
- {
- if (!$this->validate())
- return [
- 'code' => 1,
- 'msg' => $this->getErrorSummary(false)[0],
- ];
- // HKG 新增判断商城打烊状态 开始
- if(Option::get(OptionSetting::MALL_STATUS,get_store_id(),'store',0)['value'] == 1)
- return [
- 'code' => 1,
- 'msg' => '商城已打烊~'
- ];
- // HKG 新增判断商城打烊状态 结束
- try {
- // 预生成订单号
- $order_no = OrderNo::getOrderNo(OrderNo::ORDER_PT);
- cache()->set('delivery_order_no_' . get_user_id(), $order_no);
- $mchList = $this->getMchListData();
- if(isset($mchList['code']) && $mchList['code'] == 1){
- return $mchList;
- }
- } catch(\Exception $e) {
- return [
- 'code' => 1,
- 'line' => $e->getLine(),
- 'msg' => $e->getMessage(),
- 'file' => $e->getFile(),
- ];
- }
-
- $food_pay_type = [];
- $md_info = [];
- $flag_id = 0;
- $store = Store::findOne(get_store_id());
- // if (get_md_id() && (!empty(input_params('flag_id')) || !empty(input_params('table_num')))) {
- // if (!empty(input_params('flag_id'))) {
- // $flag_id = input_params('flag_id');
- // } else {
- // $flag_id = FoodFlag::findOne(['store_id' => get_store_id(), 'md_id' => get_md_id(), 'status' => 0, 'table_num' => input_params('table_num')])->id;
- // }
- // if (get_md_id() > 0) {
- // $food_payment = $md->food_payment;
- // $food_paytype = $md->food_pay_type;
- // } else {
- // $food_payment = $store->food_payment;
- // $food_paytype = $store->food_pay_type;
- // }
- // $food_pay_list = [];
- // if (!empty($food_payment)) {
- // $food_pay_type = Json::decode($food_payment);
- // $pay_type_list_json = Option::get(OptionSetting::STORE_PAYMENT, get_store_id(), 'store');
- // $is_food_ok = false;
- // if (!empty($pay_type_list_json)) {
- // $pay_type_list = Json::decode($pay_type_list_json['value']);
- // foreach ($pay_type_list as $index => $pay_type) {
- // if ($index == 'friend' && $pay_type['value'] == 1) {
- // $is_food_ok = true;
- // break;
- // }
- // }
- // }
- // foreach ($food_pay_type as &$value) {
- // if ($value['key'] == 'friend') {
- // if ($is_food_ok && $value['value'] == 1) {
- // $value['value'] = 1;
- // } else {
- // $value['value'] = 0;
- // }
- // }
- // if ($value['key'] == 'friend') {
- // $value['payment'] = 7;
- // }
- // if ($value['key'] == 'alipay') {
- // $value['payment'] = 4;
- // }
- // if ($value['key'] == 'wechat') {
- // $value['payment'] = 1;
- // }
- // if ($value['key'] == 'huodao') {
- // $value['payment'] = 2;
- // }
- // if ($value['key'] == 'bytedance') {
- // $value['payment'] = 5;
- // }
- // }
- // $food_pay_list = $food_pay_type;
- //
- // }
- // foreach ($food_pay_list as $k => $val) {
- // if ($val['payment'] == 4 && is_wechat_platform()) {
- // unset($food_pay_list[$k]);
- // }
- // if ($val['payment'] == 1 && is_alipay_platform()) {
- // unset($food_pay_list[$k]);
- // }
- // }
- // $food_pay_list = array_values($food_pay_list);
- // // 点餐支付方式
- // $food_pay_type = [
- // 'food_pay_type' => $food_paytype,
- // 'food_payment' => $food_pay_list
- // ];
- // }
- if (get_md_id() > 0) {
- $md = Md::findOne(get_md_id());
- $province_name = District::findOne($md->province)->name;
- $city_name = District::findOne($md->city)->name;
- $district_name = District::findOne($md->district)->name;
- $md_info = [
- 'is_md' => 1,
- 'name' => $md->name,
- 'detail_address' => $province_name . $city_name . $district_name . $md->address,
- 'distance' => Tools::getDistance($this->latitude, $this->longitude, $md->latitude, $md->longitude),
- 'longitude' => $md->longitude,
- 'latitude' => $md->latitude,
- 'logo' => $md->cover_url
- ];
- } else {
- $province_name = District::findOne($store->province_id)->name;
- $city_name = District::findOne($store->city_id)->name;
- $district_name = District::findOne($store->district_id)->name;
- $lat = '';
- $long = '';
- $coordinate = explode(',', $store->coordinate);
- if ($coordinate) {
- $lat = $coordinate[0];
- $long = $coordinate[1];
- }
- $md_info = [
- 'is_md' => 0,
- 'name' => $store->name,
- 'detail_address' => $province_name . $city_name . $district_name . $store->address,
- 'distance' => Tools::getDistance($this->latitude, $this->longitude, $lat, $long),
- 'longitude' => $long,
- 'latitude' => $lat,
- 'logo' => $store->logo
- ];
- }
- $template_id = NoticeAction::getSendTamplateId(['order_pay', 'order_submit', 'order_send']);
- return [
- 'code' => 0,
- 'msg' => 'OOKK',
- 'data' => [
- 'flag_id' => intval($flag_id),
- 'md_info' => $md_info,
- 'food_pay' => $food_pay_type,
- 'pay_type_list' => $this->getPayTypeList(),
- 'take_price' => sprintf('%.2f',0),
- 'send_price' => sprintf('%.2f', 0),
- 'address' => $this->address,
- 'level' => [],
- 'mch_list' => $mchList,
- 'integral'=>$this->integral,
- 'goods_card_list' => [],
- 'template_id' => $template_id
- ],
- ];
- }
- }
|