| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876 |
- <?php
- namespace Biz\Money;
- /**
- * 资金操作相关类
- */
- class Moneycopy {
- /**
- * 资金明细表
- * @var string
- */
- private $money_table = 'fund_detailed';
- /**
- * 用户详情表
- * @var string
- */
- private $account_detailed = 'account_detailed';
- /**
- * 用户银行绑定记录表
- * @var string
- */
- private $bank_table = 'account_bank';
- /**
- * 用户表
- * @var string
- */
- private $account_table = 'account';
- /**
- * 交易密码表
- * @var string
- */
- private $pay_password = 'pay_password';
- /**
- * 代理信息表
- * @var string
- */
- private $agent = 'agent_detailed';
- /**
- * 代理资金表
- * @var string
- */
- private $agent_money = 'agent_money';
- /**
- * 佣金记录表
- * @var string
- */
- private $money_reward = 'money_reward';
- /**
- * 资金明细表
- * @var string
- */
- private $money_details = 'money_details';
- /**
- * 中奖记录表
- * @var string
- */
- private $prize_table = 'money_prize';
- /**
- * 提现记录表
- * @var string
- */
- private $money_take = 'money_take';
- /**
- * 充值记录
- * @var string
- */
- private $money_recharge = 'money_recharge';
- /**
- * 反水记录表
- * @var string
- */
- private $money_back = 'money_back';
- /**
- * 回水记录表
- * @var string
- */
- private $money_return = 'money_return';
- //private $game;
- public function init() {
- }
- /**
- * 绑定银行卡
- * @param [type] $account_identity 用户id
- * @param [type] $bank_address 开户银行地址
- * @param [type] $bank_name 银行名称
- * @param [type] $bank_no 银行卡号
- * @param [type] $bank_user 银行卡用户
- * @param [type] $pay_pwd 支付密码
- * @param [type] $sure_pwd 确认密码
- * @return [type] [description]
- */
- public function bind_bank($account_identity, $bank_address, $bank_name, $bank_no, $bank_user, $pay_pwd, $sure_pwd) {
- //判断重要参数是否为空
- if (empty($account_identity)) {
- //Render('null','-2001',lang()->get('user not login'));
- return '-2001';
- }
- if (empty($bank_address)) {
- //Render('null','-2002',lang()->get('bank_address missing'));
- return '-2002';
- }
- if (empty($bank_name)) {
- //Render('null','-2003',lang()->get('bank_name missing'));
- return '-2003';
- }
- if (empty($bank_no)) {
- //Render('null','-2004',lang()->get('bank_number missing'));
- return '-2004';
- }
- if (empty($bank_user)) {
- //Render('null','-2005',lang()->get('bank_user missing'));
- return '-2005';
- }
- if (empty($pay_pwd) || empty($sure_pwd)) {
- //Render('null','-2006',lang()->get('password missing'));
- return '-2006';
- }
- //判断两次交易密码是否一致
- if ($pay_pwd != $sure_pwd) {
- //Render('null','-2007',lang()->get('two password not equal'));
- return '-2007';
- }
- //验证用户是否已设置交易密码
- $enc = lm($this->pay_password, 'commons')->select('encryption')->where('account_identity', $account_identity)->first()->toArray();
- $VerPwd = md5(md5($enc["encryption"] . $pay_pwd));
- $judge = lm($this->pay_password, 'commons')->where(['account_identity' => $account_identity, 'pay_password' => $VerPwd])->first();
- if (empty($judge)) {
- //Render('null','-2008',lang()->get('pay_pwd not set'));
- return '-2008';
- }
- //验证交易密码
- if (!$this->verifyPayPwd($account_identity, $pay_pwd)) {
- return '-2020';
- }
- //验证用户是否已经绑定了该银行卡
- $res = lm($this->bank_table, 'commons')->where(['account_identity' => $account_identity, 'bank_number' => $bank_no])->first();
- if ($res) {
- return '-2033';
- }
- //为用户绑定银行卡
- $data = array(
- 'identity' => UUID(),
- 'account_identity' => $account_identity,
- 'bank_address' => $bank_address,
- 'bank_name' => $bank_name,
- 'account_name' => $bank_user,
- 'bank_number' => $bank_no,
- 'band_time' => date('Y-m-d H:i:s', time()),
- );
- $res = lm($this->bank_table, 'commons')->insert($data);
- if ($res) {
- //Render('null','1',lang()->get('success'));
- return 1;
- } else {
- //Render('null','-2009',lang()->get('fail'));
- return '-2009';
- }
- }
- /**
- * 设置默认银行卡或者解绑银行卡
- * @param [type] $account_identity 用户id
- * @param [type] $bank_no 银行卡号
- * @param [type] $pay_pwd 交易密码
- * @param [type] $type 类型 1.设置默认银行卡,-1,解除该银行卡绑定
- * @return [type] [description]
- */
- public function bankStatus($account_identity, $bank_no, $pay_pwd, $type) {
- if ($type == 1) {
- $type = 2;
- }
- if (!$this->verifyPayPwd($account_identity, $pay_pwd)) {
- return '-2020';
- }
- $res = lm($this->bank_table, 'commons')->where(['account_identity' => $account_identity, 'bank_number' => $bank_no])->update(['status' => $type]);
- if ($res) {
- return '1';
- } else {
- return '-2016';
- }
- }
- /**
- * 设置交易密码
- * @param [type] $account_identity 用户id
- * @param [type] $pay_pwd 密码
- * @param [type] $sure_pwd 确认密码
- */
- public function setPayPwd($account_identity, $pay_pwd, $sure_pwd) {
- //判断重要参数是否为空
- if (empty($account_identity)) {
- //Render('null','-2010',lang()->get('user not login'));
- return '-2010';
- }
- if (empty($pay_pwd) || empty($sure_pwd)) {
- //Render('null','-2011',lang()->get('password missing'));
- return '-2006';
- }
- //判断两次交易密码是否一致
- if ($pay_pwd != $sure_pwd) {
- //Render('null','-2012',lang()->get('two password not equal'));
- return '-2007';
- }
- //检查用户是否已经设置密码
- $judge = lm($this->pay_password, 'commons')->where(['account_identity' => $account_identity])->first();
- if ($judge) {
- return '-2017';
- }
- //为用户设置交易密码
- $pwd = GenPassword($pay_pwd);
- $data = array(
- 'identity' => UUID(),
- 'pay_password' => $pwd['password'],
- 'encryption' => $pwd['encryption'],
- 'account_identity' => $account_identity,
- );
- $res = lm($this->pay_password, 'commons')->insert($data);
- if ($res) {
- //Render('null','1',lang()->get('success'));
- return '1';
- } else {
- //Render('null','-2013',lang()->get('fail'));
- return '-2013';
- }
- }
- /**
- * 投注追号
- * @param [type] $user_id 用户id
- * @param [type] $money 投注追号金额
- * @param array $extra 其他数据
- * @return [type] [description]
- */
- public function betting($user_id, $money, $extra = array()) {
- $type = 1;
- //处理数据
- if (isset($extra['type_name']) && !empty($extra['type_name'])) {
- $game = new \Biz\Game\GameQuery;
- $res = $game->getGameInfo($extra['type_name']);
- $extra['game_type'] = $res['identity'];
- unset($extra['type_name']);
- }
- $data = $extra;
- return $this->updateMoney($user_id, $money, $type, $data);
- }
- /**
- * 中奖
- */
- public function prize($user_id, $money, $game_type, $buy_identity) {
- $type = 0;
- $data['money_type'] = 7;
- $data['identity'] = UUID();
- $data['order_id'] = OrderID();
- $data['game_type'] = $game_type;
- $data['buy_identity'] = $buy_identity;
- return $this->updateMoney($user_id, $money, $type, $data);
- }
- /**
- * 充值
- * @param $user_id 用户id
- * @param $money 充值金额
- * @param array $extra 其他参数数组
- */
- public function addMoney($user_id, $money, $extra = array()) {
- $type = 0;
- $data = $extra;
- $data['money_type'] = 3;
- //$data['identity']= UUID();
- $data['order_id'] = OrderID();
- return $this->updateMoney($user_id, $money, $type, $data);
- }
- /**
- * 提现
- * @param array $user_id 用户id
- * @param array $money 提现金额
- * @param array $pay_pwd 交易密码
- * @return [type] [description]
- */
- public function takeMoney($user_id, $money, $pay_pwd, $bank_no) {
- if ($money < 100) {
- return '-2112';
- }
- $account = $this->getAccount($user_id);
- if (!$this->verifyAccount($account['available_cash'], $account['cash'], $account['frozen_cash'])) {
- return '-2021';
- }
- if (!$this->verifyMoney($money, $account['available_cash'])) {
- return '-2022';
- }
- //验证交易密码
- if (!$this->verifyPayPwd($user_id, $pay_pwd)) {
- return '-2020';
- }
- $data['account_identity'] = $user_id;
- $data['account_name'] = $account['account_name'];
- $data['identity'] = UUID();
- $data['order_id'] = OrderID();
- $data['money_time'] = date('Y-m-d H:i:s', time());
- $data['money_date'] = date('Y-m-d', time());
- $data['money_type'] = 4;
- $data['remarks'] = $bank_no;
- $data['money'] = $money;
- $res = lm($this->money_table, 'commons')->insert($data);
- if ($res) {
- //Render('null','1',lang()->get('success'));
- return '1';
- } else {
- // Render('null','-2014',lang()->get('cash fail'));
- return '-2014';
- }
- }
- /**
- * 更新资金
- * @param [type] $user_id 用户id
- * @param [type] $money 操作金额
- * @param integer $type 变化资金类型
- * @param array $extra 扩展数组
- * @return [type] [description]
- */
- public function updateMoney($user_id, $money, $type = 0, $extra = array()) {
- if (empty($extra['game_type'])) {
- $extra['game_type'] = 1;
- }
- $extra['buy_identity'] = isset($extra['buy_identity']) ? $extra['buy_identity'] : '';
- $account = $this->getAccount($user_id); //获取用户信息
- //验证账户异常
- if (!$this->verifyAccount($account['available_cash'], $account['cash'], $account['frozen_cash'])) {
- return 'error-2021';
- }
- //验证用户金额
- if (!$this->verifyMoney($money, $account['available_cash'])) {
- return 'error-2022';
- }
- //判断是那种更新
- if ($type == 0) {
- //增加资金
- $nowMoney = $account['available_cash'] + $money;
- $now_allMoney = $account['cash'] + $money;
- } else {
- //资金减少
- $nowMoney = $account['available_cash'] - $money;
- $now_allMoney = $account['cash'] - $money;
- }
- //更新用户余额
- $res = lm($this->account_detailed, 'Commons')
- ->where('account_identity', $user_id)
- ->update(
- ['cash' => $now_allMoney, 'available_cash' => $nowMoney]
- );
- if (!$res) {
- // Render('null','-2015',lang()->get('change fail'));
- return 'error-2016';
- }
- //查询剩余金额
- $extra['money_cash'] = lm($this->account_detailed, 'Commons')->where('account_identity', $user_id)->value('cash');
- // $data = array(
- // 'identity' => UUID(),
- // 'account_identity' => $user_id,
- // 'account_name' => $account['account_name'],
- // 'money_type' => $extra['money_type'],
- // 'money' => $money,
- // 'remarks' => $extra['buy_identity'],
- // 'order_id' => $extra['order_id'],
- // 'money_time' => date('Y-m-d H:i:s', time()),
- // 'money_date' => date('Y-m-d', time()),
- // 'game_type' => $extra['game_type'],
- // 'cur_cash' => $nowMoney,
- // 'status' => 1,
- // );
- // $result = lm($this->money_table, 'commons')->insert($data);
- $data = array(
- 'info_identity' => UUID(),
- 'trade_id' => $extra['order_number'],
- 'account_name' => $account['account_name'],
- 'account_identity'=> account_identity,
- 'money_type' => $extra['money_type'],//1.增加 2.减少
- 'money' => $money,
- 'money_time'=>$extra['money_time'],
- 'money_cash' => $extra['money_cash'],//剩余金额
- 'trade_type' => $extra['trade_type'],//交易类型
- 'trade_desc' => $extra['trade_desc'],//交易描述
- 'reason' => $extra['reason'],//理由
- // 'status' => $extra['status'], //1.成功,2失败
- );
- $result = lm('Money_details', 'commons')->insert($data);
- if (!$result) {
- // Render('null','2014',lang()->get('change fail'));
- return 'error-2016';
- }
- //Render('null','1',lang()->get('success'));
- return '1';
- }
- /**
- * 撤单
- * @param [type] $user_id 用户id
- * @param [type] $order_id 订单id
- * @param [type] $money 操作金额
- * @return [type] [description]
- */
- public function cancel($user_id, $order_id) {
- $money = lm($this->money_table, 'commons')->where('order_id', $order_id)->first()->money;
- $account = $this->getAccount($user_id);
- $nowMoney = $account['available_cash'] + $money;
- $now_allMoney = $account['cash'] + $money;
- //更新用户金额
- $res = lm($this->account_detailed, 'Commons')
- ->where('account_identity', $user_id)
- ->update(
- ['cash' => $now_allMoney, 'available_cash' => $nowMoney]
- );
- if ($res) {
- return '-2034';
- }
- //修改状态
- $res = lm($this->money_table, 'commons')->where('order_id', $order_id)->update(['state' => '0']);
- if ($res) {
- return '-2034';
- }
- return '1';
- }
- /**
- * 验证账户金额是否足够
- * @param [type] $money 操作所需金额
- * @param [type] $available_cash 账户可用金额
- * @return [type] [description]
- */
- public function verifyMoney($money, $available_cash) {
- if ($available_cash > $money) {
- return true;
- } else {
- return false;
- }
- }
- /**
- * 验证账户金额是否异常
- * @param [type] $available_cash 账户可用金额
- * @param [type] $cash 账户总金额
- * @param [type] $frozen_cash 冻结金额
- * @return [type] true or FALSE
- */
- public function verifyAccount($available_cash, $cash, $frozen_cash) {
- if ($cash == $available_cash + $frozen_cash) {
- return true;
- } else {
- return false;
- }
- }
- /**
- * 验证交易密码
- * @param [type] $account_identity 用户唯一id
- * @param [type] $pwd 密码
- * @return [type] true or false
- */
- public function verifyPayPwd($account_identity,$pwd) {
- $enc = lm($this->pay_password,'commons')->select('encryption')->where('account_identity', $account_identity)->first();
- dump($enc);die;
- // ->toArray()
- $VerPwd = md5(md5($enc["encryption"] . $pwd));
- $res = lm($this->pay_password,'commons')->where(['account_identity' => $account_identity, 'pay_password' => $VerPwd])->first();
- if ($res) {
- return true;
- } else {
- return false;
- }
- }
- /**
- * 获取用户信息
- * @param [type] $account_identity 用户唯一id
- * @return [type] 用户资金相关数组
- */
- public function getAccount($account_identity) {
- $data = array();
- $res = lm($this->account_detailed, 'Commons')
- ->select('available_cash', 'cash', 'frozen_cash', 'account_identity')
- ->where('account_identity', $account_identity)
- ->first()
- ->toArray();
- $res2 = lm($this->account_table, 'commons')->select('account')->where('identity', $account_identity)->first()->toArray();
- $data = $res;
- $data['account_name'] = $res2['account'];
- return $data;
- }
- /**
- * 根据代理id获取代理信息
- * @param [string] $agent_id 代理id
- * @return [array] 代理相关信息
- */
- public function getAgent($agent_id) {
- $res = lm($this->agent, 'Commons')
- ->select('agent_user', 'agent_identity', 'take_money')
- ->where('agent_identity', $agent_id)
- ->first();
- if ($res) {
- $agent = $res->toArray();
- } else {
- return '-2001';
- }
- return $agent;
- }
- /**
- * 新中奖信息
- * @param [type] $account_identity 用户id
- * @param [type] $money 金额
- * @param [type] $game_name 游戏英文名
- * @return [type] [description]
- */
- public function newPrize($account_identity, $money, $game_name, $buy_id) {
- $game = new \Biz\Game\GameQuery;
- //获取游戏信息
- $game = $game->getGameInfo($game_name);
- //获取用户信息
- $account = $this->getAccount($account_identity);
- //生成订单id
- $order_id = OrderID();
- //生成信息id
- $info_id = UUID();
- //将中奖插入中奖记录
- $data = array(
- 'game_name' => $game['name'],
- 'buy_id' => $buy_id,
- 'account_name' => $account['account_name'],
- 'account_identity' => $account_identity,
- 'order_id' => $order_id,
- 'info_identity' => $info_id,
- 'money' => $money,
- 'money_time' => date('Y-m-d H:i:s', time()),
- );
- $res = lm($this->prize_table, 'Commons')->insert($data);
- if ($res) {
- $type = 4;
- return $this->insertMoney($account_identity, $money, $order_id, $type);
- } else {
- return '-2113';
- }
- }
- /**
- * 申请提现接口
- * @param [type] $account_identity 用户id
- * @param [type] $money 金额
- * @param [type] $bank_no 银行卡号
- * @param [type] $pwd 支付密码
- * @return [type] [description]
- */
- public function apply_money($account_identity, $money, $bank_no, $pwd) {
- //验证交易密码
- /*if (!$this->verifyPayPwd($account_identity, $pwd)) {
- return -2020;
- }*/
- //获取用户信息
- $account = $this->getAccount($account_identity);
- //获取用户银行卡信息
- $bank_info = $this->getBankInfo($account_identity, $bank_no);
- //生成订单id
- $order_id = OrderID();
- //插入提现申请记录
- $data = array(
- 'info_identity' => UUID(),
- 'order_id' => $order_id,
- 'account_identity' => $account_identity,
- 'account_name' => $account['account_name'],
- 'money' => $money,
- 'apply_time' => date('Y-m-d H:i:s', time()),
- 'bank_no' => $bank_no,
- 'bank_address' => $bank_info['bank_address'],
- 'bank_user' => $bank_info['account_name'],
- 'status' => 1,
- );
- $res = lm($this->money_take, 'Commons')->insert($data);
- if ($res) {
- return $this->insertMoney($account_identity, $money, $order_id, 5);
- } else {
- return -2113;
- }
- }
- /**
- * 通过审核
- * @param [type] $identity 信息id
- * @return [type] [description]
- */
- public function pass_take($identity) {
- # code...
- }
- /**
- * 完成提现
- * @param [type] $identity 信息id
- * @return [type] [description]
- */
- public function give_take($identity) {
- }
- /**
- * 购买
- * @param [type] $account_identity 用户id
- * @param [type] $money 金额
- * @param [type] $order_id 订单号
- * @param [type] $type 购买类型,1,投注 2,追号
- * @return [type] [description]
- */
- public function buy_money($account_identity, $money, $order_id, $type) {
- return $this->insertMoney($account_identity, $money, $order_id, $type);
- }
- /**
- * 充值记录
- * @param [type] $account_identity 用户id
- * @param [type] $money 金额
- * @param [type] $type 充值方式
- * @return [type] [description]
- */
- public function recharge_money($account_identity, $money, $type) {
- $type = 6;
- //获取用户信息
- $account = $this->getAccount($account_identity);
- //生成订单id
- $order_id = OrderID();
- //充值记录
- $data = array(
- 'info_identity' => UUID(),
- 'order_id' => $order_id,
- 'begin_time' => date('Y-m-d H:i:s', time()),
- 'money' => $money,
- 'account_name' => $account['account_name'],
- 'account_identity' => $account_identity,
- 'status' => 1,
- 'recharge_type' => $type,
- );
- $res = lm($this->money_recharge, 'Commons')->insert($data);
- if ($res) {
- return $this->insertMoney($account_identity, $money, $order_id, 6);
- } else {
- return -2113;
- }
- }
- /**
- * 反水记录增加
- * @param string $account_identity 用户id
- * @param [type] $money 金额
- * @param string $game_name 游戏名
- * @param string $buy_id 购买记录id
- * @param [type] $ratio 反水比例
- * @return [type] [description]
- */
- public function back_money($account_identity, $money, $game_name, $buy_id, $ratio) {
- //获取用户信息
- $account = $this->getAccount($account_identity);
- //获取游戏信息
- $game = new \Biz\Game\GameQuery;
- $game_info = $game->getGameInfo($game_name);
- //生成订单id
- $order_id = OrderID();
- //插入反水信息
- $data = array(
- 'info_identity' => UUID(),
- 'order_id' => $order_id,
- 'account_name' => $account['account_name'],
- 'account_identity' => $account_identity,
- 'game_name' => $game_info['name'],
- 'game_id' => $game_info['identity'],
- 'buy_identity' => $buy_id,
- 'money' => $money,
- 'ratio' => $ratio,
- 'money_time' => date('Y-m-d H:i:s', time()),
- );
- $res = lm($this->money_back, 'Commons')->insert($data);
- if ($res) {
- return $this->insertMoney($account_identity, $money, $order_id, 7);
- } else {
- return -2113;
- }
- }
- /**
- * 回水操作
- * @param string $account_identity 用户id
- * @param string $money 金额
- * @param string $ratio 回水比例
- * @param string $total_money 亏损总金额
- * @return [type] [description]
- */
- public function return_money($account_identity, $money, $ratio, $total_money) {
- //获取用户信息
- $account = $this->getAccount($account_identity);
- //生成订单id
- $order_id = OrderID();
- //加入回水记录
- $data = array(
- 'info_identity' => UUID(),
- 'order_id' => $order_id,
- 'account_name' => $account['account_name'],
- 'account_identity' => $account_identity,
- 'money' => $money,
- 'ratio' => $ratio,
- 'total_money' => $total_money,
- 'money_time' => date('Y-m-d H:i:s'),
- );
- $res = lm($this->money_return, 'Commons')->insert($data);
- if ($res) {
- return $this->insertMoney($account_identity, $money, $order_id, 8);
- } else {
- return -2113;
- }
- }
- /**
- * 管理员扣款
- * @param [type] $account_identity 用户id
- * @param [type] $money 金额
- * @return [type] [description]
- */
- public function cut_money($account_identity, $money) {
- //生成订单id
- $order_id = OrderID();
- return $this->insertMoney($account_identity, $money, $order_id, 9);
- }
- /**
- * 资金记录修改
- * @param string $account_identity 用户id
- * @param string $money 金额
- * @param 订单号 $order_id 订单号
- * @param int $type 交易类型
- * @return [type] [description]
- */
- public function insertMoney($account_identity, $money, $order_id, $type) {
- //获取用户信息
- $account = $this->getAccount($account_identity);
- //获取money_type
- $m_type = $this->getMtype($type);
- //总资金记录表
- if ($m_type == 1) {
- $nowMoney = $account['available_cash'] + $money;
- $nowCash = $account['cash'] + $money;
- } else {
- $nowMoney = $account['available_cash'] - $money;
- $nowCash = $account['cash'] - $money;
- }
- //获取描述信息
- $trade_desc = $this->getDesc($account['account_name'], $money, $order_id, $type);
- //获取状态
- //$status = $this->getStatus($type);
- $data2 = array(
- 'info_identity' => UUID(),
- 'trade_id' => $order_id,
- 'account_name' => $account['account_name'],
- 'account_identity' => $account_identity,
- 'money' => $money,
- 'money_time' => date('Y-m-d H:i:s', time()),
- 'money_type' => $m_type,
- 'money_cash' => $nowMoney,
- //'status' => $status,
- 'trade_type' => $type,
- 'trade_desc' => $trade_desc,
- );
- $res2 = lm($this->money_details, 'Commons')->insert($data2);
- if ($res2) {
- //更新用户余额
- $update = array(
- 'available_cash' => $nowMoney,
- 'cash' => $nowCash,
- );
- $res3 = lm($this->account_detailed, 'Commons')->where('account_identity', $account_identity)->update($update);
- if ($res3) {
- return 1;
- } else {
- return -2113;
- }
- } else {
- return -2113;
- }
- }
- /**
- * 获取描述信息
- * @param string $account_name 用户名
- * @param string $money 金额
- * @param string $order_id 订单号
- * @param int $type 操作类型
- * @return [type] [description]
- */
- public function getDesc($account_name, $money, $order_id, $type) {
- switch ($type) {
- case 1:
- return $account_name . '投注' . $money . '元。' . '订单号' . $order_id;
- break;
- case 2:
- return $account_name . '追号' . $money . '元。' . '订单号' . $order_id;
- break;
- case 3:
- return $account_name . '撤单' . '订单号' . $order_id;
- break;
- case 4:
- return $account_name . '中奖' . $money . '元。' . '订单号' . $order_id;
- break;
- case 5:
- return $account_name . '申请提现' . $money . '元。' . '订单号' . $order_id;
- break;
- case 6:
- return $account_name . '充值' . $money . '元。' . '订单号' . $order_id;
- break;
- case 7:
- return $account_name . '反水' . $money . '元。' . '订单号' . $order_id;
- break;
- case 8:
- return $account_name . '回水' . $money . '元。' . '订单号' . $order_id;
- break;
- case 9:
- return $account_name . '管理员扣款' . $money . '元。' . '订单号' . $order_id;
- break;
- case 10:
- return $account_name . '佣金提成' . $money . '元。' . '订单号' . $order_id;
- break;
- default:
- return '';
- break;
- }
- }
- /**
- * 获取状态
- * @param [type] $type 操作类型
- * @return [type] [description]
- */
- public function getStatus($type) {
- $arr = array(
- '1' => '投注',
- '2' => '追号',
- '3' => '撤单',
- '4' => '派奖',
- '5' => '审核中',
- '6' => '待支付',
- '7' => '成功',
- '8' => '成功',
- '9' => '扣款',
- '10' => '佣金提成',
- );
- return $arr[$type];
- }
- /**
- * 返回money_type
- * @param [type] $type 类型
- * @return [type] [description]
- */
- public function getMtype($type) {
- $arr = array(
- '1' => 2,
- '2' => 2,
- '3' => 1,
- '4' => 1,
- '5' => 2,
- '6' => 1,
- '7' => 1,
- '8' => 1,
- '9' => 2,
- '10' => 1,
- );
- return $arr[$type];
- }
- /**
- * 获取用户绑定银行卡信息
- * @param [type] $account_identity 用户唯一id
- * @param [type] $bank_no 银行卡号
- * @return [type] [description]
- */
- public function getBankInfo($account_identity, $bank_no) {
- $res = lm($this->bank_table, 'Commons')
- ->select('bank_number', 'account_name', 'bank_address')
- ->where(['account_identity' => $account_identity, 'bank_number' => $bank_no])
- ->first();
- if ($res) {
- $data = $res->toArray();
- } else {
- return -2114;
- }
- return $data;
- }
- }
- ?>
|