1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace refill\jike;
- require_once(BASE_HELPER_RAPI_PATH . '/jike/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;
- }
- }
- public static function sign($params)
- {
- ksort($params);
- $content = '';
- if(isset($params['refundAmount'])) {
- $params['refundAmount'] = number_format($params['refundAmount'], 2);
- }
- if(isset($params['amount'])) {
- $params['amount'] = number_format($params['amount'], 2);
- }
- if(isset($params['settlementAmount'])) {
- $params['settlementAmount'] = number_format($params['settlementAmount'], 2);
- }
- foreach ($params as $key => $value) {
- if(self::check_empty($value) === false) {
- $content .= "{$key}={$value}&";
- }
- }
- $content .= 'appSecret='.config::APP_SECRET;
- return md5($content);
- }
- public static 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)
- {
- $order_sn = $params['outOrderNo'];
- $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'];
- $status = intval($params['status']);
- $updata['ch_trade_no'] = $params['orderNo'];
- Model('refill_order')->edit($order_id, $updata);
- if ($status === 1) {
- $updata['official_sn'] = strtolower($params['officialNo']) == 'null' ? '' : $params['officialNo'];
- Model('refill_order')->edit($order_id, $updata);
- return [$order_id, true, false, true];
- } elseif ($status === 2 || $status === 3) {
- return [$order_id, false, true, true];
- } else {
- return [$order_id, false, false, false];
- }
- }
- }
|