mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
修改会员级别
This commit is contained in:
parent
83c9f6cbc4
commit
b6e6e55c81
@ -11,7 +11,7 @@
|
||||
Target Server Version : 50562
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 12/03/2021 16:07:52
|
||||
Date: 12/03/2021 16:14:37
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
@ -119,8 +119,8 @@ CREATE TABLE `data_user` (
|
||||
`base_height` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户身高',
|
||||
`base_weight` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户体重',
|
||||
`base_birthday` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户生日',
|
||||
`vip_code` bigint(20) NULL DEFAULT 0 COMMENT 'VIP等级编号',
|
||||
`vip_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'VIP等级名称',
|
||||
`vip_number` bigint(20) NULL DEFAULT 0 COMMENT 'VIP等级序号',
|
||||
`vip_datetime` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'VIP等级时间',
|
||||
`buy_vip_entry` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '是否入会礼包',
|
||||
`buy_last_date` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '最后支付时间',
|
||||
@ -154,7 +154,7 @@ CREATE TABLE `data_user` (
|
||||
-- ----------------------------
|
||||
-- Records of data_user
|
||||
-- ----------------------------
|
||||
INSERT INTO `data_user` VALUES (1, 0, 0, 0, 0, '-', 1, '', '', '', '13617348882', '', '', '', 'e10adc3949ba59abbe56e057f20f883e', '', '', '', 0, '', '', '', '', '', 0, '', 0, '', 0.00, 0.00, 0.00, 0.00, 0, 0, 0, 0.00, 0.00, 0.00, 0.00, '', 1, 0, '2021-03-11 08:46:55');
|
||||
INSERT INTO `data_user` VALUES (1, 0, 0, 0, 0, '-', 1, '', '', '', '13617348882', '', '', '', 'e10adc3949ba59abbe56e057f20f883e', '', '', '', 0, '', '', '', '', 0, '', '', 0, '', 0.00, 0.00, 0.00, 0.00, 0, 0, 0, 0.00, 0.00, 0.00, 0.00, '', 1, 0, '2021-03-11 08:46:55');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for data_user_address
|
||||
@ -656,15 +656,15 @@ CREATE TABLE `shop_order_item` (
|
||||
`total_selling` decimal(20, 2) NULL DEFAULT 0.00 COMMENT '销售总价',
|
||||
`reward_balance` decimal(20, 2) NULL DEFAULT 0.00 COMMENT '奖励余额',
|
||||
`reward_integral` decimal(20, 2) NULL DEFAULT 0.00 COMMENT '奖励积分',
|
||||
`rebate_type` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '参与返利状态',
|
||||
`rebate_amount` decimal(20, 2) NULL DEFAULT 0.00 COMMENT '参与返利金额',
|
||||
`stock_sales` bigint(20) NULL DEFAULT 1 COMMENT '商品数量',
|
||||
`truck_type` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '物流配送(0无需配送,1需要配送)',
|
||||
`vip_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户等级名称',
|
||||
`vip_code` bigint(20) NULL DEFAULT 0 COMMENT '用户等级序号',
|
||||
`vip_entry` tinyint(1) NULL DEFAULT 0 COMMENT '是否入会礼包(0非礼包,1是礼包)',
|
||||
`truck_type` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '物流配送类型(0虚物,1实物)',
|
||||
`truck_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '快递邮费模板',
|
||||
`truck_number` bigint(20) NULL DEFAULT 0 COMMENT '快递计费基数',
|
||||
`vip_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户等级名称',
|
||||
`vip_entry` tinyint(1) NULL DEFAULT 0 COMMENT '是否入会礼包',
|
||||
`vip_number` bigint(20) NULL DEFAULT 0 COMMENT '用户等级序号',
|
||||
`rebate_type` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '参与返利状态(0不返,1返利)',
|
||||
`rebate_amount` decimal(20, 2) NULL DEFAULT 0.00 COMMENT '参与返利金额',
|
||||
`discount_id` bigint(20) NULL DEFAULT 0 COMMENT '优惠方案编号',
|
||||
`discount_rate` decimal(20, 6) NULL DEFAULT 100.000000 COMMENT '销售价格折扣',
|
||||
`discount_amount` decimal(20, 2) NULL DEFAULT 0.00 COMMENT '商品优惠金额',
|
||||
@ -684,9 +684,9 @@ CREATE TABLE `shop_order_item` (
|
||||
-- ----------------------------
|
||||
-- Records of shop_order_item
|
||||
-- ----------------------------
|
||||
INSERT INTO `shop_order_item` VALUES (1, 1, 'N20210311513872036', 'S7154444768356', 'G7154507000354775729', '默认分组::默认规格', '商品名称', 'http://127.0.0.1/upload/25/e9c92266d3b7ab86d3221b0c9305fe.jpg', 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1, 0.00, 1, 0, '', 1, '', 0, 0, 0, 100.000000, 0.00, 1, 0, '2021-03-11 09:15:09');
|
||||
INSERT INTO `shop_order_item` VALUES (2, 1, 'N20210311715437924', 'S7154444768356', 'G7154507000354775729', '默认分组::默认规格', '商品名称', 'http://127.0.0.1/upload/25/e9c92266d3b7ab86d3221b0c9305fe.jpg', 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1, 0.00, 1, 0, '', 1, '', 0, 0, 0, 100.000000, 0.00, 1, 0, '2021-03-11 09:35:25');
|
||||
INSERT INTO `shop_order_item` VALUES (3, 1, 'N20210311745121809', 'S7154444768356', 'G7154507000354775729', '默认分组::默认规格', '商品名称', 'http://127.0.0.1/upload/25/e9c92266d3b7ab86d3221b0c9305fe.jpg', 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1, 0.00, 1, 0, '', 1, '', 0, 0, 0, 100.000000, 0.00, 1, 0, '2021-03-11 09:38:21');
|
||||
INSERT INTO `shop_order_item` VALUES (1, 1, 'N20210311513872036', 'S7154444768356', 'G7154507000354775729', '默认分组::默认规格', '商品名称', 'http://127.0.0.1/upload/25/e9c92266d3b7ab86d3221b0c9305fe.jpg', 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1, '', 0, 0, 0, '', 1, 1, 0.00, 0, 100.000000, 0.00, 1, 0, '2021-03-11 09:15:09');
|
||||
INSERT INTO `shop_order_item` VALUES (2, 1, 'N20210311715437924', 'S7154444768356', 'G7154507000354775729', '默认分组::默认规格', '商品名称', 'http://127.0.0.1/upload/25/e9c92266d3b7ab86d3221b0c9305fe.jpg', 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1, '', 0, 0, 0, '', 1, 1, 0.00, 0, 100.000000, 0.00, 1, 0, '2021-03-11 09:35:25');
|
||||
INSERT INTO `shop_order_item` VALUES (3, 1, 'N20210311745121809', 'S7154444768356', 'G7154507000354775729', '默认分组::默认规格', '商品名称', 'http://127.0.0.1/upload/25/e9c92266d3b7ab86d3221b0c9305fe.jpg', 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1, '', 0, 0, 0, '', 1, 1, 0.00, 0, 100.000000, 0.00, 1, 0, '2021-03-11 09:38:21');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for shop_order_send
|
||||
|
@ -84,7 +84,7 @@ class Order extends Auth
|
||||
if ($buys + $count > $goods['limit_max_num']) $this->error('超过限购数量');
|
||||
}
|
||||
// 限制购买身份
|
||||
if ($goodsInfo['limit_low_vip'] > $this->user['vip_number']) {
|
||||
if ($goodsInfo['limit_low_vip'] > $this->user['vip_code']) {
|
||||
$this->error('用户等级不够');
|
||||
}
|
||||
// 商品库存检查
|
||||
@ -96,7 +96,7 @@ class Order extends Auth
|
||||
if ($goodsInfo['discount_id'] > 0) {
|
||||
$map = ['status' => 1, 'deleted' => 0, 'id' => $goodsInfo['discount_id']];
|
||||
if ($discount = $this->app->db->name('DataUserDiscount')->where($map)->value('items')) {
|
||||
foreach (json_decode($discount, true) as $vo) if ($vo['level'] == $this->user['vip_number']) {
|
||||
foreach (json_decode($discount, true) as $vo) if ($vo['level'] == $this->user['vip_code']) {
|
||||
[$discountId, $discountRate] = [$goodsInfo['discount_id'], $vo['discount']];
|
||||
}
|
||||
}
|
||||
@ -127,7 +127,7 @@ class Order extends Auth
|
||||
'reward_integral' => $goodsItem['reward_integral'] * $count,
|
||||
// 绑定用户等级
|
||||
'vip_name' => $this->user['vip_name'],
|
||||
'vip_number' => $this->user['vip_number'],
|
||||
'vip_code' => $this->user['vip_code'],
|
||||
// 是否入会礼包
|
||||
'vip_entry' => $goodsInfo['vip_entry'],
|
||||
// 是否参与返利
|
||||
|
@ -113,7 +113,7 @@ class RebateCurrentService extends Service
|
||||
if (empty($this->from1)) return false;
|
||||
$map = ['order_uid' => $this->user['id']];
|
||||
if ($this->app->db->name($this->table)->where($map)->count() > 0) return false;
|
||||
if (!$this->checkLevelPrize(self::PRIZE_01, $this->from1['vip_number'])) return false;
|
||||
if (!$this->checkLevelPrize(self::PRIZE_01, $this->from1['vip_code'])) return false;
|
||||
// 创建返利奖励记录
|
||||
$map = ['type' => self::PRIZE_01, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
|
||||
if ($this->app->db->name($this->table)->where($map)->count() < 1) {
|
||||
@ -145,7 +145,7 @@ class RebateCurrentService extends Service
|
||||
if (empty($this->from1)) return false;
|
||||
$map = ['order_uid' => $this->user['id']];
|
||||
if ($this->app->db->name($this->table)->where($map)->count() < 1) return false;
|
||||
if (!$this->checkLevelPrize(self::PRIZE_02, $this->from1['vip_number'])) return false;
|
||||
if (!$this->checkLevelPrize(self::PRIZE_02, $this->from1['vip_code'])) return false;
|
||||
// 创建返利奖励记录
|
||||
$map = ['type' => self::PRIZE_02, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
|
||||
if ($this->app->db->name($this->table)->where($map)->count() < 1) {
|
||||
@ -175,7 +175,7 @@ class RebateCurrentService extends Service
|
||||
private function _prize03(): bool
|
||||
{
|
||||
if (empty($this->from1)) return false;
|
||||
if (!$this->checkLevelPrize(self::PRIZE_03, $this->from1['vip_number'])) return false;
|
||||
if (!$this->checkLevelPrize(self::PRIZE_03, $this->from1['vip_code'])) return false;
|
||||
// 创建返利奖励记录
|
||||
$map = ['type' => self::PRIZE_03, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
|
||||
if ($this->app->db->name($this->table)->where($map)->count() < 1) {
|
||||
@ -200,7 +200,7 @@ class RebateCurrentService extends Service
|
||||
private function _prize04(): bool
|
||||
{
|
||||
if (empty($this->from2)) return false;
|
||||
if (!$this->checkLevelPrize(self::PRIZE_04, $this->from2['vip_number'])) return false;
|
||||
if (!$this->checkLevelPrize(self::PRIZE_04, $this->from2['vip_code'])) return false;
|
||||
$map = ['type' => self::PRIZE_04, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
|
||||
if ($this->app->db->name($this->table)->where($map)->count() < 1) {
|
||||
$amount = sysconf('shop.indirectValue') * $this->order['amount_total'] / 100;
|
||||
@ -227,30 +227,30 @@ class RebateCurrentService extends Service
|
||||
if (empty($puids) || $this->order['amount_total'] <= 0) return false;
|
||||
// 获取可以参与奖励的代理
|
||||
$sql = $this->app->db->name('DataUserUpgrade')->field('number')->whereLike('rebate_rule', '%,' . self::PRIZE_05 . ',%')->buildSql(true);
|
||||
$users = $this->app->db->name('DataUser')->where("vip_number in {$sql}")->whereIn('id', $puids)->orderField('id', $puids)->select()->toArray();
|
||||
$users = $this->app->db->name('DataUser')->where("vip_code in {$sql}")->whereIn('id', $puids)->orderField('id', $puids)->select()->toArray();
|
||||
// 查询需要计算奖励的商品
|
||||
$map = [['order_no', '=', $this->order['order_no']], ['discount_rate', '<', 100]];
|
||||
foreach ($this->app->db->name('StoreOrderItem')->where($map)->cursor() as $item) {
|
||||
$itemJson = $this->app->db->name('DataUserDiscount')->where(['status' => 1, 'deleted' => 0])->value('items');
|
||||
if (!empty($itemJson) && is_array($rules = json_decode($itemJson, true))) {
|
||||
[$tVip, $tRate] = [$item['vip_number'], $item['discount_rate']];
|
||||
foreach ($rules as $rule) if ($rule['level'] > $tVip) foreach ($users as $user) if ($user['vip_number'] > $tVip) {
|
||||
[$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 = [
|
||||
'type' => self::PRIZE_05, 'uid' => $user['id'],
|
||||
'code' => "{$this->order['order_no']}#{$item['id']}#{$tVip}.{$user['vip_number']}",
|
||||
'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;
|
||||
$this->app->db->name($this->table)->insert(array_merge($map, [
|
||||
'name' => "等级差额奖励{$tVip}#{$user['vip_number']}商品的{$dRate}%",
|
||||
'name' => "等级差额奖励{$tVip}#{$user['vip_code']}商品的{$dRate}%",
|
||||
'amount' => $dRate * $item['total_selling'],
|
||||
'order_no' => $this->order['order_no'],
|
||||
'order_uid' => $this->order['uid'],
|
||||
'order_amount' => $this->order['amount_total'],
|
||||
]));
|
||||
}
|
||||
[$tVip, $tRate] = [$user['vip_number'], $rule['discount']];
|
||||
[$tVip, $tRate] = [$user['vip_code'], $rule['discount']];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class UserUpgradeService extends Service
|
||||
if (empty($pid)) return [0, '绑定推荐人不存在'];
|
||||
if ($uid == $pid) return [0, '推荐人不能是自己'];
|
||||
$parant = $this->app->db->name('DataUser')->where(['id' => $pid])->find();
|
||||
if (empty($parant['pids']) || empty($parant['vip_number'])) return [0, '推荐人无推荐资格'];
|
||||
if (empty($parant['pids']) || empty($parant['vip_code'])) return [0, '推荐人无推荐资格'];
|
||||
if (stripos($parant['path'], "-{$uid}-") !== false) return [0, '不能绑定下属'];
|
||||
// 组装代理数据
|
||||
$path = rtrim($parant['path'] ?: '-', '-') . "-{$parant['id']}-";
|
||||
@ -106,7 +106,7 @@ class UserUpgradeService extends Service
|
||||
}
|
||||
// 购买商品升级
|
||||
$query = $this->app->db->name('ShopOrderItem')->alias('b')->join('shop_order a', 'b.order_no=a.order_no');
|
||||
$tmpNumber = $query->whereRaw("a.uid={$uid} and a.payment_status=1 and a.status>=4 and b.vip_entry=1")->max('b.vip_number');
|
||||
$tmpNumber = $query->whereRaw("a.uid={$uid} and a.payment_status=1 and a.status>=4 and b.vip_entry=1")->max('b.vip_code');
|
||||
if ($tmpNumber > $vipNumber) {
|
||||
$map = ['status' => 1, 'number' => $tmpNumber];
|
||||
$upgrade = $this->app->db->name('DataUserUpgrade')->where($map)->find();
|
||||
@ -119,7 +119,7 @@ class UserUpgradeService extends Service
|
||||
// 更新用户数据
|
||||
$data = [
|
||||
'vip_name' => $vipName,
|
||||
'vip_number' => $vipNumber,
|
||||
'vip_code' => $vipNumber,
|
||||
'teams_users_total' => $teamsUsers,
|
||||
'teams_users_direct' => $teamsDirect,
|
||||
'teams_users_indirect' => $teamsIndirect,
|
||||
@ -128,7 +128,7 @@ class UserUpgradeService extends Service
|
||||
'teams_amount_indirect' => $teamsAmountIndirect,
|
||||
'order_amount_total' => $orderAmountTotal,
|
||||
];
|
||||
if ($data['vip_number'] !== $user['vip_number']) {
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user