修改商城模型数据

This commit is contained in:
邹景立 2021-09-13 15:16:29 +08:00
parent a0f2609c61
commit 55f93479ad
30 changed files with 265 additions and 210 deletions

View File

@ -2,6 +2,7 @@
namespace app\data\command;
use app\data\model\DataUser;
use app\data\model\DataUserTransfer;
use app\data\service\UserRebateService;
use think\admin\Command;
@ -149,7 +150,7 @@ class UserTransfer extends Command
*/
private function getWechatInfo(int $uuid, string $type): ?array
{
$user = $this->app->db->name('DataUser')->where(['id' => $uuid])->find();
$user = DataUser::mk()->where(['id' => $uuid])->find();
if (empty($user)) return null;
$appid1 = sysconf('data.wxapp_appid');
if (strtolower(sysconf('wechat.type')) === 'api') {

View File

@ -2,6 +2,7 @@
namespace app\data\controller\api;
use app\data\model\BaseUserMessage;
use think\admin\Controller;
/**
@ -44,10 +45,10 @@ class Data extends Controller
*/
public function getNotify()
{
$query = $this->_query('BaseUserMessage')->where(['status' => 1, 'deleted' => 0]);
$query = $this->_query(BaseUserMessage::class)->where(['status' => 1, 'deleted' => 0]);
$result = $query->equal('id')->order('sort desc,id desc')->page(true, false, false, 20);
if (($id = input('id')) > 0) {
$this->app->db->name('BaseUserMessage')->where(['id' => $id])->inc('num_read')->update();
BaseUserMessage::mk()->where(['id' => $id])->inc('num_read')->update([]);
}
$this->success('获取系统通知', $result);
}

View File

@ -2,6 +2,7 @@
namespace app\data\controller\api;
use app\data\model\ShopGoods;
use app\data\service\ExpressService;
use app\data\service\GoodsService;
use think\admin\Controller;
@ -42,9 +43,9 @@ class Goods extends Controller
{
// 更新访问统计
$map = $this->_vali(['code.default' => '']);
if ($map['code']) $this->app->db->name('ShopGoods')->where($map)->inc('num_read')->update();
if ($map['code']) ShopGoods::mk()->where($map)->inc('num_read')->update([]);
// 商品数据处理
$query = $this->_query('ShopGoods')->like('name,marks,cateids,payment')->equal('code,vip_entry');
$query = $this->_query(ShopGoods::class)->like('name,marks,cateids,payment')->equal('code,vip_entry');
$result = $query->where(['deleted' => 0, 'status' => 1])->order('sort desc,id desc')->page(true, false, false, 10);
if (count($result['list']) > 0) GoodsService::instance()->bindData($result['list']);
$this->success('获取商品数据', $result);

View File

@ -2,6 +2,7 @@
namespace app\data\controller\api;
use app\data\model\DataUser;
use app\data\service\MessageService;
use app\data\service\UserAdminService;
use think\admin\Controller;
@ -19,12 +20,6 @@ class Login extends Controller
*/
private $type;
/**
* 绑定数据表
* @var string
*/
protected $table = 'DataUser';
/**
* 控制器初始化
*/
@ -55,7 +50,7 @@ class Login extends Controller
'password.require' => '登录密码不能为空!',
]);
$map = ['deleted' => 0, 'phone' => $data['phone']];
$user = $this->app->db->name($this->table)->where($map)->find();
$user = DataUser::mk()->where($map)->find();
if (empty($user)) $this->error('该手机号还没有注册哦!');
if (empty($user['status'])) $this->error('该用户账号状态异常!');
if (md5($data['password']) === $user['password']) {
@ -88,7 +83,7 @@ class Login extends Controller
// $this->error('验证失败!');
// }
$map = ['phone' => $data['phone'], 'deleted' => 0];
if ($this->app->db->name($this->table)->where($map)->count() > 0) {
if (DataUser::mk()->where($map)->count() > 0) {
$this->error('手机号已注册,请使用其它手机号!');
}
$data['password'] = md5($data['password']);

View File

@ -2,6 +2,8 @@
namespace app\data\controller\api;
use app\data\model\DataNewsItem;
use app\data\model\DataNewsXCollect;
use app\data\service\NewsService;
use think\admin\Controller;
@ -34,14 +36,14 @@ class News extends Controller
public function getItem()
{
if ($code = input('code', '')) {
$this->app->db->name('DataNewsItem')->where(['code' => $code])->inc('num_read')->update();
DataNewsItem::mk()->where(['code' => $code])->inc('num_read')->update();
if (($uuid = input('uuid', 0)) > 0) {
$data = ['uuid' => $uuid, 'code' => $code, 'type' => 3, 'status' => 2];
$this->app->db->name('DataNewsXCollect')->where($data)->delete();
$this->app->db->name('DataNewsXCollect')->insert($data);
DataNewsXCollect::mk()->where($data)->delete();
DataNewsXCollect::mk()->insert($data);
}
}
$query = $this->_query('DataNewsItem')->like('name,mark')->equal('id,code');
$query = $this->_query(DataNewsItem::class)->like('name,mark')->equal('id,code');
$query->where(['deleted' => 0, 'status' => 1])->withoutField('sort,status,deleted');
$result = $query->order('sort desc,id desc')->page(true, false, false, 15);
NewsService::instance()->buildData($result['list'], input('uuid', 0));
@ -57,7 +59,7 @@ class News extends Controller
public function getComment()
{
$map = $this->_vali(['code.require' => '文章不能为空!']);
$query = $this->_query('DataNewsXCollect')->where(['type' => 4, 'status' => 2]);
$query = $this->_query(DataNewsXCollect::class)->where(['type' => 4, 'status' => 2]);
$result = $query->where($map)->order('id desc')->page(true, false, false, 15);
NewsService::instance()->buildListByUidAndCode($result['list']);
$this->success('获取评论成功', $result);

View File

@ -72,8 +72,6 @@ class Wxapp extends Controller
/**
* 小程序数据解密
* @throws \think\admin\Exception
* @throws \think\db\exception\DbException
*/
public function decode()
{
@ -107,7 +105,6 @@ class Wxapp extends Controller
* 授权CODE换取会话信息
* @param string $code 换取授权CODE
* @return array [openid, sessionkey]
* @throws \WeChat\Exceptions\LocalCacheException
*/
private function _getSessionKey(string $code): array
{

View File

@ -3,6 +3,7 @@
namespace app\data\controller\api\auth;
use app\data\controller\api\Auth;
use app\data\model\DataNewsXCollect;
use app\data\service\NewsService;
/**
@ -12,11 +13,6 @@ use app\data\service\NewsService;
*/
class News extends Auth
{
/**
* 绑定数据表
* @var string
*/
protected $table = 'DataNewsXCollect';
/**
* 用户评论内容
@ -31,7 +27,7 @@ class News extends Auth
'code.require' => '文章不能为空!',
'reply.require' => '评论不能为空!',
]);
if ($this->app->db->name($this->table)->insert($data) !== false) {
if (DataNewsXCollect::mk()->insert($data) !== false) {
NewsService::instance()->syncNewsTotal($data['code']);
$this->success('添加评论成功!');
} else {
@ -47,7 +43,7 @@ class News extends Auth
*/
public function getComment()
{
$query = $this->_query($this->table)->where(['uuid' => $this->uuid, 'type' => 4]);
$query = $this->_query(DataNewsXCollect::class)->where(['uuid' => $this->uuid, 'type' => 4]);
$result = $query->whereIn('status', [1, 2])->order('id desc')->page(true, false, false, 15);
NewsService::instance()->buildListByUidAndCode($result);
$this->success('获取评论列表成功', $result);
@ -55,7 +51,6 @@ class News extends Auth
/**
* 删除内容评论
* @throws \think\db\exception\DbException
*/
public function delComment()
{
@ -65,7 +60,7 @@ class News extends Auth
'id.require' => '评论编号不能为空!',
'code.require' => '文章编号不能为空!',
]);
if ($this->app->db->name('DataNewsXCollect')->where($data)->delete() !== false) {
if (DataNewsXCollect::mk()->where($data)->delete() !== false) {
$this->success('评论删除成功!');
} else {
$this->error('认证删除失败!');
@ -84,10 +79,10 @@ class News extends Auth
'status.value' => 2,
'code.require' => '文章编号不能为空!',
]);
if ($this->app->db->name('DataNewsXCollect')->where($data)->count() > 0) {
if (DataNewsXCollect::mk()->where($data)->count() > 0) {
$this->success('您已收藏!');
}
if ($this->app->db->name('DataNewsXCollect')->insert($data) !== false) {
if (DataNewsXCollect::mk()->insert($data) !== false) {
NewsService::instance()->syncNewsTotal($data['code']);
$this->success('收藏成功!');
} else {
@ -106,7 +101,7 @@ class News extends Auth
'type.value' => 1,
'code.require' => '文章编号不能为空!',
]);
if ($this->app->db->name('DataNewsXCollect')->where($data)->delete() !== false) {
if (DataNewsXCollect::mk()->where($data)->delete() !== false) {
NewsService::instance()->syncNewsTotal($data['code']);
$this->success('取消收藏成功!');
} else {
@ -141,10 +136,10 @@ class News extends Auth
'status.value' => 2,
'code.require' => '文章编号不能为空!',
]);
if ($this->app->db->name('DataNewsXCollect')->where($data)->count() > 0) {
if (DataNewsXCollect::mk()->where($data)->count() > 0) {
$this->success('您已点赞!');
}
if ($this->app->db->name('DataNewsXCollect')->insert($data) !== false) {
if (DataNewsXCollect::mk()->insert($data) !== false) {
NewsService::instance()->syncNewsTotal($data['code']);
$this->success('点赞成功!');
} else {
@ -163,7 +158,7 @@ class News extends Auth
'type.value' => 2,
'code.require' => '文章编号不能为空!',
]);
if ($this->app->db->name('DataNewsXCollect')->where($data)->delete() !== false) {
if (DataNewsXCollect::mk()->where($data)->delete() !== false) {
NewsService::instance()->syncNewsTotal($data['code']);
$this->success('取消点赞成功!');
} else {
@ -179,7 +174,7 @@ class News extends Auth
*/
public function getLike()
{
$query = $this->_query('DataNewsXCollect');
$query = $this->_query(DataNewsXCollect::class);
$query->where(['uuid' => $this->uuid, 'type' => 2, 'status' => 2]);
$result = $query->order('id desc')->page(true, false, false, 15);
NewsService::instance()->buildListByUidAndCode($result['list']);
@ -198,8 +193,8 @@ class News extends Auth
'status.value' => 2,
'code.require' => '文章编号不能为空!',
]);
$this->app->db->name('DataNewsXCollect')->where($data)->delete();
$this->app->db->name('DataNewsXCollect')->insert($data);
DataNewsXCollect::mk()->where($data)->delete();
DataNewsXCollect::mk()->insert($data);
$this->success('添加浏览历史成功!');
}
@ -211,7 +206,7 @@ class News extends Auth
*/
public function getHistory()
{
$query = $this->_query('DataNewsXCollect');
$query = $this->_query(DataNewsXCollect::class);
$query->where(['uuid' => $this->uuid, 'type' => 3, 'status' => 2]);
$result = $query->order('id desc')->page(true, false, false, 15);
NewsService::instance()->buildListByUidAndCode($result['list']);

View File

@ -3,7 +3,11 @@
namespace app\data\controller\api\auth;
use app\data\controller\api\Auth;
use app\data\model\BaseUserPayment;
use app\data\model\DataUser;
use app\data\model\DataUserAddress;
use app\data\model\ShopGoods;
use app\data\model\ShopGoodsItem;
use app\data\model\ShopOrder;
use app\data\model\ShopOrderItem;
use app\data\service\ExpressService;
@ -69,15 +73,15 @@ class Order extends Auth
if ($order['puid1'] == $this->uuid) $order['puid1'] = 0;
if ($order['puid1'] > 0) {
$map = ['id' => $order['puid1'], 'status' => 1];
$order['puid2'] = $this->app->db->name('DataUser')->where($map)->value('pid2');
$order['puid2'] = DataUser::mk()->where($map)->value('pid2');
if (is_null($order['puid2'])) $this->error('代理异常');
}
// 订单商品处理
foreach (explode('||', $rules) as $rule) {
[$code, $spec, $count] = explode('@', $rule);
// 商品信息检查
$goodsInfo = $this->app->db->name('ShopGoods')->where(['code' => $code, 'status' => 1, 'deleted' => 0])->find();
$goodsItem = $this->app->db->name('ShopGoodsItem')->where(['status' => 1, 'goods_code' => $code, 'goods_spec' => $spec])->find();
$goodsInfo = ShopGoods::mk()->where(['code' => $code, 'status' => 1, 'deleted' => 0])->find();
$goodsItem = ShopGoodsItem::mk()->where(['status' => 1, 'goods_code' => $code, 'goods_spec' => $spec])->find();
if (empty($goodsInfo) || empty($goodsItem)) $this->error('商品查询异常');
// 商品类型检查
if ($truckType < 0) $truckType = $goodsInfo['truck_type'];
@ -305,7 +309,7 @@ class Order extends Auth
$payments = ShopOrder::mk()->where($data)->value('payment_allow');
if (empty($payments)) $this->error('获取订单支付参数失败');
// 读取支付通道配置
$query = $this->app->db->name('BaseUserPayment')->where(['status' => 1, 'deleted' => 0]);
$query = BaseUserPayment::mk()->where(['status' => 1, 'deleted' => 0]);
$query->whereIn('code', str2arr($payments))->whereIn('type', PaymentService::getTypeApi($this->type));
$result = $query->order('sort desc,id desc')->column('type,code,name,cover,content,remark', 'code');
foreach ($result as &$vo) $vo['content'] = ['voucher_qrcode' => json_decode($vo['content'])->voucher_qrcode ?? ''];

View File

@ -3,6 +3,8 @@
namespace app\data\controller\api\auth;
use app\data\controller\api\Auth;
use app\data\model\BaseUserUpgrade;
use app\data\model\DataUserRebate;
use app\data\service\RebateService;
/**
@ -37,8 +39,8 @@ class Rebate extends Auth
public function prize()
{
[$map, $data] = [['number' => $this->user['vip_code']], []];
$prizes = $this->app->db->name('DataUserRebate')->group('name')->column('name');
$rebate = $this->app->db->name('BaseUserUpgrade')->where($map)->value('rebate_rule', '');
$prizes = DataUserRebate::mk()->group('name')->column('name');
$rebate = BaseUserUpgrade::mk()->where($map)->value('rebate_rule', '');
$codemap = array_merge($prizes, str2arr($rebate));
foreach (RebateService::PRIZES as $prize) {
if (in_array($prize['code'], $codemap)) $data[] = $prize;

View File

@ -2,6 +2,7 @@
namespace app\data\controller\base;
use app\data\model\BaseUserUpgrade;
use app\data\service\RebateService;
use think\admin\Controller;
@ -29,7 +30,7 @@ class Upgrade extends Controller
public function index()
{
$this->title = '用户等级管理';
$this->_query($this->table)->order('number asc')->page();
$this->_query(BaseUserUpgrade::class)->order('number asc')->page();
}
/**
@ -55,7 +56,7 @@ class Upgrade extends Controller
*/
public function add()
{
$this->_form($this->table, 'form');
$this->_form(BaseUserUpgrade::class, 'form');
}
/**
@ -67,7 +68,7 @@ class Upgrade extends Controller
*/
public function edit()
{
$this->_form($this->table, 'form');
$this->_form(BaseUserUpgrade::class, 'form');
}
/**
@ -79,7 +80,7 @@ class Upgrade extends Controller
if ($this->request->isGet()) {
$this->prizes = RebateService::PRIZES;
if (!isset($vo['number'])) {
$vo['number'] = $this->app->db->name($this->table)->order('number desc')->value('number', -1) + 1;
$vo['number'] = BaseUserUpgrade::mk()->order('number desc')->value('number', -1) + 1;
}
$vo['rebate_rule'] = str2arr($vo['rebate_rule'] ?? '');
} else {
@ -113,8 +114,8 @@ class Upgrade extends Controller
if ($state) {
$order = 'number asc,utime desc';
if (input('old_number', 100) <= input('number', 0)) $order = 'number asc,utime asc';
foreach ($this->app->db->name($this->table)->order($order)->cursor() as $k => $vo) {
$this->app->db->name($this->table)->where(['id' => $vo['id']])->update(['number' => $k]);
foreach (BaseUserUpgrade::mk()->order($order)->cursor() as $k => $vo) {
BaseUserUpgrade::mk()->where(['id' => $vo['id']])->update(['number' => $k]);
}
}
}
@ -135,7 +136,7 @@ class Upgrade extends Controller
*/
public function state()
{
$this->_save($this->table);
$this->_save(BaseUserUpgrade::class);
}
/**
@ -145,7 +146,7 @@ class Upgrade extends Controller
*/
public function remove()
{
$this->_delete($this->table);
$this->_delete(BaseUserUpgrade::class);
}
/**

View File

@ -2,6 +2,7 @@
namespace app\data\controller\base\postage;
use app\data\model\BasePostageRegion;
use app\data\service\ExpressService;
use think\admin\Controller;
use think\admin\extend\CodeExtend;
@ -48,8 +49,8 @@ class Template extends Controller
$this->fetch('form_region');
} else {
$data = $this->_vali(['nos.default' => '', 'oks.default' => '']);
if ($data['nos']) $this->app->db->name('BasePostageRegion')->whereIn('id', str2arr($data['nos']))->update(['status' => 0]);
if ($data['oks']) $this->app->db->name('BasePostageRegion')->whereIn('id', str2arr($data['oks']))->update(['status' => 1]);
if ($data['nos']) BasePostageRegion::mk()->whereIn('id', str2arr($data['nos']))->update(['status' => 0]);
if ($data['oks']) BasePostageRegion::mk()->whereIn('id', str2arr($data['oks']))->update(['status' => 1]);
$this->success('修改配送区域成功!', 'javascript:history.back()');
}
}

View File

@ -2,6 +2,8 @@
namespace app\data\controller\news;
use app\data\model\DataNewsItem;
use app\data\model\DataNewsMark;
use app\data\service\NewsService;
use think\admin\Controller;
use think\admin\extend\CodeExtend;
@ -13,12 +15,6 @@ use think\admin\extend\CodeExtend;
*/
class Item extends Controller
{
/**
* 绑定数据表
* @var string
*/
private $table = 'DataNewsItem';
/**
* 文章内容管理
* @auth true
@ -30,7 +26,7 @@ class Item extends Controller
public function index()
{
$this->title = '文章内容管理';
$query = $this->_query($this->table);
$query = $this->_query(DataNewsItem::class);
$query->like('mark,name')->dateBetween('create_at');
$query->where(['deleted' => 0])->order('sort desc,id desc')->page();
}
@ -44,7 +40,7 @@ class Item extends Controller
*/
public function select()
{
$query = $this->_query($this->table);
$query = $this->_query(DataNewsItem::class);
$query->equal('status')->like('name')->dateBetween('create_at');
$query->where(['deleted' => 0])->order('sort desc,id desc')->page();
}
@ -68,7 +64,7 @@ class Item extends Controller
public function add()
{
$this->title = '添加文章内容';
$this->_form($this->table, 'form');
$this->_form(DataNewsItem::class, 'form');
}
/**
@ -81,7 +77,7 @@ class Item extends Controller
public function edit()
{
$this->title = '编辑文章内容';
$this->_form($this->table, 'form');
$this->_form(DataNewsItem::class, 'form');
}
/**
@ -97,9 +93,8 @@ class Item extends Controller
$data['code'] = CodeExtend::uniqidNumber(20, 'A');
}
if ($this->request->isGet()) {
$map = ['status' => 1, 'deleted' => 0];
$query = $this->app->db->name('DataNewsMark')->where($map);
$this->marks = $query->order('sort desc,id desc')->select()->toArray();
$model = DataNewsMark::mk()->where(['status' => 1, 'deleted' => 0]);
$this->marks = $model->order('sort desc,id desc')->select()->toArray();
$data['mark'] = str2arr($data['mark'] ?? '');
} else {
$data['mark'] = arr2str($data['mark'] ?? []);
@ -124,7 +119,7 @@ class Item extends Controller
*/
public function state()
{
$this->_save($this->table, $this->_vali([
$this->_save(DataNewsItem::class, $this->_vali([
'status.in:0,1' => '状态值范围异常!',
'status.require' => '状态值不能为空!',
]));
@ -137,7 +132,7 @@ class Item extends Controller
*/
public function remove()
{
$this->_delete($this->table);
$this->_delete(DataNewsItem::class);
}
}

View File

@ -2,6 +2,7 @@
namespace app\data\controller\news;
use app\data\model\DataNewsMark;
use think\admin\Controller;
/**
@ -11,12 +12,6 @@ use think\admin\Controller;
*/
class Mark extends Controller
{
/**
* 绑定数据表
* @var string
*/
private $table = 'DataNewsMark';
/**
* 文章标签管理
* @auth true
@ -27,7 +22,7 @@ class Mark extends Controller
public function index()
{
$this->title = '文章标签管理';
$query = $this->_query($this->table);
$query = $this->_query(DataNewsMark::class);
$query->like('name')->equal('status')->dateBetween('create_at');
$query->where(['deleted' => 0])->order('sort desc,id desc')->page();
}
@ -41,7 +36,7 @@ class Mark extends Controller
*/
public function add()
{
$this->_form($this->table, 'form');
$this->_form(DataNewsMark::class, 'form');
}
/**
@ -53,7 +48,7 @@ class Mark extends Controller
*/
public function edit()
{
$this->_form($this->table, 'form');
$this->_form(DataNewsMark::class, 'form');
}
/**
@ -63,7 +58,7 @@ class Mark extends Controller
*/
public function state()
{
$this->_save($this->table, $this->_vali([
$this->_save(DataNewsMark::class, $this->_vali([
'status.in:0,1' => '状态值范围异常!',
'status.require' => '状态值不能为空!',
]));
@ -76,7 +71,7 @@ class Mark extends Controller
*/
public function remove()
{
$this->_delete($this->table);
$this->_delete(DataNewsMark::class);
}
}

View File

@ -2,6 +2,7 @@
namespace app\data\controller\shop;
use app\data\model\ShopGoodsCate;
use think\admin\Controller;
use think\admin\extend\DataExtend;
@ -12,12 +13,6 @@ use think\admin\extend\DataExtend;
*/
class Cate extends Controller
{
/**
* 绑定数据表
* @var string
*/
private $table = 'ShopGoodsCate';
/**
* 商品分类管理
* @auth true
@ -29,7 +24,7 @@ class Cate extends Controller
public function index()
{
$this->title = "商品分类管理";
$query = $this->_query($this->table)->like('name')->dateBetween('create_at');
$query = $this->_query(ShopGoodsCate::class)->like('name')->dateBetween('create_at');
$query->equal('status')->where(['deleted' => 0])->order('sort desc,id desc')->page(false);
}
@ -54,7 +49,7 @@ class Cate extends Controller
*/
public function add()
{
$this->_form($this->table, 'form');
$this->_form(ShopGoodsCate::mk(), 'form');
}
/**
@ -66,7 +61,7 @@ class Cate extends Controller
*/
public function edit()
{
$this->_form($this->table, 'form');
$this->_form(ShopGoodsCate::class, 'form');
}
/**
@ -80,7 +75,7 @@ class Cate extends Controller
{
if ($this->request->isGet()) {
$data['pid'] = intval($data['pid'] ?? input('pid', '0'));
$cates = $this->app->db->name($this->table)->where(['deleted' => 0])->order('sort desc,id desc')->select()->toArray();
$cates = ShopGoodsCate::mk()->where(['deleted' => 0])->order('sort desc,id desc')->select()->toArray();
$this->cates = DataExtend::arr2table(array_merge($cates, [['id' => '0', 'pid' => '-1', 'name' => '顶部分类']]));
if (isset($data['id'])) foreach ($this->cates as $cate) if ($cate['id'] === $data['id']) $data = $cate;
foreach ($this->cates as $key => $cate) if ((isset($data['spt']) && $data['spt'] <= $cate['spt'])) {
@ -96,7 +91,7 @@ class Cate extends Controller
*/
public function state()
{
$this->_save($this->table, $this->_vali([
$this->_save(ShopGoodsCate::mk(), $this->_vali([
'status.in:0,1' => '状态值范围异常!',
'status.require' => '状态值不能为空!',
]));
@ -109,6 +104,6 @@ class Cate extends Controller
*/
public function remove()
{
$this->_delete($this->table);
$this->_delete(ShopGoodsCate::mk());
}
}

View File

@ -2,6 +2,8 @@
namespace app\data\controller\shop;
use app\data\model\ShopGoods;
use app\data\model\ShopGoodsStock;
use app\data\service\ExpressService;
use app\data\service\GoodsService;
use app\data\service\UserUpgradeService;
@ -15,12 +17,6 @@ use think\admin\extend\CodeExtend;
*/
class Goods extends Controller
{
/**
* 绑定数据表
* @var string
*/
private $table = 'ShopGoods';
/**
* 最大分类等级
* @var integer
@ -38,7 +34,7 @@ class Goods extends Controller
public function index()
{
$this->title = '商品数据管理';
$query = $this->_query($this->table);
$query = $this->_query(ShopGoods::class);
// 加载对应数据
$this->type = $this->request->get('type', 'index');
if ($this->type === 'index') $query->where(['deleted' => 0]);
@ -58,7 +54,7 @@ class Goods extends Controller
*/
public function select()
{
$query = $this->_query($this->table);
$query = $this->_query(ShopGoods::mk());
$query->equal('status')->like('code,name,marks')->in('cateids');
$query->where(['deleted' => 0])->order('sort desc,id desc')->page();
}
@ -88,7 +84,7 @@ class Goods extends Controller
{
$this->mode = 'add';
$this->title = '添加商品数据';
$this->_form($this->table, 'form', 'code');
$this->_form(ShopGoods::mk(), 'form', 'code');
}
/**
@ -102,7 +98,7 @@ class Goods extends Controller
{
$this->mode = 'edit';
$this->title = '编辑商品数据';
$this->_form($this->table, 'form', 'code');
$this->_form(ShopGoods::mk(), 'form', 'code');
}
/**
@ -116,7 +112,7 @@ class Goods extends Controller
{
$this->mode = 'copy';
$this->title = '复制编辑商品';
$this->_form($this->table, 'form', 'code');
$this->_form(ShopGoods::mk(), 'form', 'code');
}
/**
@ -215,7 +211,7 @@ class Goods extends Controller
{
$map = $this->_vali(['code.require' => '商品编号不能为空哦!']);
if ($this->request->isGet()) {
$list = $this->app->db->name('ShopGoods')->where($map)->select()->toArray();
$list = ShopGoods::mk()->where($map)->select()->toArray();
if (empty($list)) $this->error('无效的商品数据,请稍候再试!');
[$this->vo] = GoodsService::instance()->bindData($list);
$this->fetch();
@ -231,7 +227,7 @@ class Goods extends Controller
];
}
if (!empty($data)) {
$this->app->db->name('ShopGoodsStock')->insertAll($data);
ShopGoodsStock::mk()->insertAll($data);
GoodsService::instance()->stock($map['code']);
$this->success('商品数据入库成功!');
}
@ -247,7 +243,7 @@ class Goods extends Controller
*/
public function state()
{
$this->_save($this->table, $this->_vali([
$this->_save(ShopGoods::mk(), $this->_vali([
'status.in:0,1' => '状态值范围异常!',
'status.require' => '状态值不能为空!',
]), 'code');
@ -260,7 +256,7 @@ class Goods extends Controller
*/
public function remove()
{
$this->_save($this->table, $this->_vali([
$this->_save(ShopGoods::mk(), $this->_vali([
'deleted.in:0,1' => '状态值范围异常!',
'deleted.require' => '状态值不能为空!',
]), 'code');

View File

@ -2,6 +2,7 @@
namespace app\data\controller\shop;
use app\data\model\ShopGoodsMark;
use think\admin\Controller;
/**
@ -11,12 +12,6 @@ use think\admin\Controller;
*/
class Mark extends Controller
{
/**
* 绑定数据表
* @var string
*/
private $table = 'ShopGoodsMark';
/**
* 商品标签管理
* @auth true
@ -27,7 +22,7 @@ class Mark extends Controller
public function index()
{
$this->title = '商品标签管理';
$query = $this->_query($this->table);
$query = $this->_query(ShopGoodsMark::mk());
$query->like('name')->dateBetween('create_at');
$query->equal('status')->order('sort desc,id desc')->page();
}
@ -41,7 +36,7 @@ class Mark extends Controller
*/
public function select()
{
$this->_query($this->table)->order('sort desc,id desc')->page();
$this->_query(ShopGoodsMark::mk())->order('sort desc,id desc')->page();
}
/**
@ -53,7 +48,7 @@ class Mark extends Controller
*/
public function add()
{
$this->_form($this->table, 'form');
$this->_form(ShopGoodsMark::mk(), 'form');
}
/**
@ -65,7 +60,7 @@ class Mark extends Controller
*/
public function edit()
{
$this->_form($this->table, 'form');
$this->_form(ShopGoodsMark::mk(), 'form');
}
/**
@ -75,7 +70,7 @@ class Mark extends Controller
*/
public function state()
{
$this->_save($this->table);
$this->_save(ShopGoodsMark::mk());
}
/**
@ -85,7 +80,7 @@ class Mark extends Controller
*/
public function remove()
{
$this->_delete($this->table);
$this->_delete(ShopGoodsMark::mk());
}
}

View File

@ -2,6 +2,9 @@
namespace app\data\controller\shop;
use app\data\model\DataUser;
use app\data\model\ShopOrder;
use app\data\model\ShopOrderSend;
use app\data\service\OrderService;
use app\data\service\PaymentService;
use app\data\service\UserAdminService;
@ -50,21 +53,21 @@ class Order extends Controller
$this->title = '订单数据管理';
// 状态数据统计
$this->total = ['t0' => 0, 't1' => 0, 't2' => 0, 't3' => 0, 't4' => 0, 't5' => 0, 't6' => 0, 'ta' => 0];
foreach ($this->app->db->name($this->table)->field('status,count(1) total')->group('status')->cursor() as $vo) {
foreach (ShopOrder::mk()->field('status,count(1) total')->group('status')->cursor() as $vo) {
[$this->total["t{$vo['status']}"] = $vo['total'], $this->total["ta"] += $vo['total']];
}
// 订单列表查询
$query = $this->_query($this->table);
$query = $this->_query(ShopOrder::mk());
$query->like('order_no,truck_name,truck_phone,truck_province|truck_area|truck_address#address,truck_send_no,truck_send_name');
$query->equal('status,payment_type,payment_status')->dateBetween('create_at,payment_datetime,cancel_datetime,truck_datetime,truck_send_datetime');
// 发货信息搜索
$db = $this->_query('ShopOrderSend')->like('address_name#truck_address_name,address_phone#truck_address_phone,address_province|address_city|address_area|address_content#truck_address_content')->db();
$db = $this->_query(ShopOrderSend::class)->like('address_name#truck_address_name,address_phone#truck_address_phone,address_province|address_city|address_area|address_content#truck_address_content')->db();
if ($db->getOptions('where')) $query->whereRaw("order_no in {$db->field('order_no')->buildSql()}");
// 用户搜索查询
$db = $this->_query('DataUser')->like('phone#user_phone,nickname#user_nickname')->db();
$db = $this->_query(DataUser::class)->like('phone#user_phone,nickname#user_nickname')->db();
if ($db->getOptions('where')) $query->whereRaw("uuid in {$db->field('id')->buildSql()}");
// 代理搜索查询
$db = $this->_query('DataUser')->like('phone#from_phone,nickname#from_nickname')->db();
$db = $this->_query(DataUser::class)->like('phone#from_phone,nickname#from_nickname')->db();
if ($db->getOptions('where')) $query->whereRaw("puid1 in {$db->field('id')->buildSql()}");
// 列表选项卡
if (is_numeric($this->type = trim(input('type', 'ta'), 't'))) {
@ -99,7 +102,7 @@ class Order extends Controller
public function audit()
{
if ($this->request->isGet()) {
$this->_form($this->table, '', 'order_no');
$this->_form(ShopOrder::mk(), '', 'order_no');
} else {
$data = $this->_vali([
'order_no.require' => '订单单号不能为空!',
@ -119,13 +122,13 @@ class Order extends Controller
$data['payment_remark'] = $data['remark'] ?: '后台审核支付凭证通过';
$data['payment_datetime'] = date('Y-m-d H:i:s');
}
$order = $this->app->db->name($this->table)->where(['order_no' => $data['order_no']])->find();
$order = ShopOrder::mk()->where(['order_no' => $data['order_no']])->find();
if (empty($order) || $order['status'] !== 3) $this->error('不允许操作审核!');
// 无需发货时的处理
if ($data['status'] === 4 && empty($order['truck_type'])) $data['status'] = 6;
// 更新订单支付状态
$map = ['status' => 3, 'order_no' => $data['order_no']];
if ($this->app->db->name($this->table)->strict(false)->where($map)->update($data) !== false) {
if (ShopOrder::mk()->strict(false)->where($map)->update($data) !== false) {
if (in_array($data['status'], [4, 5, 6])) {
$this->app->event->trigger('ShopOrderPayment', $data['order_no']);
$this->success('订单审核通过成功!');
@ -159,11 +162,11 @@ class Order extends Controller
public function cancel()
{
$map = $this->_vali(['order_no.require' => '订单号不能为空!',]);
$order = $this->app->db->name($this->table)->where($map)->find();
$order = ShopOrder::mk()->where($map)->find();
if (empty($order)) $this->error('订单查询异常!');
if (!in_array($order['status'], [1, 2, 3])) $this->error('订单不能取消!');
try {
$result = $this->app->db->name($this->table)->where($map)->update([
$result = $order->save([
'status' => 0,
'cancel_status' => 1,
'cancel_remark' => '后台取消未支付的订单',
@ -182,5 +185,4 @@ class Order extends Controller
$this->error($exception->getMessage());
}
}
}

View File

@ -2,6 +2,9 @@
namespace app\data\controller\shop;
use app\data\model\BasePostageCompany;
use app\data\model\ShopOrder;
use app\data\model\ShopOrderSend;
use app\data\service\ExpressService;
use app\data\service\OrderService;
use think\admin\Controller;
@ -14,12 +17,6 @@ use think\exception\HttpResponseException;
*/
class Send extends Controller
{
/**
* 绑定数据表
* @var string
*/
private $table = 'ShopOrderSend';
/**
* 订单发货管理
* @auth true
@ -35,21 +32,21 @@ class Send extends Controller
$this->address = sysdata('ordersend');
// 状态数据统计
$this->total = ['t0' => 0, 't1' => 0, 't2' => 0, 'ta' => 0];
$db = $this->app->db->name('ShopOrder')->whereIn('status', [4, 5, 6])->where(['truck_type' => 1]);
$query = $this->app->db->name($this->table)->whereRaw("order_no in {$db->field('order_no')->buildSql()}");
$db = ShopOrder::mk()->whereIn('status', [4, 5, 6])->where(['truck_type' => 1]);
$query = ShopOrderSend::mk()->whereRaw("order_no in {$db->field('order_no')->buildSql()}");
foreach ($query->fieldRaw('status,count(1) total')->group('status')->cursor() as $vo) {
$this->total["t{$vo['status']}"] = $vo['total'];
$this->total["ta"] += $vo['total'];
}
// 订单列表查询
$query = $this->_query($this->table);
$query = $this->_query(ShopOrderSend::class);
$query->dateBetween('address_datetime,send_datetime')->equal('status')->like('send_number#truck_number,order_no');
$query->like('address_phone,address_name,address_province|address_city|address_area|address_content#address_content');
// 用户搜索查询
$db = $this->_query('DataUser')->like('phone#user_phone,nickname#user_nickname')->db();
if ($db->getOptions('where')) $query->whereRaw("uuid in {$db->field('id')->buildSql()}");
// 订单搜索查询
$db = $this->app->db->name('ShopOrder')->whereIn('status', [4, 5, 6])->where(['truck_type' => 1]);
$db = ShopOrder::mk()->whereIn('status', [4, 5, 6])->where(['truck_type' => 1]);
$query->whereRaw("order_no in {$db->field('order_no')->buildSql()}");
// 列表选项卡状态
if (is_numeric($this->type = trim(input('type', 'ta'), 't'))) {
@ -70,7 +67,7 @@ class Send extends Controller
{
OrderService::instance()->buildData($data, false);
$orders = array_unique(array_column($data, 'order_no'));
$orderList = $this->app->db->name('ShopOrder')->whereIn('order_no', $orders)->column('*', 'order_no');
$orderList = ShopOrder::mk()->whereIn('order_no', $orders)->column('*', 'order_no');
foreach ($data as &$vo) $vo['order'] = $orderList[$vo['order_no']] ?? [];
}
@ -102,8 +99,7 @@ class Send extends Controller
public function truck()
{
if ($this->request->isGet()) {
$map = ['deleted' => 0, 'status' => 1];
$query = $this->app->db->name('BasePostageCompany')->where($map);
$query = BasePostageCompany::mk()->where(['deleted' => 0, 'status' => 1]);
$this->items = $query->order('sort desc,id desc')->select()->toArray();
}
$this->_form('ShopOrderSend', 'truck_form', 'order_no');
@ -120,11 +116,11 @@ class Send extends Controller
{
if ($this->request->isPost()) {
$map = ['order_no' => $vo['order_no']];
$order = $this->app->db->name('ShopOrder')->where($map)->find();
$order = ShopOrder::mk()->where($map)->find();
if (empty($order)) $this->error('订单查询异常,请稍候再试!');
// 配送快递公司填写
$map = ['code_1|code_2|code_3' => $vo['company_code']];
$company = $this->app->db->name('BasePostageCompany')->where($map)->find();
$company = BasePostageCompany::mk()->where($map)->find();
if (empty($company)) $this->error('配送快递公司异常,请重新选择快递公司!');
$vo['status'] = 2;
$vo['company_name'] = $company['name'];
@ -132,7 +128,7 @@ class Send extends Controller
// 更新订单发货状态
if ($order['status'] === 3) {
$map = ['order_no' => $vo['order_no']];
$this->app->db->name('ShopOrder')->where($map)->update(['status' => 4]);
ShopOrder::mk()->where($map)->update(['status' => 4]);
}
}
}
@ -145,10 +141,7 @@ class Send extends Controller
public function query()
{
try {
$data = $this->_vali([
'code.require' => '快递编号不能为空!',
'number.require' => '配送单号不能为空!',
]);
$data = $this->_vali(['code.require' => '快递不能为空!', 'number.require' => '单号不能为空!']);
$this->result = ExpressService::instance()->query($data['code'], $data['number']);
if (empty($this->result['code'])) $this->error($this->result['info']);
$this->fetch('truck_query');
@ -158,5 +151,4 @@ class Send extends Controller
$this->error($exception->getMessage());
}
}
}

View File

@ -2,6 +2,12 @@
namespace app\data\controller\total;
use app\data\model\BaseUserUpgrade;
use app\data\model\DataUser;
use app\data\model\DataUserBalance;
use app\data\model\DataUserRebate;
use app\data\model\ShopGoods;
use app\data\model\ShopOrder;
use think\admin\Controller;
/**
@ -18,10 +24,10 @@ class Portal extends Controller
*/
public function index()
{
$this->usersTotal = $this->app->db->name('DataUser')->cache(true, 60)->count();
$this->goodsTotal = $this->app->db->name('ShopGoods')->cache(true, 60)->where(['deleted' => 0])->count();
$this->orderTotal = $this->app->db->name('ShopOrder')->cache(true, 60)->whereRaw('status >= 4')->count();
$this->amountTotal = $this->app->db->name('ShopOrder')->cache(true, 60)->whereRaw('status >= 4')->sum('amount_total');
$this->usersTotal = DataUser::mk()->cache(true, 60)->count();
$this->goodsTotal = ShopGoods::mk()->cache(true, 60)->where(['deleted' => 0])->count();
$this->orderTotal = ShopOrder::mk()->cache(true, 60)->whereRaw('status >= 4')->count();
$this->amountTotal = ShopOrder::mk()->cache(true, 60)->whereRaw('status >= 4')->sum('amount_total');
// 近十天用户及交易趋势
$this->days = $this->app->cache->get('portals', []);
if (empty($this->days)) {
@ -29,20 +35,20 @@ class Portal extends Controller
$date = date('Y-m-d', strtotime("-{$i}days"));
$this->days[] = [
'当天日期' => date('m-d', strtotime("-{$i}days")),
'增加用户' => $this->app->db->name('DataUser')->whereLike('create_at', "{$date}%")->count(),
'订单数量' => $this->app->db->name('ShopOrder')->whereLike('create_at', "{$date}%")->whereRaw('status>=4')->count(),
'订单金额' => $this->app->db->name('ShopOrder')->whereLike('create_at', "{$date}%")->whereRaw('status>=4')->sum('amount_total'),
'返利金额' => $this->app->db->name('DataUserRebate')->whereLike('create_at', "{$date}%")->sum('amount'),
'剩余余额' => $this->app->db->name('DataUserBalance')->whereRaw("create_at<='{$date} 23:59:59' and deleted=0")->sum('amount'),
'充值余额' => $this->app->db->name('DataUserBalance')->whereLike('create_at', "{$date}%")->whereRaw('amount>0 and deleted=0')->sum('amount'),
'消费余额' => $this->app->db->name('DataUserBalance')->whereLike('create_at', "{$date}%")->whereRaw('amount<0 and deleted=0')->sum('amount'),
'增加用户' => DataUser::mk()->whereLike('create_at', "{$date}%")->count(),
'订单数量' => ShopOrder::mk()->whereLike('create_at', "{$date}%")->whereRaw('status>=4')->count(),
'订单金额' => ShopOrder::mk()->whereLike('create_at', "{$date}%")->whereRaw('status>=4')->sum('amount_total'),
'返利金额' => DataUserRebate::mk()->whereLike('create_at', "{$date}%")->sum('amount'),
'剩余余额' => DataUserBalance::mk()->whereRaw("create_at<='{$date} 23:59:59' and deleted=0")->sum('amount'),
'充值余额' => DataUserBalance::mk()->whereLike('create_at', "{$date}%")->whereRaw('amount>0 and deleted=0')->sum('amount'),
'消费余额' => DataUserBalance::mk()->whereLike('create_at', "{$date}%")->whereRaw('amount<0 and deleted=0')->sum('amount'),
];
}
$this->app->cache->set('portals', $this->days, 60);
}
// 会员级别分布统计
$levels = $this->app->db->name('BaseUserUpgrade')->where(['status' => 1])->order('number asc')->column('number code,name,0 count', 'number');
foreach ($this->app->db->name('DataUser')->field('count(1) count,vip_code level')->group('vip_code')->cursor() as $vo) {
$levels = BaseUserUpgrade::mk()->where(['status' => 1])->order('number asc')->column('number code,name,0 count', 'number');
foreach (DataUser::mk()->field('count(1) count,vip_code level')->group('vip_code')->cursor() as $vo) {
$levels[$vo['level']]['count'] = isset($levels[$vo['level']]) ? $vo['count'] : 0;
}
$this->levels = array_values($levels);

View File

@ -2,6 +2,7 @@
namespace app\data\controller\user;
use app\data\model\DataUser;
use app\data\service\UserAdminService;
use app\data\service\UserUpgradeService;
use think\admin\Controller;
@ -13,12 +14,6 @@ use think\admin\Controller;
*/
class Admin extends Controller
{
/**
* 绑定数据表
* @var string
*/
private $table = 'DataUser';
/**
* 普通用户管理
* @auth true
@ -35,7 +30,7 @@ class Admin extends Controller
foreach ($ls as $k => $v) $ts["t{$k}"] = ['vip' => $k, 'name' => $v['name'], 'count' => 0,];
$ts['to'] = ['vip' => '', 'name' => '其他用户', 'count' => 0];
// 等级分组统计
foreach ($this->app->db->name($this->table)->field('vip_code vip,count(1) count')->group('vip_code')->cursor() as $v) {
foreach (DataUser::mk()->field('vip_code vip,count(1) count')->group('vip_code')->cursor() as $v) {
[$name, $count] = ["t{$v['vip']}", $v['count'], $ts['ta']['count'] += $v['count']];
isset($ts[$name]) ? $ts[$name]['count'] += $count : $ts['to']['count'] += $count;
}
@ -45,13 +40,13 @@ class Admin extends Controller
// 设置页面标题
$this->title = '普通用户管理';
// 创建查询对象
$query = $this->_query($this->table)->order('id desc');
$query = $this->_query(DataUser::class)->order('id desc');
// 数据筛选选项
$this->type = ltrim(input('type', 'ta'), 't');
if (is_numeric($this->type)) $query->where(['vip_code' => $this->type]);
elseif ($this->type === 'o') $query->whereNotIn('vip_code', array_keys($ls));
// 用户搜索查询
$db = $this->_query($this->table)->equal('vip_code#from_vipcode')->like('phone#from_phone,username|nickname#from_username')->db();
$db = $this->_query(DataUser::class)->equal('vip_code#from_vipcode')->like('phone#from_phone,username|nickname#from_username')->db();
if ($db->getOptions('where')) $query->whereRaw("pid1 in {$db->field('id')->buildSql()}");
// 数据查询分页
$query->like('phone,username|nickname#username')->equal('status,vip_code')->dateBetween('create_at')->page();
@ -79,7 +74,7 @@ class Admin extends Controller
{
$this->title = '用户团队关系';
$map = ['pid1' => input('from', 0)];
$this->_query($this->table)->where($map)->page(false);
$this->_query(DataUser::class)->where($map)->page(false);
}
/**
@ -89,7 +84,7 @@ class Admin extends Controller
protected function _teams_page_filter(array &$data)
{
$uids = array_unique(array_column($data, 'id'));
$subCount = $this->app->db->name($this->table)->whereIn('pid1', $uids)->group('pid1')->column('count(1) count', 'pid1');
$subCount = DataUser::mk()->whereIn('pid1', $uids)->group('pid1')->column('count(1) count', 'pid1');
foreach ($data as &$vo) $vo['subCount'] = $subCount[$vo['id']] ?? 0;
}
@ -103,7 +98,7 @@ class Admin extends Controller
public function forever()
{
$map = $this->_vali(['id.require' => '用户ID不能为空']);
$user = $this->app->db->name($this->table)->where($map)->find();
$user = DataUser::mk()->where($map)->find();
if (empty($user) || empty($user['pid0'])) $this->error('用户不符合操作要求!');
[$status, $message] = UserUpgradeService::instance()->bindAgent($user['id'], $user['pid0']);
$status && sysoplog('前端用户管理', "修改用户[{$map['id']}]的代理为永久状态");
@ -120,10 +115,10 @@ class Admin extends Controller
public function unbind()
{
$map = $this->_vali(['id.require' => '用户ID不能为空']);
$user = $this->app->db->name($this->table)->where($map)->find();
$user = DataUser::mk()->where($map)->find();
if (empty($user)) $this->error('用户不符合操作要求!');
// 修改指定用户代理数据
$this->app->db->name($this->table)->where(['id' => $user['id']])->update([
DataUser::mk()->where(['id' => $user['id']])->update([
'pid0' => 0, 'pid1' => 0, 'pid2' => 0, 'pids' => 1, 'path' => '-', 'layer' => 1,
]);
// 刷新用户等级及上级等级
@ -145,11 +140,11 @@ class Admin extends Controller
$this->upgrades = UserUpgradeService::instance()->levels();
$data = $this->_vali(['uuid.require' => '待操作UID不能为空']);
// 排除下级用户
$path = $this->app->db->name($this->table)->where(['id' => $data['uuid']])->value('path', '-');
$subids = $this->app->db->name($this->table)->whereLike('path', "{$path}{$data['uuid']}-%")->column('id');
$query = $this->_query($this->table)->order('id desc')->whereNotIn('id', array_merge($subids, array_values($data)));
$path = DataUser::mk()->where(['id' => $data['uuid']])->value('path', '-');
$subids = DataUser::mk()->whereLike('path', "{$path}{$data['uuid']}-%")->column('id');
$query = $this->_query(DataUser::class)->order('id desc')->whereNotIn('id', array_merge($subids, array_values($data)));
// 用户搜索查询
$db = $this->_query($this->table)->equal('vip_code#from_vipcode')->like('phone#from_phone,username|nickname#from_username')->db();
$db = $this->_query(DataUser::class)->equal('vip_code#from_vipcode')->like('phone#from_phone,username|nickname#from_username')->db();
if ($db->getOptions('where')) $query->whereRaw("pid1 in {$db->field('id')->buildSql()}");
// 数据查询分页
$query->like('phone,username|nickname#username')->whereRaw('vip_code>0')->equal('status,vip_code')->dateBetween('create_at')->page();
@ -177,7 +172,7 @@ class Admin extends Controller
*/
public function state()
{
$this->_save($this->table, $this->_vali([
$this->_save(DataUser::class, $this->_vali([
'status.in:0,1' => '状态值范围异常!',
'status.require' => '状态值不能为空!',
]));

View File

@ -2,6 +2,8 @@
namespace app\data\controller\user;
use app\admin\model\SystemUser;
use app\data\model\DataUser;
use app\data\service\UserAdminService;
use app\data\service\UserBalanceService;
use app\data\service\UserUpgradeService;
@ -54,7 +56,7 @@ class Balance extends Controller
{
UserAdminService::instance()->buildByUid($data);
$uids = array_unique(array_column($data, 'create_by'));
$users = $this->app->db->name('SystemUser')->whereIn('id', $uids)->column('username', 'id');
$users = SystemUser::mk()->whereIn('id', $uids)->column('username', 'id');
$this->upgrades = UserUpgradeService::instance()->levels();
foreach ($data as &$vo) {
$vo['upgradeinfo'] = $this->upgrades[$vo['upgrade']] ?? [];
@ -72,7 +74,7 @@ class Balance extends Controller
public function add()
{
$data = $this->_vali(['uuid.require' => '用户UID不能为空']);
$this->user = $this->app->db->name('DataUser')->where(['id' => $data['uuid']])->find();
$this->user = DataUser::mk()->where(['id' => $data['uuid']])->find();
if (empty($this->user)) $this->error('待充值的用户不存在!');
$this->_form($this->table, 'form');
}

View File

@ -2,6 +2,7 @@
namespace app\data\controller\user;
use app\data\model\DataUserMessage;
use app\data\service\MessageService;
use think\admin\Controller;
@ -12,12 +13,6 @@ use think\admin\Controller;
*/
class Message extends Controller
{
/**
* 绑定数据表
* @var string
*/
protected $table = 'DataUserMessage';
/**
* 短信发送管理
* @auth true
@ -29,7 +24,7 @@ class Message extends Controller
public function index()
{
$this->title = '短信发送管理';
$query = $this->_query($this->table);
$query = $this->_query(DataUserMessage::mk());
$query->equal('status')->like('phone,content');
$query->dateBetween('create_at')->order('id desc')->page();
}
@ -62,7 +57,7 @@ class Message extends Controller
*/
public function remove()
{
$this->_delete($this->table);
$this->_delete(DataUserMessage::mk());
}
}

View File

@ -2,6 +2,9 @@
namespace app\data\controller\user;
use app\data\model\DataUser;
use app\data\model\DataUserRebate;
use app\data\model\ShopOrderItem;
use app\data\service\RebateService;
use app\data\service\UserRebateService;
use app\data\service\UserUpgradeService;
@ -14,13 +17,6 @@ use think\admin\Controller;
*/
class Rebate extends Controller
{
/**
* 绑定数据表
* @var string
*/
private $table = 'DataUserRebate';
/**
* 用户返利管理
* @auth true
@ -36,7 +32,7 @@ class Rebate extends Controller
$this->types = RebateService::PRIZES;
$this->rebate = UserRebateService::instance()->amount(0);
// 创建查询对象
$query = $this->_query($this->table)->equal('type')->like('name,order_no');
$query = $this->_query(DataUserRebate::class)->equal('type')->like('name,order_no');
// 会员条件查询
$db = $this->_query('DataUser')->like('nickname#order_nickname,phone#order_phone')->db();
if ($db->getOptions('where')) $query->whereRaw("order_uuid in {$db->field('id')->buildSql()}");
@ -57,8 +53,8 @@ class Rebate extends Controller
protected function _index_page_filter(array &$data)
{
$uids = array_merge(array_column($data, 'uuid'), array_column($data, 'order_uuid'));
$userItem = $this->app->db->name('DataUser')->whereIn('id', array_unique($uids))->select();
$goodsItem = $this->app->db->name('ShopOrderItem')->whereIn('order_no', array_unique(array_column($data, 'order_no')))->select();
$userItem = DataUser::mk()->whereIn('id', array_unique($uids))->select();
$goodsItem = ShopOrderItem::mk()->whereIn('order_no', array_unique(array_column($data, 'order_no')))->select();
foreach ($data as &$vo) {
$vo['type'] = RebateService::instance()->name($vo['type']);
[$vo['user'], $vo['agent'], $vo['list']] = [[], [], []];

View File

@ -2,6 +2,8 @@
namespace app\data\controller\user;
use app\data\model\DataUser;
use app\data\model\DataUserTransfer;
use app\data\service\UserAdminService;
use app\data\service\UserTransferService;
use think\admin\Controller;
@ -89,9 +91,9 @@ class Transfer extends Controller
$this->title = '用户提现管理';
$this->transfer = UserTransferService::instance()->amount(0);
// 创建查询对象
$query = $this->_query($this->table)->order('id desc');
$query = $this->_query(DataUserTransfer::mk())->order('id desc');
// 用户条件搜索
$db = $this->_query('DataUser')->like('phone,username|nickname#nickname')->db();
$db = $this->_query(DataUser::class)->like('phone,username|nickname#nickname')->db();
if ($db->getOptions('where')) $query->whereRaw("uuid in {$db->field('id')->buildSql()}");
// 数据列表处理
$query->equal('type,status')->dateBetween('create_at')->page();
@ -143,7 +145,7 @@ class Transfer extends Controller
private function _audit()
{
if ($this->request->isGet()) {
$this->_form($this->table, 'audit', 'code');
$this->_form(DataUserTransfer::mk(), 'audit', 'code');
} else {
$data = $this->_vali([
'code.require' => '打款单号不能为空!',
@ -152,7 +154,7 @@ class Transfer extends Controller
'remark.default' => '',
]);
$map = ['code' => $data['code']];
$find = $this->app->db->name($this->table)->where($map)->find();
$find = DataUserTransfer::mk()->where($map)->find();
if (empty($find)) $this->error('不允许操作审核!');
// 提现状态(0已拒绝, 1待审核, 2已审核, 3打款中, 4已打款, 5已收款)
if (in_array($data['status'], [0, 1, 2, 3])) {
@ -163,7 +165,7 @@ class Transfer extends Controller
$data['change_time'] = date('Y-m-d H:i:s');
$data['change_desc'] = ($data['remark'] ?: '线下打款成功') . ' By ' . AdminService::instance()->getUserName();
}
if ($this->app->db->name($this->table)->strict(false)->where($map)->update($data) !== false) {
if (DataUserTransfer::mk()->strict(false)->where($map)->update($data) !== false) {
$this->success('操作成功');
} else {
$this->error('操作失败!');

View File

@ -0,0 +1,15 @@
<?php
namespace app\data\model;
use think\admin\Model;
/**
*
* Class BasePostageCompany
* @package app\data\model
*/
class BasePostageCompany extends Model
{
}

View File

@ -0,0 +1,14 @@
<?php
namespace app\data\model;
use think\admin\Model;
/**
*
* Class BasePostageRegion
* @package app\data\model
*/
class BasePostageRegion extends Model
{
}

View File

@ -0,0 +1,15 @@
<?php
namespace app\data\model;
use think\admin\Model;
/**
* 用户通知消息模型
* Class BaseUserMessage
* @package app\data\model
*/
class BaseUserMessage extends Model
{
}

View File

@ -0,0 +1,15 @@
<?php
namespace app\data\model;
use think\admin\Model;
/**
*
* Class DataNewsItem
* @package app\data\model
*/
class DataNewsItem extends Model
{
}

View File

@ -0,0 +1,15 @@
<?php
namespace app\data\model;
use think\admin\Model;
/**
*
* Class DataNewsMark
* @package app\data\model
*/
class DataNewsMark extends Model
{
}

View File

@ -0,0 +1,15 @@
<?php
namespace app\data\model;
use think\admin\Model;
/**
*
* Class DataNewsXCollect
* @package app\data\model
*/
class DataNewsXCollect extends Model
{
}