|
|
@@ -10,7 +10,6 @@ use bizMall\goods\classes\GoodsClass;
|
|
|
use bizMall\item\classes\ItemClass;
|
|
|
use bizMall\order\classes\OrderClass;
|
|
|
use bizMall\order\classes\OrderForwardClass;
|
|
|
-use bizMall\order\classes\OrderGoodsClass;
|
|
|
use bizMall\order\classes\OrderItemClass;
|
|
|
use bizMall\order\services\OrderService;
|
|
|
use bizMall\promote\services\CouponService;
|
|
|
@@ -19,7 +18,6 @@ use bizMall\shop\classes\ShopExtClass;
|
|
|
use bizMall\user\services\UserService;
|
|
|
use common\components\dateUtil;
|
|
|
use common\components\dict;
|
|
|
-use common\components\httpUtil;
|
|
|
use common\components\imgUtil;
|
|
|
use common\components\noticeUtil;
|
|
|
use common\components\orderSn;
|
|
|
@@ -28,6 +26,7 @@ use common\services\xhPayToolService;
|
|
|
use Yii;
|
|
|
use common\components\util;
|
|
|
use common\components\lakala\Lakala;
|
|
|
+use common\components\IntraCityExpress;
|
|
|
|
|
|
class OrderController extends BaseController
|
|
|
{
|
|
|
@@ -61,6 +60,45 @@ class OrderController extends BaseController
|
|
|
util::success($respond);
|
|
|
}
|
|
|
|
|
|
+ //新计算运费
|
|
|
+ public function actionNewFreight()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $shopId = $this->shopId;
|
|
|
+ if (empty($shopId)) {
|
|
|
+ util::fail("门店不存在");
|
|
|
+ }
|
|
|
+ $shopExt = ShopExtClass::getByCondition(['shopId'=>$shopId], false, false, 'id, wxStoreId');
|
|
|
+
|
|
|
+ $cargoName = $post['cargo_name']; // 商品名称
|
|
|
+ $cargo = [
|
|
|
+ 'cargo_name' => $cargoName, // 商品名称
|
|
|
+ 'cargo_weight' => intval($post['weight'] * 1000), // 单位:克 -- 把千克转换为克 ---- 重量(用户未知)-- 大概
|
|
|
+ 'cargo_price' => intval($post['price'] * 100), // 单位:分 -- 把元转换为分
|
|
|
+ 'cargo_type' => IntraCityExpress::GOODS_TYPE_FLOWER,
|
|
|
+ 'cargo_num' => intval($post['package_num'])
|
|
|
+ ];
|
|
|
+ $originalLng = doubleval($post['user_lng']);
|
|
|
+ $originalLat = doubleval($post['user_lat']);
|
|
|
+ $orderData = [
|
|
|
+ 'wx_store_id' => $shopExt['wxStoreId'],
|
|
|
+ 'user_name' => $post['user_name'],
|
|
|
+ 'user_phone' => $post['user_phone'],
|
|
|
+ 'user_lng' => $originalLng,
|
|
|
+ 'user_lat' => $originalLat,
|
|
|
+ 'user_address' => $post['user_address'],
|
|
|
+ 'cargo' => $cargo,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $result = IntraCityExpress::preAddOrder($orderData);
|
|
|
+ if ($result['errcode'] === 0) {
|
|
|
+ util::success($result, "运费查询成功");
|
|
|
+ } else {
|
|
|
+ Yii::error("运费查询失败:" . json_encode($result));
|
|
|
+ util::fail('运费查询失败' . json_encode($result));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//计算运费,请搜索关键词calc_freight,二个方法要合一起 ssh 20221014
|
|
|
public function actionFreight()
|
|
|
{
|
|
|
@@ -68,18 +106,44 @@ class OrderController extends BaseController
|
|
|
$shop = $this->shop;
|
|
|
$shopLat = isset($shop->lat) ? $shop->lat : '';
|
|
|
$shopLong = isset($shop->long) ? $shop->long : '';
|
|
|
+
|
|
|
+ // 判断地图功能是否正常。0 表示地图定位不可用,全部经纬度数据失效
|
|
|
+ if (dict::getDict('hasMap') == 0) {
|
|
|
+ $shopLat = '';
|
|
|
+ $shopLong = '';
|
|
|
+ }
|
|
|
if (empty($shopLat) || empty($shopLong)) {
|
|
|
- util::success(['distance' => 0, 'showDistance' => 0, 'fee' => 0]);
|
|
|
+ util::success([
|
|
|
+ 'distance' => 0,
|
|
|
+ 'showDistance' => 0,
|
|
|
+ 'fee' => 0,
|
|
|
+ 'hasMap'=>dict::getDict('hasMap'),
|
|
|
+ 'shop' => 'fail' //门店引起的失败
|
|
|
+ ]);
|
|
|
}
|
|
|
$userLat = $get['lat'] ?? '';
|
|
|
$userLong = $get['long'] ?? '';
|
|
|
if (empty($userLat) || empty($userLong)) {
|
|
|
- util::success(['distance' => 0, 'showDistance' => 0, 'fee' => 0]);
|
|
|
+ util::success([
|
|
|
+ 'distance' => 0,
|
|
|
+ 'showDistance' => 0,
|
|
|
+ 'fee' => 0,
|
|
|
+ 'hasMap'=>dict::getDict('hasMap'),
|
|
|
+ 'client' => 'fail' //用户端定位失败
|
|
|
+ ]);
|
|
|
}
|
|
|
$weight = $get['weight'] ?? 0;
|
|
|
if (empty($weight)) {
|
|
|
- util::success(['distance' => 0, 'showDistance' => 0, 'fee' => 0]);
|
|
|
+ util::success([
|
|
|
+ 'distance' => 0,
|
|
|
+ 'showDistance' => 0,
|
|
|
+ 'fee' => 0,
|
|
|
+ 'hasMap'=>dict::getDict('hasMap'),
|
|
|
+ 'weight' => 'fail' //重量不对
|
|
|
+ ]);
|
|
|
}
|
|
|
+
|
|
|
+ //data: {distance: "321", showDistance: "0.3", fee: "12.00"}
|
|
|
$respond = OrderClass::getDistanceFee($userLat, $userLong, $shopLat, $shopLong, $weight);
|
|
|
util::success($respond);
|
|
|
}
|
|
|
@@ -288,8 +352,8 @@ class OrderController extends BaseController
|
|
|
$post['payWay'] = 0;
|
|
|
|
|
|
//计算运费
|
|
|
- $sendDistance = 0;
|
|
|
- $sendCost = 0;
|
|
|
+ //$sendDistance = 0;
|
|
|
+ //$sendCost = 0;
|
|
|
$shop = $this->shop;
|
|
|
if ($sendType == dict::getDict('sendType', 'thirdSend')) {
|
|
|
$lat = $post['lat'] ?? '';
|
|
|
@@ -309,11 +373,12 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
//花束重量默认1.5
|
|
|
$weight = 1.5;
|
|
|
- $disRespond = OrderClass::getDistanceFee($lat, $lng, $shopLat, $shopLong, $weight);
|
|
|
- $sendCost = $disRespond['fee'] ?? 0;
|
|
|
- $sendDistance = $disRespond['distance'] ?? 0;
|
|
|
+ //$disRespond = OrderClass::getDistanceFee($lat, $lng, $shopLat, $shopLong, $weight);
|
|
|
+ //$sendCost = $disRespond['fee'] ?? 0;
|
|
|
+ //$sendDistance = $disRespond['distance'] ?? 0;
|
|
|
}
|
|
|
- $post['sendDistance'] = $sendDistance;
|
|
|
+ $post['sendDistance'] = isset($post['sendDistance']) ? $post['sendDistance'] : 0;
|
|
|
+ $sendCost = isset($post['sendCost']) ? floatval($post['sendCost']) : 0;
|
|
|
$post['sendCost'] = $sendCost;
|
|
|
$post['sjId'] = $this->sjId;
|
|
|
$post['shopId'] = $this->shopId;
|