1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace mini\sdk\controller;
- use huo\controller\pay\Notify;
- use huo\controller\pay\Sdk;
- use huolib\constant\OrderConst;
- use huolib\status\OrderStatus;
- use huoMpay\Payments;
- use mini\common\controller\V2ApiBaseController;
- use think\Log;
- class MpayController extends V2ApiBaseController {
- public function _initialize() {
- parent::_initialize();
- }
-
- public function get_balance_m() {
- $this->checkLogin();
- $_order_rq = $this->setOrderData();
- $_order_id = $_order_rq->getOrderId();
- if (empty($_order_id)) {
- $_code = OrderStatus::ORDER_ID_EMPTY;
- $this->error(OrderStatus::getMsg($_code), [], $_code);
- }
-
- $_order = new Sdk();
- $_rdata = $_order->getStatus($_order_rq->getOrderId());
- if (false == $_rdata) {
- $_code = OrderStatus::INVALID_PARAMS;
- $this->error(OrderStatus::getMsg($_code), [], $_code);
- }
-
- if (OrderConst::PAY_STATUS_SUC != $_rdata['status']) {
- $_rs = (new Payments())->getBalanceAndPay($this->mem_id, $_order_rq->getOrderId());
- if (OrderStatus::NO_ERROR != $_rs['code']) {
- $this->returnData($_rs);
- }
- $_rdata = $_rs['data'];
- }
- if (OrderConst::CP_STATUS_SUC != $_rdata['cp_status'] && OrderConst::PAY_STATUS_SUC == $_rdata['status']) {
- $_rs = (new Notify())->notify($_order_rq->getOrderId());
- if (OrderStatus::NO_ERROR == $_rs['code']) {
- $_rdata['status'] = OrderConst::PAY_STATUS_SUC;
- $_rdata['cp_status'] = OrderConst::CP_STATUS_SUC;
- }
- }
- $_rdata['order_id'] = $_order_rq->getOrderId();
- $this->success(lang('SUCCESS'), $_rdata);
- }
- }
|