|
|
@@ -25,6 +25,7 @@ class NoticeController extends PublicController
|
|
|
|
|
|
public $categoryList;
|
|
|
|
|
|
+ //拉卡拉回高通知 ssh 20231009
|
|
|
public function actionPayCallback()
|
|
|
{
|
|
|
$postStr = file_get_contents('php://input');//接收微信服务器返回的xml消息体
|
|
|
@@ -47,26 +48,134 @@ class NoticeController extends PublicController
|
|
|
];
|
|
|
$laResource = new Lakala($params);
|
|
|
$return = $laResource->signatureVerification($Authorization, $postStr);
|
|
|
- if ($return == false) {
|
|
|
- noticeUtil::push('支付回调验证失败了,请注意', '15280215347');
|
|
|
- return false;
|
|
|
- }
|
|
|
+
|
|
|
$postData = json_decode($postStr, true);
|
|
|
$orderSn = $postData['out_trade_no'] ?? '';
|
|
|
$payer_amount = $postData['payer_amount'] ?? 0;
|
|
|
+ $account_type = $postData['account_type'] ?? '';
|
|
|
+ if (empty($account_type)) {
|
|
|
+ noticeUtil::push('支付回调失败了,没有找到钱包类型,请注意,orderSn:' . $orderSn, '15280215347');
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
$totalFee = $payer_amount / 100;
|
|
|
$transactionId = $postData['trade_no'] ?? 0;
|
|
|
|
|
|
+ if ($return == false) {
|
|
|
+ noticeUtil::push('支付回调验证失败了,请注意,orderSn:' . $orderSn, '15280215347');
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+
|
|
|
$attach = $postData['promo_info'];
|
|
|
noticeUtil::push($attach, '15280215347');
|
|
|
-// //接收流水类型、代金劵
|
|
|
-// parse_str($attach);
|
|
|
-// //流水类型
|
|
|
-// $capitalType = isset($capitalType) ? $capitalType : null;
|
|
|
-// if (isset($capitalType) == false) {
|
|
|
-// Yii::warning('capitalType empty,orderSn:' . $orderSn);
|
|
|
-// util::end();
|
|
|
-// }
|
|
|
+ //接收流水类型、代金劵
|
|
|
+ $remarkString = $postData['remark'] ?? '';
|
|
|
+ $remarkData = json_decode($remarkString, true);
|
|
|
+ //流水类型
|
|
|
+ $capitalType = isset($remarkData['capitalType']) ? $remarkData['capitalType'] : null;
|
|
|
+ if (isset($capitalType) == false) {
|
|
|
+ noticeUtil::push('支付回调失败了,没有找到capitalType,orderSn:' . $orderSn, '15280215347');
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ $payWayType = null;
|
|
|
+ if ($account_type == 'WECHAT') {
|
|
|
+ $payWayType = dict::getDict('payWay', 'wxPay');
|
|
|
+ }
|
|
|
+ if ($account_type == 'ALIPAY') {
|
|
|
+ $payWayType = dict::getDict('payWay', 'alipay');
|
|
|
+ }
|
|
|
+ if (empty($payWayType)) {
|
|
|
+ noticeUtil::push('支付回调失败了,没有找到支付类型,orderSn:' . $orderSn, '15280215347');
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+ //支付成功后续流程
|
|
|
+ payUtil::thirdPay($payWayType, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
|
|
|
+ $transaction->commit();
|
|
|
+ echo '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
|
|
|
+
|
|
|
+ //解决重复通知
|
|
|
+ $cacheKey = 'pay_success_notice_' . $orderSn;
|
|
|
+ $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
|
|
|
+ if (!empty($has)) {
|
|
|
+ Yii::$app->end();
|
|
|
+ }
|
|
|
+ Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 864000, 'has']);
|
|
|
+
|
|
|
+ //零售采购结账通知
|
|
|
+ if ($capitalType == dict::getDict('capitalType', 'xhPurchase', 'id')) {
|
|
|
+ $cg = PurchaseClass::getByCondition(['orderSn' => $orderSn], true);
|
|
|
+
|
|
|
+ if (isset($cg->localOrder) && $cg->localOrder == 1) {
|
|
|
+ if ($cg->transType != 5 && $cg->transType != 4) {
|
|
|
+ //昆明发货,客户算了一次打包费和运费,第二次就不再算了
|
|
|
+ $customId = $cg->customId ?? 0;
|
|
|
+ $current = date("Y_m_d");
|
|
|
+ $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId;
|
|
|
+ Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (isset($cg->sendType) && $cg->sendType == 4) {
|
|
|
+ //标记当天发快递方式已收一次包装费,岭南批发市场用的功能
|
|
|
+ $customId = $cg->customId ?? 0;
|
|
|
+ $current = date("Y_m_d");
|
|
|
+ $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId;
|
|
|
+ Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($cg) && $cg->payStatus == 1) {
|
|
|
+ //微信通知
|
|
|
+ $saleId = $cg->saleId ?? 0;
|
|
|
+ $order = OrderClass::getById($saleId, true);
|
|
|
+ if (!empty($order)) {
|
|
|
+ //订单生成时唤起在线打印
|
|
|
+ if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'need')) {
|
|
|
+ //有几个地方要同步去修改
|
|
|
+ if (getenv('YII_ENV') == 'production') {
|
|
|
+ //源花汇不自动打开小票
|
|
|
+ $mallOrderNoPrint = [10536];
|
|
|
+ } else {
|
|
|
+ $mallOrderNoPrint = [644];
|
|
|
+ }
|
|
|
+ if (in_array($order->mainId, $mallOrderNoPrint)) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ OrderClass::onlinePrint($order);
|
|
|
+ $order->printNum += 1;
|
|
|
+ $order->save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $cgShopId = $cg->shopId ?? 0;
|
|
|
+ $cgShop = ShopClass::getById($cgShopId, true);
|
|
|
+ if (!empty($cgShop)) {
|
|
|
+ \bizHd\notice\classes\NoticeClass::cgSuccessMiniNotice($cgShop, $cg);
|
|
|
+ }
|
|
|
+ //如果是门店用手机开单,让客户扫码付款的,则也要语音提示
|
|
|
+ if (isset($order->shopAdminId) && $order->shopAdminId > 0) {
|
|
|
+ ShopExtClass::ghsGatheringReport($order);
|
|
|
+ }
|
|
|
+ $shopId = $order->shopId ?? 0;
|
|
|
+ $shop = ShopClass::getById($shopId, true);
|
|
|
+ if (!empty($shop)) {
|
|
|
+ //花店采购供货商端微信收到通知
|
|
|
+ //WxMessageClass::ghsHasNewOrderInform($shop, $order);
|
|
|
+ $noticeText = json_encode(['orderId' => $saleId]);
|
|
|
+ $noticeKey = "hdCgNoticeGhs";
|
|
|
+ Yii::$app->redis->executeCommand('LPUSH', [$noticeKey, $noticeText]);
|
|
|
+ }
|
|
|
+ //花店采购供货商端APP收到通知
|
|
|
+ //NoticeClass::ghsNewOrderNotice($order);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::error("失败原因:" . $e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//微信支付异步回调
|