| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- /**
- * 支付接口控制器
- *
- */
- namespace app\api\controller\v1;
- use app\api\controller\Api;
- use app\common\model\Members;
- use app\common\model\Game;
- use app\common\model\ChannelFrozen;
- use app\common\model\Cpurl;
- use app\common\model\Pay as PayModel;
- use app\common\model\PayCpinfo;
- use app\common\model\MemberChannelGame;
- use app\common\logic\PayCallback;
- use app\common\logic\Pay as PayLogic;
- use app\common\library\WeixinPay;
- use app\service\GamePayService;
- use app\service\MemberCoinService;
- use think\Db;
- use think\Config;
- use app\common\model\Setting;
- class PayCoin extends Api {
- protected $nowTime;
- protected $payRequestLimit = 15; //重复下单的限制时间
- protected $redis; //redis的句柄对象
- /**
- * 不进行父类的登录验证,所以增加构造方法重写了父类的初始化方法
- */
- public function _initialize()
- {
- parent::_initialize();
- $this->nowTime = NOW_TIMESTAMP;
- $this->redis = \think\Cache::store('default')->handler();
- }
- /**
- * 支付处理 新整理
- */
- public function index(){
- $data['type'] = 1; //类型 1充值平台币 2 充值游戏
- $data['paytype'] = input('paytype'); //支付类型
- $data['amount'] = input('amount'); //支付金额
- $data['accountType'] = 1; //账号类型1当前账号2其他账号
- $data['username'] = input('username');
- $data['gameid'] = input('gameid');
- $data['serverid'] = input('serverid');
- $data['roleid'] = input('roleid');
- $data['ip'] = request()->ip();
- $data['member_id'] = $this->input('userid'); //用户ID
- $checkResult = $this->validate($data,
- [
- ['type', 'require|integer|in:1,2', '类型不能为空|必须为整型'],
- ['paytype', 'require', '支付类型不能为空'],
- ['amount', 'require|integer|egt:0', '支付金额不能为空|支付金额必须为整型|支付金额大于等于0的整型'],
- ['accountType', 'require|in:1,2', '账号类型不能为空|账号类型错误'],
- ['username', 'requireIf:accountType,2', '账号必填'],
- ['gameid', 'requireIf:type,2|integer', '游戏必填|游戏必须为整型'],
- ['serverid', 'requireIf:type,2', '区服必填'],
- ['roleid', 'requireIf:type,2', '角色必填'],
- ['coin_amt', 'float|egt:0', '金额必须为数字|支付金额大于等于0'],
- ]);
- if (true !== $checkResult) {
- $this->result('', 0, $checkResult, 'json');
- }
- $data['coin_amt'] = 0;
- $result = (new MemberCoinService())->payCoin($data);
- if ($result['code'] == 1) {
- $this->jsonResult($result['data'], 1, (isset($result['data']['pay_status'])&&$result['data']['pay_status'] == 1) ? '付款成功' : '订单生成成功', false);
- } else {
- $this->jsonResult('', 0, $result['msg']);
- }
- }
- }
|