123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace Journal\Lib;
- use Dever;
- class Pay
- {
- /**
- * 支付成功后,调取的接口
- *
- * @return mixed
- */
- public function act_api($param = array())
- {
- $send = Dever::preInput('pay_');
- $key = md5('jmss_2018');
- ksort($send);
- $send['signature'] = md5($key . '&' . http_build_query($send));
- $signature = Dever::input('signature');
- if ($send['signature'] == $signature) {
- $product_id = $send['pay_product_id'];
- $uid = $send['pay_uid'];
- $cash = $send['pay_cash'];
- $order_id = $send['pay_order_id'];
- $status = $send['pay_status'];
- $msg = $send['pay_msg'];
- $order = Dever::db('journal/order')->one(array('order_id' => $order_id, 'uid' => $uid));
- if ($send['pay_status'] == 2 && $order) {
- Dever::db('journal/order')->update(array('where_id' => $order['id'], 'status' => 2));
- # 订阅
- Dever::load('act/lib/subscribe')->submit($uid, $product_id, 1);
- $num = false;
- if ($order['buy_id'] > 0) {
- $buy = Dever::db('journal/buy_num')->one($order['buy_id']);
- if ($buy && $buy['score'] > 0) {
- $num = $buy['score'];
- }
- }
- Dever::score($uid, 'buy_journal', '购买小刊', 'act/lib/score.submit?method=pay&type=4&id=' . $product_id, $num);
- # 发消息
- $journal = Dever::db('journal/info')->one($order['product_id']);
- Dever::load('message/lib/data')->push(-1, $uid, '购买提醒', '购买成功,您获得了 '.$journal['name'].' 的阅读资格!', $type = 1);
- } else {
- Dever::db('journal/order')->update(array('where_id' => $order['id'], 'status' => 3));
- }
- }
- }
- }
|