diff --git a/app/admin/controller/user_recharge/UserRechargeController.php b/app/admin/controller/user_recharge/UserRechargeController.php index 27a48b982..f583a2e56 100644 --- a/app/admin/controller/user_recharge/UserRechargeController.php +++ b/app/admin/controller/user_recharge/UserRechargeController.php @@ -7,6 +7,8 @@ use app\admin\controller\BaseAdminController; use app\admin\lists\user_recharge\UserRechargeLists; use app\admin\logic\user_recharge\UserRechargeLogic; use app\admin\validate\user_recharge\UserRechargeValidate; +use app\common\logic\PayNotifyLogic; +use app\common\model\user\UserRecharge; /** @@ -91,5 +93,29 @@ class UserRechargeController extends BaseAdminController return $this->data($result); } + public function refund() + { + $params = (new UserRechargeValidate())->goCheck('refund'); + $detail = UserRecharge::where('id',$params['id'])->findOrEmpty(); + if(empty($detail)){ + return $this->fail('无该充值订单请检查'); + } + //现金 + if($detail['recharge_type'] =='CASH_PAY'){ + PayNotifyLogic::recharge_cash_refund($params['id']); + return $this->success(); + } + //微信 + if($detail['recharge_type'] == 'INDUSTRYMEMBERS'){ + $money = (int)bcmul($detail['price'],100); + (new \app\common\logic\store_order\StoreOrderLogic()) + ->refund($detail['order_id'],$money,$money); + return $this->success(); + } + + //支付宝 + + + } } \ No newline at end of file diff --git a/app/admin/validate/user_recharge/UserRechargeValidate.php b/app/admin/validate/user_recharge/UserRechargeValidate.php index 4abccd2d6..553b1ae7d 100644 --- a/app/admin/validate/user_recharge/UserRechargeValidate.php +++ b/app/admin/validate/user_recharge/UserRechargeValidate.php @@ -32,6 +32,12 @@ class UserRechargeValidate extends BaseValidate ]; + public function sceneRefund() + { + return $this->only(['id']); + } + + /** * @notes 添加场景 * @return UserRechargeValidate diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php index e422175d5..6b5d5ff94 100644 --- a/app/api/controller/PayController.php +++ b/app/api/controller/PayController.php @@ -28,6 +28,8 @@ class PayController extends BaseApiController { $app = new PayService(1); $result = $app->wechat->callback(Request()->post()); + Cache::set('6log'.time(),$result); + Cache::set('6logJ'.time(),json_encode($result)); if ($result && $result->event_type == 'TRANSACTION.SUCCESS') { $ciphertext = $result->resource['ciphertext']; if ($ciphertext['trade_state'] === 'SUCCESS') { @@ -47,6 +49,7 @@ class PayController extends BaseApiController } else { if ($result && $result->event_type == 'REFUND.SUCCESS') { $ciphertext = $result->resource['ciphertext']; + Cache::set('6logC'.time(),json_encode($ciphertext)); if ($ciphertext['refund_status'] === 'SUCCESS') { //处理订单 -1判断是退的一单还是拆分的订单 $out_trade_no = $ciphertext['out_trade_no'] . '-1'; diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index fe50ec195..f9877d6d3 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -296,7 +296,7 @@ class PayNotifyLogic extends BaseLogic //处理财务流水退还 self::store_finance_back($orderSn); self::addStock($order['id']);//微信 - + return true; // self::afterPay($order,$extra['transaction_id']); } @@ -359,6 +359,28 @@ class PayNotifyLogic extends BaseLogic return true; } + /** + * 充值现金退款相关 + * @param $orderId + * @param $extra + * @return true + */ + public static function recharge_cash_refund($orderId,$extra = []) + { + $order = UserRecharge::where('id',$orderId)->findOrEmpty(); + if ($order->isEmpty() || $order->status == -1) { + return true; + } + $order->status = -1; + $order->refund_price = $order->price; + $order->refund_time = time(); + $order->remarks = ''; + $order->save(); + return true; + } + + + /** * 充值 */ @@ -427,6 +449,7 @@ class PayNotifyLogic extends BaseLogic self::descStock($order['id']); } // Redis::send('push-platform-print', ['id' => $order['id']]); + return true; } /**