| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- /**
- * User: admin
- * Date Time: 2021/2/21 19:55
- */
- namespace ghs\controllers;
- use biz\shop\classes\ShopExpressClass;
- use bizGhs\custom\classes\CustomClass;
- use bizGhs\custom\services\CustomService;
- use bizGhs\express\services\MiniExpressService;
- use bizGhs\merchant\services\ShopService;
- use bizGhs\product\services\ProductService;
- use common\components\util;
- use Yii;
- class ExpressController extends BaseController
- {
- //获取即时配送快递列表
- public function actionList()
- {
- $data = MiniExpressService::getAllImmeDelivery("id,deliveryId,deliveryName", ['status' => 1]);
- util::success($data);
- }
- //配送费预估
- public function actionPreAddOrder()
- {
- // util::success(['fee' => 16.5]);
- $post = Yii::$app->request->post();
- $expressId = $post['expressId'] ?? 0;
- $ghsItemInfo = $post['itemInfo'] ?? '';
- if (empty($ghsItemInfo)) {
- util::fail('请选择花材');
- }
- $ghsItemInfo = json_decode($ghsItemInfo, true); // [{productId:0,itemPrice:1,bigNum:1,smallNum:0}]
- //计算总价格,总重量
- $cargoInfo = ProductService::groupCargo($ghsItemInfo);
- $shop_order_id = time();
- $expressData = MiniExpressService::getExpressInfo($expressId);
- if(empty($expressData)){
- util::fail("暂不支持");
- }
- $shop_no = ShopExpressClass::getShopNo($this->sjId,$this->shopId,strtolower( $expressData['deliveryId'])); //与快递签约时的门店ID
- $openid = isset($this->admin) && !empty($this->admin) ? $this->admin->miniOpenId : '';
- if (empty($openId)) {
- util::fail('没有找到openId');
- }
- //客户id
- $customId = $post['customId'] ?? 0;
- //获取客户name
- $customInfo = CustomService::getCustomInfo($customId);
- CustomClass::valid($customInfo, $this->shopId);
- //当前门店的地址信息
- $shopInfo = ShopService::getById($this->shopId);
- $sender = [
- 'name' => $shopInfo['shopName'],
- 'city' => $shopInfo['city'] ?? '',
- 'address' => $shopInfo['address'] ?? '',
- 'address_detail' => $shopInfo['floor'] ?? '',
- 'phone' => $shopInfo['telephone'] ?? '',
- 'lng' => (float)$shopInfo['long'] ?? '',
- 'lat' => (float)$shopInfo['lat'] ?? '',
- 'coordinate_type' => 0,
- ];
- $receiver = [
- 'name' => $customInfo['name'],
- 'city' => $post['city'] ?? '',
- 'address' => $post['address'] ?? '',
- 'address_detail' => $post['floor'] ?? '',
- //'phone'=>$customInfo['mobile']??'199121223333',
- 'phone' => '18030142050',
- 'lng' => (float)$post['long'] ?? '118.134343',
- 'lat' => (float)$post['lat'] ?? '24.491566',
- 'coordinate_type' => 0,
- ];
- $cargo = [
- 'goods_value' => $cargoInfo['totalPrice'], //总价格 元
- 'goods_weight' => $cargoInfo['totalWeight'], //总重量 kg
- 'cargo_first_class' => '鲜花',
- 'cargo_second_class' => '鲜花',
- ];
- $orderInfo = [
- 'is_direct_delivery' => 0,//闪送只能为1,只能直拿直送
- ];
- $shop = [
- 'wxa_path' => '/shop',
- 'img_url' => 'http://www.baidu.com/test.png',
- 'goods_name' => '鲜花',
- 'goods_count' => count($ghsItemInfo),
- ];
- $res = MiniExpressService::preAddOrder($expressId, $shop_no, $shop_order_id, $openid, $sender, $receiver, $cargo, $orderInfo, $shop);
- util::success(['fee' => $res['fee']]);
- }
- //根据订单号发货
- public function actionAddOrder()
- {
- $post = Yii::$app->request->post();
- $expressId = $post['expressId'] ?? 0;// 快递ID
- $orderSn = $post['orderSn'] ?? '';
- }
- }
|