|
@@ -51,14 +51,18 @@ class Pay extends Controller{
|
|
|
return json(["errno"=>101, "msg"=>"签名不对"]);
|
|
|
}
|
|
|
|
|
|
- $iapInfo = Db::name('iap_config')->where(['item_id'=>$order_id])->find();
|
|
|
+ $arr = explode("|", $exinfo);
|
|
|
+ $item_id = $arr[0];
|
|
|
+ $user_id = $arr[1];
|
|
|
+
|
|
|
+ $iapInfo = Db::name('iap_config')->where(['item_id'=>$item_id])->find();
|
|
|
if(empty($iapInfo)) return (json(['errno'=>1111, "msg"=>"商品ID错误"]));
|
|
|
|
|
|
$user = Db::name('user')->where(['id'=>$role_id])->find();
|
|
|
if(empty($user)) return (json(['errno'=>1111, 'msg'=>"用户ID错误"]));
|
|
|
|
|
|
$arr = array();
|
|
|
- $arr['user_id'] = $role_id;
|
|
|
+ $arr['user_id'] = $user_id;
|
|
|
$arr['pay_id'] = $iapInfo['id'];
|
|
|
$arr['out_trade_no'] = $order_id;
|
|
|
$arr['cost'] = $pay_money;
|
|
@@ -68,6 +72,29 @@ class Pay extends Controller{
|
|
|
return json(['errno'=>1, 'msg'=>""]);
|
|
|
}
|
|
|
|
|
|
+ public function get_reward()
|
|
|
+ {
|
|
|
+ $data = decode($this->request->post());
|
|
|
+ $user_id = $data['user_id'];
|
|
|
+
|
|
|
+ $user_pay = Db::name('user_pay')->where(['user_id'=>$user_id])->order('id DESC')->find();
|
|
|
+ if(!$user_pay)
|
|
|
+ {
|
|
|
+ return json(['error'=>0]);
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::name('user_pay')->update(["reward"=>1])->where(["id"=>$user_pay['id']]);
|
|
|
+
|
|
|
+ $pay_id = $user_pay['pay_id'];
|
|
|
+ $iap_info = Db::name('iap_config')->where(['id'=>$pay_id])->find();
|
|
|
+ if(!$iap_info)
|
|
|
+ {
|
|
|
+ return json(['error'=>0]);
|
|
|
+ }
|
|
|
+
|
|
|
+ return json(['error'=>0, "reward"=>$iap_info["reward"]]);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public function notify(){
|
|
|
echo 'success';
|