|
|
@@ -17,9 +17,36 @@ class GhsDeliveryOrderClass extends BaseClass
|
|
|
|
|
|
public static function payAfter($order)
|
|
|
{
|
|
|
- $orderId = $order->id ?? 0;
|
|
|
+ $orderId = $order->id;
|
|
|
try {
|
|
|
- //noticeUtil::push('批发,付款成功之后要发跑腿的订单:' . $order->id, '15280215347');
|
|
|
+ noticeUtil::push('批发,付款成功之后要发跑腿的订单:' . $orderId, '15280215347');
|
|
|
+ $cacheKey = 'ghs_pt_cacheData:' . $orderId;
|
|
|
+ $cachedData = Yii::$app->redis->get($cacheKey);
|
|
|
+ if (!empty($cachedData)) {
|
|
|
+ $cachedData = json_decode($cachedData, true);
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'orderId' => $orderId,
|
|
|
+ 'shopId' => $order->shopId,
|
|
|
+ 'mainId' => $order->mainId,
|
|
|
+ 'platform' => $cachedData['deliveryPlatform'],
|
|
|
+ 'ip' => '127.0.0.1',
|
|
|
+ 'deliveryPrice' => $cachedData['deliveryPrice'],
|
|
|
+ 'deliveryDistance' => $cachedData['deliveryDistance'],
|
|
|
+ 'deliveryBracketContent' => $cachedData['deliveryBracketContent'],
|
|
|
+ 'pickupTime' => $cachedData['pickupTime'],
|
|
|
+ 'allParams' => $cachedData['deliveryAllParams'],
|
|
|
+ 'weight' => $cachedData['weight'] ?? 1,
|
|
|
+ 'remark' => $cachedData['deliveryRemark'] ?? '',
|
|
|
+ 'price' => $order->actPrice,
|
|
|
+ ];
|
|
|
+ self::askCreateOrder($data);
|
|
|
+ } else {
|
|
|
+ noticeUtil::push("批发-缓存数据不存在或已过期,cacheKey:{$cacheKey}");
|
|
|
+ // 发送 app 通知
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
} catch (\Exception $e) {
|
|
|
$msg = $e->getMessage();
|
|
|
$remind = "批发,付款成功之后要发跑腿的订单,报错 {$orderId} {$msg}";
|
|
|
@@ -31,36 +58,55 @@ class GhsDeliveryOrderClass extends BaseClass
|
|
|
public static function prepareAskData($post, $order)
|
|
|
{
|
|
|
try {
|
|
|
- $callErrand = $post['callErrand'] ?? 0;
|
|
|
- $sendType = $post['sendType'] ?? 0;
|
|
|
- $saleId = $order->id ?? 0;
|
|
|
- $shopId = $order->shopId ?? 0;
|
|
|
- $mainId = $order->mainId ?? 0;
|
|
|
- if ($callErrand == 1) {
|
|
|
- if ($order->payStatus == 1 && $sendType == dict::getDict('sendType', 'thirdSend')) { // $post 中有 pickupTime,则说明是要立即发跑腿 或者 callErrand == 1
|
|
|
- $platform = $post['deliveryPlatform'];
|
|
|
- $deliveryPrice = $post['deliveryPrice'];
|
|
|
- $deliveryDistance = $post['deliveryDistance'];
|
|
|
- $deliveryBracketContent = $post['deliveryBracketContent'];
|
|
|
- $pickupTime = $post['pickupTime'];
|
|
|
- $allParams = $post['deliveryAllParams'];
|
|
|
- $data = [
|
|
|
- 'orderId' => $saleId,
|
|
|
- 'shopId' => $shopId,
|
|
|
- 'mainId' => $mainId,
|
|
|
- 'platform' => $platform,
|
|
|
- 'ip' => Yii::$app->request->userIP,
|
|
|
- 'deliveryPrice' => $deliveryPrice,
|
|
|
- 'deliveryDistance' => $deliveryDistance,
|
|
|
- 'deliveryBracketContent' => $deliveryBracketContent,
|
|
|
- 'pickupTime' => $pickupTime,
|
|
|
- 'allParams' => $allParams,
|
|
|
- // ----------
|
|
|
- 'weight' => $post['weight'] ?? 1,
|
|
|
- 'remark' => $post['deliveryRemark'] ?? '',
|
|
|
- 'price' => $order->actPrice,
|
|
|
- ];
|
|
|
- GhsDeliveryOrderClass::askCreateOrder($data);
|
|
|
+ $callErrand = $post['callErrand']; // 是否立即发跑腿 1:是 0:否
|
|
|
+ $saleId = $order->id;
|
|
|
+
|
|
|
+ if ($callErrand == 1) { // 是否立即发跑腿 1:是 0:否
|
|
|
+ $hasPay = $post['hasPay'] ?? dict::getDict('hasPay', 'unPay'); //收款方式 0:扫码付(待付款) 1:线下(已付款) 2:赊账(欠款)3:现金 4:余额
|
|
|
+
|
|
|
+ if ($hasPay == dict::getDict('hasPay', 'unPay')) { // 0:扫码付(待付款)
|
|
|
+ $deliveryPlatform = $post['deliveryPlatform'];
|
|
|
+ $expireTime = 0;
|
|
|
+ if($deliveryPlatform == 'shansong'){
|
|
|
+ $expireTime = 1800 - 60;
|
|
|
+ }elseif($deliveryPlatform == 'didi'){
|
|
|
+ $expireTime = 7200;
|
|
|
+ }else{
|
|
|
+ $expireTime = 7200; // 默认缓存时长2小时
|
|
|
+ }
|
|
|
+
|
|
|
+ // 把跑腿数据缓存到 redis 中,等待付款成功后,再发跑腿订单
|
|
|
+ $cacheKey = 'ghs_pt_orderId hd_pt_' . $saleId;
|
|
|
+ Yii::$app->redis->set($cacheKey, json_encode($post, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
|
|
+ Yii::$app->redis->expire($cacheKey, $expireTime);
|
|
|
+ } else {
|
|
|
+ $sendType = $post['sendType'];
|
|
|
+
|
|
|
+ if ($order->payStatus == 1 && $sendType == dict::getDict('sendType', 'thirdSend')) {
|
|
|
+ $platform = $post['deliveryPlatform'];
|
|
|
+ $deliveryPrice = $post['deliveryPrice'];
|
|
|
+ $deliveryDistance = $post['deliveryDistance'];
|
|
|
+ $deliveryBracketContent = $post['deliveryBracketContent'];
|
|
|
+ $pickupTime = $post['pickupTime'];
|
|
|
+ $allParams = $post['deliveryAllParams'];
|
|
|
+ $data = [
|
|
|
+ 'orderId' => $saleId,
|
|
|
+ 'shopId' => $order->shopId,
|
|
|
+ 'mainId' => $order->mainId,
|
|
|
+ 'platform' => $platform,
|
|
|
+ 'ip' => Yii::$app->request->userIP,
|
|
|
+ 'deliveryPrice' => $deliveryPrice,
|
|
|
+ 'deliveryDistance' => $deliveryDistance,
|
|
|
+ 'deliveryBracketContent' => $deliveryBracketContent,
|
|
|
+ 'pickupTime' => $pickupTime,
|
|
|
+ 'allParams' => $allParams,
|
|
|
+ // ----------
|
|
|
+ 'weight' => $post['weight'] ?? 1,
|
|
|
+ 'remark' => $post['deliveryRemark'] ?? '',
|
|
|
+ 'price' => $order->actPrice,
|
|
|
+ ];
|
|
|
+ self::askCreateOrder($data);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} catch (\Exception $e) {
|