RefillCallBack.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace refill\bjbnew;
  3. require_once(BASE_HELPER_RAPI_PATH . '/bjbnew/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['verifystring'] == $sign) {
  11. return true;
  12. } else {
  13. return false;
  14. }
  15. }
  16. private function sign($params)
  17. {
  18. $agentid = config::AGENT_ID;
  19. $key = config::MerchantKey;
  20. $content = "agentid={$agentid}&orderno={$params['orderno']}&orderstatus={$params['orderstatus']}&merchantKey={$key}";
  21. return md5($content);
  22. }
  23. public function notify($params)
  24. {
  25. $status = intval($params['orderstatus']);
  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. $data['official_sn'] = $params['supplierOrderNo'];
  33. Model('refill_order')->edit($order_id, $data);
  34. if ($status === 0014) {
  35. return [$order_id, true, false,true];
  36. }
  37. elseif ($status === 0015) {
  38. return [$order_id, false, true,true];
  39. }
  40. else {
  41. return [$order_id, false, false,false];
  42. }
  43. }
  44. }