|
|
@@ -7,7 +7,7 @@ use bizHd\express\models\ExpressOrder;
|
|
|
use bizHd\order\classes\OrderClass;
|
|
|
use bizHd\order\classes\OrderGoodsClass;
|
|
|
use bizHd\order\classes\OrderItemClass;
|
|
|
-use bizHd\shop\classes\ShopExtClass;
|
|
|
+use bizHd\shop\classes\MainClass;
|
|
|
use bizHd\user\classes\UserClass;
|
|
|
use common\components\noticeUtil;
|
|
|
use common\components\util;
|
|
|
@@ -15,7 +15,6 @@ use hd\models\IntraCity\StoreFeeForm;
|
|
|
use Yii;
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
use yii\helpers\Json;
|
|
|
-use yii\web\Response;
|
|
|
use common\components\IntraCityExpress;
|
|
|
use yii\db\Query;
|
|
|
|
|
|
@@ -35,20 +34,19 @@ class IntraCityController extends BaseController
|
|
|
public function actionCreateStore()
|
|
|
{
|
|
|
try {
|
|
|
- $shopId = $this->shopId;
|
|
|
$shop = $this->shop;
|
|
|
$shopName = $shop->shopName ?? '';
|
|
|
$sjName = $shop->merchantName ?? '';
|
|
|
$name = $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
|
|
|
|
|
|
$storeData = [
|
|
|
- 'out_store_id' => $shop->id,
|
|
|
+ 'out_store_id' => $this->mainId, //自定义门店编号 -- 从 shopId 改为 dmainId
|
|
|
'store_name' => $name,
|
|
|
'address_info' => [
|
|
|
'province' => $shop->province,
|
|
|
'city' => $shop->city,
|
|
|
'area' => $shop->dist,
|
|
|
- 'street' => $shop->address,
|
|
|
+ 'street' => '',
|
|
|
'house' => $shop->floor ? $shop->address . $shop->floor : $shop->address,
|
|
|
'lat' => $shop->lat,
|
|
|
'lng' => $shop->long,
|
|
|
@@ -65,7 +63,9 @@ class IntraCityController extends BaseController
|
|
|
}
|
|
|
|
|
|
// 创建门店前,检查是否已经 开通门店权限 (有wxStoreId,即说明开通了)
|
|
|
- $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true, false, 'id, wxStoreId');
|
|
|
+ //$shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true, false, 'id, wxStoreId');
|
|
|
+ $shopExt = MainClass::getById($this->mainId, true, false, 'id, wxStoreId');
|
|
|
+
|
|
|
// 查询是否存在 wx_store_id,不存在则执行apply
|
|
|
if ($shopExt->wxStoreId == '') {
|
|
|
$re = IntraCityExpress::applyStore();
|
|
|
@@ -102,9 +102,10 @@ class IntraCityController extends BaseController
|
|
|
{
|
|
|
$shopId = $this->shopId;
|
|
|
// 首先从门店扩展表查询是否已经创建
|
|
|
- $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true, false, 'id, wxStoreId');
|
|
|
+ //$shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true, false, 'id, wxStoreId');
|
|
|
+ $shopExt = MainClass::getById($this->mainId, true, false, 'id, wxStoreId');
|
|
|
if ($shopExt->wxStoreId == '') { // 不存在,则从微信接口查询
|
|
|
- $result = IntraCityExpress::getStore($shopId);
|
|
|
+ $result = IntraCityExpress::getStore($this->mainId);
|
|
|
if ($result['errcode'] === 0) {
|
|
|
$store = $result['store_list'][0];
|
|
|
// 保存 wx_store_id
|
|
|
@@ -129,9 +130,9 @@ class IntraCityController extends BaseController
|
|
|
*/
|
|
|
public function actionUpdateStore()
|
|
|
{
|
|
|
- $shopId = $this->shopId;
|
|
|
// 首先从门店扩展表查询是否已经创建
|
|
|
- $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'id, wxStoreId');
|
|
|
+ //$shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'id, wxStoreId');
|
|
|
+ $shopExt = MainClass::getById($this->mainId, false, false, 'id, wxStoreId');
|
|
|
if ($shopExt['wxStoreId'] == '') {
|
|
|
util::fail('未创建门店,请先创建');
|
|
|
}
|
|
|
@@ -149,7 +150,7 @@ class IntraCityController extends BaseController
|
|
|
'province' => $shop->province,
|
|
|
'city' => $shop->city,
|
|
|
'area' => $shop->dist,
|
|
|
- 'street' => $shop->address,
|
|
|
+ 'street' => '',
|
|
|
'house' => $shop->floor ? $shop->address . $shop->floor : $shop->address,
|
|
|
'lat' => $shop->lat,
|
|
|
'lng' => $shop->long,
|
|
|
@@ -187,12 +188,8 @@ class IntraCityController extends BaseController
|
|
|
util::fail('快递动力ID出错');
|
|
|
}
|
|
|
|
|
|
- $shopId = intval($this->shopId);
|
|
|
- if (empty($shopId)) {
|
|
|
- util::fail("门店不存在");
|
|
|
- }
|
|
|
-
|
|
|
- $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'id, wxStoreId');
|
|
|
+ //$shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'id, wxStoreId');
|
|
|
+ $shopExt = MainClass::getById($this->mainId, false, false, 'id, wxStoreId');
|
|
|
if ($shopExt['wxStoreId'] == '') {
|
|
|
util::fail('微信门店编号为空');
|
|
|
}
|
|
|
@@ -212,7 +209,8 @@ class IntraCityController extends BaseController
|
|
|
public function actionStoreBalance()
|
|
|
{
|
|
|
$shopId = $this->shopId;
|
|
|
- $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'id, wxStoreId');
|
|
|
+ //$shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'id, wxStoreId');
|
|
|
+ $shopExt = MainClass::getById($this->mainId, false, false, 'id, wxStoreId');
|
|
|
if ($shopExt['wxStoreId'] == '') {
|
|
|
util::fail('微信门店编号为空');
|
|
|
}
|
|
|
@@ -261,7 +259,11 @@ class IntraCityController extends BaseController
|
|
|
if (empty($shopId)) {
|
|
|
util::fail("门店不存在");
|
|
|
}
|
|
|
- $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'id, wxStoreId');
|
|
|
+ //$shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'id, wxStoreId');
|
|
|
+ $shopExt = MainClass::getById($this->mainId, false, false, 'id, wxStoreId');
|
|
|
+ if (empty($shopExt)) {
|
|
|
+ util::fail("微信门店不存在");
|
|
|
+ }
|
|
|
|
|
|
$itemInfoList = OrderItemClass::getListBySn($sn);
|
|
|
$orderType = 2; // 默认是 2。说明:1花束订单 2花材订单 3花束和花材都有
|
|
|
@@ -333,7 +335,7 @@ class IntraCityController extends BaseController
|
|
|
$itemList = [];
|
|
|
$orderType = 2; // 默认是 2。说明:1花束订单 2花材订单 3花束和花材都有
|
|
|
if (empty($itemInfoList)) {
|
|
|
- $orderType = 1;
|
|
|
+ $orderType = 1; // 花束订单
|
|
|
$goodsInfoList = OrderGoodsClass::getListBySn($sn);
|
|
|
$itemCount = 0;
|
|
|
foreach ($goodsInfoList as $itemInfo) {
|
|
|
@@ -358,11 +360,11 @@ class IntraCityController extends BaseController
|
|
|
$post['packageNum'] = $itemCount;
|
|
|
}
|
|
|
|
|
|
- $shopId = intval($this->shopId);
|
|
|
- if (empty($shopId)) {
|
|
|
- util::fail("门店不存在");
|
|
|
+ //$shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'id, wxStoreId');
|
|
|
+ $shopExt = MainClass::getById($this->mainId, false, false, 'id, wxStoreId');
|
|
|
+ if (empty($shopExt)) {
|
|
|
+ util::fail("微信门店不存在");
|
|
|
}
|
|
|
- $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'id, wxStoreId');
|
|
|
|
|
|
$cargoName = '花材'; // 商品名称,默认是花材
|
|
|
$goodsInfoList = OrderGoodsClass::getListBySn($sn);
|
|
|
@@ -431,8 +433,8 @@ class IntraCityController extends BaseController
|
|
|
|
|
|
// 保存进 xhExpressOrder 表
|
|
|
$orderData = [
|
|
|
- 'mainId' => intval($this->mainId),
|
|
|
- 'shopId' => intval($this->shopId),
|
|
|
+ 'mainId' => $this->mainId,
|
|
|
+ 'shopId' => $this->shopId,
|
|
|
'deliveryId' => isset($result['service_trans_id']) ? $result['service_trans_id'] : '',
|
|
|
'wxOrderId' => isset($result['wx_order_id']) ? $result['wx_order_id'] : '',
|
|
|
'wxStoreId' => isset($result['wx_store_id']) ? $result['wx_store_id'] : '',
|
|
|
@@ -447,7 +449,7 @@ class IntraCityController extends BaseController
|
|
|
|
|
|
util::success('订单创建成功', ['fee' => $result['fee']]);
|
|
|
} else {
|
|
|
- noticeUtil::push("门店 -- " . $shopId . ",订单创建失败:" . json_encode($result));
|
|
|
+ noticeUtil::push("门店 -- " . $this->mainId . ",订单创建失败:" . json_encode($result));
|
|
|
Yii::error("订单创建失败:" . ($result['errmsg'] ?? '未知错误'), 'intracity');
|
|
|
util::fail($result['errmsg'] ?? '订单创建失败', $result['errcode'] ?? -1);
|
|
|
}
|
|
|
@@ -464,8 +466,11 @@ class IntraCityController extends BaseController
|
|
|
public function actionGetOrder()
|
|
|
{
|
|
|
try {
|
|
|
- $shopId = $this->shopId;
|
|
|
- $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'id, wxStoreId');
|
|
|
+ //$shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'id, wxStoreId');
|
|
|
+ $shopExt = MainClass::getById($this->mainId, false, false, 'id, wxStoreId');
|
|
|
+ if (empty($shopExt)) {
|
|
|
+ util::fail("微信门店不存在");
|
|
|
+ }
|
|
|
|
|
|
$post = Yii::$app->request->post();
|
|
|
$wxOrderId = isset($post['wx_order_id']) ? $post['wx_order_id'] : '';
|
|
|
@@ -522,11 +527,12 @@ class IntraCityController extends BaseController
|
|
|
try {
|
|
|
$post = Yii::$app->request->post();
|
|
|
|
|
|
- $shopId = intval($this->shopId);
|
|
|
- if (empty($shopId)) {
|
|
|
- util::fail("门店不存在");
|
|
|
+
|
|
|
+ //$shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'id, wxStoreId');
|
|
|
+ $shopExt = MainClass::getById($this->mainId, false, false, 'id, wxStoreId');
|
|
|
+ if (empty($shopExt)) {
|
|
|
+ util::fail("微信门店不存在");
|
|
|
}
|
|
|
- $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'id, wxStoreId');
|
|
|
|
|
|
$wxOrderId = isset($post['wx_order_id']) ? $post['wx_order_id'] : '';
|
|
|
$orderId = $post['orderId']; //配送订单创建成功后,也会返回的 store_order_id。 即 orderId
|
|
|
@@ -593,30 +599,7 @@ class IntraCityController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取门店列表
|
|
|
- * GET /intra-city/store-list
|
|
|
- */
|
|
|
- public function actionStoreList()
|
|
|
- {
|
|
|
- Yii::$app->response->format = Response::FORMAT_JSON;
|
|
|
-
|
|
|
- try {
|
|
|
- $request = Yii::$app->request;
|
|
|
- $offset = $request->get('offset', 0);
|
|
|
- $limit = $request->get('limit', 20);
|
|
|
|
|
|
- $list = [];
|
|
|
-
|
|
|
- if ($list) {
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- }
|
|
|
- } catch (\Exception $e) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 获取订单列表
|
|
|
@@ -624,27 +607,7 @@ class IntraCityController extends BaseController
|
|
|
*/
|
|
|
public function actionOrderList()
|
|
|
{
|
|
|
- Yii::$app->response->format = Response::FORMAT_JSON;
|
|
|
-
|
|
|
- try {
|
|
|
- $request = Yii::$app->request;
|
|
|
- $offset = $request->get('offset', 0);
|
|
|
- $limit = $request->get('limit', 20);
|
|
|
-
|
|
|
- $result = ExpressOrderClass::getOrderList($offset, $limit);
|
|
|
-
|
|
|
- if ($result['errcode'] === 0) {
|
|
|
- return [
|
|
|
|
|
|
- ];
|
|
|
- } else {
|
|
|
- return [
|
|
|
-
|
|
|
- ];
|
|
|
- }
|
|
|
- } catch (\Exception $e) {
|
|
|
-
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -686,7 +649,7 @@ class IntraCityController extends BaseController
|
|
|
]);
|
|
|
exit();
|
|
|
}
|
|
|
- // 提取 orderId
|
|
|
+ // 从 $storeOrderId 提取 orderId
|
|
|
$arr = explode('_', $storeOrderId);
|
|
|
$orderId = intval($arr[0]);
|
|
|
|