| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <?php
- namespace app\admin\controller\xzdata;
- use alipay\AopCertClient;
- use alipay\request\AlipayFundTransUniTransferRequest;
- use app\common\model\MoneyLog;
- use app\common\model\ScoreLog;
- //use app\admin\model\UpgradeLog;
- use app\common\model\ScoreLogModel;
- use app\common\model\ThirdxzDforderModel;
- use app\common\model\ThirdxzHforderModel;
- use app\common\model\User as UserModel;
- use app\common\model\UserData;
- use app\admin\traits\Curd;
- use app\common\constants\AdminConstant;
- use app\common\controller\AdminController;
- use app\common\model\UserMoneyModel;
- use app\Request;
- use EasyAdmin\tool\CommonTool;
- use jianyan\excel\Excel;
- use think\App;
- use think\facade\Db;
- class Dianfei extends AdminController
- {
- public function __construct (App $app)
- {
- parent::__construct($app);
- $this->model = new ThirdxzDforderModel();
- }
- use Curd;
- /**
- * 充值列表
- * @return mixed|\think\response\Json
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function index ()
- {
- if ($this->request->isAjax()) {
- if (input('selectFields')) {
- return $this->selectList();
- }
- list($page, $limit, $where) = $this->buildTableParames();
- if (($pid = $this->request->param('pid')) !== false && $pid)
- $where[] = ['pid', '=', $this->request->param('pid', '')];
- // if (($create_time = $this->request->param('create_time')) !== false && $create_time)
- // $where[] = ['create_time','in', explode(' - ', $create_time)];
- foreach ($where as $key=>&$val){
- if ($val[0] == 'create_time'){
- $val[2] = sr_getcurtime($val[2]);
- }
- }
- // sr_log(json_encode($where));
- $count = $this->model
- // ->withJoin('userData', 'INNER')
- ->where($where)
- ->where($this->user_map)
- ->count();
- $list = $this->model
- // ->withJoin('userData', 'INNER')
- ->where($where)
- ->where($this->user_map)
- ->withAttr('type', function ($val, $data){
- return ($val==1?'移动':($val==2?'联通':'电信'));
- })
- ->page($page, $limit)
- ->order($this->sort)
- ->select();
- $data = [
- 'code' => 0,
- 'msg' => Db::getLastSql(),
- 'count' => $count,
- 'data' => $list,
- ];
- return json($data);
- }
- return $this->fetch();
- }
- /**
- * 执行提现
- * @param $id
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function czsuccess ($id)
- {
- $info = $this->model->where('id', $id)->where('status', 1)->find();
- if (empty($info))
- $this->error('充值记录状态或已充值');
- $user = Db::name('user')->findOrEmpty(['id' => $info['uid']]);
- if (empty($user) || $user['status'] != 1)
- $this->error('用户不存在或已被禁用');
- if ($user['is_auth'] != 1)
- $this->error('该用户还未实名认证');
- $this->model->where('id', $id)->save(['status'=>2]);
- $this->success('充值成功');
- }
- /**
- * 充值失败
- * @return mixed
- */
- public function czerror ()
- {
- if ($this->request->isPost()) {
- $post = $this->request->post();
- $order_info = $this->model->where('id', $post['id'])->findOrEmpty();
- $is_backsx = $post['is_backsx'];
- $error_text = $post['error_text'];
- empty($order_info) && $this->error('信息不存在');
- if ($order_info['status'] != 1){
- $this->error('状态错误,请刷新数据');
- }
- $this->model->startTrans();
- try {
- $this->model->where('id', $post['id'])->save(['status'=>3,'error_text'=>$error_text, 'is_backsx'=>$is_backsx]);
- if ($is_backsx == 1){
- edit_user_xz(18, $order_info['uid'], $order_info['xz_num']+$order_info['shouxu'], $order_info['hf_ordersn'], $order_info['shouxu']);
- edit_user_couponnum(6, $order_info['uid'], $order_info['price']/10);
- }else{
- edit_user_xz(18, $order_info['uid'], $order_info['xz_num'], $order_info['hf_ordersn'], 0);
- edit_user_couponnum(6, $order_info['uid'], $order_info['price']/10);
- }
- $this->model->commit();
- } catch (\Exception $e) {
- $this->model->rollback();
- $this->error('失败'.$e->getMessage());
- }
- $this->success('成功');
- }
- return $this->fetch();
- }
- /**
- * 增加余额
- * @return mixed
- */
- public function editmoney ()
- {
- if ($this->request->isPost()) {
- $post = $this->request->post();
- $user = $this->model->findOrEmpty(['id' => $post['uid']]);
- $money = $post['money'];
- $type = $post['type'];
- empty($user) && $this->error('用户不存在');
- $this->model->startTrans();
- try {
- if ($type == 'more'){
- edit_user_money(7, $post['uid'], $money);
- }else {
- edit_user_money(8, $post['uid'], $money);
- }
- $this->model->commit();
- } catch (\Exception $e) {
- $this->model->rollback();
- $this->error('失败'.$e->getMessage());
- }
- $this->success('成功');
- }
- return $this->fetch();
- }
- }
|