|
@@ -38,6 +38,170 @@ class Sandpay extends Api
|
|
|
}
|
|
|
}*/
|
|
|
|
|
|
+
|
|
|
+ //vip用的,创建订单废弃
|
|
|
+ public function sand_vip_recharge(){
|
|
|
+
|
|
|
+ $rc_id = input('rc_id',0);
|
|
|
+ $pay_type = input('pay_type','wechat');
|
|
|
+ $uid = $this->auth->id;
|
|
|
+
|
|
|
+ if(!$rc_id){
|
|
|
+ $this->error('请选择会员套餐');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //赋值money
|
|
|
+ $recharge_config = Db::name('payvip_config')->where('id',$rc_id)->find();
|
|
|
+ $money = $recharge_config['money'];
|
|
|
+
|
|
|
+ if($money<=0)
|
|
|
+ {
|
|
|
+ $this->error('支付金额必须大于0');
|
|
|
+ }
|
|
|
+ if($money > 10000){
|
|
|
+ $this->error('支付金额太大');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //会员等级冲突
|
|
|
+ //当前是会员,但是却要向下级续费,直接提示报错
|
|
|
+ //修改等级,向上立刻改,向下不允许
|
|
|
+ $wallet_info = model('wallet')->getWallet($this->auth->id);
|
|
|
+ if($wallet_info['vip_endtime'] > time() && $recharge_config['vip_level'] < $wallet_info['vip_level']){
|
|
|
+ $this->error('当前会员没有过期,不能续费');
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建订单
|
|
|
+ $data = [];
|
|
|
+ $data['status'] = 0;
|
|
|
+ $pay_no = createUniqueNo('V',$uid);
|
|
|
+ $data['pay_no'] = $pay_no;
|
|
|
+ $data['money'] = $money;
|
|
|
+ $data['payment_class'] = $pay_type;
|
|
|
+ $data['user_id'] = $uid;
|
|
|
+ $data['ext_info'] = json_encode(['subject'=>'充值vip支付']);
|
|
|
+ $data['memo'] = '充值会员支付';
|
|
|
+ $data['createtime'] = time();
|
|
|
+ //$data['payment'] = 'miniapp';
|
|
|
+ $data['payment'] = 'app';
|
|
|
+ $orderid = Db::name('pay_order')->insertGetId($data);
|
|
|
+
|
|
|
+ //创建回调
|
|
|
+ $even_data = [];
|
|
|
+ $even_data['event'] = 'success';
|
|
|
+ $even_data['class'] = 'app\common\model\Recharge';
|
|
|
+ $even_data['method'] = 'sandvippaysucc';
|
|
|
+ $even_data['args'] = json_encode(['user_id'=>$uid,'days'=>$recharge_config['days'],'vip_level'=>$recharge_config['vip_level'],'gold_num'=>$recharge_config['gold_num'],'money'=>$money]);
|
|
|
+ $even_data['pay_no'] = $pay_no;
|
|
|
+ Db::name('pay_event')->insertGetId($even_data);
|
|
|
+
|
|
|
+ //下单
|
|
|
+ $sandpay = new \app\common\library\Sandpay();
|
|
|
+ $sandpayParams = [
|
|
|
+ 'order_no' => $pay_no,//订单号
|
|
|
+ 'goods_name' => '充值会员',//商品名称
|
|
|
+ 'money' => $money,//金额
|
|
|
+ 'type' => 'vip',//会员
|
|
|
+ ];
|
|
|
+ $res = $sandpay->wechat($sandpayParams);
|
|
|
+ if ($res['status'] == 1) {
|
|
|
+ $this->success('成功', $res['data']);
|
|
|
+ }else {
|
|
|
+ $this->error('失败', $res['data']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //充值金币 创建订单废弃
|
|
|
+ public function sand_gold_recharge(){
|
|
|
+ exit;
|
|
|
+ $rc_id = input_post('rc_id',0);
|
|
|
+ $pay_type = input_post('pay_type','wechat');
|
|
|
+ $freemoney = input_post('freemoney', 0, 'intval');
|
|
|
+ $uid = $this->auth->id;
|
|
|
+
|
|
|
+ if(!$rc_id && !$freemoney){
|
|
|
+ $this->error('请选择或填写充值金额');
|
|
|
+ }
|
|
|
+// if(!$rc_id){
|
|
|
+// $this->error('请选择充值金额');
|
|
|
+// }
|
|
|
+
|
|
|
+ //赋值money
|
|
|
+ if($rc_id){
|
|
|
+ $recharge_config = Db::name('paygold_config')->where('id',$rc_id)->find();
|
|
|
+ $money = $recharge_config ? $recharge_config['money']: 0;
|
|
|
+ $gold = $recharge_config ? $recharge_config['gold'] : 0;
|
|
|
+ $first_gold = $recharge_config ? $recharge_config['first_gold'] : 0;
|
|
|
+ $first_vipdays = $recharge_config ? $recharge_config['first_vipdays'] : 0;
|
|
|
+ $vip_gold = $recharge_config ? $recharge_config['vip_gold'] : 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ //自由输入覆盖
|
|
|
+ if(!empty($freemoney)){
|
|
|
+ $rc_id = 0;
|
|
|
+ $money = floatval($freemoney);
|
|
|
+ $bili = config('site.rmb_to_gold') ?: 10;
|
|
|
+ $gold = bcmul($money,$bili,0);
|
|
|
+ $first_gold = 0;
|
|
|
+ $first_vipdays = 0;
|
|
|
+ $vip_gold = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ //
|
|
|
+ if($money<=0)
|
|
|
+ {
|
|
|
+ $this->error('支付金额必须大于0');
|
|
|
+ }
|
|
|
+ if($money > 10000){
|
|
|
+ $this->error('支付金额太大');
|
|
|
+ }
|
|
|
+ //查询是不是会员,若不是则不赠送金币
|
|
|
+ $vip_endtime = Db::name('user_wallet')->where('user_id',$this->auth->id)->value('vip_endtime');
|
|
|
+ if ($vip_endtime < time()) {
|
|
|
+ $vip_gold = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建订单
|
|
|
+ $data = [];
|
|
|
+ $data['status'] = 0;
|
|
|
+ $pay_no = createUniqueNo('P',$uid);
|
|
|
+ $data['pay_no'] = $pay_no;
|
|
|
+ $data['money'] = $money;
|
|
|
+ $data['payment_class'] = $pay_type;
|
|
|
+ $data['user_id'] = $uid;
|
|
|
+ $data['ext_info'] = json_encode(['subject'=>'充值金币支付']);
|
|
|
+ $data['memo'] = '充值金币支付';
|
|
|
+ $data['createtime'] = time();
|
|
|
+ $data['payment'] = 'app';
|
|
|
+ $orderid = Db::name('pay_order')->insertGetId($data);
|
|
|
+
|
|
|
+ //创建回调
|
|
|
+ $even_data = [];
|
|
|
+ $even_data['event'] = 'success';
|
|
|
+ $even_data['class'] = 'app\common\model\Recharge';
|
|
|
+ $even_data['method'] = 'sandgoldpaysucc';
|
|
|
+ $even_data['args'] = json_encode(['user_id'=>$uid,'gold'=>$gold,'money'=>$money,'pg_id'=>$rc_id,'first_gold'=>$first_gold,'first_vipdays'=>$first_vipdays, 'intro_uid' => $this->auth->intro_uid, 'vip_gold' => $vip_gold]);
|
|
|
+ $even_data['pay_no'] = $pay_no;
|
|
|
+ Db::name('pay_event')->insertGetId($even_data);
|
|
|
+
|
|
|
+ //下单
|
|
|
+ $sandpay = new \app\common\library\Sandpay();
|
|
|
+ $sandpayParams = [
|
|
|
+ 'order_no' => $pay_no,//订单号
|
|
|
+ 'goods_name' => '充值金币',//商品名称
|
|
|
+ 'money' => $money,//金额
|
|
|
+ 'type' => 'gold',//充值
|
|
|
+ ];
|
|
|
+ $res = $sandpay->wechat($sandpayParams);
|
|
|
+ if ($res['status'] == 1) {
|
|
|
+ $this->success('成功', $res['data']);
|
|
|
+ }else {
|
|
|
+ $this->error('失败', $res['data']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 支付成功(插件)
|
|
|
*/
|