12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace refill\huiyuan;
- require_once(BASE_HELPER_RAPI_PATH . '/huiyuan/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)
- {
- $agent_id = config::AGENT_ID;
- $key = config::KEY;
- $content = "agent_id={$agent_id}&bill_id={$params['bill_id']}&jnet_bill_no={$params['jnet_bill_no']}&par_price={$params['par_price']}&purchase_amt={$params['purchase_amt']}";
- $content .= "&bill_charge_time={$params['bill_charge_time']}&bill_status={$params['bill_status']}|||{$key}";
- return md5($content);
- }
- public function notify($params)
- {
- $status = $params['bill_status'];
- $order_sn = $params['bill_id'];
- $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 === '成功') {
- $official_sn = strtolower($params['operator_bill_no']) == 'null' ? '' : $params['operator_bill_no'];
- $data['official_sn'] = $official_sn;
- Model('refill_order')->edit($order_id, $data);
- return [$order_id, true, false, true];
- } elseif ($status === '失败') {
- return [$order_id, false, true, true];
- } else {
- return [$order_id, false, false, false];
- }
- }
- }
|