Pay.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Journal\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('jmss_2018');
  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('journal/order')->one(array('order_id' => $order_id, 'uid' => $uid));
  26. if ($send['pay_status'] == 2 && $order) {
  27. Dever::db('journal/order')->update(array('where_id' => $order['id'], 'status' => 2));
  28. # 订阅
  29. Dever::load('act/lib/subscribe')->submit($uid, $product_id, 1);
  30. $num = false;
  31. if ($order['buy_id'] > 0) {
  32. $buy = Dever::db('journal/buy_num')->one($order['buy_id']);
  33. if ($buy && $buy['score'] > 0) {
  34. $num = $buy['score'];
  35. }
  36. }
  37. Dever::score($uid, 'buy_journal', '购买小刊', 'act/lib/score.submit?method=pay&type=4&id=' . $product_id, $num);
  38. # 发消息
  39. $journal = Dever::db('journal/info')->one($order['product_id']);
  40. Dever::load('message/lib/data')->push(-1, $uid, '购买提醒', '购买成功,您获得了 '.$journal['name'].' 的阅读资格!', $type = 1);
  41. } else {
  42. Dever::db('journal/order')->update(array('where_id' => $order['id'], 'status' => 3));
  43. }
  44. }
  45. }
  46. }