123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace refill\zhenghe;
- require_once(BASE_HELPER_RAPI_PATH . '/zhenghe/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)
- {
- $mchid = config::MCHID;
- $key = config::KEY;
- $content = "mchid={$mchid}&orderid={$params['orderid']}&oid={$params['oid']}&number={$params['number']}&status={$params['status']}&key={$key}";
- return md5($content);
- }
- public function notify($params)
- {
- $order_sn = $params['orderid'];
- $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'];
- $status = intval($params['status']);
- if ($status === 2) {
- $official_sn = strtolower($params['voucher']) == 'null' ? '' : $params['voucher'];
- $data['official_sn'] = $official_sn;
- Model('refill_order')->edit($order_id, $data);
- return [$order_id, true, false, true, $official_sn];
- } elseif ($status === 3) {
- return [$order_id, false, true, true, ''];
- } else {
- return [$order_id, false, false, false, ''];
- }
- }
- }
|