| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- /**
- * User: admin
- * Date Time: 2021/2/21 19:55
- */
- namespace ghs\controllers;
- 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();
- util::success($data);
- }
- //配送费预估
- public function actionPreAddOrder()
- {
- $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();
- $shop_no = 1; //与快递签约时的门店ID(应该是固定的)
- $openid = $this->admin['miniOpenId'];
- //客户id
- $customId = $post['customId']??0;
- //获取客户name
- $customInfo = CustomService::getCustomInfo($customId);
- CustomClass::valid($customInfo, $this->sjId);
- //当前门店的地址信息
- $shopInfo = ShopService::getById($this->shopId);
- $sender =[
- 'name'=>$shopInfo['shopName'],
- 'city'=>$shopInfo['city']??'',
- 'address'=>$shopInfo['address']??'',
- 'address_detail'=>$shopInfo['floor']??'',
- 'phone'=>$shopInfo['telephone']??'',
- 'lng'=>$shopInfo['long']??'',
- 'lat'=>$shopInfo['lat']??'',
- 'coordinate_type'=>0,
- ];
- $receiver = [
- 'name'=>$customInfo['name'],
- 'city'=>$post['receiveCity']??'',
- 'address'=>$post['receiveAddress']??'',
- 'address_detail'=>$post['receiveFloor']??'',
- 'phone'=>$customInfo['mobile']??'',
- 'lng'=>$post['receiveLong']??'',
- 'lat'=>$post['receiveLat']??'',
- 'coordinate_type'=>0,
- ];
- $cargo = [
- 'goods_value'=>$cargoInfo['totalPrice'], //总价格 元
- 'goods_weight'=>$cargoInfo['totalWeight'], //总重量 kg
- 'cargo_first_class'=>'鲜花',
- 'cargo_second_class'=>'鲜花',
- ];
- $orderInfo = [];
- $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']]);
- }
- //
- }
|