|
|
@@ -51,11 +51,13 @@ class FengniaoAdapter extends Fengniao implements Adapter
|
|
|
/**
|
|
|
* 转化订单数据
|
|
|
* @param $order
|
|
|
+ * @param string $type 订单类型:xhOrder 或 xhGhsOrder
|
|
|
* @param $shop
|
|
|
* @param $params
|
|
|
* @return array
|
|
|
+ * @throws \Exception
|
|
|
*/
|
|
|
- public function formatOrderData($order, $shop, $params)
|
|
|
+ public function formatOrderData($order, $type, $shop, $params)
|
|
|
{
|
|
|
// 订单类型为预约单时必传,如需要送达时间 – 推单时间 < 60min,则蜂鸟配送开放平台自动将订单类型置为即时单
|
|
|
$timeDiff = strtotime($params['pickupTime']) - time();
|
|
|
@@ -66,9 +68,9 @@ class FengniaoAdapter extends Fengniao implements Adapter
|
|
|
|
|
|
$sn = $order['orderSn'];
|
|
|
// 批发
|
|
|
- if(strstr($sn, 'XSD_CS') || strstr($sn, 'XSD')){
|
|
|
+ if($type == 'xhGhsOrder'){
|
|
|
$itemInfos = OrderItemClass::getAllByCondition(['orderSn' => $sn], null, 'id, name, unitPrice, num, unitWeight');
|
|
|
- $goodsWeight = 0;
|
|
|
+ //$goodsWeight = 0;
|
|
|
$goodsItemList = [];
|
|
|
foreach ($itemInfos as $item){
|
|
|
$goodsItemList[] = [
|
|
|
@@ -78,13 +80,13 @@ class FengniaoAdapter extends Fengniao implements Adapter
|
|
|
'item_name' => $item['name'],
|
|
|
'item_quantity' => $item['num'],
|
|
|
];
|
|
|
- $goodsWeight += $item['unitWeight'];
|
|
|
+ //$goodsWeight += $item['unitWeight'];
|
|
|
}
|
|
|
$goodsCount = count($goodsItemList);
|
|
|
// 零售
|
|
|
- }else if(strstr($sn, 'KD_CS') || strstr($sn, 'KD')){
|
|
|
+ }else if($type == 'xhOrder'){
|
|
|
$itemInfos = OrderGoodsClass::getAllByCondition(['orderSn' => $sn], null, 'id, name, unitPrice, num');
|
|
|
- $goodsWeight = 0;
|
|
|
+ //$goodsWeight = 0;
|
|
|
$goodsItemList = [];
|
|
|
foreach ($itemInfos as $item){
|
|
|
$goodsItemList[] = [
|
|
|
@@ -100,9 +102,11 @@ class FengniaoAdapter extends Fengniao implements Adapter
|
|
|
Yii::error('订单编号出错: '.$sn);
|
|
|
util::fail('订单编号出错');
|
|
|
}
|
|
|
+ $goodsWeight = floatval($params['weight']);//取客户端传来的重量
|
|
|
|
|
|
$orderData = [
|
|
|
//'out_shop_code' => $params['mainId'], // 当使用门店发单 out_shop_code 和 chain_store_id 必填1个
|
|
|
+ 'chain_store_id' => $this->getShopId(), // 动态修改为门店号 -- (点对点不传)
|
|
|
'partner_order_code' => $order['orderSn'],
|
|
|
'receiver_primary_phone' => Functions::getMobile($order),
|
|
|
'receiver_name' => $order['customName'],
|
|
|
@@ -116,7 +120,6 @@ class FengniaoAdapter extends Fengniao implements Adapter
|
|
|
'goods_actual_amount_cent' => (int)($order['actPrice'] * 100), //订单货物实付金额
|
|
|
'goods_item_list' => $goodsItemList,
|
|
|
'order_type' => $orderType,
|
|
|
- 'chain_store_id' => $this->getShopId(), // 动态修改为门店号 -- (点对点不传)
|
|
|
'order_remark' => $order['remark'],
|
|
|
'serial_number' => $order['sendNum'] // 配送编号,方便寻找订单对应的花材
|
|
|
];
|