|
|
@@ -142,7 +142,7 @@ class OrderClass extends BaseClass
|
|
|
}
|
|
|
|
|
|
//第三方支付后回调处理流程 shish 2021.4.30
|
|
|
- public static function thirdPay($payWay, $orderSn, $totalFee, $attach)
|
|
|
+ public static function thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId)
|
|
|
{
|
|
|
$order = self::getByCondition(['orderSn' => $orderSn], true);
|
|
|
if (empty($order)) {
|
|
|
@@ -156,40 +156,21 @@ class OrderClass extends BaseClass
|
|
|
util::fail($msg);
|
|
|
}
|
|
|
|
|
|
- //临时解决微信一秒内通知二次问题
|
|
|
$id = $order->id;
|
|
|
$order = self::getLockById($id);
|
|
|
-
|
|
|
$date = date("Y-m-d H:i:s");
|
|
|
$order->payTime = $date;
|
|
|
+ $order->thirdNo = $transactionId;
|
|
|
$order->onlinePay = dict::getDict('onlinePay', 'yes');
|
|
|
$order->save();
|
|
|
- self::complete($order, $payWay);
|
|
|
- //订单全部流程走完了再通知
|
|
|
- if ($order->fromType == dict::getDict("fromType", "shop")) {
|
|
|
- $shopAdminIds = \bizGhs\shop\classes\ShopAdminClass::getRemindAdminIdsByShopId($order->shopId);
|
|
|
- if ($shopAdminIds) {
|
|
|
- foreach ($shopAdminIds as $v) {
|
|
|
- WsService::arrivalNotice($v, $order->actPrice, $order->payWay);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- //员工开单选择付款方式 shish 2021.5.4
|
|
|
- public static function staffKdPay($payWay, $orderSn)
|
|
|
- {
|
|
|
- $order = self::getByCondition(['orderSn' => $orderSn], true);
|
|
|
- if (empty($order)) {
|
|
|
- $msg = "没有找到零售订单 orderSn:{$orderSn}";
|
|
|
- Yii::info($msg);
|
|
|
- util::fail($msg);
|
|
|
- }
|
|
|
- self::complete($order, $payWay);
|
|
|
+ self::payAfter($order, $payWay);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//订单完成 shish 2021.4.20
|
|
|
- public static function complete($order, $payWay)
|
|
|
+ public static function payAfter($order, $payWay)
|
|
|
{
|
|
|
if (empty($order)) {
|
|
|
util::fail('没有找到订单');
|
|
|
@@ -197,24 +178,17 @@ class OrderClass extends BaseClass
|
|
|
if (isset($order->status) == false || $order->status != self::ORDER_STATUS_UN_PAY) {
|
|
|
util::fail('订单不是待付款状态');
|
|
|
}
|
|
|
- $orderGoods = OrderGoodsClass::getAllByCondition(['orderId' => $order->id], null, '*');
|
|
|
-
|
|
|
+ $orderId = $order->id ?? 0;
|
|
|
$order->status = self::ORDER_STATUS_UN_SEND;
|
|
|
$order->currentFlow = 2;
|
|
|
$order->payWay = $payWay;
|
|
|
$order->save();
|
|
|
|
|
|
- //下单完成,开始制单
|
|
|
- $current = time();
|
|
|
- $orderId = $order->id;
|
|
|
- $orderSn = $order->orderSn;
|
|
|
- OrderSendClass::placeOrder(['orderId' => $orderId, 'payTime' => $current, 'orderSn' => $orderSn]);
|
|
|
|
|
|
$realPrice = $order->realPrice ?? 0;
|
|
|
$shopId = $order->shopId;
|
|
|
$shop = ShopClass::getLockById($shopId);
|
|
|
if (empty($shop)) {
|
|
|
- Yii::info("没有找到门店 OrderClass::complete() orderId:{$order->id}");
|
|
|
util::fail('没有找到门店');
|
|
|
}
|
|
|
$shop->unSendOrder += 1;
|
|
|
@@ -227,11 +201,7 @@ class OrderClass extends BaseClass
|
|
|
$shopAdminId = $order->shopAdminId ?? 0;
|
|
|
$shopAdminName = $order->shopAdminName ?? '';
|
|
|
$sjId = $order->sjId;
|
|
|
- $event = '客户下单';
|
|
|
- if (!empty($shopAdminId)) {
|
|
|
- $event = '员工开单';
|
|
|
- }
|
|
|
-
|
|
|
+ $event = !empty($shopAdminId) ? '员工开单' : '客户下单';
|
|
|
$capital = [
|
|
|
'capitalType' => $capitalType,
|
|
|
'relateId' => $orderId,
|
|
|
@@ -246,61 +216,25 @@ class OrderClass extends BaseClass
|
|
|
'amount' => $realPrice,
|
|
|
];
|
|
|
ShopCapitalClass::addCapital($capital);
|
|
|
-
|
|
|
//每天和每月收入增加
|
|
|
StatIncomeClass::updateOrInsert($shop, $realPrice);
|
|
|
//今日订单+1
|
|
|
StatOrderClass::updateOrInsert($shop);
|
|
|
|
|
|
- //二维码收款订单存在没有商品的情况
|
|
|
- if (!empty($orderGoods)) {
|
|
|
- // 扣库存
|
|
|
- self::decGoodsStock($orderGoods);
|
|
|
- // 增加销量
|
|
|
- self::updateGoodsActualSold($orderGoods);
|
|
|
+ //客户在线支付下单增加商家可提现余额
|
|
|
+ if (isset($order->onlinePay) && $order->onlinePay == dict::getDict('onlinePay', 'yes')) {
|
|
|
+ $amount = $order->actPrice;
|
|
|
+ ShopClass::customKdAddBalance($shop, $amount, $order, $capitalType);
|
|
|
}
|
|
|
-
|
|
|
- if (isset($order->shopAdminId) == false) {
|
|
|
- util::fail('没有员工字段');
|
|
|
- }
|
|
|
- if (isset($order->fromType) == false) {
|
|
|
- util::fail('没有来源字段');
|
|
|
+ if (in_array($order->fromType, [dict::getDict("fromType", "shop"), dict::getDict("fromType", "friend")])) {
|
|
|
+ //您有新的收入提醒
|
|
|
+ WxMessageClass::gatheringIncomeInform($shop, $order);
|
|
|
}
|
|
|
-
|
|
|
- if (!empty($order->shopAdminId)) {
|
|
|
- //员工开单,自取订单,直接完成
|
|
|
- if ($order->sendType == self::SEND_TYPE_NO) {
|
|
|
- OrderSendClass::withoutSend($order);
|
|
|
- }
|
|
|
- } else {
|
|
|
- //客户在线支付下单增加商家可提现余额
|
|
|
- if (isset($order->onlinePay) && $order->onlinePay == dict::getDict('onlinePay', 'yes')) {
|
|
|
- $amount = $order->actPrice;
|
|
|
- ShopClass::customKdAddBalance($shop, $amount, $order, $capitalType);
|
|
|
- }
|
|
|
- //门店和朋友圈订单并且没有填写收花人的直接将订单置为自取并且是完成状态
|
|
|
- if (in_array($order->fromType, [dict::getDict("fromType", "shop"), dict::getDict("fromType", "friend")])) {
|
|
|
- if (isset($order->receiveMobile) && isset($order->address)) {
|
|
|
- if (empty($order->receiveMobile) && empty($order->address)) {
|
|
|
- OrderSendClass::withoutSend($order);
|
|
|
- }
|
|
|
- }
|
|
|
- //您有新的收入提醒(门店订单)
|
|
|
- WxMessageClass::gatheringIncomeInform($shop, $order);
|
|
|
- }
|
|
|
- };
|
|
|
- //来自商城的订单通知 linqh 2021.5.19
|
|
|
if ($order->fromType == dict::getDict("fromType", "mall")) {
|
|
|
- $shopIdAdminIds = \bizGhs\shop\classes\ShopAdminClass::getRemindAdminIdsByShopId($shopId);
|
|
|
- //语音通知
|
|
|
- if ($shopIdAdminIds) {
|
|
|
- foreach ($shopIdAdminIds as $v) {
|
|
|
- WsService::newOrderNotice($v);
|
|
|
- }
|
|
|
- }
|
|
|
- //新订单微信通知
|
|
|
+ //来自商城的新订单微信通知
|
|
|
WxMessageClass::hdNewOrderInform($shop, $order);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//转化出送到时间 ssh 2020.3.15
|