同步代码

This commit is contained in:
邹景立 2021-06-17 13:17:32 +08:00
parent 95236e9b9f
commit 19eadbcbad
32 changed files with 8840 additions and 4876 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -18,9 +18,9 @@ class UserAgent extends Command
protected function configure()
{
$this->setName('xdata:UserAgent');
$this->addArgument('uid', Argument::OPTIONAL, '目标用户', '');
$this->addArgument('pid', Argument::OPTIONAL, '上级代理', '');
$this->setDescription('重新设置用户上级代理, 参数:UID PID');
$this->addArgument('uuid', Argument::OPTIONAL, '目标用户', '');
$this->addArgument('puid', Argument::OPTIONAL, '上级代理', '');
$this->setDescription('重新设置用户上级代理, 参数:uuid puid');
}
/**
@ -34,12 +34,12 @@ class UserAgent extends Command
*/
protected function execute(Input $input, Output $output)
{
[$uid, $pid] = [$input->getArgument('uid'), $input->getArgument('pid')];
if (empty($uid)) $this->setQueueError("参数UID无效请传入正确的参数!");
[$uuid, $pid] = [$input->getArgument('uuid'), $input->getArgument('pid')];
if (empty($uuid)) $this->setQueueError("参数UID无效请传入正确的参数!");
if (empty($pid)) $this->setQueueError("参数PID无效请传入正确的参数!");
// 检查当前用户资料
$user = $this->app->db->name('DataUser')->where(['id' => $uid])->find();
$user = $this->app->db->name('DataUser')->where(['id' => $uuid])->find();
if (empty($user)) $this->setQueueError("读取用户数据失败!");
// 检查上级代理用户

View File

@ -98,7 +98,7 @@ class UserTransfer extends Command
*/
private function createTransferBank(array $item): array
{
$config = $this->getConfig($item['uid']);
$config = $this->getConfig($item['uuid']);
return [$config, TransfersBank::instance($config)->create([
'partner_trade_no' => $item['code'],
'enc_bank_no' => $item['bank_code'],
@ -111,14 +111,14 @@ class UserTransfer extends Command
/**
* 获取微信提现参数
* @param int $uid
* @param int $uuid
* @return array
* @throws Exception
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
private function getConfig(int $uid): array
private function getConfig(int $uuid): array
{
$data = sysdata('TransferWxpay');
if (empty($data)) throw new Exception('未配置微信提现商户');
@ -131,7 +131,7 @@ class UserTransfer extends Command
$local->set($file2, $data['wechat_mch_cert_text'], true);
}
// 获取用户支付信息
$result = $this->getWechatInfo($uid, $data['wechat_type']);
$result = $this->getWechatInfo($uuid, $data['wechat_type']);
if (empty($result)) throw new Exception('无法读取打款数据');
return [
'appid' => $result[0],
@ -146,16 +146,16 @@ class UserTransfer extends Command
/**
* 根据配置获取用户OPENID
* @param int $uid
* @param int $uuid
* @param string $type
* @return mixed|null
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
private function getWechatInfo(int $uid, string $type): ?array
private function getWechatInfo(int $uuid, string $type): ?array
{
$user = $this->app->db->name('DataUser')->where(['id' => $uid])->find();
$user = $this->app->db->name('DataUser')->where(['id' => $uuid])->find();
if (empty($user)) return null;
$appid1 = sysconf('data.wxapp_appid');
if (strtolower(sysconf('wechat.type')) === 'api') {
@ -189,7 +189,7 @@ class UserTransfer extends Command
*/
private function createTransferWallet(array $item): array
{
$config = $this->getConfig($item['uid']);
$config = $this->getConfig($item['uuid']);
return [$config, Transfers::instance($config)->create([
'openid' => $config['openid'],
'amount' => intval($item['amount'] - $item['charge_amount']) * 100,
@ -212,7 +212,7 @@ class UserTransfer extends Command
*/
private function queryTransferBank(array $item)
{
$config = $this->getConfig($item['uid']);
$config = $this->getConfig($item['uuid']);
[$config['appid'], $config['openid']] = [$item['appid'], $item['openid']];
$result = TransfersBank::instance($config)->query($item['trade_no']);
if ($result['return_code'] === 'SUCCESS' && $result['result_code'] === 'SUCCESS') {
@ -233,7 +233,7 @@ class UserTransfer extends Command
'change_desc' => '微信提现打款失败',
]);
// 刷新用户可提现余额
UserRebateService::instance()->amount($item['uid']);
UserRebateService::instance()->amount($item['uuid']);
}
}
}
@ -250,7 +250,7 @@ class UserTransfer extends Command
*/
private function queryTransferWallet(array $item)
{
$config = $this->getConfig($item['uid']);
$config = $this->getConfig($item['uuid']);
[$config['appid'], $config['openid']] = [$item['appid'], $item['openid']];
$result = Transfers::instance($config)->query($item['trade_no']);
if ($result['return_code'] === 'SUCCESS' && $result['result_code'] === 'SUCCESS') {

View File

@ -35,8 +35,8 @@ class News extends Controller
{
if ($code = input('code', '')) {
$this->app->db->name('DataNewsItem')->where(['code' => $code])->inc('num_read')->update();
if (($uid = input('uid', 0)) > 0) {
$data = ['uid' => $uid, 'code' => $code, 'type' => 3, 'status' => 2];
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);
}
@ -44,7 +44,7 @@ class News extends Controller
$query = $this->_query('DataNewsItem')->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('uid', 0));
NewsService::instance()->buildData($result['list'], input('uuid', 0));
$this->success('获取文章内容', $result);
}

View File

@ -25,7 +25,7 @@ class Address extends Auth
public function set()
{
$data = $this->_vali([
'uid.value' => $this->uuid,
'uuid.value' => $this->uuid,
'type.default' => 0,
'code.default' => '',
'idcode.default' => '', // 身份证号码
@ -50,14 +50,14 @@ class Address extends Auth
$this->error('添加地址失败!');
}
} else {
$map = ['uid' => $this->uuid, 'code' => $data['code']];
$map = ['uuid' => $this->uuid, 'code' => $data['code']];
$address = $this->app->db->name($this->table)->where($map)->find();
if (empty($address)) $this->error('修改地址不存在!');
$this->app->db->name($this->table)->where($map)->update($data);
}
// 去除其它默认选项
if (isset($data['type']) && $data['type'] > 0) {
$map = [['uid', '=', $this->uuid], ['code', '<>', $data['code']]];
$map = [['uuid', '=', $this->uuid], ['code', '<>', $data['code']]];
$this->app->db->name($this->table)->where($map)->update(['type' => 0]);
}
$this->success('地址保存成功!', $this->_getAddress($data['code']));
@ -72,7 +72,7 @@ class Address extends Auth
public function get()
{
$query = $this->_query($this->table)->withoutField('deleted');
$query->equal('code')->where(['uid' => $this->uuid, 'deleted' => 0]);
$query->equal('code')->where(['uuid' => $this->uuid, 'deleted' => 0]);
$result = $query->order('type desc,id desc')->page(false, false, false, 15);
$this->success('获取地址数据!', $result);
}
@ -84,13 +84,13 @@ class Address extends Auth
public function state()
{
$data = $this->_vali([
'uid.value' => $this->uuid,
'uuid.value' => $this->uuid,
'type.in:0,1' => '地址状态不在范围!',
'type.require' => '地址状态不能为空!',
'code.require' => '地址编号不能为空!',
]);
// 检查地址是否存在
$map = ['uid' => $data['uid'], 'code' => $data['code']];
$map = ['uuid' => $data['uuid'], 'code' => $data['code']];
if ($this->app->db->name($this->table)->where($map)->count() < 1) {
$this->error('修改的地址不存在!');
}
@ -99,7 +99,7 @@ class Address extends Auth
$this->app->db->name($this->table)->where($map)->update(['type' => $data['type']]);
// 去除其它默认选项
if ($data['type'] > 0) {
$map = [['uid', '=', $this->uuid], ['code', '<>', $data['code']]];
$map = [['uuid', '=', $this->uuid], ['code', '<>', $data['code']]];
$this->app->db->name($this->table)->where($map)->update(['type' => 0]);
}
$this->success('默认设置成功!', $this->_getAddress($data['code']));
@ -112,7 +112,7 @@ class Address extends Auth
public function remove()
{
$map = $this->_vali([
'uid.value' => $this->uuid, 'code.require' => '地址编号不能为空!',
'uuid.value' => $this->uuid, 'code.require' => '地址编号不能为空!',
]);
$address = $this->app->db->name($this->table)->where($map)->find();
if (empty($address)) $this->error('需要删除的地址不存在!');
@ -133,7 +133,7 @@ class Address extends Auth
*/
private function _getAddress(string $code): ?array
{
$map = ['code' => $code, 'uid' => $this->uuid, 'deleted' => 0];
$map = ['code' => $code, 'uuid' => $this->uuid, 'deleted' => 0];
return $this->app->db->name($this->table)->withoutField('deleted')->where($map)->find();
}

View File

@ -26,7 +26,7 @@ class Balance extends Auth
public function get()
{
$query = $this->_query($this->table);
$query->withoutField('deleted,create_by')->where(['uid' => $this->uuid, 'deleted' => 0]);
$query->withoutField('deleted,create_by')->where(['uuid' => $this->uuid, 'deleted' => 0]);
$result = $query->like('create_at#date')->order('id desc')->page(true, false, false, 10);
$this->success('获取数据成功', $result);
}

View File

@ -126,7 +126,7 @@ class Center extends Auth
$map[] = ['path', 'like', "%-{$this->uuid}-%"];
// 查询邀请的朋友
$query = $this->_query($this->table);
$query->like('nickname|username#nickname')->equal('vip_code,pids,pid1,id#uid');
$query->like('nickname|username#nickname')->equal('vip_code,pids,pid1,id#uuid');
$query->field('id,pid0,pid1,pid2,pids,username,nickname,headimg,order_amount_total,teams_amount_total,teams_amount_direct,teams_amount_indirect,teams_users_total,teams_users_direct,teams_users_indirect,rebate_total,rebate_used,rebate_lock,create_at');
$result = $query->where($map)->order('id desc')->page(true, false, false, 15);
// 统计当前用户所有下属数

View File

@ -25,7 +25,7 @@ class News extends Auth
public function addComment()
{
$data = $this->_vali([
'uid.value' => $this->uuid,
'uuid.value' => $this->uuid,
'type.value' => 4,
'status.value' => 1,
'code.require' => '文章不能为空!',
@ -47,7 +47,7 @@ class News extends Auth
*/
public function getComment()
{
$query = $this->_query($this->table)->where(['uid' => $this->uuid, 'type' => 4]);
$query = $this->_query($this->table)->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);
@ -60,7 +60,7 @@ class News extends Auth
public function delComment()
{
$data = $this->_vali([
'uid.value' => $this->uuid,
'uuid.value' => $this->uuid,
'type.value' => 4,
'id.require' => '评论编号不能为空!',
'code.require' => '文章编号不能为空!',
@ -79,7 +79,7 @@ class News extends Auth
public function addCollect()
{
$data = $this->_vali([
'uid.value' => $this->uuid,
'uuid.value' => $this->uuid,
'type.value' => 1,
'status.value' => 2,
'code.require' => '文章编号不能为空!',
@ -102,7 +102,7 @@ class News extends Auth
public function delCollect()
{
$data = $this->_vali([
'uid.value' => $this->uuid,
'uuid.value' => $this->uuid,
'type.value' => 1,
'code.require' => '文章编号不能为空!',
]);
@ -120,7 +120,7 @@ class News extends Auth
*/
public function getCollect()
{
$map = ['uid' => $this->uuid, 'type' => 1];
$map = ['uuid' => $this->uuid, 'type' => 1];
$query = $this->_query('DataNewsXCollect')->where($map);
$result = $query->order('id desc')->page(true, false, false, 15);
NewsService::instance()->buildListByUidAndCode($result['list']);
@ -134,7 +134,7 @@ class News extends Auth
public function addLike()
{
$data = $this->_vali([
'uid.value' => $this->uuid,
'uuid.value' => $this->uuid,
'type.value' => 2,
'status.value' => 2,
'code.require' => '文章编号不能为空!',
@ -157,7 +157,7 @@ class News extends Auth
public function delLike()
{
$data = $this->_vali([
'uid.value' => $this->uuid,
'uuid.value' => $this->uuid,
'type.value' => 2,
'code.require' => '文章编号不能为空!',
]);
@ -176,7 +176,7 @@ class News extends Auth
public function getLike()
{
$query = $this->_query('DataNewsXCollect');
$query->where(['uid' => $this->uuid, 'type' => 2, 'status' => 2]);
$query->where(['uuid' => $this->uuid, 'type' => 2, 'status' => 2]);
$result = $query->order('id desc')->page(true, false, false, 15);
NewsService::instance()->buildListByUidAndCode($result['list']);
$this->success('获取点赞记录成功!', $result);
@ -189,7 +189,7 @@ class News extends Auth
public function addHistory()
{
$data = $this->_vali([
'uid.value' => $this->uuid,
'uuid.value' => $this->uuid,
'type.value' => 2,
'status.value' => 2,
'code.require' => '文章编号不能为空!',
@ -208,7 +208,7 @@ class News extends Auth
public function getHistory()
{
$query = $this->_query('DataNewsXCollect');
$query->where(['uid' => $this->uuid, 'type' => 3, 'status' => 2]);
$query->where(['uuid' => $this->uuid, 'type' => 3, 'status' => 2]);
$result = $query->order('id desc')->page(true, false, false, 15);
NewsService::instance()->buildListByUidAndCode($result['list']);
$this->success('获取浏览历史成功!', $result);

View File

@ -37,7 +37,7 @@ class Order extends Auth
*/
public function get()
{
$map = ['uid' => $this->uuid, 'deleted_status' => 0];
$map = ['uuid' => $this->uuid, 'deleted_status' => 0];
$query = $this->_query('ShopOrder')->in('status')->equal('order_no');
$result = $query->where($map)->order('id desc')->page(true, false, false, 20);
if (count($result['list']) > 0) OrderService::instance()->buildData($result['list']);
@ -59,7 +59,7 @@ class Order extends Auth
if (empty($rules)) $this->error('商品不能为空');
// 订单数据
[$items, $order, $truckType, $allowPayments] = [[], [], -1, null];
$order['uid'] = $this->uuid;
$order['uuid'] = $this->uuid;
$order['order_no'] = CodeExtend::uniqidDate(18, 'N');
// 代理处理
$order['puid1'] = input('from', $this->user['pid1']);
@ -81,7 +81,7 @@ class Order extends Auth
if ($truckType !== $goodsInfo['truck_type']) $this->error('不能混合下单');
// 限制购买数量
if (isset($goods['limit_max_num']) && $goods['limit_max_num'] > 0) {
$map = [['a.uid', '=', $this->uuid], ['a.status', 'in', [2, 3, 4, 5]], ['b.goods_code', '=', $goods['code']]];
$map = [['a.uuid', '=', $this->uuid], ['a.status', 'in', [2, 3, 4, 5]], ['b.goods_code', '=', $goods['code']]];
$buys = $this->app->db->name('StoreOrder')->alias('a')->join('store_order_item b', 'a.order_no=b.order_no')->where($map)->sum('b.stock_sales');
if ($buys + $count > $goods['limit_max_num']) $this->error('超过限购数量');
}
@ -103,7 +103,7 @@ class Order extends Auth
[$discountId, $discountRate] = OrderService::instance()->discount($goodsInfo['discount_id'], $this->user['vip_code']);
// 订单详情处理
$items[] = [
'uid' => $order['uid'],
'uuid' => $order['uuid'],
'order_no' => $order['order_no'],
// 商品信息字段
'goods_name' => $goodsInfo['name'],
@ -205,16 +205,16 @@ class Order extends Auth
public function express()
{
$data = $this->_vali([
'uid.value' => $this->uuid,
'uuid.value' => $this->uuid,
'code.require' => '地址不能为空',
'order_no.require' => '单号不能为空',
]);
// 用户收货地址
$map = ['uid' => $this->uuid, 'code' => $data['code']];
$map = ['uuid' => $this->uuid, 'code' => $data['code']];
$addr = $this->app->db->name('DataUserAddress')->where($map)->find();
if (empty($addr)) $this->error('收货地址异常');
// 订单状态检查
$map = ['uid' => $this->uuid, 'order_no' => $data['order_no']];
$map = ['uuid' => $this->uuid, 'order_no' => $data['order_no']];
$tCount = $this->app->db->name('ShopOrderItem')->where($map)->sum('truck_number');
// 根据地址计算运费
$map = ['status' => 1, 'deleted' => 0, 'order_no' => $data['order_no']];
@ -232,16 +232,16 @@ class Order extends Auth
public function perfect()
{
$data = $this->_vali([
'uid.value' => $this->uuid,
'uuid.value' => $this->uuid,
'code.require' => '地址不能为空',
'order_no.require' => '单号不能为空',
]);
// 用户收货地址
$map = ['uid' => $this->uuid, 'code' => $data['code'], 'deleted' => 0];
$map = ['uuid' => $this->uuid, 'code' => $data['code'], 'deleted' => 0];
$addr = $this->app->db->name('DataUserAddress')->where($map)->find();
if (empty($addr)) $this->error('收货地址异常');
// 订单状态检查
$map1 = ['uid' => $this->uuid, 'order_no' => $data['order_no']];
$map1 = ['uuid' => $this->uuid, 'order_no' => $data['order_no']];
$order = $this->app->db->name('ShopOrder')->where($map1)->whereIn('status', [1, 2])->find();
if (empty($order)) $this->error('不能修改地址');
if (empty($order['truck_type'])) $this->success('无需快递配送', ['order_no' => $order['order_no']]);
@ -252,7 +252,7 @@ class Order extends Auth
[$amount, $tCount, $tCode, $remark] = ExpressService::instance()->amount($tCodes, $addr['province'], $addr['city'], $tCount);
// 创建订单发货信息
$express = [
'template_code' => $tCode, 'template_count' => $tCount, 'uid' => $this->uuid,
'template_code' => $tCode, 'template_count' => $tCount, 'uuid' => $this->uuid,
'template_remark' => $remark, 'template_amount' => $amount, 'status' => 1,
];
$express['order_no'] = $data['order_no'];
@ -282,7 +282,7 @@ class Order extends Auth
if ($update['amount_real'] <= 0) $update['amount_real'] = 0.00;
if ($update['amount_total'] <= 0) $update['amount_total'] = 0.00;
// 更新用户订单数据
$map = ['uid' => $this->uuid, 'order_no' => $data['order_no']];
$map = ['uuid' => $this->uuid, 'order_no' => $data['order_no']];
if ($this->app->db->name('ShopOrder')->where($map)->update($update) !== false) {
// 触发订单确认事件
$this->app->event->trigger('ShopOrderPerfect', $order['order_no']);
@ -298,7 +298,7 @@ class Order extends Auth
*/
public function channel()
{
$data = $this->_vali(['uid.value' => $this->uuid, 'order_no.require' => '单号不能为空']);
$data = $this->_vali(['uuid.value' => $this->uuid, 'order_no.require' => '单号不能为空']);
$payments = $this->app->db->name('ShopOrder')->where($data)->value('payment_allow');
if (empty($payments)) $this->error('获取订单支付参数失败');
// 读取支付通道配置
@ -318,7 +318,7 @@ class Order extends Auth
public function payment()
{
$data = $this->_vali([
'uid.value' => $this->uuid,
'uuid.value' => $this->uuid,
'order_no.require' => '单号不能为空',
'order_remark.default' => '',
'payment_code.require' => '支付不能为空',
@ -443,7 +443,7 @@ class Order extends Auth
*/
private function getOrderData(): array
{
$map = $this->_vali(['uid.value' => $this->uuid, 'order_no.require' => '单号不能为空']);
$map = $this->_vali(['uuid.value' => $this->uuid, 'order_no.require' => '单号不能为空']);
$order = $this->app->db->name('ShopOrder')->where($map)->find();
if (empty($order)) $this->error('读取订单失败');
return [$map, $order];
@ -455,7 +455,7 @@ class Order extends Auth
public function total()
{
$data = ['t0' => 0, 't1' => 0, 't2' => 0, 't3' => 0, 't4' => 0, 't5' => 0, 't6' => 0];
$query = $this->app->db->name('ShopOrder')->where(['uid' => $this->uuid, 'deleted_status' => 0]);
$query = $this->app->db->name('ShopOrder')->where(['uuid' => $this->uuid, 'deleted_status' => 0]);
foreach ($query->field('status,count(1) count')->group('status')->cursor() as $item) {
$data["t{$item['status']}"] = $item['count'];
}

View File

@ -27,7 +27,7 @@ class Rebate extends Auth
public function get()
{
$date = trim(input('date', date('Y-m')), '-');
[$map, $year] = [['uid' => $this->uuid], substr($date, 0, 4)];
[$map, $year] = [['uuid' => $this->uuid], substr($date, 0, 4)];
$query = $this->_query($this->table)->where($map)->equal('type,status')->whereLike('date', "{$date}%");
$this->success('获取返利统计', array_merge($query->order('id desc')->page(true, false, false, 10), [
'total' => [

View File

@ -41,7 +41,7 @@ class Transfer extends Auth
$transfers = UserTransferService::instance()->config('transfer');
if (empty($transfers[$data['type']]['state'])) $this->error('提现方式已停用!');
// 提现数据补充
$data['uid'] = $this->uuid;
$data['uuid'] = $this->uuid;
$data['date'] = date('Y-m-d');
$data['code'] = CodeExtend::uniqidDate(20, 'T');
// 提现状态处理
@ -83,7 +83,7 @@ class Transfer extends Auth
$this->error('转账方式不存在!');
}
// 当日提现次数限制
$map = ['uid' => $this->uuid, 'type' => $data['type'], 'date' => $data['date']];
$map = ['uuid' => $this->uuid, 'type' => $data['type'], 'date' => $data['date']];
$count = $this->app->db->name($this->table)->where($map)->count();
if ($count >= $transfers[$data['type']]['dayNumber']) $this->error("当日提现次数受限");
// 提现金额范围控制
@ -110,10 +110,10 @@ class Transfer extends Auth
*/
public function get()
{
$query = $this->_query($this->table)->where(['uid' => $this->uuid]);
$query = $this->_query($this->table)->where(['uuid' => $this->uuid]);
$result = $query->like('date,code')->in('status')->order('id desc')->page(true, false, false, 10);
// 统计历史数据
$map = [['uid', '=', $this->uuid], ['status', '>', 0]];
$map = [['uuid', '=', $this->uuid], ['status', '>', 0]];
[$total, $count, $locks] = UserRebateService::instance()->amount($this->uuid);
$this->success('获取提现成功', array_merge($result, [
'total' => [
@ -132,7 +132,7 @@ class Transfer extends Auth
*/
public function cancel()
{
$data = $this->_vali(['uid.value' => $this->uuid, 'code.require' => '单号不能为空!']);
$data = $this->_vali(['uuid.value' => $this->uuid, 'code.require' => '单号不能为空!']);
$this->app->db->name($this->table)->where($data)->whereIn('status', [1, 2, 3])->update([
'status' => 0, 'change_time' => date("Y-m-d H:i:s"), 'change_desc' => '用户主动取消提现',
]);
@ -146,7 +146,7 @@ class Transfer extends Auth
*/
public function confirm()
{
$data = $this->_vali(['uid.value' => $this->uuid, 'code.require' => '单号不能为空!']);
$data = $this->_vali(['uuid.value' => $this->uuid, 'code.require' => '单号不能为空!']);
$this->app->db->name($this->table)->where($data)->whereIn('status', [4])->update([
'status' => 5, 'change_time' => date("Y-m-d H:i:s"), 'change_desc' => '用户主动确认收款',
]);

View File

@ -62,7 +62,7 @@ class Order extends Controller
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();
if ($db->getOptions('where')) $query->whereRaw("uid in {$db->field('id')->buildSql()}");
if ($db->getOptions('where')) $query->whereRaw("uuid in {$db->field('id')->buildSql()}");
// 代理搜索查询
$db = $this->_query('DataUser')->like('phone#from_phone,nickname#from_nickname')->db();
if ($db->getOptions('where')) $query->whereRaw("puid1 in {$db->field('id')->buildSql()}");

View File

@ -47,7 +47,7 @@ class Send extends Controller
$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("uid in {$db->field('id')->buildSql()}");
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]);
$query->whereRaw("order_no in {$db->field('order_no')->buildSql()}");

View File

@ -143,10 +143,10 @@ class Admin extends Controller
{
if ($this->request->isGet()) {
$this->upgrades = UserUpgradeService::instance()->levels();
$data = $this->_vali(['uid.require' => '待操作UID不能为空']);
$data = $this->_vali(['uuid.require' => '待操作UID不能为空']);
// 排除下级用户
$path = $this->app->db->name($this->table)->where(['id' => $data['uid']])->value('path', '-');
$subids = $this->app->db->name($this->table)->whereLike('path', "{$path}{$data['uid']}-%")->column('id');
$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)));
// 用户搜索查询
$db = $this->_query($this->table)->equal('vip_code#from_vipcode')->like('phone#from_phone,username|nickname#from_username')->db();
@ -154,9 +154,9 @@ class Admin extends Controller
// 数据查询分页
$query->like('phone,username|nickname#username')->whereRaw('vip_code>0')->equal('status,vip_code')->dateBetween('create_at')->page();
} else {
$data = $this->_vali(['pid.require' => '待绑定代理不能为空!', 'uid.require' => '待操作用户不能为空!']);
[$status, $message] = UserUpgradeService::instance()->bindAgent($data['uid'], $data['pid'], 2);
$status && sysoplog('前端用户管理', "修改用户[{$data['uid']}]的代理为用户[{$data['pid']}]");
$data = $this->_vali(['pid.require' => '待绑定代理不能为空!', 'uuid.require' => '待操作用户不能为空!']);
[$status, $message] = UserUpgradeService::instance()->bindAgent($data['uuid'], $data['pid'], 2);
$status && sysoplog('前端用户管理', "修改用户[{$data['uuid']}]的代理为用户[{$data['pid']}]");
empty($status) ? $this->error($message) : $this->success($message);
}
}

View File

@ -41,7 +41,7 @@ class Balance extends Controller
$query = $this->_query($this->table)->equal('name,upgrade');
// 用户搜索查询
$db = $this->_query('DataUser')->like('phone#user_phone,nickname#user_nickname')->db();
if ($db->getOptions('where')) $query->whereRaw("uid in {$db->field('id')->buildSql()}");
if ($db->getOptions('where')) $query->whereRaw("uuid in {$db->field('id')->buildSql()}");
// 数据查询分页
$query->where(['deleted' => 0])->like('code,remark')->dateBetween('create_at')->order('id desc')->page();
}
@ -71,8 +71,8 @@ class Balance extends Controller
*/
public function add()
{
$data = $this->_vali(['uid.require' => '用户UID不能为空']);
$this->user = $this->app->db->name('DataUser')->where(['id' => $data['uid']])->find();
$data = $this->_vali(['uuid.require' => '用户UID不能为空']);
$this->user = $this->app->db->name('DataUser')->where(['id' => $data['uuid']])->find();
if (empty($this->user)) $this->error('待充值的用户不存在!');
$this->_form($this->table, 'form');
}
@ -105,9 +105,9 @@ class Balance extends Controller
*/
protected function _form_result(bool $state, array $data)
{
if ($state && isset($data['uid'])) {
UserBalanceService::instance()->amount($data['uid']);
UserUpgradeService::instance()->upgrade($data['uid']);
if ($state && isset($data['uuid'])) {
UserBalanceService::instance()->amount($data['uuid']);
UserUpgradeService::instance()->upgrade($data['uuid']);
}
}
@ -132,8 +132,8 @@ class Balance extends Controller
if ($state) {
$map = [['id', 'in', str2arr(input('id', ''))]];
foreach ($this->app->db->name($this->table)->where($map)->cursor() as $vo) {
UserBalanceService::instance()->amount($vo['uid']);
UserUpgradeService::instance()->upgrade($vo['uid']);
UserBalanceService::instance()->amount($vo['uuid']);
UserUpgradeService::instance()->upgrade($vo['uuid']);
}
}
}

View File

@ -42,7 +42,7 @@ class Rebate extends Controller
if ($db->getOptions('where')) $query->whereRaw("order_uid in {$db->field('id')->buildSql()}");
// 代理条件查询
$db = $this->_query('DataUser')->like('nickname#agent_nickname,phone#agent_phone')->db();
if ($db->getOptions('where')) $query->whereRaw("uid in {$db->field('id')->buildSql()}");
if ($db->getOptions('where')) $query->whereRaw("uuid in {$db->field('id')->buildSql()}");
// 查询分页
$query->dateBetween('create_at')->order('id desc')->page();
}
@ -56,14 +56,14 @@ class Rebate extends Controller
*/
protected function _index_page_filter(array &$data)
{
$uids = array_merge(array_column($data, 'uid'), array_column($data, 'order_uid'));
$uids = array_merge(array_column($data, 'uuid'), array_column($data, 'order_uid'));
$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();
foreach ($data as &$vo) {
$vo['type'] = RebateService::instance()->name($vo['type']);
[$vo['user'], $vo['agent'], $vo['list']] = [[], [], []];
foreach ($userItem as $user) {
if ($user['id'] === $vo['uid']) $vo['agent'] = $user;
if ($user['id'] === $vo['uuid']) $vo['agent'] = $user;
if ($user['id'] === $vo['order_uid']) $vo['user'] = $user;
}
foreach ($goodsItem as $goods) {

View File

@ -92,7 +92,7 @@ class Transfer extends Controller
$query = $this->_query($this->table)->order('id desc');
// 用户条件搜索
$db = $this->_query('DataUser')->like('phone,username|nickname#nickname')->db();
if ($db->getOptions('where')) $query->whereRaw("uid in {$db->field('id')->buildSql()}");
if ($db->getOptions('where')) $query->whereRaw("uuid in {$db->field('id')->buildSql()}");
// 数据列表处理
$query->equal('type,status')->dateBetween('create_at')->page();
}

View File

@ -45,7 +45,7 @@ class NewsService extends Service
foreach ($list as &$vo) $vo['record'] = $items[$vo['code']] ?? [];
/*! 绑定用户数据 */
$colls = 'id,phone,nickname,username,headimg,status';
UserAdminService::instance()->buildByUid($list, 'uid', 'user', $colls);
UserAdminService::instance()->buildByUid($list, 'uuid', 'user', $colls);
}
return $list;
}
@ -53,16 +53,16 @@ class NewsService extends Service
/**
* 获取列表状态
* @param array $list 数据列表
* @param integer $uid 用户UID
* @param integer $uuid 用户UID
* @return array
*/
public function buildData(array &$list, int $uid = 0): array
public function buildData(array &$list, int $uuid = 0): array
{
if (count($list) > 0) {
[$code2, $code1] = [[], []];
$marks = $this->app->db->name('DataNewsMark')->where(['status' => 1])->column('name');
if ($uid > 0) {
$map = [['uid', '=', $uid], ['code', 'in', array_unique(array_column($list, 'code'))]];
if ($uuid > 0) {
$map = [['uuid', '=', $uuid], ['code', 'in', array_unique(array_column($list, 'code'))]];
$code1 = $this->app->db->name('DataNewsXCollect')->where($map)->where(['type' => 1])->column('code');
$code2 = $this->app->db->name('DataNewsXCollect')->where($map)->where(['type' => 2])->column('code');
}

View File

@ -51,17 +51,17 @@ class OrderService extends Service
$order = $this->app->db->name('ShopOrder')->where($map)->find();
if (empty($order)) return null;
// 订单用户数据
$user = $this->app->db->name('DataUser')->where(['id' => $order['uid']])->find();
$user = $this->app->db->name('DataUser')->where(['id' => $order['uuid']])->find();
if (empty($user)) return null;
// 更新用户购买资格
$entry = $this->vipEntry($order['uid']);
$entry = $this->vipEntry($order['uuid']);
// 尝试绑定代理用户
if (empty($user['pids']) && ($order['puid1'] > 0 || $user['pid1'] > 0)) {
$puid1 = $order['puid1'] > 0 ? $order['puid1'] : $user['pid0'];
UserUpgradeService::instance()->bindAgent($user['id'], $puid1);
}
// 重置用户信息并绑定订单
$user = $this->app->db->name('DataUser')->where(['id' => $order['uid']])->find();
$user = $this->app->db->name('DataUser')->where(['id' => $order['uuid']])->find();
if ($user['pid1'] > 0) {
$this->app->db->name('ShopOrder')->where(['order_no' => $orderNo])->update([
'puid1' => $user['pid1'], 'puid2' => $user['pid2'],
@ -74,21 +74,21 @@ class OrderService extends Service
/**
* 刷新用户入会礼包
* @param integer $uid 用户UID
* @param integer $uuid 用户UID
* @return integer
* @throws \think\db\exception\DbException
*/
private function vipEntry(int $uid): int
private function vipEntry(int $uuid): int
{
// 检查是否购买入会礼包
$query = $this->app->db->table('shop_order a')->join('shop_order_item b', 'a.order_no=b.order_no');
$entry = $query->where("a.uid={$uid} and a.status>=4 and a.payment_status=1 and b.vip_entry>0")->count() ? 1 : 0;
$entry = $query->where("a.uuid={$uuid} and a.status>=4 and a.payment_status=1 and b.vip_entry>0")->count() ? 1 : 0;
// 用户最后支付时间
$query = $this->app->db->name('ShopOrder');
$lastMap = [['uid', '=', $uid], ['status', '>=', 4], ['payment_status', '=', 1]];
$lastMap = [['uuid', '=', $uuid], ['status', '>=', 4], ['payment_status', '=', 1]];
$lastDate = $query->where($lastMap)->order('payment_datetime desc')->value('payment_datetime');
// 更新用户支付信息
$this->app->db->name('DataUser')->where(['id' => $uid])->update(['buy_vip_entry' => $entry, 'buy_last_date' => $lastDate]);
$this->app->db->name('DataUser')->where(['id' => $uuid])->update(['buy_vip_entry' => $entry, 'buy_last_date' => $lastDate]);
return $entry;
}
@ -127,13 +127,13 @@ class OrderService extends Service
// 关联发货信息
$nobs = array_unique(array_column($data, 'order_no'));
$trucks = $this->app->db->name('ShopOrderSend')->whereIn('order_no', $nobs)->column('*', 'order_no');
foreach ($trucks as &$item) unset($item['id'], $item['uid'], $item['status'], $item['deleted'], $item['create_at']);
foreach ($trucks as &$item) unset($item['id'], $item['uuid'], $item['status'], $item['deleted'], $item['create_at']);
// 关联订单商品
$query = $this->app->db->name('ShopOrderItem')->where(['status' => 1, 'deleted' => 0]);
$items = $query->withoutField('id,uid,status,deleted,create_at')->whereIn('order_no', $nobs)->select()->toArray();
$items = $query->withoutField('id,uuid,status,deleted,create_at')->whereIn('order_no', $nobs)->select()->toArray();
// 关联用户数据
$fields = 'phone,username,nickname,headimg,status,vip_code,vip_name';
if ($data) UserAdminService::instance()->buildByUid($data, 'uid', 'user', $fields);
if ($data) UserAdminService::instance()->buildByUid($data, 'uuid', 'user', $fields);
if ($from) UserAdminService::instance()->buildByUid($data, 'puid1', 'from', $fields);
foreach ($data as &$vo) {
[$vo['sales'], $vo['truck'], $vo['items']] = [0, $trucks[$vo['order_no']] ?? [], []];

View File

@ -82,7 +82,7 @@ class RebateService extends Service
if ($this->order['amount_total'] <= 0) throw new Exception('订单金额为零');
if ($this->order['rebate_amount'] <= 0) throw new Exception('订单返利为零');
// 获取用户数据
$map = ['id' => $this->order['uid'], 'deleted' => 0];
$map = ['id' => $this->order['uuid'], 'deleted' => 0];
$this->user = $this->app->db->name('DataUser')->where($map)->find();
if (empty($this->user)) throw new Exception('用户不存在');
// 获取直接代理数据
@ -150,7 +150,7 @@ class RebateService extends Service
if (!$this->checkPrizeStatus(self::PRIZE_01, $this->from1['vip_code'])) return false;
// 创建返利奖励记录
$key = "{$this->from1['vip_code']}_{$this->user['vip_code']}";
$map = ['type' => self::PRIZE_01, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
$map = ['type' => self::PRIZE_01, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uuid']];
if ($this->config("frist_state_vip_{$key}") && $this->app->db->name($this->table)->where($map)->count() < 1) {
$value = $this->config("frist_value_vip_{$key}");
if ($this->config("frist_type_vip_{$key}") == 1) {
@ -190,27 +190,27 @@ class RebateService extends Service
/**
* 写返利记录
* @param int $uid
* @param int $uuid
* @param array $map
* @param string $name
* @param float $amount
* @throws \think\db\exception\DbException
*/
private function writeRabate(int $uid, array $map, string $name, float $amount)
private function writeRabate(int $uuid, array $map, string $name, float $amount)
{
$this->app->db->name($this->table)->insert(array_merge($map, [
'uid' => $uid,
'uuid' => $uuid,
'date' => date('Y-m-d'),
'code' => CodeExtend::uniqidDate(20, 'R'),
'name' => $name,
'amount' => $amount,
'status' => $this->status,
'order_no' => $this->order['order_no'],
'order_uid' => $this->order['uid'],
'order_uid' => $this->order['uuid'],
'order_amount' => $this->order['amount_total'],
]));
// 刷新用户返利统计
UserRebateService::instance()->amount($uid);
UserRebateService::instance()->amount($uuid);
}
/**
@ -231,7 +231,7 @@ class RebateService extends Service
if (!$this->checkPrizeStatus(self::PRIZE_02, $this->from1['vip_code'])) return false;
// 创建返利奖励记录
$key = "vip_{$this->from1['vip_code']}_{$this->user['vip_code']}";
$map = ['type' => self::PRIZE_02, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
$map = ['type' => self::PRIZE_02, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uuid']];
if ($this->config("repeat_state_{$key}") && $this->app->db->name($this->table)->where($map)->count() < 1) {
$value = $this->config("repeat_value_{$key}");
if ($this->config("repeat_type_{$key}") == 1) {
@ -260,7 +260,7 @@ class RebateService extends Service
if (!$this->checkPrizeStatus(self::PRIZE_03, $this->from1['vip_code'])) return false;
// 创建返利奖励记录
$key = "{$this->user['vip_code']}";
$map = ['type' => self::PRIZE_03, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
$map = ['type' => self::PRIZE_03, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uuid']];
if ($this->config("direct_state_vip_{$key}") && $this->app->db->name($this->table)->where($map)->count() < 1) {
$value = $this->config("direct_value_vip_{$key}");
if ($this->config("direct_type_vip_{$key}") == 1) {
@ -288,7 +288,7 @@ class RebateService extends Service
if (empty($this->from2)) return false;
if (!$this->checkPrizeStatus(self::PRIZE_04, $this->from2['vip_code'])) return false;
$key = "{$this->user['vip_code']}";
$map = ['type' => self::PRIZE_04, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
$map = ['type' => self::PRIZE_04, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uuid']];
if ($this->config("indirect_state_vip_{$key}") && $this->app->db->name($this->table)->where($map)->count() < 1) {
$value = $this->config("indirect_value_vip_{$key}");
if ($this->config("indirect_type_vip_{$key}") == 1) {
@ -325,7 +325,7 @@ class RebateService extends Service
[$tVip, $tRate] = [$item['vip_code'], $item['discount_rate']];
foreach ($rules as $rule) if ($rule['level'] > $tVip) foreach ($users as $user) if ($user['vip_code'] > $tVip) {
if ($tRate > $rule['discount'] && $tRate < 100) {
$map = ['uid' => $user['id'], 'type' => self::PRIZE_05];
$map = ['uuid' => $user['id'], 'type' => self::PRIZE_05];
$map['code'] = "{$this->order['order_no']}#{$item['id']}#{$tVip}.{$user['vip_code']}";
if ($this->app->db->name($this->table)->where($map)->count() < 1) {
$dRate = ($tRate - $rule['discount']) / 100;
@ -360,7 +360,7 @@ class RebateService extends Service
foreach ($this->app->db->name('DataUser')->whereIn('vip_code', $vips)->whereIn('id', $puids)->orderField('id', $puids)->cursor() as $user) {
if ($user['vip_code'] > $prevLevel) {
if (($amount = $this->_prize06amount($prevLevel + 1, $user['vip_code'])) > 0.00) {
$map = ['uid' => $user['id'], 'type' => self::PRIZE_06, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
$map = ['uuid' => $user['id'], 'type' => self::PRIZE_06, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uuid']];
if ($this->app->db->name($this->table)->where($map)->count() < 1) {
$name = "{$this->name(self::PRIZE_06)}[ VIP{$prevLevel} > VIP{$user['vip_code']} ] 每单 {$amount}";
$this->writeRabate($user['id'], $map, $name, $amount);
@ -413,7 +413,7 @@ class RebateService extends Service
if (!$this->checkPrizeStatus(self::PRIZE_07, $this->from1['vip_code'])) return false;
// 创建返利奖励记录
$key = "{$this->user['vip_code']}";
$map = ['type' => self::PRIZE_07, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
$map = ['type' => self::PRIZE_07, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uuid']];
if ($this->config("upgrade_state_vip_{$key}") && $this->app->db->name($this->table)->where($map)->count() < 1) {
$value = $this->config("upgrade_value_vip_{$key}");
if ($this->config("upgrade_type_vip_{$key}") == 1) {

View File

@ -89,7 +89,7 @@ class UserAdminService extends Service
$user = $this->app->db->name('DataUser')->where($map)->find();
if (empty($user)) throw new Exception('指定UID用户不存在');
if (!is_null($type)) {
$map = ['uid' => $uuid, 'type' => $type];
$map = ['uuid' => $uuid, 'type' => $type];
$data = $this->app->db->name('DataUserToken')->where($map)->find();
if (empty($data)) {
[$state, $info, $data] = UserTokenService::instance()->token($uuid, $type);
@ -123,8 +123,8 @@ class UserAdminService extends Service
{
if (!empty($unionid)) {
[$map1, $map2] = [[['unionid', '=', $unionid]], [[$field, '=', $openid]]];
if ($uid = $this->app->db->name('DataUser')->whereOr([$map1, $map2])->value('id')) {
return ['id' => $uid];
if ($uuid = $this->app->db->name('DataUser')->whereOr([$map1, $map2])->value('id')) {
return ['id' => $uuid];
}
}
return [$field => $openid];
@ -138,7 +138,7 @@ class UserAdminService extends Service
* @param string $cols 返回用户字段
* @return array
*/
public function buildByUid(array &$list, string $keys = 'uid', string $bind = 'user', string $cols = '*'): array
public function buildByUid(array &$list, string $keys = 'uuid', string $bind = 'user', string $cols = '*'): array
{
if (count($list) < 1) return $list;
$uids = array_unique(array_column($list, $keys));

View File

@ -28,14 +28,14 @@ class UserBalanceService extends Service
if (empty($order)) throw new \think\admin\Exception('需处理的订单状态异常');
if ($order['reward_balance'] > 0) data_save('DataUserBalance', [
'uid' => $order['uid'],
'uuid' => $order['uuid'],
'code' => "CZ{$order['order_no']}",
'name' => "订单余额充值",
'remark' => "来自订单 {$order['order_no']} 的余额充值 {$order['reward_balance']}",
'amount' => $order['reward_balance'],
], 'code');
return $this->amount($order['uid']);
return $this->amount($order['uuid']);
}
/**
@ -48,12 +48,12 @@ class UserBalanceService extends Service
public function amount(int $uuid, array $nots = []): array
{
if ($uuid > 0) {
$total = abs($this->app->db->name('DataUserBalance')->whereRaw("uid='{$uuid}' and amount>0 and deleted=0")->sum('amount'));
$count = abs($this->app->db->name('DataUserBalance')->whereRaw("uid='{$uuid}' and amount<0 and deleted=0")->sum('amount'));
$total = abs($this->app->db->name('DataUserBalance')->whereRaw("uuid='{$uuid}' and amount>0 and deleted=0")->sum('amount'));
$count = abs($this->app->db->name('DataUserBalance')->whereRaw("uuid='{$uuid}' and amount<0 and deleted=0")->sum('amount'));
if (empty($nots)) {
$this->app->db->name('DataUser')->where(['id' => $uuid])->update(['balance_total' => $total, 'balance_used' => $count]);
} else {
$count -= $this->app->db->name('DataUserBalance')->whereRaw("uid={$uuid}")->whereIn('code', $nots)->sum('amount');
$count -= $this->app->db->name('DataUserBalance')->whereRaw("uuid={$uuid}")->whereIn('code', $nots)->sum('amount');
}
} else {
$total = abs($this->app->db->name('DataUserBalance')->whereRaw("amount>0 and deleted=0")->sum('amount'));

View File

@ -20,9 +20,9 @@ class UserRebateService extends Service
public function amount(int $uuid): array
{
if ($uuid > 0) {
$count = $this->app->db->name('DataUserTransfer')->whereRaw("uid='{$uuid}' and status>0")->sum('amount');
$total = $this->app->db->name('DataUserRebate')->whereRaw("uid='{$uuid}' and status=1 and deleted=0")->sum('amount');
$locks = $this->app->db->name('DataUserRebate')->whereRaw("uid='{$uuid}' and status=0 and deleted=0")->sum('amount');
$count = $this->app->db->name('DataUserTransfer')->whereRaw("uuid='{$uuid}' and status>0")->sum('amount');
$total = $this->app->db->name('DataUserRebate')->whereRaw("uuid='{$uuid}' and status=1 and deleted=0")->sum('amount');
$locks = $this->app->db->name('DataUserRebate')->whereRaw("uuid='{$uuid}' and status=0 and deleted=0")->sum('amount');
$this->app->db->name('DataUser')->where(['id' => $uuid])->update(['rebate_total' => $total, 'rebate_used' => $count, 'rebate_lock' => $locks]);
} else {
$count = $this->app->db->name('DataUserTransfer')->whereRaw("status>0")->sum('amount');
@ -48,7 +48,7 @@ class UserRebateService extends Service
$map = [['status', '=', 0], ['order_no', 'like', "{$orderNo}%"]];
$this->app->db->name('DataUserRebate')->where($map)->update(['status' => 1]);
if (UserUpgradeService::instance()->upgrade($order['uid'])) {
if (UserUpgradeService::instance()->upgrade($order['uuid'])) {
return [1, '重新计算用户金额成功!'];
} else {
return [0, '重新计算用户金额失败!'];

View File

@ -37,7 +37,7 @@ class UserTokenService extends Service
$map = ['type' => $type, 'token' => $token];
$data = $this->app->db->name('DataUserToken')->where($map)->find();
}
if (empty($data) || empty($data['uid'])) {
if (empty($data) || empty($data['uuid'])) {
return [0, '请重新登录,登录认证无效', 0, 0];
} elseif ($token !== 'token' && $data['time'] < time()) {
return [0, '请重新登录,登录认证失效', 0, 0];
@ -45,7 +45,7 @@ class UserTokenService extends Service
return [0, '请重新登录,客户端已更换', 0, 0];
} else {
$this->expire($type, $token);
return [1, '登录验证成功', $data['uid'], $data['time']];
return [1, '登录验证成功', $data['uuid'], $data['time']];
}
}
@ -84,13 +84,13 @@ class UserTokenService extends Service
// 清理无效认证数据
$time = time();
$map1 = [['token', '<>', 'token'], ['time', '<', $time]];
$map2 = [['token', '<>', 'token'], ['type', '=', $type], ['uid', '=', $uuid]];
$map2 = [['token', '<>', 'token'], ['type', '=', $type], ['uuid', '=', $uuid]];
$this->app->db->name('DataUserToken')->whereOr([$map1, $map2])->delete();
// 创建新的认证数据
do $map = ['type' => $type, 'token' => md5(uniqid() . rand(100, 999))];
while ($this->app->db->name('DataUserToken')->where($map)->count() > 0);
// 写入用户认证数据
$data = array_merge($map, ['uid' => $uuid, 'time' => $time + $this->expire, 'tokenv' => $this->_buildTokenVerify()]);
$data = array_merge($map, ['uuid' => $uuid, 'time' => $time + $this->expire, 'tokenv' => $this->_buildTokenVerify()]);
if ($this->app->db->name('DataUserToken')->insert($data) !== false) {
return [1, '刷新认证成功', $data];
} else {

View File

@ -100,10 +100,10 @@ class UserTransferService extends Service
public function amount(int $uuid): array
{
if ($uuid > 0) {
$locks = abs($this->app->db->name('DataUserTransfer')->whereRaw("uid='{$uuid}' and status=3")->sum('amount'));
$total = abs($this->app->db->name('DataUserTransfer')->whereRaw("uid='{$uuid}' and status>=1")->sum('amount'));
$count = abs($this->app->db->name('DataUserTransfer')->whereRaw("uid='{$uuid}' and status>=4")->sum('amount'));
$audit = abs($this->app->db->name('DataUserTransfer')->whereRaw("uid='{$uuid}' and status>=1 and status<3")->sum('amount'));
$locks = abs($this->app->db->name('DataUserTransfer')->whereRaw("uuid='{$uuid}' and status=3")->sum('amount'));
$total = abs($this->app->db->name('DataUserTransfer')->whereRaw("uuid='{$uuid}' and status>=1")->sum('amount'));
$count = abs($this->app->db->name('DataUserTransfer')->whereRaw("uuid='{$uuid}' and status>=4")->sum('amount'));
$audit = abs($this->app->db->name('DataUserTransfer')->whereRaw("uuid='{$uuid}' and status>=1 and status<3")->sum('amount'));
} else {
$locks = abs($this->app->db->name('DataUserTransfer')->whereRaw("status=3")->sum('amount'));
$total = abs($this->app->db->name('DataUserTransfer')->whereRaw("status>=1")->sum('amount'));

View File

@ -24,7 +24,7 @@ class UserUpgradeService extends Service
/**
* 尝试绑定上级代理
* @param integer $uid 用户UID
* @param integer $uuid 用户UID
* @param integer $pid 代理UID
* @param integer $mod 操作类型0临时绑定, 1永久绑定, 2强行绑定)
* @return array
@ -32,19 +32,19 @@ class UserUpgradeService extends Service
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function bindAgent(int $uid, int $pid = 0, int $mod = 1): array
public function bindAgent(int $uuid, int $pid = 0, int $mod = 1): array
{
$user = $this->app->db->name('DataUser')->where(['id' => $uid])->find();
$user = $this->app->db->name('DataUser')->where(['id' => $uuid])->find();
if (empty($user)) return [0, '用户查询失败'];
if ($user['pids'] && in_array($mod, [0, 1])) return [1, '已经绑定代理'];
// 检查代理用户
if (empty($pid)) $pid = $user['pid0'];
if (empty($pid)) return [0, '绑定的代理不存在'];
if ($uid == $pid) return [0, '不能绑定自己为代理'];
if ($uuid == $pid) return [0, '不能绑定自己为代理'];
// 检查代理资格
$agent = $this->app->db->name('DataUser')->where(['id' => $pid])->find();
if (empty($agent['vip_code'])) return [0, '代理无推荐资格'];
if (stripos($agent['path'], "-{$uid}-") !== false) return [0, '不能绑定下属'];
if (stripos($agent['path'], "-{$uuid}-") !== false) return [0, '不能绑定下属'];
// 组装代理数据
try {
@ -75,7 +75,7 @@ class UserUpgradeService extends Service
/**
* 同步计算用户等级
* @param integer $uid 指定用户UID
* @param integer $uuid 指定用户UID
* @param boolean $parent 同步计算上级
* @param ?string $orderNo 升级触发订单
* @return boolean
@ -83,18 +83,18 @@ class UserUpgradeService extends Service
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function upgrade(int $uid, bool $parent = true, ?string $orderNo = null): bool
public function upgrade(int $uuid, bool $parent = true, ?string $orderNo = null): bool
{
$user = $this->app->db->name('DataUser')->where(['id' => $uid])->find();
$user = $this->app->db->name('DataUser')->where(['id' => $uuid])->find();
if (empty($user)) return true;
// 初始化等级参数
$levels = $this->levels();
[$vipName, $vipCode, $vipTeam] = [$levels[0]['name'] ?? '普通用户', 0, []];
// 统计用户数据
foreach ($levels as $key => $level) if ($level['upgrade_team'] === 1) $vipTeam[] = $key;
$orderAmount = $this->app->db->name('ShopOrder')->where("uid={$uid} and status>=4")->sum('amount_total');
$teamsDirect = $this->app->db->name('DataUser')->where(['pid1' => $uid])->whereIn('vip_code', $vipTeam)->count();
$teamsIndirect = $this->app->db->name('DataUser')->where(['pid2' => $uid])->whereIn('vip_code', $vipTeam)->count();
$orderAmount = $this->app->db->name('ShopOrder')->where("uuid={$uuid} and status>=4")->sum('amount_total');
$teamsDirect = $this->app->db->name('DataUser')->where(['pid1' => $uuid])->whereIn('vip_code', $vipTeam)->count();
$teamsIndirect = $this->app->db->name('DataUser')->where(['pid2' => $uuid])->whereIn('vip_code', $vipTeam)->count();
$teamsUsers = $teamsDirect + $teamsIndirect;
// 动态计算用户等级
foreach ($levels as $item) {
@ -114,21 +114,21 @@ class UserUpgradeService extends Service
}
// 购买入会商品升级
$query = $this->app->db->name('ShopOrderItem')->alias('b')->join('shop_order a', 'b.order_no=a.order_no');
$tmpCode = $query->whereRaw("a.uid={$uid} and a.payment_status=1 and a.status>=4 and b.vip_entry=1")->max('b.vip_upgrade');
$tmpCode = $query->whereRaw("a.uuid={$uuid} and a.payment_status=1 and a.status>=4 and b.vip_entry=1")->max('b.vip_upgrade');
if ($tmpCode > $vipCode && isset($levels[$tmpCode])) {
[$vipName, $vipCode] = [$levels[$tmpCode]['name'], $levels[$tmpCode]['number']];
} else {
$orderNo = null;
}
// 后台余额充值升级
$tmpCode = $this->app->db->name('DataUserBalance')->where(['uid' => $uid, 'deleted' => 0])->max('upgrade');
$tmpCode = $this->app->db->name('DataUserBalance')->where(['uuid' => $uuid, 'deleted' => 0])->max('upgrade');
if ($tmpCode > $vipCode && isset($levels[$tmpCode])) {
[$vipName, $vipCode] = [$levels[$tmpCode]['name'], $levels[$tmpCode]['number']];
}
// 统计用户订单金额
$orderAmountTotal = $this->app->db->name('ShopOrder')->whereRaw("uid={$uid} and status>=4")->sum('amount_goods');
$teamsAmountDirect = $this->app->db->name('ShopOrder')->whereRaw("puid1={$uid} and status>=4")->sum('amount_goods');
$teamsAmountIndirect = $this->app->db->name('ShopOrder')->whereRaw("puid2={$uid} and status>=4")->sum('amount_goods');
$orderAmountTotal = $this->app->db->name('ShopOrder')->whereRaw("uuid={$uuid} and status>=4")->sum('amount_goods');
$teamsAmountDirect = $this->app->db->name('ShopOrder')->whereRaw("puid1={$uuid} and status>=4")->sum('amount_goods');
$teamsAmountIndirect = $this->app->db->name('ShopOrder')->whereRaw("puid2={$uuid} and status>=4")->sum('amount_goods');
// 更新用户团队数据
$data = [
'vip_name' => $vipName,
@ -143,10 +143,10 @@ class UserUpgradeService extends Service
];
if (!empty($orderNo)) $data['vip_order'] = $orderNo;
if ($data['vip_code'] !== $user['vip_code']) $data['vip_datetime'] = date('Y-m-d H:i:s');
$this->app->db->name('DataUser')->where(['id' => $uid])->update($data);
$this->app->db->name('DataUser')->where(['id' => $uuid])->update($data);
// 用户升级事件
if ($user['vip_code'] < $vipCode) $this->app->event->trigger('UserUpgradeLevel', [
'uid' => $user['id'], 'order_no' => $orderNo, 'vip_code_old' => $user['vip_code'], 'vip_code_new' => $vipCode,
'uuid' => $user['id'], 'order_no' => $orderNo, 'vip_code_old' => $user['vip_code'], 'vip_code_new' => $vipCode,
]);
return !($parent && $user['pid1'] > 0) || $this->upgrade($user['pid1'], false);
}

View File

@ -56,7 +56,7 @@ class BalancePyamentService extends PaymentService
// 创建支付行为
$this->createPaymentAction($orderNo, $paymentTitle, $paymentAmount);
// 检查能否支付
[$total, $count] = UserBalanceService::instance()->amount($order['uid'], [$orderNo]);
[$total, $count] = UserBalanceService::instance()->amount($order['uuid'], [$orderNo]);
if ($paymentAmount > $total - $count) throw new Exception("可抵扣余额不足");
try {
// 扣减用户余额
@ -67,7 +67,7 @@ class BalancePyamentService extends PaymentService
]);
// 扣除余额金额
data_save('DataUserBalance', [
'uid' => $order['uid'],
'uuid' => $order['uuid'],
'code' => "KC{$order['order_no']}",
'name' => "账户余额支付",
'remark' => "支付订单 {$order['order_no']} 的扣除余额 {$paymentAmount}",
@ -77,7 +77,7 @@ class BalancePyamentService extends PaymentService
$this->updatePaymentAction($order['order_no'], CodeExtend::uniqidDate(20), $paymentAmount, '账户余额支付');
});
// 刷新用户余额
UserBalanceService::instance()->amount($order['uid']);
UserBalanceService::instance()->amount($order['uuid']);
return ['code' => 1, 'info' => '余额支付完成'];
} catch (\Exception $exception) {
return ['code' => 0, 'info' => $exception->getMessage()];

View File

@ -103,7 +103,7 @@
代理关联:<!--{notempty name='vo.pids'}-->
<b class="color-green">永久绑定</b>
<!--{if auth('parent')}-->
<a data-width="1080px" data-height="700px" data-iframe="{:url('parent')}?uid={$vo.id}" class="margin-left-5 notselect">更改绑定</a>
<a data-width="1080px" data-height="700px" data-iframe="{:url('parent')}?uuid={$vo.id}" class="margin-left-5 notselect">更改绑定</a>
<!--{/if}-->
<!--{else}-->
{notempty name='vo.pid0'}
@ -114,7 +114,7 @@
{else}
<b class="color-desc">没有绑定</b>
<!--{if auth('parent')}-->
<a data-width="1080px" data-height="700px" data-iframe="{:url('parent')}?uid={$vo.id}" class="margin-left-5 notselect">设置绑定</a>
<a data-width="1080px" data-height="700px" data-iframe="{:url('parent')}?uuid={$vo.id}" class="margin-left-5 notselect">设置绑定</a>
<!--{/if}-->
{/notempty}
<!--{/notempty}-->
@ -132,11 +132,11 @@
<td class="nowrap">
<!--{if auth("parent") and false}-->
<a class="layui-btn layui-btn-sm layui-btn-primary" data-iframe="{:url('parent')}?uid={$vo.id}" data-width="900px">修改上级</a>
<a class="layui-btn layui-btn-sm layui-btn-primary" data-iframe="{:url('parent')}?uuid={$vo.id}" data-width="900px">修改上级</a>
<!--{/if}-->
<!--{if auth("user.balance/add")}-->
<a class="layui-btn layui-btn-sm layui-btn-primary" data-modal="{:url('user.balance/add')}?uid={$vo.id}" data-title="充值账户余额"> </a>
<a class="layui-btn layui-btn-sm layui-btn-primary" data-modal="{:url('user.balance/add')}?uuid={$vo.id}" data-title="充值账户余额"> </a>
<!--{/if}-->
<!--{if auth("state") and $vo.status eq 1}-->

View File

@ -62,7 +62,7 @@
</td>
<td class="nowrap text-right">
<!--{if auth("parent")}-->
<a class="layui-btn layui-btn-sm layui-btn-primary" data-parent-uid="{:input('uid')}" data-parent-pid="{$vo.id}">选择绑定</a>
<a class="layui-btn layui-btn-sm layui-btn-primary" data-parent-uuid="{:input('uuid')}" data-parent-pid="{$vo.id}">选择绑定</a>
<!--{/if}-->
</td>
</tr>
@ -75,8 +75,8 @@
{block name='script'}
<script>
$('body').off('click', '[data-parent-uid]').on('click', '[data-parent-uid]', function () {
$.form.load('{:sysuri()}', {uid: this.dataset.parentUid, pid: this.dataset.parentPid}, 'post', function (ret) {
$('body').off('click', '[data-parent-uuid]').on('click', '[data-parent-uuid]', function () {
$.form.load('{:sysuri()}', {uuid: this.dataset.parentUid, pid: this.dataset.parentPid}, 'post', function (ret) {
if (ret.code > 0) return $.msg.success(ret.info, 3, function () {
top.layer.close(top.layer.getFrameIndex(window.name));
top.$.form.reload();

View File

@ -6,9 +6,9 @@
<script>
(function (inst1) {
// 加载指定用户下级
function loaded(uid) {
function loaded(uuid) {
var deferred = jQuery.Deferred();
$.form.load('{:url("teams")}', {output: 'json', from: uid}, 'get', function (ret) {
$.form.load('{:url("teams")}', {output: 'json', from: uuid}, 'get', function (ret) {
var data = [];
ret.data.list.forEach(function (item) {
data.push({

View File

@ -68,7 +68,7 @@
</div>
<div class="hr-line-dashed"></div>
<input name='uid' type='hidden' value='{$vo.uid|default=$user.id}'>
<input name='uuid' type='hidden' value='{$vo.uuid|default=$user.id}'>
{notempty name='vo.id'}<input name='id' type='hidden' value='{$vo.id}'>{/notempty}
<div class="layui-form-item text-center">