RefillCallBack.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace refill\weishengy;
  3. require_once(BASE_HELPER_RAPI_PATH . '/weishengy/config.php');
  4. use refill;
  5. class RefillCallBack implements refill\IRefillCallBack
  6. {
  7. public function verify($params): bool
  8. {
  9. $sign = $this->sign($params);
  10. if ($params['sign'] == $sign) {
  11. return true;
  12. } else {
  13. return false;
  14. }
  15. }
  16. private function sign($params)
  17. {
  18. $masId = config::masId;
  19. $content = "masId={$masId}&oids={$params['oids']}&orderNo={$params['orderNo']}&orderPrice={$params['orderPrice']}&phone={$params['phone']}";
  20. $content .= "&status={$params['status']}&time={$params['time']}&type={$params['type']}";
  21. return strtoupper(md5($content));
  22. }
  23. public function notify($params)
  24. {
  25. $status = $params['status'];
  26. $order_sn = $params['orderNo'];
  27. $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
  28. if (empty($order_info)) {
  29. return [false, false, false,false];
  30. }
  31. $order_id = $order_info['order_id'];
  32. if ($status == 1) {
  33. $data['official_sn'] = strtolower($params['oids']) == 'null' ? '' : $params['oids'];
  34. Model('refill_order')->edit($order_id, $data);
  35. return [$order_id, true, false,true];
  36. }
  37. // elseif ($status == 2) {
  38. // return [$order_id, false, false,true];
  39. // }
  40. else {
  41. return [$order_id, false, false,false];
  42. }
  43. }
  44. }