1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace refill\moxj_new;
- require_once(BASE_HELPER_RAPI_PATH . '/moxj_new/config.php');
- use refill;
- class RefillCallBack implements refill\IRefillCallBack
- {
- public function verify($params): bool
- {
- $input = $params;
- unset($input['sign']);
- $sign = $this->sign($input);
- if ($params['sign'] == $sign) {
- return true;
- } else {
- return false;
- }
- }
- private function sign($params)
- {
- ksort($params);
- $body = "";
- $key = config::KEY;
- foreach ($params as $k => $v)
- {
- $body .= "{$k}={$v}&";
- }
- $body .= "key={$key}";
- return strtoupper(md5($body));
- }
- //[$order_id, $success, $can_try, $need_handle]
- public function notify($params)
- {
- $status = intval($params['code']);
- $order_sn = $params['partner_order_no'];
- $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
- if (empty($order_info)) {
- return [false, false, false,false];
- }
- $order_id = $order_info['order_id'];
- if ($status === 2001) {
- $data['official_sn'] = strtolower($params['official_order_no']) == 'null' ? '' : $params['official_order_no'];
- Model('refill_order')->edit($order_id, $data);
- return [$order_id, true, false,true];
- }
- elseif ($status === 2000) {
- //2000为充值中
- return [$order_id, false, false,false];
- }
- else {
- //其余皆失败
- return [$order_id, false, true,true];
- }
- }
- }
|