123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace refill\leyou;
- require_once(BASE_HELPER_RAPI_PATH . '/leyou/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)
- {
- $key = config::APP_KEY;
- $content = "{$params['username']}{$params['orderNumber']}{$params['number']}{$params['money']}[{$params['status']}]{$params['endTime']}$key";
- return md5($content);
- }
- public function notify($params)
- {
- $status = intval($params['status']);
- $order_sn = $params['orderNumber'];
- $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 === 5) {
- $official_sn = config::extract_official_sn($params['voucher']);
- Model('refill_order')->edit($order_id, ['official_sn' => $official_sn]);
- return [$order_id, true, false, true, ''];
- }
- elseif ($status === 6) {
- return [$order_id, false, true, true, ''];
- }
- else {
- return [$order_id, false, false, false, ''];
- }
- }
- }
|