sjId; $sourceId = SjExpressClass::getSourceId($sjId); $orderParams = self::orderParams($orderInfo->attributes,$expressRemark); $res = dada::addOrder($sourceId, $orderParams); Yii::debug($orderParams); Yii::debug($res); return $res; } //根据订单号,运费计算 /* * 返回数据 deliverFee: 12 //运费(单位:元) deliveryNo: "Dada5ba78cd1b7df4948b54c8021f3c84db8" //平台订单号 distance: 1134639.1063765883 //配送距离(单位:米) fee: 12 //实际运费(单位:元),运费减去优惠券费用 insuranceFee: 0 // 保价费(单位:元) tips: 0 // 小费(单位:元) */ public static function queryDeliverFee($orderInfo) { // if (empty($orderInfo)) { util::fail("订单不存在"); } $sjId = $orderInfo['sjId']; $sourceId = SjExpressClass::getSourceId($sjId); $orderParams = self::orderParams($orderInfo); $res = dada::queryDeliverFee($sourceId, $orderParams); Yii::debug($orderParams); Yii::debug($res); return $res; } //取消订单 public static function cancelOrder($orderSn, $reasonId, $reason = '') { $orderInfo = OrderClass::getByOrderSn($orderSn); $sjId = $orderInfo['sjId']; $sourceId = SjExpressClass::getSourceId($sjId); $res = dada::formalCancel($sourceId, $orderSn, $reasonId, $reason); return $res; } //订单状态查询 public static function statusOrder($orderSn) { $orderInfo = OrderClass::getByOrderSn($orderSn); $sjId = $orderInfo['sjId']; $sourceId = SjExpressClass::getSourceId($sjId); $res = dada::statusQuery($sourceId, $orderSn); return $res; } //订单重发 public static function reAddOrder($orderInfo) { if (empty($orderInfo)) { util::fail("订单不存在"); } $sjId = $orderInfo['sjId']; $sourceId = SjExpressClass::getSourceId($sjId); $orderParams = self::orderParams($orderInfo); $res = dada::reAddOrder($sourceId, $orderParams); return $res; } //组装订单参数 public static function orderParams($orderInfo,$expressRemark='') { $sjId = $orderInfo['sjId']; //$online = Yii::$app->params['dadaOnline']; $shopId = $orderInfo['shopId']; $orderSn = $orderInfo['orderSn']; //获取快递方 商户id, 跟门店id $shopNo = ShopExpressClass::getShopNo($sjId, $shopId); if (getenv('YII_ENV', 'local') != 'production') { $shopNo = '11047059'; } $params = [ 'shop_no' => $shopNo, 'origin_id' => $orderSn, 'city_code' => '0592', //厦门 暂写死 'cargo_price' => (float)$orderInfo['actPrice'], //订单金额(单位:元) 实际支付价格? 'is_prepay' => 0, // 是否需要垫付 1:是 0:否 (垫付订单金额,非运费) 'receiver_name' => $orderInfo['customName'], //收货人姓名 'receiver_address' => $orderInfo['fullAddress'], //收货人地址 'receiver_lat' => (float)$orderInfo['lat'], // 存的是百度经纬度,需要转高德经纬度 'receiver_lng' => (float)$orderInfo['long'], // 存的是百度经纬度,需要转高德经纬度 'callback' => Yii::$app->params['ghsHost'] . '/notice/express-call-back', 'cargo_weight' => (float)$orderInfo['weight'],//订单重量(单位:Kg) 'receiver_phone' => $orderInfo['customMobile'],//否 收货人手机号(手机号和座机号必填一项) 'info' => $expressRemark,//备注 'cargo_type' => 3, //类型:鲜花 'cargo_num' => (int)$orderInfo['bigNum'], 'origin_mark_no' => '#销花宝#', ]; if ($orderInfo['sendTime'] != '0000-00-00 00:00:00') { $params['delay_publish_time'] = strtotime($orderInfo['sendTime']); } return $params; } }