Pay.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace Vip\Lib;
  3. use Dever;
  4. class Pay
  5. {
  6. /**
  7. * 支付成功后,调取的接口
  8. *
  9. * @return mixed
  10. */
  11. public function act_api($param = array())
  12. {
  13. $send = Dever::preInput('pay_');
  14. $key = md5('vip_buy');
  15. ksort($send);
  16. $send['signature'] = md5($key . '&' . http_build_query($send));
  17. $signature = Dever::input('signature');
  18. if ($send['signature'] == $signature) {
  19. $product_id = $send['pay_product_id'];
  20. $uid = $send['pay_uid'];
  21. $cash = $send['pay_cash'];
  22. $order_id = $send['pay_order_id'];
  23. $status = $send['pay_status'];
  24. $msg = $send['pay_msg'];
  25. $order = Dever::db('vip/order')->one(array('order_id' => $order_id, 'uid' => $uid));
  26. if ($send['pay_status'] == 2 && $order) {
  27. $update = array();
  28. $update['where_id'] = $order['id'];
  29. $update['status'] = 2;
  30. Dever::db('vip/order')->update($update);
  31. if ($order['type'] != 1) {
  32. return;
  33. }
  34. if ($order['buy_id'] > 0) {
  35. $buy = Dever::db('vip/time')->one($order['buy_id']);
  36. if ($buy) {
  37. $member = Dever::db('vip/member')->one(array('mobile' => $order['mobile'], 'cate_id' => $order['cate_id']));
  38. $insert['cate_id'] = $order['cate_id'];
  39. $insert['mobile'] = $order['mobile'];
  40. $insert['uid'] = $order['uid'];
  41. $time = time();
  42. if ($member) {
  43. if ($time > $member['end']) {
  44. $member['end'] = $time;
  45. }
  46. $insert['end'] = Dever::load('vip/lib/member')->getEnd($buy['time'], $buy['time_type'], $member['end']);
  47. $insert['where_id'] = $member['id'];
  48. Dever::db('vip/member')->update($insert);
  49. } else {
  50. $insert['end'] = Dever::load('vip/lib/member')->getEnd($buy['time'], $buy['time_type'], $time);
  51. $insert['start'] = $time;
  52. Dever::db('vip/member')->insert($insert);
  53. }
  54. # 发消息
  55. /*
  56. if (Dever::project('message')) {
  57. Dever::load('message/lib/data')->push(-1, $uid, '购买提醒', '购买成功,您获得了 '.$buy['name'].' 的会员资格!', 11);
  58. }
  59. # 发短信
  60. if (Dever::project('sms')) {
  61. $send = array();
  62. $send['name'] = $buy['name'];
  63. Dever::load('sms/api.send', 'buy_member', $order['mobile'], $send);
  64. }
  65. */
  66. }
  67. }
  68. } else {
  69. Dever::db('vip/order')->update(array('where_id' => $order['id'], 'status' => 3));
  70. }
  71. }
  72. }
  73. }