123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace refill\zhiren_doubi;
- require_once(BASE_HELPER_RAPI_PATH . '/zhiren_doubi/config.php');
- use refill;
- class RefillCallBack implements refill\IRefillCallBack
- {
- public function verify($params): bool
- {
- $input = $params;
- unset($input['verifyString']);
- $sign = $this->sign($input);
- if ($params['verifyString'] == $sign) {
- return true;
- } else {
- return false;
- }
- }
- private function sign($params)
- {
- ksort($params);
- $content = '';
- foreach ($params as $key => $value) {
- if($this->check_empty($value) === false) {
- $content .= "{$key}={$value}&";
- }
- }
- $content = $content . "key=" . config::Key;
- return md5($content);
- }
- private function check_empty($value)
- {
- if (!isset($value))
- return true;
- if ($value === null)
- return true;
- if (trim($value) === "")
- return true;
- return false;
- }
- public function notify($params)
- {
- $status = intval($params['status']);
- $order_sn = $params['clientOrderNo'];
- $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 === 4) {
- $data['official_sn'] = strtolower($params['officialOrderNo']) == 'null' ? '' : $params['officialOrderNo'];
- Model('refill_order')->edit($order_id, $data);
- return [$order_id, true, false, true];
- } elseif ($status === 3) {
- return [$order_id, false, true, true];
- } else {
- return [$order_id, false, false, false];
- }
- }
- }
|