| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\common\controllers;
- use app\models\ReOrder;
- use app\modules\common\models\NotifyForm;
- use app\utils\OrderNo;
- use app\utils\Wechat\Wechat;
- use app\utils\Wechat\WechatProfit;
- use app\utils\Wechat\WechatShare;
- use EasyWeChat\Kernel\Exceptions\Exception;
- use EasyWeChat\Kernel\BaseClient;
- use yii\web\Controller;
- use app\utils\IotCloudHelper;
- use app\models\Store;
- use app\models\OrderUnion;
- use app\models\Order;
- use app\models\WechatConfig;
- use app\utils\Adapay\Adapay;
- use app\utils\Adapay\AdapayV2;
- use app\utils\Allinpay\Allinpay;
- use app\utils\Allinpay\AppUtil;
- /**
- * 微信回调类
- * Class WechatNotifyController
- * @package app\modules\common\controllers
- */
- class AllinpayNotifyController extends Controller
- {
- public static $plugins = [
- 'SC' => '\app\plugins\scanCodePay\controllers\CallbackController::execute'
- ];
- public function actionTest() {
- $order = Order::findOne(['order_no' => 'ML20230522140611637863']);
- \app\utils\Adapay\Adapay::paymentConfirmQueryList($order);die;
- $out_trade_no = input_params('out_trade_no');
- $data = [
- 'order_no' => $out_trade_no,
- ];
- $this->notify($data, 317);
- }
- /**
- * 入口文件
- * @throws \Exception
- */
- public function actionIndex() {
- $store_id = get_params('store_id');
- \Yii::error(['Allinpay NOTIFY INDEX <==========> ', all_params()]);
- debug_log([all_params()], __CLASS__ . '.log');
- $post = all_params();
- foreach($post as $key=>$val) {//动态遍历获取所有收到的参数,此步非常关键,因为收银宝以后可能会加字段,动态获取可以兼容由于收银宝加字段而引起的签名异常
- $post[$key] = $val;
- }
- if(count($post)<1){//如果参数为空,则不进行处理
- echo "error";
- \Yii::$app->end();
- }
- if(!AppUtil::ValidSign($post)){
- echo "error";
- \Yii::$app->end();
- }
- // $post = [
- // 'created_time' => '1684142110',
- // 'data' => "{\"app_id\":\"app_9aa823b9-d959-4307-a931-23ba8780f9aa\",\"created_time\":\"20230515171510\",\"description\":\"\",\"end_time\":\"20230515171620\",\"expend\":{\"bank_type\":\"CMB\",\"open_id\":\"o8jhotynrwBGRepP0IKKJ-5zuykY\",\"sub_open_id\":\"oNiCd4gweWf2Irg2K5WfTFWFGEts\"},\"fee_amt\":\"0.00\",\"id\":\"002212023051517151010504112702133735424\",\"order_no\":\"ML20230515171505384756\",\"out_trans_id\":\"4200001875202305153971501223\",\"party_order_id\":\"02212305156211026504784\",\"pay_amt\":\"0.01\",\"pay_channel\":\"wx_lite\",\"real_amt\":\"0.01\",\"share_eq\":\"Y\",\"status\":\"succeeded\",\"wx_user_id\":\"\"}",
- // 'prod_mode' => 'true',
- // 'sign' => 'ZaWpAQfqOzgRE6OUYDY/pt8jQRnMJ1K1YQkCukLRVlS8N9MycpP022pbaTvWovJY3a+do4lyWsFaKS16CfXcdAj1/4zHTh4YDO7PLYMf3c86cna/VrhuD9aIedPVUe0tkdarODPS7M3W3lt90iPRJ8LsuvLQjrD+go2hXr6NKak=',
- // 'id' => '002210504112997909880832',
- // 'type' => 'payment.succeeded',
- // 'app_id' => 'app_9aa823b9-d959-4307-a931-23ba8780f9aa',
- // 'object' => 'payment',
- //];
- if(in_array($post['trxcode'], ['VSP681', 'VSP501', 'VSP511'])){
- $post['order_no'] = $post['cusorderid'];
- // $orderNoHead = substr($post['cusorderid'], 0, 2);
- $this->notify($post, $store_id);
- return;
- }
- }
- /**
- * @param $data
- * @param $store_id
- * 回调逻辑处理
- */
- private function notify($data, $store_id) {
- \Yii::error(['Allinpay NOTIFY <==========> ', $store_id, $data]);
- try {
- $notify = new NotifyForm();
-
-
- if(in_array($data['trxcode'], ['VSP681', 'VSP501'])){
- $notify->pay_type = Order::PAY_TYPE_ALLINPAY_WX;
- $channelName = '微信';
- }
- if(in_array($data['trxcode'], ['VSP511'])){
- $notify->pay_type = Order::PAY_TYPE_ALLINPAY_ALIPAY;
- $channelName = '支付宝';
- }
- if (isset($data['trxamt'])) {
- $store = Store::findOne($store_id);
- if ($store && !empty($store->device_name)) {
- $total_fee = $data['trxamt'];
- IotCloudHelper::sendMessage($store_id, '{"cmd":"voice","msg":"' . $channelName . '收款'.$total_fee.'元","msgid":"'.$store_id. time() .'"}');
- }
- }
- $orderNoHead = substr($data['order_no'], 0, 2);
- $message = array_merge([
- 'out_trade_no' => $data['order_no'],
- 'transaction_id' => '',
- 'out_batch_no' => '',
- 'batch_status' => '',
- 'fail_count' => '',
- 'batch_status' => '',
- 'batch_status' => '',
- ], $data);
- switch ($orderNoHead) {
- case 'UN':
- // 合并支付的订单
- $notify->UnionOrderNotify($message);
- break;
- case 'RG':
- // 充值订单
- $notify->RechargeOrderNotify($message);
- case OrderNo::INTEGRAL_RECHARGE:
- // 充值订单
- $notify->IntegralRechargeOrderNotify($message);
- break;
- case 'LV':
- // 会员购买
- $notify->LevelOrderNotify($message);
- break;
- case 'ML':
- // 商城订单
- $notify->MallOrderNotify($message);
- break;
- case 'SC':
- // 当面付订单
- $notify->ScanOrderNotify($message);
- break;
- case 'PC':
- // 联盟佣金提现订单
- $notify->saasProfitCash($message);
- break;
- case 'FO':
- // 点餐订单
- $notify->FoodNotify($message);
- break;
- case 'SG':
- // 店铺充值订单
- $notify->StoreReOrderNotify($message);
- break;
- case 'AM':
- //商盟会员卡订单
- $notify->BusinessMemberOrderNotify($message);
- break;
- case 'AL':
- //商盟会员购物订单
- $notify->BusinessNotify($message);
- break;
- case 'AD':
- // 认养费用
- $notify->AdoptCostOrderNotify($message);
- break;
- case 'AP':
- // 采购员订单
- $notify->APOrderNotify($message);
- break;
- case 'PR':
- \Yii::error([__METHOD__, 'PROrderNotify', $message]);
- // 采购员充值
- $notify->PROrderNotify($message);
- break;
- case 'LP':
- // 联盟券充值
- $notify->LPorderNotify($message);
- break;
- case 'PT':
- // 充值订单
- $notify->ptActivityOrderNotify($message);
- break;
- default:
- break;
- }
- return true; // 返回处理完成
- } catch (\Exception $e) {
- \Yii::warning(['ADAPAY NOTIFY EXCEPTION <==========> ', $e->getMessage()]);
- }
- }
- }
|