|
@@ -8,12 +8,15 @@ use Dever;
|
|
|
|
|
|
class Pay
|
|
|
{
|
|
|
+ # 发起支付
|
|
|
public function action($uid, $id, $sku, $num, $source)
|
|
|
{
|
|
|
if (!$uid) {
|
|
|
Dever::alert('错误的用户信息');
|
|
|
}
|
|
|
|
|
|
+ $source = 'android';
|
|
|
+
|
|
|
$goods = Dever::load('goods/lib/info')->getPayInfo($id, $sku);
|
|
|
|
|
|
$user = Dever::db('passport/user')->one($uid);
|
|
@@ -83,6 +86,54 @@ class Pay
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
+ # 支付成功回调 安全加密 设置token
|
|
|
+ public function success_secure_api_token()
|
|
|
+ {
|
|
|
+ $project_id = Dever::input('pay_project_id');
|
|
|
+ $info = Dever::db('pay/project')->one($project_id);
|
|
|
+ if ($info) {
|
|
|
+ return $info['key'];
|
|
|
+ }
|
|
|
+ return 'goods_dever_2020';
|
|
|
+ }
|
|
|
+
|
|
|
+ # 支付成功回调 安全加密
|
|
|
+ public function success_secure_api($param = array())
|
|
|
+ {
|
|
|
+ $this->success($param);
|
|
|
+ }
|
|
|
+
|
|
|
+ # 支付成功回调
|
|
|
+ public function success($param = array())
|
|
|
+ {
|
|
|
+ $send = $param ? $param : Dever::preInput('pay_');
|
|
|
+ $order_id = $send['pay_order_id'];
|
|
|
+ $status = $send['pay_status'];
|
|
|
+ $msg = $send['pay_msg'];
|
|
|
+
|
|
|
+ $order = Dever::db('goods/order')->one(array('order_id' => $order_id));
|
|
|
+
|
|
|
+ if ($order && $order['status'] == 1) {
|
|
|
+
|
|
|
+ if ($status == 2) {
|
|
|
+ # 增加积分
|
|
|
+ Dever::score($order['uid'], 'buy_goods', '购买商品');
|
|
|
+
|
|
|
+ # 发消息
|
|
|
+ if (Dever::project('message')) {
|
|
|
+ Dever::load('message/lib/data')->push(-1, $order['uid'], '购买提醒', '购买成功', 11);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $update['status'] = $status;
|
|
|
+ $update['where_id'] = $order['id'];
|
|
|
+ Dever::db('goods/order')->update($update);
|
|
|
+ }
|
|
|
+
|
|
|
+ return 'ok';
|
|
|
+ }
|
|
|
+
|
|
|
# 生成订单号
|
|
|
public function getOrderId()
|
|
|
{
|