|
@@ -1460,6 +1460,150 @@ class OrdersController extends Controller
|
|
|
echo "success";
|
|
|
}
|
|
|
|
|
|
+ //市民卡支付回调
|
|
|
+ function wcback_smkpay(Request $request)
|
|
|
+ {
|
|
|
+ Log::info('wcback_smkpay start:');
|
|
|
+ $res_data = [];
|
|
|
+ try {
|
|
|
+ $data = $request->except('_url');
|
|
|
+ $source_sign = $data['sign'];
|
|
|
+ unset($data['sign']);
|
|
|
+
|
|
|
+ //订单
|
|
|
+ $trade_no = $data['orderNo'];
|
|
|
+ $order = OrderService::getByTradeNo($trade_no);
|
|
|
+ if (!$order) die('failed');
|
|
|
+
|
|
|
+ $pay_merchant = DB::table('pay_merchants')->select('appid', 'source', 'config_info')->where('id', $order->pay_merchant_id)->first();
|
|
|
+ $pay_config_info = json_decode($pay_merchant->config_info, 1);
|
|
|
+
|
|
|
+ // 防止重复推送
|
|
|
+ if (isset($order->status) && $order->status == 'PAID') {
|
|
|
+ Log::info('has_pay:' . $trade_no);
|
|
|
+ $res_data['respCode'] = '00';
|
|
|
+ $res_data['respDesc'] = '成功';
|
|
|
+ $res_data['merCode'] = $pay_config_info['merCode'];
|
|
|
+ $res_data['reqSeq'] = $data['reqSeq'];
|
|
|
+ return response()->json($res_data);
|
|
|
+ }
|
|
|
+
|
|
|
+ //校验签名
|
|
|
+ $wechatPay = WechatPay::instance($pay_merchant->source, $pay_config_info);
|
|
|
+ if(!$wechatPay->checkSign($data, $source_sign))
|
|
|
+ {
|
|
|
+ Log::info('sign check error:');
|
|
|
+ Log::info($request->all());
|
|
|
+ die('failed');
|
|
|
+ }
|
|
|
+
|
|
|
+ $trade_code = $data['respCode'];
|
|
|
+ $trade_status = $data['status'];
|
|
|
+ $transaction_id = $data['serialNo'];
|
|
|
+
|
|
|
+ if ($trade_code == '00' && $trade_status=='01') {
|
|
|
+ Log::info('wcback_wcback_smkpay_notify_sign_success');
|
|
|
+ // 修改表比较多,开启事务
|
|
|
+ DB::beginTransaction();
|
|
|
+
|
|
|
+ $uid = $order->uid;
|
|
|
+ $distribution_channel_id = $order->distribution_channel_id;
|
|
|
+ $product_id = $order->product_id;
|
|
|
+ $product = ProductService::getProductSingle($product_id);
|
|
|
+ $send_order_id = $order->send_order_id;
|
|
|
+ $price = $product->price;
|
|
|
+ Log::info('save_order_end');
|
|
|
+
|
|
|
+ Log::info($product);
|
|
|
+
|
|
|
+ Log::info('product_type:' . $product->type);
|
|
|
+ $prize_fee = (int)(($product->price * 100) * 0.1);
|
|
|
+ $this->substituteOrderPrice($order->id, $prize_fee);
|
|
|
+ $this->smartPushTestBookPaidUv($order->from_bid, $order->uid, $order->price);
|
|
|
+ //获取用户充值次数
|
|
|
+ $order->pay_type = $this->getChargeTimes($order->uid);
|
|
|
+ // 更新其他定制Order表
|
|
|
+ if ($product->type == 'YEAR_ORDER') {
|
|
|
+ Log::info('YEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDERYEAR_ORDER');
|
|
|
+ $order_type = 'YEAR';
|
|
|
+ $this->yearOrder($uid, $distribution_channel_id, $price, $send_order_id);
|
|
|
+ $order->order_type = $order_type;
|
|
|
+ $order->status = 'PAID';
|
|
|
+ $order->pay_end_at = date('Y-m-d H:i:s');
|
|
|
+ $order->transaction_id = $transaction_id;
|
|
|
+ $order->save();
|
|
|
+ } elseif ($product->type == 'BOOK_ORDER') {
|
|
|
+ Log::info('BOOK_ORDERBOOK_ORDERBOOK_ORDERBOOK_ORDERBOOK_ORDERBOOK_ORDERBOOK_ORDERBOOK_ORDER');
|
|
|
+ $order_type = 'BOOK';
|
|
|
+ $this->bookOrder($product_id, $uid, $send_order_id, $price, $distribution_channel_id);
|
|
|
+ $order->order_type = $order_type;
|
|
|
+ $order->status = 'PAID';
|
|
|
+ $order->pay_end_at = date('Y-m-d H:i:s');
|
|
|
+ $order->transaction_id = $transaction_id;
|
|
|
+ $order->save();
|
|
|
+ } elseif ($product->type == 'TICKET_RECHARGE' || $product->type == 'NEW_USER') {
|
|
|
+ Log::info('TICKET_RECHARGETICKET_RECHARGETICKET_RECHARGETICKET_RECHARGETICKET_RECHARGE');
|
|
|
+ $order_type = 'RECHARGE';
|
|
|
+ $this->userCharge($product, $uid);
|
|
|
+ $order->order_type = $order_type;
|
|
|
+ $order->status = 'PAID';
|
|
|
+ $order->pay_end_at = date('Y-m-d H:i:s');
|
|
|
+ $order->transaction_id = $transaction_id;
|
|
|
+ $order->save();
|
|
|
+ } elseif ($product->type == 'FOREVER') {
|
|
|
+ Log::info('FOREVER------------------------FOREVER');
|
|
|
+ $order_type = 'FOREVER';
|
|
|
+ $this->foreverFreeOrder($uid, $distribution_channel_id, $price, $send_order_id);
|
|
|
+ $order->order_type = $order_type;
|
|
|
+ $order->status = 'PAID';
|
|
|
+ $order->pay_end_at = date('Y-m-d H:i:s');
|
|
|
+ $order->transaction_id = $transaction_id;
|
|
|
+ $order->save();
|
|
|
+ }
|
|
|
+ $this->successPayPushMsg($uid, $product, $order->id);
|
|
|
+ $this->orderStatistical($order);
|
|
|
+ DB::commit();
|
|
|
+ //redis 删除未支付的uid
|
|
|
+ try {
|
|
|
+ $key = 'leyuee:to_send_not_pay_uid:distribution_channel_id:' . $distribution_channel_id;
|
|
|
+ Redis::hdel($key, $uid);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Log::info('redis remote error-----------------------');
|
|
|
+ Log::info($e);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 注册动作-》回调订单
|
|
|
+ $action_type = 'CallBackOrder';
|
|
|
+ $param = [
|
|
|
+ 'order_sn' => isset($trade_no) ? $trade_no : '0',
|
|
|
+ 'openid' => isset($uid) ? $uid : '0',// 没有openid,用uid写log
|
|
|
+ ];
|
|
|
+ UserService::PushUserActionToQueue($action_type, $distribution_channel_id, $param);
|
|
|
+
|
|
|
+ $this->userProperty($uid,$price,$product->type,$order->activity_id);
|
|
|
+
|
|
|
+ }else {
|
|
|
+
|
|
|
+ Log::info('wcback_smkpay_notify_sign_fail');
|
|
|
+ }
|
|
|
+
|
|
|
+ $res_data['respCode'] = '00';
|
|
|
+ $res_data['respDesc'] = '成功';
|
|
|
+ $res_data['merCode'] = $pay_config_info['merCode'];
|
|
|
+ $res_data['reqSeq'] = $order->transaction_id;
|
|
|
+ return response()->json($res_data);
|
|
|
+ Log::info('pay_callback_end');
|
|
|
+
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ DB::rollBack();
|
|
|
+ Log::info('receive_smkpay_palmpay_ept:' . $e->getMessage());
|
|
|
+ echo 'fail';
|
|
|
+ Log::info('pay_callback_end error');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 公众号签名@华灯初上
|
|
|
* @param $params
|