|
@@ -159,134 +159,139 @@ class Pay
|
|
|
$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'];
|
|
|
+ $this->act_action($send);
|
|
|
+ }
|
|
|
|
|
|
- $order = Dever::db('act/order')->one(array('order_id' => $order_id, 'uid' => $uid));
|
|
|
+ return 'ok';
|
|
|
+ }
|
|
|
|
|
|
- if ($send['pay_status'] == 2 && $order) {
|
|
|
+ public function act_action($send)
|
|
|
+ {
|
|
|
+ $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('act/order')->one(array('order_id' => $order_id, 'uid' => $uid));
|
|
|
+
|
|
|
+ if ($send['pay_status'] == 2 && $order) {
|
|
|
+
|
|
|
+ $update = array();
|
|
|
+ $update['where_id'] = $order['id'];
|
|
|
+ $update['status'] = 2;
|
|
|
+ if ($order['type'] == 3 && !$order['code']) {
|
|
|
+ if ($order['system'] == 2) {
|
|
|
+ $code = Dever::load('code/lib/core')->createCodeByOrder($order);
|
|
|
+ } else {
|
|
|
+ $code = Dever::load('code/lib/core')->createCodeByOrder($order, -1);
|
|
|
+ }
|
|
|
|
|
|
- $update = array();
|
|
|
- $update['where_id'] = $order['id'];
|
|
|
- $update['status'] = 2;
|
|
|
- if ($order['type'] == 3 && !$order['code']) {
|
|
|
- if ($order['system'] == 2) {
|
|
|
- $code = Dever::load('code/lib/core')->createCodeByOrder($order);
|
|
|
- } else {
|
|
|
- $code = Dever::load('code/lib/core')->createCodeByOrder($order, -1);
|
|
|
- }
|
|
|
-
|
|
|
- if ($code) {
|
|
|
- $update['code'] = $code;
|
|
|
- }
|
|
|
+ if ($code) {
|
|
|
+ $update['code'] = $code;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- Dever::db('act/order')->update($update);
|
|
|
-
|
|
|
- $score = false;
|
|
|
- $num = false;
|
|
|
- $journal = Dever::load('act/order')->getJournal($order['product_id']);
|
|
|
- if ($order['buy_id'] > 0) {
|
|
|
- $buy = Dever::load('act/order')->getBuy($order['buy_id']);
|
|
|
- if ($buy && $buy['score'] > 0) {
|
|
|
- $score = $buy['num'] * $buy['score'];
|
|
|
- } else {
|
|
|
- if ($order['type'] == 1) {
|
|
|
- # 直接购买
|
|
|
- $col = 'score';
|
|
|
- } elseif ($order['type'] == 3) {
|
|
|
- $col = 'dh_score';
|
|
|
- }
|
|
|
-
|
|
|
- if ($journal && $buy && $journal[$col] > 0) {
|
|
|
- $score = $buy['num'] * $journal[$col];
|
|
|
- } elseif ($journal && $buy) {
|
|
|
- $num = $buy['num'];
|
|
|
- }
|
|
|
+ Dever::db('act/order')->update($update);
|
|
|
+
|
|
|
+ $score = false;
|
|
|
+ $num = false;
|
|
|
+ $journal = Dever::load('act/order')->getJournal($order['product_id']);
|
|
|
+ if ($order['buy_id'] > 0) {
|
|
|
+ $buy = Dever::load('act/order')->getBuy($order['buy_id']);
|
|
|
+ if ($buy && $buy['score'] > 0) {
|
|
|
+ $score = $buy['num'] * $buy['score'];
|
|
|
+ } else {
|
|
|
+ if ($order['type'] == 1) {
|
|
|
+ # 直接购买
|
|
|
+ $col = 'score';
|
|
|
+ } elseif ($order['type'] == 3) {
|
|
|
+ $col = 'dh_score';
|
|
|
}
|
|
|
|
|
|
- if ($buy && $buy['num']) {
|
|
|
+ if ($journal && $buy && $journal[$col] > 0) {
|
|
|
+ $score = $buy['num'] * $journal[$col];
|
|
|
+ } elseif ($journal && $buy) {
|
|
|
+ $num = $buy['num'];
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- $active = Dever::load('act/order')->getActive($order['product_id']);
|
|
|
- $active_state = true;
|
|
|
- if ($active && $active['status'] == 2) {
|
|
|
- //$active_state = false;
|
|
|
- }
|
|
|
- if ($active && time() > $active['end']) {
|
|
|
- $active_state = false;
|
|
|
- }
|
|
|
- if ($active_state) {
|
|
|
- # 增加本数
|
|
|
- Dever::load('act/lib/num')->submit($order['product_id'], $order['uid'], $buy['num']);
|
|
|
- }
|
|
|
+ if ($buy && $buy['num']) {
|
|
|
|
|
|
- # 增加订阅数
|
|
|
- Dever::load('act/lib/num')->setCounter($order['product_id'], $buy['num']);
|
|
|
+ $active = Dever::load('act/order')->getActive($order['product_id']);
|
|
|
+ $active_state = true;
|
|
|
+ if ($active && $active['status'] == 2) {
|
|
|
+ //$active_state = false;
|
|
|
+ }
|
|
|
+ if ($active && time() > $active['end']) {
|
|
|
+ $active_state = false;
|
|
|
+ }
|
|
|
+ if ($active_state) {
|
|
|
+ # 增加本数
|
|
|
+ Dever::load('act/lib/num')->submit($order['product_id'], $order['uid'], $buy['num']);
|
|
|
}
|
|
|
- }
|
|
|
- # 积分
|
|
|
- Dever::score($order['uid'], 'buy_journal', '购买小刊', '', $score, $num);
|
|
|
|
|
|
- if ($order['system'] == 2) {
|
|
|
- return;
|
|
|
+ # 增加订阅数
|
|
|
+ Dever::load('act/lib/num')->setCounter($order['product_id'], $buy['num']);
|
|
|
}
|
|
|
+ }
|
|
|
+ # 积分
|
|
|
+ Dever::score($order['uid'], 'buy_journal', '购买小刊', '', $score, $num);
|
|
|
|
|
|
- # 发消息
|
|
|
- $journal['id'] = $order['product_id'];
|
|
|
- $journal['name'] = $order['name'];
|
|
|
- if (strstr('-', $journal['name'])) {
|
|
|
- $name = explode('-', $journal['name']);
|
|
|
- $journal['name'] = $name[0];
|
|
|
- }
|
|
|
-
|
|
|
- //$journal = Dever::db('journal/info')->one($order['product_id']);
|
|
|
+ if ($order['system'] == 2) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if (Dever::project('message')) {
|
|
|
- Dever::load('message/lib/data')->push(-1, $order['uid'], '购买提醒', '购买成功,您获得了 '.$journal['name'].' 的阅读资格!', 11, $order['cate_id'], 1, Dever::load('act/lib/note')->push(4, $journal['id'], $journal['name']));
|
|
|
- }
|
|
|
+ # 发消息
|
|
|
+ $journal['id'] = $order['product_id'];
|
|
|
+ $journal['name'] = $order['name'];
|
|
|
+ if (strstr('-', $journal['name'])) {
|
|
|
+ $name = explode('-', $journal['name']);
|
|
|
+ $journal['name'] = $name[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ //$journal = Dever::db('journal/info')->one($order['product_id']);
|
|
|
|
|
|
- $user = Dever::db('passport/user')->one($order['uid']);
|
|
|
+ if (Dever::project('message')) {
|
|
|
+ Dever::load('message/lib/data')->push(-1, $order['uid'], '购买提醒', '购买成功,您获得了 '.$journal['name'].' 的阅读资格!', 11, $order['cate_id'], 1, Dever::load('act/lib/note')->push(4, $journal['id'], $journal['name']));
|
|
|
+ }
|
|
|
|
|
|
- # 发短信
|
|
|
- /*
|
|
|
- if (isset($user['mobile']) && $user['mobile'] && Dever::project('sms') && $order['cate_id'] == 1) {
|
|
|
- $send = array();
|
|
|
- $send['name'] = $journal['name'];
|
|
|
- Dever::load('sms/api.send', 'buy_journal', $user['mobile'], $send);
|
|
|
- }
|
|
|
- */
|
|
|
-
|
|
|
- # 发模板消息
|
|
|
- $wechat = Dever::db('passport/wechat')->one(array('uid' => $order['uid'], 'type' => 1, 'system_id' => $order['cate_id']));
|
|
|
- if ($wechat && Dever::project('wechat_applet')) {
|
|
|
- $send['key'] = 'buy_journal';
|
|
|
- $send['project_id'] = $order['cate_id'];
|
|
|
- $send['touser'] = $wechat['openid'];
|
|
|
- $send['page'] = Dever::config('base')->applet_index . '?scene=' . $order['uid'] . ',' . '4,' . $order['product_id'];
|
|
|
- $send['data'] = array
|
|
|
- (
|
|
|
- 'keyword1' => array('value' => date('Y年m月d日 H:i', $order['cdate'])),
|
|
|
- 'keyword2' => array('value' => '购买成功,您获得了 '.$journal['name'].' 的阅读资格!'),
|
|
|
- );
|
|
|
- $send['data'] = json_encode($send['data']);
|
|
|
- $send['form_id'] = Dever::load('act/lib/form')->get($order['uid'], 2, $order['cate_id']);
|
|
|
-
|
|
|
- if ($send['form_id']) {
|
|
|
- Dever::load('wechat_applet/msg.send', $send);
|
|
|
- }
|
|
|
- }
|
|
|
+ $user = Dever::db('passport/user')->one($order['uid']);
|
|
|
|
|
|
- } else {
|
|
|
- Dever::db('act/order')->update(array('where_id' => $order['id'], 'status' => 3));
|
|
|
+ # 发短信
|
|
|
+ /*
|
|
|
+ if (isset($user['mobile']) && $user['mobile'] && Dever::project('sms') && $order['cate_id'] == 1) {
|
|
|
+ $send = array();
|
|
|
+ $send['name'] = $journal['name'];
|
|
|
+ Dever::load('sms/api.send', 'buy_journal', $user['mobile'], $send);
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
+ # 发模板消息
|
|
|
+ $wechat = Dever::db('passport/wechat')->one(array('uid' => $order['uid'], 'type' => 1, 'system_id' => $order['cate_id']));
|
|
|
+ if ($wechat && Dever::project('wechat_applet')) {
|
|
|
+ $send['key'] = 'buy_journal';
|
|
|
+ $send['project_id'] = $order['cate_id'];
|
|
|
+ $send['touser'] = $wechat['openid'];
|
|
|
+ $send['page'] = Dever::config('base')->applet_index . '?scene=' . $order['uid'] . ',' . '4,' . $order['product_id'];
|
|
|
+ $send['data'] = array
|
|
|
+ (
|
|
|
+ 'keyword1' => array('value' => date('Y年m月d日 H:i', $order['cdate'])),
|
|
|
+ 'keyword2' => array('value' => '购买成功,您获得了 '.$journal['name'].' 的阅读资格!'),
|
|
|
+ );
|
|
|
+ $send['data'] = json_encode($send['data']);
|
|
|
+ $send['form_id'] = Dever::load('act/lib/form')->get($order['uid'], 2, $order['cate_id']);
|
|
|
+
|
|
|
+ if ($send['form_id']) {
|
|
|
+ Dever::load('wechat_applet/msg.send', $send);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- return 'ok';
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ Dever::db('act/order')->update(array('where_id' => $order['id'], 'status' => 3));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public function send_api()
|
|
|
{
|