123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace refill\lechong;
- require_once(BASE_HELPER_RAPI_PATH . '/lechong/config.php');
- use refill;
- class RefillCallBack implements refill\IRefillCallBack
- {
- public function verify($params): bool
- {
- $sign = $this->sign($params);
- if ($params['sign'] == $sign) {
- return true;
- } else {
- return false;
- }
- }
- private function sign($params)
- {
- $agentcode = config::AgentCode;
- $key = config::KEY;
- $content = "{$params['sellerid']}{$agentcode}{$params['account']}{$params['value']}{$params['payvalue']}{$params['voucher']}{$params['createtime']}{$params['endtime']}";
- $content .= "{$params['state']}{$params['remark']}{$params['time']}{$key}";
- return md5($content);
- }
- public function notify($params)
- {
- $status = intval($params['state']);
- $order_sn = $params['sellerid'];
- $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
- if (empty($order_info)) {
- return [false, false, false,false];
- }
- $order_id = $order_info['order_id'];
- if ($status === 2) {
- $data['official_sn'] = strtolower($params['voucher']) == 'null' ? '' : $params['voucher'];
- Model('refill_order')->edit($order_id, $data);
- return [$order_id, true, false,true];
- }
- elseif (in_array($status, [4,-11])) {
- return [$order_id, false, true,true];
- }
- else {
- return [$order_id, false, false,false];
- }
- }
- }
|