|
@@ -65,7 +65,7 @@ class ZopOrderService extends ZopBaseService
|
|
|
$images = $produce->images ?? '';
|
|
|
$resourceId = $produce->resource_id ?? 0;
|
|
|
|
|
|
- if (empty($resourceId)) {
|
|
|
+ // if (empty($resourceId)) {
|
|
|
if (empty($goodsId)) {
|
|
|
return self::error('上游编码为空');
|
|
|
}
|
|
@@ -110,7 +110,7 @@ class ZopOrderService extends ZopBaseService
|
|
|
$resourceId = $resourceResult['data']['resourceId'] ?? '';
|
|
|
$produce->resource_id = $resourceId;
|
|
|
$produce->save();
|
|
|
- }
|
|
|
+ // }
|
|
|
|
|
|
// 2. 客户资料校验
|
|
|
$cityData = $order->city ?? '';
|
|
@@ -151,7 +151,7 @@ class ZopOrderService extends ZopBaseService
|
|
|
// 获取uuid
|
|
|
$uuid = $identityResult['data']['uuid'] ?? '';
|
|
|
|
|
|
- // 3. 选号后置-意向单同步
|
|
|
+ // 3.0 判断有没有手机号, 如果没有手机号, 则走自动选好接口
|
|
|
$orderId = $order->order_no ?? '';
|
|
|
$contactNum = $order->phone ?? '';
|
|
|
$postProvinceCode = Area::where('id', $province)->value('post_code');
|
|
@@ -164,64 +164,99 @@ class ZopOrderService extends ZopBaseService
|
|
|
$orderTotalFee = bcmul($amount, 1000, 0);
|
|
|
$pageUrl = $produce->link ?? '';
|
|
|
|
|
|
- $preOrderParams = [
|
|
|
- 'orderId' => $orderId,
|
|
|
- 'goodsId' => $goodsId,
|
|
|
- 'certName' => $certName,
|
|
|
- 'certNo' => $certNum,
|
|
|
- 'contactNum' => $contactNum,
|
|
|
- 'postProvinceCode' => $postProvinceCode,
|
|
|
- 'postCityCode' => $postCityCode,
|
|
|
- 'postDistrictCode' => $postDistrictCode,
|
|
|
- 'postAddr' => $postAddr,
|
|
|
- 'channel' => $channel,
|
|
|
- 'createTime' => $createTime,
|
|
|
- 'updateTime' => $updateTime,
|
|
|
- 'orderTotalFee' => $orderTotalFee,
|
|
|
- 'pageUrl' => $pageUrl,
|
|
|
- 'resourceId' => $resourceId,
|
|
|
- ];
|
|
|
-
|
|
|
- $preOrderResult = self::preOrdersync($preOrderParams);
|
|
|
- if ($preOrderResult['code'] != 0) {
|
|
|
- // 写入订单错误信息
|
|
|
- $order->failure_reason = $preOrderResult['message'];
|
|
|
- $order->save();
|
|
|
-
|
|
|
- return $preOrderResult;
|
|
|
- }
|
|
|
-
|
|
|
- $token = $preOrderResult['data']['token'] ?? '';
|
|
|
- // 4. 选号服务(暂不需要)
|
|
|
-
|
|
|
- // 5. 选号后置-正式单同步(非提前预占版)
|
|
|
- $phoneNum = $order->no ?? '';
|
|
|
- $isOpenCF = 0;
|
|
|
-
|
|
|
- // 判断产品是否使用用户收货地址区号
|
|
|
- $homeLocationType = $produce->home_location_type ?? 'address';
|
|
|
- if ($homeLocationType == 'assign') {
|
|
|
- $provinceNumCode = $produce->home_location_province ?? 0;
|
|
|
- $cityNumCode = $produce->home_location_city ?? 0;
|
|
|
- }
|
|
|
-
|
|
|
- $orderParams = [
|
|
|
- 'goodsId' => $goodsId,
|
|
|
- 'provinceCode' => $provinceNumCode,
|
|
|
- 'cityCode' => $cityNumCode,
|
|
|
- 'phoneNum' => $phoneNum,
|
|
|
- 'token' => $token,
|
|
|
- 'createTime' => $createTime,
|
|
|
- 'isOpenCF' => $isOpenCF,
|
|
|
- ];
|
|
|
+ $no = $order['no'];
|
|
|
+ if (empty($no)) {
|
|
|
+ // 自动选号-订单同步接口
|
|
|
+ $autoOrderParams = [
|
|
|
+ 'orderId' => $orderId,
|
|
|
+ 'goodsId' => $goodsId,
|
|
|
+ 'certName' => $certName,
|
|
|
+ 'certNo' => $certNum,
|
|
|
+ 'contactNum' => $contactNum,
|
|
|
+ 'postProvinceCode' => $postProvinceCode,
|
|
|
+ 'postCityCode' => $postCityCode,
|
|
|
+ 'postDistrictCode' => $postDistrictCode,
|
|
|
+ 'postAddr' => $postAddr,
|
|
|
+ 'channel' => $channel,
|
|
|
+ 'createTime' => $createTime,
|
|
|
+ 'updateTime' => $updateTime,
|
|
|
+ 'orderTotalFee' => $orderTotalFee,
|
|
|
+ 'pageUrl' => $pageUrl,
|
|
|
+ 'resourceId' => $resourceId,
|
|
|
+ ];
|
|
|
+ $autoOrderResult = self::autoNumSync($autoOrderParams);
|
|
|
+ if ($autoOrderResult['code'] != 0) {
|
|
|
+ // 写入订单错误信息
|
|
|
+ $order->failure_reason = $autoOrderResult['message'];
|
|
|
+ $order->save();
|
|
|
+
|
|
|
+ return $autoOrderResult;
|
|
|
+ }
|
|
|
|
|
|
- $orderResult = self::ordersync($orderParams);
|
|
|
- if ($orderResult['code'] != 0) {
|
|
|
- // 写入订单错误信息
|
|
|
- $order->failure_reason = $orderResult['message'];
|
|
|
+ $no = $autoOrderResult['preNumber'];
|
|
|
+ $order->no = $no;
|
|
|
$order->save();
|
|
|
-
|
|
|
- return $orderResult;
|
|
|
+ } else {
|
|
|
+ // 3. 选号后置-意向单同步
|
|
|
+ $preOrderParams = [
|
|
|
+ 'orderId' => $orderId,
|
|
|
+ 'goodsId' => $goodsId,
|
|
|
+ 'certName' => $certName,
|
|
|
+ 'certNo' => $certNum,
|
|
|
+ 'contactNum' => $contactNum,
|
|
|
+ 'postProvinceCode' => $postProvinceCode,
|
|
|
+ 'postCityCode' => $postCityCode,
|
|
|
+ 'postDistrictCode' => $postDistrictCode,
|
|
|
+ 'postAddr' => $postAddr,
|
|
|
+ 'channel' => $channel,
|
|
|
+ 'createTime' => $createTime,
|
|
|
+ 'updateTime' => $updateTime,
|
|
|
+ 'orderTotalFee' => $orderTotalFee,
|
|
|
+ 'pageUrl' => $pageUrl,
|
|
|
+ 'resourceId' => $resourceId,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $preOrderResult = self::preOrdersync($preOrderParams);
|
|
|
+ if ($preOrderResult['code'] != 0) {
|
|
|
+ // 写入订单错误信息
|
|
|
+ $order->failure_reason = $preOrderResult['message'];
|
|
|
+ $order->save();
|
|
|
+
|
|
|
+ return $preOrderResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ $token = $preOrderResult['data']['token'] ?? '';
|
|
|
+ // 4. 选号服务(暂不需要)
|
|
|
+
|
|
|
+ // 5. 选号后置-正式单同步(非提前预占版)
|
|
|
+ $phoneNum = $order->no ?? '';
|
|
|
+ $isOpenCF = 0;
|
|
|
+
|
|
|
+ // 判断产品是否使用用户收货地址区号
|
|
|
+ $homeLocationType = $produce->home_location_type ?? 'address';
|
|
|
+ if ($homeLocationType == 'assign') {
|
|
|
+ $provinceNumCode = $produce->home_location_province ?? 0;
|
|
|
+ $cityNumCode = $produce->home_location_city ?? 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ $orderParams = [
|
|
|
+ 'goodsId' => $goodsId,
|
|
|
+ 'provinceCode' => $provinceNumCode,
|
|
|
+ 'cityCode' => $cityNumCode,
|
|
|
+ 'phoneNum' => $phoneNum,
|
|
|
+ 'token' => $token,
|
|
|
+ 'createTime' => $createTime,
|
|
|
+ 'isOpenCF' => $isOpenCF,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $orderResult = self::ordersync($orderParams);
|
|
|
+ if ($orderResult['code'] != 0) {
|
|
|
+ // 写入订单错误信息
|
|
|
+ $order->failure_reason = $orderResult['message'];
|
|
|
+ $order->save();
|
|
|
+
|
|
|
+ return $orderResult;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$order->is_push_zop = 1;
|
|
@@ -602,4 +637,51 @@ class ZopOrderService extends ZopBaseService
|
|
|
|
|
|
return self::success('删除成功数量: ' . $delSuccessNum);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 自动选号-订单同步接口
|
|
|
+ *
|
|
|
+ * @param array $params [orderId: 订单ID, goodsId: 商品ID, certName: 证件姓名, certNo: 证件编码, contactNum: 联系电话, postProvinceCode: 省份编码, postCityCode: 地市编码, postDistrictCode: 区县编码, postAddr: 详细地址, channel: 渠道, createTime: 创建时间, updateTime: 更新时间, orderTotalFee: 订单总金额, pageUrl: 页面地址, resourceId: 资源ID]
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public static function autoNumSync($params = [])
|
|
|
+ {
|
|
|
+ $url = '/link/king/card/preOrder/autoNumSync';
|
|
|
+
|
|
|
+ $data = array_only($params, [
|
|
|
+ 'orderId',
|
|
|
+ 'goodsId',
|
|
|
+ 'certName',
|
|
|
+ 'certNo',
|
|
|
+ 'contactNum',
|
|
|
+ 'postProvinceCode',
|
|
|
+ 'postCityCode',
|
|
|
+ 'postDistrictCode',
|
|
|
+ 'postAddr',
|
|
|
+ 'channel',
|
|
|
+ 'createTime',
|
|
|
+ 'updateTime',
|
|
|
+ 'orderTotalFee',
|
|
|
+ 'pageUrl',
|
|
|
+ 'resourceId'
|
|
|
+ ]);
|
|
|
+ $data['launchPlatform'] = self::getRandLaunchPlatform();
|
|
|
+
|
|
|
+ $result = self::send($url, $data);
|
|
|
+ if (empty($result)) {
|
|
|
+ return self::error('自动选号请求失败');
|
|
|
+ }
|
|
|
+ $resArr = json_decode($result, true);
|
|
|
+
|
|
|
+ if ($resArr['rspCode'] != '0000') {
|
|
|
+ return self::error('自动选号请求失败, 错误编码为: ' . $resArr['rspCode'] . '错误信息为: ' . $resArr['rspDesc']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $body = $resArr['body'] ?? '';
|
|
|
+ if (is_string($body)) {
|
|
|
+ $body = json_decode($body, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ return self::success($body);
|
|
|
+ }
|
|
|
}
|