You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
108
hyhproject/admin/model/LogMoneys.php
Executable file
108
hyhproject/admin/model/LogMoneys.php
Executable file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
namespace wstmart\admin\model;
|
||||
use think\Db;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 资金流水日志业务处理
|
||||
*/
|
||||
class LogMoneys extends Base{
|
||||
/**
|
||||
* 用户资金列表
|
||||
*/
|
||||
public function pageQueryByUser(){
|
||||
$key = input('key');
|
||||
$where = [];
|
||||
// 排序
|
||||
$sort = input('sort');
|
||||
$order = [];
|
||||
if($sort!=''){
|
||||
$sortArr = explode('.',$sort);
|
||||
$order[$sortArr[0]] = $sortArr[1];
|
||||
}
|
||||
$where['dataFlag'] = 1;
|
||||
$where['loginName'] = ['like','%'.$key.'%'];
|
||||
return model('users')->where($where)->field('loginName,userId,userName,userMoney,lockMoney')->order($order)->paginate(input('limit/d'));
|
||||
}
|
||||
/**
|
||||
* 商家资金列表
|
||||
*/
|
||||
public function pageQueryByShop(){
|
||||
$key = input('key');
|
||||
$where = [];
|
||||
$where['u.dataFlag'] = 1;
|
||||
$where['s.dataFlag'] = 1;
|
||||
$where['loginName'] = ['like','%'.$key.'%'];
|
||||
return Db::name('shops')->alias('s')->join('__USERS__ u','s.userId=u.userId','inner')->where($where)->field('loginName,shopId,shopName,shopMoney,s.lockMoney')->paginate(input('limit/d'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
public function getUserInfoByType(){
|
||||
$type = (int)input('type',0);
|
||||
$id = (int)input('id');
|
||||
$data = [];
|
||||
if($type==1){
|
||||
$data = Db::name('shops')->alias('s')->join('__USERS__ u','s.userId=u.userId','inner')->where('shopId',$id)->field('shopId as userId,shopName as userName,loginName,1 as userType')->find();
|
||||
}else{
|
||||
$data = model('users')->where('userId',$id)->field('loginName,userId,userName,0 as userType')->find();
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
public function pageQuery(){
|
||||
$userType = input('type');
|
||||
$userId = input('id');
|
||||
$startDate = input('startDate');
|
||||
$endDate = input('endDate');
|
||||
$where = [];
|
||||
if($startDate!='')$where['createTime'] = ['>=',$startDate." 00:00:00"];
|
||||
if($endDate!='')$where[' createTime'] = ['<=',$endDate." 23:59:59"];
|
||||
$where['targetType'] = $userType;
|
||||
$where['targetId'] = $userId;
|
||||
$page = $this->where($where)->order('id', 'desc')->paginate(input('limit/d'))->toArray();
|
||||
if(count($page['Rows'])>0){
|
||||
foreach ($page['Rows'] as $key => $v) {
|
||||
$page['Rows'][$key]['dataSrc'] = WSTLangMoneySrc($v['dataSrc']);
|
||||
}
|
||||
}
|
||||
return $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增记录
|
||||
*/
|
||||
public function add($log){
|
||||
$log['createTime'] = date('Y-m-d H:i:s');
|
||||
$this->create($log);
|
||||
//dump($log);
|
||||
if($log['moneyType']==1){
|
||||
if($log['targetType']==1){
|
||||
if($log['payType']==='ect'){
|
||||
ectLog($log['targetId'],$log['money'],12,'结算',['userECT'=>['exp','userECT+'.$log['money']]],1);
|
||||
}else {
|
||||
Db::name('shops')->where(["shopId" => $log['targetId']])->setInc('shopMoney', $log['money']);
|
||||
}
|
||||
}else{
|
||||
if($log['payType']==='ect'){
|
||||
ectLog($log['targetId'],$log['money'],13,'退款',['userECT'=>['exp','userECT+'.$log['money']]],1);
|
||||
}else{
|
||||
Db::name('users')->where(["userId"=>$log['targetId']])->setInc('userMoney',$log['money']);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if($log['targetType']==1){
|
||||
Db::name('shops')->where(["shopId"=>$log['targetId']])->setDec('shopMoney',$log['money']);
|
||||
}else{
|
||||
if($log['payType']==='ect'){
|
||||
ectLog($log['targetId'],$log['money'],11,'购物',['userECT'=>['exp','userECT-'.$log['money']]],2);
|
||||
}else{
|
||||
Db::name('users')->where(["userId"=>$log['targetId']])->setDec('userMoney',$log['money']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user