提交
This commit is contained in:
parent
1719ebfa07
commit
339bcc7470
4
.env
4
.env
|
|
@ -1,4 +1,4 @@
|
|||
APP_DEBUG = true
|
||||
APP_DEBUG = false
|
||||
|
||||
[APP]
|
||||
DEFAULT_TIMEZONE = Asia/Shanghai
|
||||
|
|
@ -11,7 +11,7 @@ USERNAME = youda_test
|
|||
PASSWORD = youda_test
|
||||
HOSTPORT = 3306
|
||||
CHARSET = utf8
|
||||
DEBUG = true
|
||||
DEBUG = false
|
||||
|
||||
[LANG]
|
||||
default_lang = zh-cn
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ class Goods extends Base
|
|||
}
|
||||
if ($type !== '') {
|
||||
$where[] = ['type', '=', $type];
|
||||
} else {
|
||||
$where[] = ['type', '!=', 15];
|
||||
}
|
||||
|
||||
$query = GoodsModel::where($where)->order('id desc');
|
||||
|
|
@ -566,7 +568,7 @@ class Goods extends Base
|
|||
#循环数据
|
||||
$save_sports_data = [];
|
||||
$start_num = $info['stock'] + 1;
|
||||
|
||||
|
||||
// 获取宝箱类型的父奖品记录及其prize_code
|
||||
$box_prize_codes = [];
|
||||
foreach ($goods_list as $item) {
|
||||
|
|
@ -574,7 +576,7 @@ class Goods extends Base
|
|||
$box_prize_codes[$item['prize_code']] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 先处理父奖品(包括宝箱类型的父奖品)
|
||||
for ($i = $start_num; $i <= $data['stock']; $i++) {
|
||||
foreach ($goods_list as $k => $v) {
|
||||
|
|
@ -587,23 +589,23 @@ class Goods extends Base
|
|||
$save_sports_data[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 先插入父奖品
|
||||
if (!empty($save_sports_data)) {
|
||||
$res[] = GoodsList::insertAll($save_sports_data);
|
||||
}
|
||||
|
||||
|
||||
// 如果有宝箱类型的奖品,需要处理子奖品
|
||||
if (!empty($box_prize_codes)) {
|
||||
// 处理所有新套数的子奖品
|
||||
for ($i = $start_num; $i <= $data['stock']; $i++) {
|
||||
// 先获取当前套数下所有新插入的宝箱类型父奖品
|
||||
$new_box_parents = GoodsList::where([
|
||||
'goods_id' => $info['id'],
|
||||
'num' => $i,
|
||||
'goods_type' => 4,
|
||||
'goods_list_id' => 0
|
||||
])
|
||||
'goods_id' => $info['id'],
|
||||
'num' => $i,
|
||||
'goods_type' => 4,
|
||||
'goods_list_id' => 0
|
||||
])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
|
|
@ -615,12 +617,12 @@ class Goods extends Base
|
|||
foreach ($new_box_parents as $new_box_parent) {
|
||||
// 找到第一套中相同prize_code的宝箱父奖品
|
||||
$original_parent = GoodsList::where([
|
||||
'goods_id' => $info['id'],
|
||||
'num' => 1,
|
||||
'goods_type' => 4,
|
||||
'prize_code' => $new_box_parent['prize_code'],
|
||||
'goods_list_id' => 0
|
||||
])
|
||||
'goods_id' => $info['id'],
|
||||
'num' => 1,
|
||||
'goods_type' => 4,
|
||||
'prize_code' => $new_box_parent['prize_code'],
|
||||
'goods_list_id' => 0
|
||||
])
|
||||
->find();
|
||||
|
||||
if (!$original_parent) {
|
||||
|
|
@ -629,9 +631,9 @@ class Goods extends Base
|
|||
|
||||
// 获取原始父奖品的所有子奖品
|
||||
$child_items = GoodsList::where([
|
||||
'goods_id' => $info['id'],
|
||||
'goods_list_id' => $original_parent['id']
|
||||
])
|
||||
'goods_id' => $info['id'],
|
||||
'goods_list_id' => $original_parent['id']
|
||||
])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
|
|
@ -647,36 +649,36 @@ class Goods extends Base
|
|||
for ($j = 1; $j < $i; $j++) {
|
||||
// 找到对应套数的父奖品
|
||||
$existing_parent = GoodsList::where([
|
||||
'goods_id' => $info['id'],
|
||||
'num' => $j,
|
||||
'prize_code' => $new_box_parent['prize_code'],
|
||||
'goods_list_id' => 0
|
||||
])
|
||||
'goods_id' => $info['id'],
|
||||
'num' => $j,
|
||||
'prize_code' => $new_box_parent['prize_code'],
|
||||
'goods_list_id' => 0
|
||||
])
|
||||
->find();
|
||||
|
||||
|
||||
if ($existing_parent) {
|
||||
// 找到这个父奖品下与当前子奖品对应的子奖品
|
||||
$similar_child = GoodsList::where([
|
||||
'goods_id' => $info['id'],
|
||||
'num' => $j,
|
||||
'goods_list_id' => $existing_parent['id'],
|
||||
'title' => $child_item['title'], // 使用标题匹配相似子奖品
|
||||
'shang_id' => $child_item['shang_id'] // 确保奖品类型相同
|
||||
])
|
||||
'goods_id' => $info['id'],
|
||||
'num' => $j,
|
||||
'goods_list_id' => $existing_parent['id'],
|
||||
'title' => $child_item['title'], // 使用标题匹配相似子奖品
|
||||
'shang_id' => $child_item['shang_id'] // 确保奖品类型相同
|
||||
])
|
||||
->find();
|
||||
|
||||
|
||||
if ($similar_child) {
|
||||
$existing_children[] = $similar_child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$child_data = $child_item;
|
||||
unset($child_data['id']);
|
||||
$child_data['num'] = $i; // 设置新的套数
|
||||
$child_data['goods_list_id'] = $new_box_parent['id']; // 关联到新的父奖品
|
||||
$child_data['surplus_stock'] = $child_data['stock']; // 重置库存
|
||||
|
||||
|
||||
// 如果存在其他套数的相同子奖品,使用相同的prize_code
|
||||
if (!empty($existing_children)) {
|
||||
$child_data['prize_code'] = $existing_children[0]['prize_code'];
|
||||
|
|
@ -684,7 +686,7 @@ class Goods extends Base
|
|||
// 否则生成新的prize_code
|
||||
$child_data['prize_code'] = getPrizeCode() . '_' . time() . '_' . mt_rand(1000, 9999);
|
||||
}
|
||||
|
||||
|
||||
$child_save_data[] = $child_data;
|
||||
}
|
||||
|
||||
|
|
@ -730,7 +732,7 @@ class Goods extends Base
|
|||
$result = GoodsModel::where(['id' => $id])->update(['status' => $status]);
|
||||
} elseif ($status == 3) {
|
||||
$result = GoodsModel::where(['id' => $id])->update(['delete_time' => time(), 'status' => 2]);
|
||||
|
||||
|
||||
} else {
|
||||
return $this->renderError("请求参数错误");
|
||||
}
|
||||
|
|
@ -796,9 +798,9 @@ class Goods extends Base
|
|||
$where[] = ['goods_list_id', '=', 0];
|
||||
$query = GoodsList::where($where)->order('sort desc, shang_id asc, id asc');
|
||||
$count = $query->count();
|
||||
|
||||
$real_pro = GoodsList::where($where)->sum('real_pro');
|
||||
$list = $query->page($page, $limit)->select()->toArray();
|
||||
$real_pro = 0;
|
||||
// $real_pro = 0;
|
||||
|
||||
// 处理数据
|
||||
foreach ($list as &$item) {
|
||||
|
|
@ -807,7 +809,7 @@ class Goods extends Base
|
|||
if (!empty($item['imgurl_detail'])) {
|
||||
$item['imgurl_detail'] = imageUrl($item['imgurl_detail']);
|
||||
}
|
||||
$real_pro += $item['real_pro'];
|
||||
// $real_pro += $item['real_pro'];
|
||||
if ($item['goods_type'] == 4) {
|
||||
$goods_list = GoodsList::where('goods_id', $item['goods_id'])
|
||||
->where('goods_list_id', '=', $item['id'])
|
||||
|
|
@ -935,51 +937,51 @@ class Goods extends Base
|
|||
#循环数据
|
||||
$save_sports_data = [];
|
||||
$prize_code = getPrizeCode() . '_' . time(); // 生成唯一的prize_code
|
||||
|
||||
|
||||
// 处理子奖品添加的情况
|
||||
$goods_list_id = $request->param('goods_list_id/d', 0); // 获取父奖品ID,如果是子奖品
|
||||
$is_box_type = ($data['goods_type'] == 4); // 是否为宝箱类型
|
||||
|
||||
|
||||
if ($goods_list_id > 0) {
|
||||
// 获取父奖品信息,确保父奖品存在
|
||||
$parent_prize = GoodsList::where('id', $goods_list_id)->find();
|
||||
if (!$parent_prize) {
|
||||
return $this->renderError('宝箱父奖品不存在');
|
||||
}
|
||||
|
||||
|
||||
// 子奖品应该生成自己的prize_code
|
||||
$data['prize_code'] = getPrizeCode() . '_' . time() . '_' . mt_rand(1000, 9999);
|
||||
$data['goods_list_id'] = $goods_list_id;
|
||||
$data['num'] = $parent_prize['num'];
|
||||
|
||||
|
||||
// 如果父奖品存在于多个套数中,需要为每个套数创建对应的子奖品
|
||||
$same_prize_parents = GoodsList::where([
|
||||
'goods_id' => $data['goods_id'],
|
||||
'prize_code' => $parent_prize['prize_code'],
|
||||
'goods_list_id' => 0 // 确保只查询父奖品
|
||||
])
|
||||
'goods_id' => $data['goods_id'],
|
||||
'prize_code' => $parent_prize['prize_code'],
|
||||
'goods_list_id' => 0 // 确保只查询父奖品
|
||||
])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
|
||||
if (count($same_prize_parents) > 1) {
|
||||
// 有多个套数的相同父奖品
|
||||
$multi_data = [];
|
||||
|
||||
|
||||
foreach ($same_prize_parents as $same_parent) {
|
||||
if ($same_parent['id'] == $goods_list_id) {
|
||||
// 跳过当前指定的父奖品,因为下面要单独处理
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$child_data = $data;
|
||||
$child_data['goods_list_id'] = $same_parent['id'];
|
||||
$child_data['num'] = $same_parent['num'];
|
||||
$multi_data[] = $child_data;
|
||||
}
|
||||
|
||||
|
||||
// 先插入指定父奖品的子奖品
|
||||
$res = GoodsList::insert($data);
|
||||
|
||||
|
||||
// 再插入其他套数的子奖品
|
||||
if (!empty($multi_data)) {
|
||||
GoodsList::insertAll($multi_data);
|
||||
|
|
@ -988,18 +990,17 @@ class Goods extends Base
|
|||
// 只有一个套数,直接保存
|
||||
$res = GoodsList::insert($data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// 添加正常奖品或宝箱父奖品,为所有套数都添加
|
||||
$data['prize_code'] = $prize_code; // 使用新生成的prize_code
|
||||
for ($i = 1; $i <= $stock; $i++) {
|
||||
$data['num'] = $i;
|
||||
$save_sports_data[] = $data;
|
||||
}
|
||||
|
||||
|
||||
// 批量插入奖品
|
||||
$res = GoodsList::insertAll($save_sports_data);
|
||||
|
||||
|
||||
// 如果是宝箱类型,则需要记录下插入后的ID,以供后续可能添加的子奖品使用
|
||||
if ($is_box_type && $res) {
|
||||
// 获取已插入的宝箱奖品ID
|
||||
|
|
@ -1007,7 +1008,7 @@ class Goods extends Base
|
|||
->where('goods_id', $data['goods_id'])
|
||||
->where('goods_type', 4)
|
||||
->select()->toArray();
|
||||
|
||||
|
||||
// 通知前端已成功添加宝箱类型,提示可继续添加子奖品
|
||||
if (!empty($inserted_boxes)) {
|
||||
return $this->renderSuccess('添加成功,您可以继续为此宝箱添加子奖品', [
|
||||
|
|
@ -1015,7 +1016,7 @@ class Goods extends Base
|
|||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return $this->renderSuccess('添加成功');
|
||||
} elseif (in_array($type, [2, 8, 9, 16])) {
|
||||
|
|
@ -1040,51 +1041,51 @@ class Goods extends Base
|
|||
#循环数据
|
||||
$save_sports_data = [];
|
||||
$prize_code = getPrizeCode() . '_' . time(); // 生成唯一的prize_code
|
||||
|
||||
|
||||
// 处理子奖品添加的情况
|
||||
$goods_list_id = $request->param('goods_list_id/d', 0); // 获取父奖品ID,如果是子奖品
|
||||
$is_box_type = ($data['goods_type'] == 4); // 是否为宝箱类型
|
||||
|
||||
|
||||
if ($goods_list_id > 0) {
|
||||
// 获取父奖品信息,确保父奖品存在
|
||||
$parent_prize = GoodsList::where('id', $goods_list_id)->find();
|
||||
if (!$parent_prize) {
|
||||
return $this->renderError('宝箱父奖品不存在');
|
||||
}
|
||||
|
||||
|
||||
// 子奖品应该生成自己的prize_code
|
||||
$data['prize_code'] = getPrizeCode() . '_' . time() . '_' . mt_rand(1000, 9999);
|
||||
$data['goods_list_id'] = $goods_list_id;
|
||||
$data['num'] = $parent_prize['num'];
|
||||
|
||||
|
||||
// 如果父奖品存在于多个套数中,需要为每个套数创建对应的子奖品
|
||||
$same_prize_parents = GoodsList::where([
|
||||
'goods_id' => $data['goods_id'],
|
||||
'prize_code' => $parent_prize['prize_code'],
|
||||
'goods_list_id' => 0 // 确保只查询父奖品
|
||||
])
|
||||
'goods_id' => $data['goods_id'],
|
||||
'prize_code' => $parent_prize['prize_code'],
|
||||
'goods_list_id' => 0 // 确保只查询父奖品
|
||||
])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
|
||||
if (count($same_prize_parents) > 1) {
|
||||
// 有多个套数的相同父奖品
|
||||
$multi_data = [];
|
||||
|
||||
|
||||
foreach ($same_prize_parents as $same_parent) {
|
||||
if ($same_parent['id'] == $goods_list_id) {
|
||||
// 跳过当前指定的父奖品,因为下面要单独处理
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$child_data = $data;
|
||||
$child_data['goods_list_id'] = $same_parent['id'];
|
||||
$child_data['num'] = $same_parent['num'];
|
||||
$multi_data[] = $child_data;
|
||||
}
|
||||
|
||||
|
||||
// 先插入指定父奖品的子奖品
|
||||
$res = GoodsList::insert($data);
|
||||
|
||||
|
||||
// 再插入其他套数的子奖品
|
||||
if (!empty($multi_data)) {
|
||||
GoodsList::insertAll($multi_data);
|
||||
|
|
@ -1093,18 +1094,17 @@ class Goods extends Base
|
|||
// 只有一个套数,直接保存
|
||||
$res = GoodsList::insert($data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// 添加正常奖品或宝箱父奖品,为所有套数都添加
|
||||
$data['prize_code'] = $prize_code; // 使用新生成的prize_code
|
||||
for ($i = 1; $i <= $stock; $i++) {
|
||||
$data['num'] = $i;
|
||||
$save_sports_data[] = $data;
|
||||
}
|
||||
|
||||
|
||||
// 批量插入奖品
|
||||
$res = GoodsList::insertAll($save_sports_data);
|
||||
|
||||
|
||||
// 如果是宝箱类型,则需要记录下插入后的ID,以供后续可能添加的子奖品使用
|
||||
if ($is_box_type && $res) {
|
||||
// 获取已插入的宝箱奖品ID
|
||||
|
|
@ -1112,7 +1112,7 @@ class Goods extends Base
|
|||
->where('goods_id', $data['goods_id'])
|
||||
->where('goods_type', 4)
|
||||
->select()->toArray();
|
||||
|
||||
|
||||
// 通知前端已成功添加宝箱类型,提示可继续添加子奖品
|
||||
if (!empty($inserted_boxes)) {
|
||||
return $this->renderSuccess('添加成功,您可以继续为此宝箱添加子奖品', [
|
||||
|
|
@ -1121,7 +1121,7 @@ class Goods extends Base
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (RegInt($data['prize_num']) && $data['shang_id'] == 5) {
|
||||
return $this->renderError("擂台赏抽全局赏数量设置错误,请设置大于0的整数");
|
||||
}
|
||||
|
|
@ -1248,7 +1248,7 @@ class Goods extends Base
|
|||
//
|
||||
|
||||
if ($type == 1 || $type == 5 || $type == 10 || $type == 6 || $type == 11 || $type == 15) {
|
||||
|
||||
|
||||
|
||||
} elseif ($type == 2 || $type == 8 || $type == 9 || $type == 16 || $type == 17) {
|
||||
if (RegMoney($data['real_pro'] * 10000)) {
|
||||
|
|
@ -1665,9 +1665,9 @@ class Goods extends Base
|
|||
->where($whe)
|
||||
->order('id desc')
|
||||
->paginate([
|
||||
'list_rows' => $this->page,
|
||||
'query' => request()->param(),
|
||||
]);
|
||||
'list_rows' => $this->page,
|
||||
'query' => request()->param(),
|
||||
]);
|
||||
|
||||
// 获取所有相关的盒子信息
|
||||
$goodsIds = array_column($list->items(), 'goods_id');
|
||||
|
|
@ -1725,7 +1725,7 @@ class Goods extends Base
|
|||
}
|
||||
|
||||
$url .= 'api/goods/receive_sync';
|
||||
|
||||
|
||||
// 获取盒子数据
|
||||
$goods = GoodsModel::where(['id' => $id])->find();
|
||||
if (!$goods) {
|
||||
|
|
@ -1741,10 +1741,10 @@ class Goods extends Base
|
|||
|
||||
// 获取盒子奖品数据
|
||||
$goodsLists = GoodsList::where(['goods_id' => $id])->select()->toArray();
|
||||
|
||||
|
||||
// 获取盒子扩展配置
|
||||
$goodsExtend = GoodsExtend::where(['goods_id' => $id])->find();
|
||||
|
||||
|
||||
// 收集所有奖励ID
|
||||
$rewardIds = [];
|
||||
foreach ($goodsLists as $item) {
|
||||
|
|
@ -1752,7 +1752,7 @@ class Goods extends Base
|
|||
$rewardIds[] = $item['reward_id'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 获取奖励数据
|
||||
$rewards = [];
|
||||
if (!empty($rewardIds)) {
|
||||
|
|
@ -1766,7 +1766,7 @@ class Goods extends Base
|
|||
'async_code' => $async_code,
|
||||
'rewards' => $rewards
|
||||
];
|
||||
|
||||
|
||||
if ($goodsExtend) {
|
||||
$postData['goodsExtend'] = $goodsExtend->toArray();
|
||||
}
|
||||
|
|
@ -1782,28 +1782,28 @@ class Goods extends Base
|
|||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen(json_encode($postData))
|
||||
]);
|
||||
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
|
||||
if ($status !== 200) {
|
||||
return $this->renderError('同步失败,服务器返回状态码: ' . $status);
|
||||
}
|
||||
|
||||
|
||||
$responseData = json_decode($response, true);
|
||||
if (!$responseData || $responseData['code'] !== 1) {
|
||||
$errorMsg = isset($responseData['msg']) ? $responseData['msg'] : '服务器未返回预期响应';
|
||||
return $this->renderError('同步失败: ' . $errorMsg);
|
||||
}
|
||||
|
||||
|
||||
// 更新同步状态
|
||||
$goods->save([
|
||||
'sync_status' => 1,
|
||||
'sync_url' => $url,
|
||||
'sync_time' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
|
||||
|
||||
return $this->renderSuccess('同步成功');
|
||||
} catch (\Exception $e) {
|
||||
return $this->renderError('同步失败: ' . $e->getMessage());
|
||||
|
|
@ -1871,7 +1871,7 @@ class Goods extends Base
|
|||
$goodsData['status'] = 2; // 默认下架状态
|
||||
$goodsData['addtime'] = time();
|
||||
$goodsData['async_code'] = ''; // 清空同步代码,避免混淆
|
||||
$goodsData['is_open'] = 0;
|
||||
$goodsData['is_open'] = 0;
|
||||
$goodsData['king_user_id'] = 0;
|
||||
// 插入新盒子
|
||||
$newGoods = new GoodsModel();
|
||||
|
|
@ -1890,7 +1890,7 @@ class Goods extends Base
|
|||
|
||||
// 创建父奖品prize_code映射表
|
||||
$parentPrizeCodeMapping = [];
|
||||
|
||||
|
||||
// 创建子奖品prize_code映射表
|
||||
$childPrizeCodeMapping = [];
|
||||
|
||||
|
|
@ -1898,7 +1898,7 @@ class Goods extends Base
|
|||
$parentPrizes = GoodsList::where(['goods_id' => $id, 'goods_list_id' => 0])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
|
||||
$prizeCodeGroups = [];
|
||||
foreach ($parentPrizes as $prize) {
|
||||
if (!isset($prizeCodeGroups[$prize['prize_code']])) {
|
||||
|
|
@ -1906,12 +1906,12 @@ class Goods extends Base
|
|||
}
|
||||
$prizeCodeGroups[$prize['prize_code']][] = $prize;
|
||||
}
|
||||
|
||||
|
||||
// 为每个父prize_code组创建新的prize_code
|
||||
foreach ($prizeCodeGroups as $oldPrizeCode => $prizes) {
|
||||
$newPrizeCode = 'MHHZ' . date('YmdHis') . mt_rand(1000, 9999);
|
||||
$parentPrizeCodeMapping[$oldPrizeCode] = $newPrizeCode;
|
||||
|
||||
|
||||
// 复制每个prize_code组的奖品
|
||||
foreach ($prizes as $prize) {
|
||||
$newPrizeData = $prize;
|
||||
|
|
@ -1920,7 +1920,7 @@ class Goods extends Base
|
|||
$newPrizeData['prize_code'] = $newPrizeCode;
|
||||
$newPrizeData['addtime'] = time();
|
||||
$newPrizeData['surplus_stock'] = $newPrizeData['stock'];
|
||||
|
||||
|
||||
// 处理奖励ID
|
||||
if ($newPrizeData['reward_id'] && $newPrizeData['reward_id'] != '') {
|
||||
$reward = Reward::where(['reward_id' => $newPrizeData['reward_id']])->select();
|
||||
|
|
@ -1936,19 +1936,19 @@ class Goods extends Base
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 插入新奖品
|
||||
$newGoodsList = new GoodsList();
|
||||
$newGoodsList->save($newPrizeData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 获取所有子奖品
|
||||
$childPrizes = GoodsList::where(['goods_id' => $id])
|
||||
->where('goods_list_id', '>', 0)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
|
||||
// 对子奖品按prize_code分组
|
||||
$childGroups = [];
|
||||
foreach ($childPrizes as $child) {
|
||||
|
|
@ -1958,13 +1958,13 @@ class Goods extends Base
|
|||
}
|
||||
$childGroups[$childPrizeCode][] = $child;
|
||||
}
|
||||
|
||||
|
||||
// 为每组子奖品创建新的prize_code映射
|
||||
foreach ($childGroups as $oldChildCode => $group) {
|
||||
$newChildCode = 'MHHZ' . date('YmdHis') . mt_rand(1000, 9999);
|
||||
$childPrizeCodeMapping[$oldChildCode] = $newChildCode;
|
||||
}
|
||||
|
||||
|
||||
// 处理每个子奖品
|
||||
foreach ($childPrizes as $childPrize) {
|
||||
// 查找子奖品对应的父奖品
|
||||
|
|
@ -1972,10 +1972,10 @@ class Goods extends Base
|
|||
if (!$parentPrize) {
|
||||
continue; // 如果找不到父奖品,跳过
|
||||
}
|
||||
|
||||
|
||||
// 获取父奖品的prize_code
|
||||
$parentPrizeCode = $parentPrize['prize_code'];
|
||||
|
||||
|
||||
// 如果父奖品的prize_code有映射,则复制子奖品
|
||||
if (isset($parentPrizeCodeMapping[$parentPrizeCode])) {
|
||||
// 找到新盒子中对应的父奖品
|
||||
|
|
@ -1984,14 +1984,14 @@ class Goods extends Base
|
|||
'prize_code' => $parentPrizeCodeMapping[$parentPrizeCode],
|
||||
'num' => $parentPrize['num'] // 确保套数也匹配
|
||||
])->find();
|
||||
|
||||
|
||||
if ($newParent) {
|
||||
// 复制子奖品数据
|
||||
$newChildData = $childPrize;
|
||||
unset($newChildData['id']);
|
||||
$newChildData['goods_id'] = $newGoodsId;
|
||||
$newChildData['goods_list_id'] = $newParent['id']; // 关联到新的父奖品
|
||||
|
||||
|
||||
// 使用子奖品的prize_code映射,确保相同的子奖品有相同的prize_code
|
||||
if (isset($childPrizeCodeMapping[$childPrize['prize_code']])) {
|
||||
$newChildData['prize_code'] = $childPrizeCodeMapping[$childPrize['prize_code']];
|
||||
|
|
@ -2001,10 +2001,10 @@ class Goods extends Base
|
|||
$childPrizeCodeMapping[$childPrize['prize_code']] = $newChildCode;
|
||||
$newChildData['prize_code'] = $newChildCode;
|
||||
}
|
||||
|
||||
|
||||
$newChildData['addtime'] = time();
|
||||
$newChildData['surplus_stock'] = $newChildData['stock'];
|
||||
|
||||
|
||||
// 处理奖励ID
|
||||
if ($newChildData['reward_id'] && $newChildData['reward_id'] != '') {
|
||||
$reward = Reward::where(['reward_id' => $newChildData['reward_id']])->select();
|
||||
|
|
@ -2020,7 +2020,7 @@ class Goods extends Base
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 插入新的子奖品
|
||||
$newChildList = new GoodsList();
|
||||
$newChildList->save($newChildData);
|
||||
|
|
|
|||
|
|
@ -550,4 +550,70 @@ class Statistics extends Base
|
|||
return View::fetch("Statistics/shipmentList");
|
||||
}
|
||||
|
||||
/**
|
||||
* 出货概览
|
||||
*/
|
||||
public function productsOverview(Request $request)
|
||||
{
|
||||
$goodsId = $request->param('goods_id', 0, 'intval');
|
||||
|
||||
// 获取测试用户ID
|
||||
$testUsers = User::where('istest', '>', 0)->column('id');
|
||||
|
||||
// 查询条件
|
||||
$where = [
|
||||
['goods_id', '=', $goodsId]
|
||||
];
|
||||
|
||||
if (!empty($testUsers)) {
|
||||
$where[] = ['user_id', 'not in', $testUsers];
|
||||
}
|
||||
|
||||
// 第一个SQL:按奖品ID分组统计出货数量
|
||||
$productStats = OrderList::where($where)
|
||||
->field('goodslist_id, COUNT(1) as goods_count')
|
||||
->group('goodslist_id')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 获取所有涉及的奖品ID
|
||||
$goodslistIds = array_column($productStats, 'goodslist_id');
|
||||
|
||||
// 第二个SQL:查询奖品详细信息
|
||||
$productInfos = [];
|
||||
if (!empty($goodslistIds)) {
|
||||
$productInfos = GoodsList::where('id', 'in', $goodslistIds)
|
||||
->field('id, title, imgurl, price, money, sc_money, real_pro')
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
// 将两个查询结果合并,以奖品ID为键
|
||||
$productInfoMap = [];
|
||||
foreach ($productInfos as $info) {
|
||||
$productInfoMap[$info['id']] = $info;
|
||||
}
|
||||
|
||||
// 合并结果
|
||||
$result = [];
|
||||
foreach ($productStats as $stat) {
|
||||
$goodslistId = $stat['goodslist_id'];
|
||||
if (array_key_exists($goodslistId, $productInfoMap)) {
|
||||
$result[] = array_merge($stat, $productInfoMap[$goodslistId]);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取盒子信息
|
||||
$boxInfo = GoodsModel::where('id', $goodsId)->find();
|
||||
|
||||
// 传递数据给视图
|
||||
View::assign([
|
||||
'list' => $result,
|
||||
'goods_id' => $goodsId,
|
||||
'boxInfo' => $boxInfo
|
||||
]);
|
||||
|
||||
return View::fetch('Statistics/productsOverview');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ class User extends Base
|
|||
public function list()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
$limit = request()->param('limit', '');
|
||||
|
||||
// 构建查询条件
|
||||
$where = [];
|
||||
if (!empty($param['user_id'])) {
|
||||
|
|
@ -62,7 +64,7 @@ class User extends Base
|
|||
}
|
||||
$field = '*';
|
||||
$order = 'id desc';
|
||||
$data = UserModel::getList($where, $field, $order, $this->page);
|
||||
$data = UserModel::getList($where, $field, $order, $limit);
|
||||
foreach ($data['list'] as &$value) {
|
||||
$pid_info = UserModel::field('id,nickname,headimg,uid')->where(['id' => $value['pid']])->find();
|
||||
$value['pid_info'] = $pid_info;
|
||||
|
|
@ -1405,4 +1407,40 @@ class User extends Base
|
|||
return json(['status' => 0, 'msg' => '重置失败:' . $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定用户手机号
|
||||
*/
|
||||
public function bindUserMobile(Request $request)
|
||||
{
|
||||
$id = $request->post('id/d', 0);
|
||||
$mobile = $request->post('mobile', '');
|
||||
|
||||
// 验证手机号格式
|
||||
if (!preg_match('/^1\d{10}$/', $mobile)) {
|
||||
return json(['status' => 0, 'msg' => '手机号格式不正确']);
|
||||
}
|
||||
|
||||
$user = UserModel::getInfo(['id' => $id]);
|
||||
if (!$user) {
|
||||
return json(['status' => 0, 'msg' => '用户不存在']);
|
||||
}
|
||||
|
||||
// 检查手机号是否已被其他用户使用
|
||||
$existUser = UserModel::where('mobile', $mobile)
|
||||
->where('id', '<>', $id)
|
||||
->find();
|
||||
if ($existUser) {
|
||||
return json(['status' => 0, 'msg' => '该手机号已被其他用户使用']);
|
||||
}
|
||||
|
||||
// 更新用户手机号
|
||||
$result = $user->save(['mobile' => $mobile]);
|
||||
|
||||
if ($result) {
|
||||
return json(['status' => 1, 'msg' => '手机号绑定成功']);
|
||||
} else {
|
||||
return json(['status' => 0, 'msg' => '手机号绑定失败']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ Route::rule('usermobileclear', 'User/usermobileclear', 'POST');//清空手机号
|
|||
Route::rule('userwxclear', 'User/userwxclear', 'POST');//清空微信登录数据
|
||||
Route::rule('userUidClear', 'User/userUidClear', 'POST');//清空UID
|
||||
Route::rule('resetUserSign', 'User/resetUserSign', 'POST');//重置用户签到数据
|
||||
Route::rule('bindUserMobile', 'User/bindUserMobile', 'POST');//绑定用户手机号
|
||||
|
||||
// 添加用户登录统计路由
|
||||
Route::rule('user_loginStat', 'user/loginStat');
|
||||
|
|
@ -320,6 +321,8 @@ Route::rule('statistics_shipmentList', 'Statistics/shipmentList', 'GET');
|
|||
Route::rule('statistics_orderList', 'Statistics/goodsList', 'GET');
|
||||
//支付订单
|
||||
Route::rule('statistics_order', 'Statistics/orderList', 'GET');
|
||||
//出货概览
|
||||
Route::rule('statistics_productsOverview', 'Statistics/productsOverview', 'GET');
|
||||
|
||||
//利润支出
|
||||
Route::rule('ProfitExpenses', 'Profit/index', 'GET');
|
||||
|
|
|
|||
|
|
@ -1,48 +1,54 @@
|
|||
{include file="Public:header3"/}
|
||||
|
||||
<body>
|
||||
<div class="layui-fluid" style="padding-top: 15px;">
|
||||
<div class="layui-fluid" style="padding-top: 15px;">
|
||||
<div class=" layui-card">
|
||||
<div class="layui-form layui-card-header layuiadmin-card-header-auto">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline" style="width: 300px;margin-left: 0px">
|
||||
<input type="text" name="title" id="title" placeholder="请输入盒子标题" autocomplete="off"
|
||||
class="layui-input">
|
||||
<div class="layui-form layui-card-header layuiadmin-card-header-auto" style="height: 84px;">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline" style="width: 300px;margin-left: 0px">
|
||||
<input type="text" name="title" id="title" placeholder="请输入盒子标题" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline" style="width: 180px;margin-left: 0px">
|
||||
<select name="status" id="status" style="width:100%">
|
||||
<option value="">--请选择状态--</option>
|
||||
<option value="1">上架</option>
|
||||
<option value="2">下架</option>
|
||||
<option value="3">售罄</option>
|
||||
</select>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline" style="width: 180px;margin-left: 0px">
|
||||
<select name="status" id="status" style="width:100%">
|
||||
<option value="">--请选择状态--</option>
|
||||
<option value="1">上架</option>
|
||||
<option value="2">下架</option>
|
||||
<option value="3">售罄</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline" style="width: 180px;margin-left: 0px">
|
||||
<select name="type" id="goodsType" style="width:100%">
|
||||
<option value="">--盒子类型--</option>
|
||||
<!-- 盒子类型由JS动态加载 -->
|
||||
</select>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline" style="width: 180px;margin-left: 0px">
|
||||
<select name="type" id="goodsType" style="width:100%">
|
||||
<option value="">--盒子类型--</option>
|
||||
<!-- 盒子类型由JS动态加载 -->
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layuiadmin-btn-useradmin" id="searchBtn">
|
||||
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
||||
</button>
|
||||
<button class="layui-btn" id="addGoodsBtn">添加盒子</button>
|
||||
<button class="layui-btn layui-btn-normal" id="offshelfLogBtn">自动下架日志</button>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
默认不显示福利屋数据,查看福利屋盒子,请在盒子类型选择福利屋单独查看。
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layuiadmin-btn-useradmin" id="searchBtn">
|
||||
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
||||
</button>
|
||||
<button class="layui-btn" id="addGoodsBtn">添加盒子</button>
|
||||
<button class="layui-btn layui-btn-normal" id="offshelfLogBtn">自动下架日志</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="layui-card-body">
|
||||
<table id="goodsTable" lay-filter="goodsTable"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card-body">
|
||||
<table id="goodsTable" lay-filter="goodsTable"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 盒子类型模板 -->
|
||||
|
|
@ -245,13 +251,13 @@
|
|||
$.ajax({
|
||||
url: '{:url("/admin/api/goods/types")}',
|
||||
type: 'GET',
|
||||
success: function(res) {
|
||||
success: function (res) {
|
||||
if (res.code === 0) {
|
||||
// 保存类型数据到全局变量
|
||||
window.goodsTypes = res.data;
|
||||
|
||||
|
||||
var html = '<option value="">--盒子类型--</option>';
|
||||
$.each(res.data, function(index, item) {
|
||||
$.each(res.data, function (index, item) {
|
||||
html += '<option value="' + item.value + '" title="' + item.remark + '">' + item.fl_name + '</option>';
|
||||
});
|
||||
$('#goodsType').html(html);
|
||||
|
|
@ -269,6 +275,7 @@
|
|||
lineStyle: 'height:150px',
|
||||
height: 'full-120',
|
||||
cols: [[
|
||||
{ field: 'id', type: 'numbers', title: '序号',width:60 },
|
||||
{
|
||||
field: 'id', title: '盒子ID', width: 80, templet: function (d) {
|
||||
if (d.type == 1 || d.type == 11) {
|
||||
|
|
@ -280,7 +287,7 @@
|
|||
},
|
||||
{ field: 'type', title: '盒子类型', width: 120, templet: '#typeTpl' },
|
||||
{ field: 'title', title: '盒子名称', width: 180 },
|
||||
{
|
||||
{
|
||||
field: 'price_stock', title: '价格/套数', width: 140, templet: '#priceStockTpl'
|
||||
},
|
||||
{
|
||||
|
|
@ -294,28 +301,30 @@
|
|||
}
|
||||
},
|
||||
{ field: 'limit_info', title: '限购信息', width: 160, templet: '#limitInfoTpl' },
|
||||
|
||||
|
||||
{ field: 'pay_info', title: '支付信息', width: 150, templet: '#payInfoTpl' },
|
||||
{ field: 'is_auto_xiajia', title: '自动下架', width: 150, templet: '#autoOffshelfTpl' },
|
||||
{ field: 'sort', title: '排序', width: 100, edit: 'text' },
|
||||
{ field: 'is_flw', title: '福利屋信息', width: 200, templet: function(d) {
|
||||
if (d.type == 15) {
|
||||
var startTime = d.flw_start_time ? new Date(d.flw_start_time * 1000).toLocaleString() : '未设置';
|
||||
var endTime = d.flw_end_time ? new Date(d.flw_end_time * 1000).toLocaleString() : '未设置';
|
||||
var openTime = d.open_time ? new Date(d.open_time * 1000).toLocaleString() : '未设置';
|
||||
var isOpen = d.is_open == 1 ? '<span class="layui-badge layui-bg-green">已开奖</span>' : '<span class="layui-badge layui-bg-gray">未开奖</span>';
|
||||
return '<div><b>开始:</b> ' + startTime + '</div>' +
|
||||
'<div><b>结束:</b> ' + endTime + '</div>' +
|
||||
'<div><b>开奖:</b> ' + openTime + '</div>' +
|
||||
'<div><b>状态:</b> ' + isOpen + '</div>';
|
||||
} else {
|
||||
return '';
|
||||
{
|
||||
field: 'is_flw', title: '福利屋信息', width: 200, templet: function (d) {
|
||||
if (d.type == 15) {
|
||||
var startTime = d.flw_start_time ? new Date(d.flw_start_time * 1000).toLocaleString() : '未设置';
|
||||
var endTime = d.flw_end_time ? new Date(d.flw_end_time * 1000).toLocaleString() : '未设置';
|
||||
var openTime = d.open_time ? new Date(d.open_time * 1000).toLocaleString() : '未设置';
|
||||
var isOpen = d.is_open == 1 ? '<span class="layui-badge layui-bg-green">已开奖</span>' : '<span class="layui-badge layui-bg-gray">未开奖</span>';
|
||||
return '<div><b>开始:</b> ' + startTime + '</div>' +
|
||||
'<div><b>结束:</b> ' + endTime + '</div>' +
|
||||
'<div><b>开奖:</b> ' + openTime + '</div>' +
|
||||
'<div><b>状态:</b> ' + isOpen + '</div>';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}},
|
||||
},
|
||||
{ field: 'show_lock', title: '显示/锁箱', width: 150, templet: '#showLockTpl' },
|
||||
|
||||
{
|
||||
field: 'addtime', title: '添加/修改时间', width: 180, templet: function(d) {
|
||||
|
||||
{
|
||||
field: 'addtime', title: '添加/修改时间', width: 180, templet: function (d) {
|
||||
if (d.update_time) {
|
||||
return '<div><b>添加:</b> ' + d.addtime_text + '</div><div><b>修改:</b> ' + new Date(d.update_time * 1000).toLocaleString() + '</div>';
|
||||
} else {
|
||||
|
|
@ -323,7 +332,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{ fixed: 'right',field: 'status', title: '状态', width: 100, templet: '#statusTpl' },
|
||||
{ fixed: 'right', field: 'status', title: '状态', width: 100, templet: '#statusTpl' },
|
||||
{ fixed: 'right', title: '操作', width: 200, toolbar: '#toolbarTpl' }
|
||||
]],
|
||||
done: function () {
|
||||
|
|
@ -399,13 +408,13 @@
|
|||
goods_extend_del(data.id);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 监听单元格编辑
|
||||
table.on('edit(goodsTable)', function(obj){
|
||||
table.on('edit(goodsTable)', function (obj) {
|
||||
var value = obj.value, // 得到修改后的值
|
||||
data = obj.data, // 得到所在行所有键值
|
||||
field = obj.field; // 得到字段
|
||||
|
||||
|
||||
// 排序字段修改
|
||||
if (field === 'sort') {
|
||||
var loadIndex = layer.load(2);
|
||||
|
|
@ -417,19 +426,19 @@
|
|||
id: data.id,
|
||||
sort: value
|
||||
},
|
||||
success: function(res) {
|
||||
success: function (res) {
|
||||
layer.close(loadIndex);
|
||||
if (res.status === 1) {
|
||||
layer.msg('排序修改成功', {icon: 1, time: 1000});
|
||||
layer.msg('排序修改成功', { icon: 1, time: 1000 });
|
||||
} else {
|
||||
layer.msg(res.msg || '修改失败', {icon: 2, anim: 6, time: 2000});
|
||||
layer.msg(res.msg || '修改失败', { icon: 2, anim: 6, time: 2000 });
|
||||
// 重载表格以恢复原值
|
||||
table.reload('goodsTable');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
error: function () {
|
||||
layer.close(loadIndex);
|
||||
layer.msg('网络错误,请稍后重试', {icon: 2, anim: 6, time: 2000});
|
||||
layer.msg('网络错误,请稍后重试', { icon: 2, anim: 6, time: 2000 });
|
||||
// 重载表格以恢复原值
|
||||
table.reload('goodsTable');
|
||||
}
|
||||
|
|
@ -673,7 +682,7 @@
|
|||
$.post(url, { "goods_id": goods_id }, function (data) {
|
||||
layer.close(load);
|
||||
if (data.status == 1) {
|
||||
layer.msg(data.msg, { icon: 1, time: 2000 }, function() {
|
||||
layer.msg(data.msg, { icon: 1, time: 2000 }, function () {
|
||||
table.reload('goodsTable');
|
||||
});
|
||||
} else {
|
||||
|
|
@ -688,41 +697,40 @@
|
|||
function previewImg(obj) {
|
||||
var img = new Image();
|
||||
img.src = obj.src;
|
||||
|
||||
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: false,
|
||||
closeBtn: 1,
|
||||
shadeClose: true,
|
||||
area: [img.width > 800 ? '800px' : img.width+'px', ''],
|
||||
area: [img.width > 800 ? '800px' : img.width + 'px', ''],
|
||||
content: '<div style="text-align: center;"><img src="' + obj.src + '" style="max-width: 100%;" /></div>'
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
|
||||
.combined-values div {
|
||||
margin: 0;
|
||||
padding: 0px 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 图片放大样式 */
|
||||
.layui-admin-img {
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
|
||||
.layui-admin-img:hover {
|
||||
transform: scale(1.1);
|
||||
box-shadow: 0 0 10px rgba(0,0,0,0.2);
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
|
||||
/* 支付信息容器样式 */
|
||||
.pay-info-container {
|
||||
padding: 5px 0;
|
||||
}
|
||||
|
||||
|
||||
/* 徽章样式 */
|
||||
.layui-badge {
|
||||
margin: 2px;
|
||||
|
|
|
|||
|
|
@ -105,6 +105,17 @@
|
|||
{{# } }}
|
||||
</script>
|
||||
|
||||
<!-- 是否为领主模板 -->
|
||||
<script type="text/html" id="isLingzhuTpl">
|
||||
{{# if(d.id!=-1){ }}
|
||||
{{# if(d.is_lingzhu == 1){ }}
|
||||
<span>是</span>
|
||||
{{# } else { }}
|
||||
<span>否</span>
|
||||
{{# } }}
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<!-- 价格信息模板 -->
|
||||
<script type="text/html" id="priceTpl">
|
||||
{{# if(d.id!=-1){ }}
|
||||
|
|
@ -138,7 +149,7 @@
|
|||
function initTable() {
|
||||
// 构建表格列配置
|
||||
var columns = [];
|
||||
|
||||
columns.push({ field: 'id', type: 'numbers', title: '序号', width: 60 },);
|
||||
// columns.push({ field: 'id', title: 'ID', minWidth: 80 });
|
||||
// columns.push({ field: 'goods_list_id', title: '所属宝箱id', minWidth: 80 });
|
||||
// 基础列
|
||||
|
|
@ -151,11 +162,11 @@
|
|||
columns.push({ field: 'price', title: '价格信息', templet: '#priceTpl', minWidth: 150 });
|
||||
|
||||
// 根据类型添加特定列
|
||||
if ([1, 3, 5,6, 10, 11, 15,17].indexOf(goodsType) > -1) {
|
||||
if ([1, 3, 5, 6, 10, 11, 15, 17].indexOf(goodsType) > -1) {
|
||||
columns.push({ field: 'stock', title: '奖品数量', minWidth: 100 });
|
||||
}
|
||||
|
||||
if ([2, 8, 9, 16,17].indexOf(goodsType) > -1) {
|
||||
if ([2, 8, 9, 16, 17].indexOf(goodsType) > -1) {
|
||||
columns.push({
|
||||
field: 'real_pro', title: '真实概率', templet: function (d) {
|
||||
return d.real_pro + '%'
|
||||
|
|
@ -171,6 +182,9 @@
|
|||
columns.push({ field: 'lian_ji_type', title: '奖池分类', templet: '#lianJiTypeTpl', minWidth: 100 });
|
||||
}
|
||||
|
||||
if (goodsType === 8) {
|
||||
columns.push({ field: 'is_lingzhu', title: '是否为领主', templet: '#isLingzhuTpl', minWidth: 100 });
|
||||
}
|
||||
|
||||
columns.push({ field: 'sort', title: '排序', minWidth: 80, edit: 'text' });
|
||||
columns.push({ title: '操作', toolbar: '#operationTpl', minWidth: 210, fixed: 'right' });
|
||||
|
|
@ -180,6 +194,7 @@
|
|||
elem: '#goodsListTable',
|
||||
url: '{:url("/admin/getGoodsListData")}',
|
||||
method: 'get',
|
||||
toolbar: true,
|
||||
where: {
|
||||
goods_id: goodsId
|
||||
},
|
||||
|
|
@ -257,13 +272,13 @@
|
|||
openAddLayer(data.goods_id, data.id);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 监听单元格编辑
|
||||
table.on('edit(goodsListTable)', function(obj){
|
||||
table.on('edit(goodsListTable)', function (obj) {
|
||||
var value = obj.value, // 得到修改后的值
|
||||
data = obj.data, // 得到所在行所有键值
|
||||
field = obj.field; // 得到字段
|
||||
|
||||
|
||||
// 排序字段修改
|
||||
if (field === 'sort') {
|
||||
var loadIndex = layer.load(2);
|
||||
|
|
@ -275,19 +290,19 @@
|
|||
id: data.id,
|
||||
sort: value
|
||||
},
|
||||
success: function(res) {
|
||||
success: function (res) {
|
||||
layer.close(loadIndex);
|
||||
if (res.status === 1) {
|
||||
layer.msg('排序修改成功', {icon: 1, time: 1000});
|
||||
layer.msg('排序修改成功', { icon: 1, time: 1000 });
|
||||
} else {
|
||||
layer.msg(res.msg || '修改失败', {icon: 2, anim: 6, time: 2000});
|
||||
layer.msg(res.msg || '修改失败', { icon: 2, anim: 6, time: 2000 });
|
||||
// 重载表格以恢复原值
|
||||
table.reload('goodsListTable');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
error: function () {
|
||||
layer.close(loadIndex);
|
||||
layer.msg('网络错误,请稍后重试', {icon: 2, anim: 6, time: 2000});
|
||||
layer.msg('网络错误,请稍后重试', { icon: 2, anim: 6, time: 2000 });
|
||||
// 重载表格以恢复原值
|
||||
table.reload('goodsListTable');
|
||||
}
|
||||
|
|
@ -325,7 +340,7 @@
|
|||
end: function () {
|
||||
// 刷新表格
|
||||
console.log('aaaa');
|
||||
|
||||
|
||||
table.reload('goodsListTable');
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
title="宝箱" {if $goods_list_id}disabled{/if} {if $type eq 17}disabled{/if}>
|
||||
<br />
|
||||
<span
|
||||
style="font-size: 12px;color: #999;">货币:抽到后会发放“赠送货币”中配置的数据,本奖品不会到用户的盒柜里。</span><br />
|
||||
style="font-size: 12px;color: #999;">货币:抽到后会发放"赠送货币"中配置的数据,本奖品不会到用户的盒柜里。</span><br />
|
||||
<span style="font-size: 12px;color: #999;">盒子类型为特殊盒子时,无法选择宝箱</span>
|
||||
</div>
|
||||
|
||||
|
|
@ -125,6 +125,16 @@
|
|||
</div>
|
||||
{/if}
|
||||
|
||||
{if $type eq 8}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否为领主</label>
|
||||
<div class="layui-input-inline" style="width: 700px">
|
||||
<input type="radio" name="is_lingzhu" value="1" class="layui-input" title="是">
|
||||
<input type="radio" name="is_lingzhu" value="0" class="layui-input" title="否" checked>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="layui-form-item sale_time" style="display: none">
|
||||
<label class="layui-form-label">预售时间</label>
|
||||
<div class="layui-input-inline" style="width: 512px;">
|
||||
|
|
|
|||
|
|
@ -126,6 +126,16 @@
|
|||
</div>
|
||||
{/if}
|
||||
|
||||
{if $type eq 8}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否为领主</label>
|
||||
<div class="layui-input-inline" style="width: 700px">
|
||||
<input type="radio" name="is_lingzhu" value="1" class="layui-input" title="是" {if $goods.is_lingzhu eq 1} checked {/if}>
|
||||
<input type="radio" name="is_lingzhu" value="0" class="layui-input" title="否" {if $goods.is_lingzhu eq 0 || $goods.is_lingzhu eq null} checked {/if}>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="layui-form-item sale_time" {if $goods.goods_type eq 1 || $goods.goods_type
|
||||
eq 3 || $goods.goods_type eq 4} style="display: none" {/if}>
|
||||
<label class="layui-form-label">预售时间</label>
|
||||
|
|
|
|||
171
app/admin/view/Statistics/productsOverview.html
Normal file
171
app/admin/view/Statistics/productsOverview.html
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
{include file="Public:header2"/}
|
||||
|
||||
<body>
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
出货概览 - {$boxInfo.title|default='未知盒子'}
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-row layui-col-space15">
|
||||
<div class="layui-col-md12">
|
||||
<?php
|
||||
// 预先计算总出货数量
|
||||
$totalCount = 0;
|
||||
$totalValue = 0;
|
||||
foreach($list as $item) {
|
||||
$totalCount += isset($item['goods_count']) ? $item['goods_count'] : 0;
|
||||
$sc_money = isset($item['sc_money']) ? $item['sc_money'] : 0;
|
||||
$goods_count = isset($item['goods_count']) ? $item['goods_count'] : 0;
|
||||
$totalValue += $sc_money * $goods_count;
|
||||
}
|
||||
?>
|
||||
<table class="layui-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>奖品ID</th>
|
||||
<th>奖品名称</th>
|
||||
<th>奖品图片</th>
|
||||
<th>出货数量</th>
|
||||
<th>奖品单价</th>
|
||||
<th>兑换金额</th>
|
||||
<th>出货金额</th>
|
||||
<th>理论概率</th>
|
||||
<th>实际概率</th>
|
||||
<th>概率偏差</th>
|
||||
<th>总价值</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{volist name="list" id="vo"}
|
||||
<tr>
|
||||
<td>{$vo.goodslist_id}</td>
|
||||
<td>{$vo.title}</td>
|
||||
<td>
|
||||
<img src="{$vo.imgurl}" style="height:50px;" onerror="this.src='/static/admin/images/nopic.jpg'">
|
||||
</td>
|
||||
<td>
|
||||
<span class="layui-badge layui-bg-blue">{$vo.goods_count}</span>
|
||||
</td>
|
||||
<td>¥ {$vo.price|default="0"}</td>
|
||||
<td>¥ {$vo.money|default="0"}</td>
|
||||
<td>¥ {$vo.sc_money|default="0"}</td>
|
||||
<td>
|
||||
<span class="layui-badge layui-bg-green">{$vo.real_pro|default="0"}%</span>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
$actual_percent = 0;
|
||||
if(!empty($totalCount) && $totalCount > 0) {
|
||||
$goods_count = isset($vo['goods_count']) ? $vo['goods_count'] : 0;
|
||||
$actual_percent = round(($goods_count / $totalCount) * 100, 2);
|
||||
}
|
||||
?>
|
||||
<span class="layui-badge layui-bg-orange">{$actual_percent}%</span>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
$real_pro = isset($vo['real_pro']) ? $vo['real_pro'] : 0;
|
||||
$diff = round($actual_percent - $real_pro, 2);
|
||||
$color = $diff >= 0 ? '#5FB878' : '#FF5722';
|
||||
$sign = $diff > 0 ? '+' : '';
|
||||
?>
|
||||
<span style="color: <?php echo $color; ?>; font-weight: bold;"><?php echo $sign.$diff; ?>%</span>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
$sc_money = isset($vo['sc_money']) ? $vo['sc_money'] : 0;
|
||||
$goods_count = isset($vo['goods_count']) ? $vo['goods_count'] : 0;
|
||||
$total_value = $sc_money * $goods_count;
|
||||
?>
|
||||
¥ <?php echo round($total_value, 2); ?>
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
{if condition="empty($list)"}
|
||||
<tr>
|
||||
<td colspan="9" style="text-align:center;">暂时没有数据!</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- 统计摘要 -->
|
||||
{if condition="!empty($list)"}
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">统计摘要</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-row layui-col-space15">
|
||||
<div class="layui-col-md6">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">总出货数量</div>
|
||||
<div class="layui-card-body" style="font-size: 24px; color: #01AAED;">
|
||||
{$totalCount}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md6">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">总出货价值</div>
|
||||
<div class="layui-card-body" style="font-size: 24px; color: #FF5722;">
|
||||
¥ {$totalValue|round=2}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if($totalCount > 0): ?>
|
||||
<div class="layui-row layui-col-space15" style="margin-top: 15px;">
|
||||
<div class="layui-col-md6">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">平均每次出货价值</div>
|
||||
<div class="layui-card-body" style="font-size: 24px; color: #01AAED;">
|
||||
¥ <?php echo round($totalValue / $totalCount, 2); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md6">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">数据分析</div>
|
||||
<div class="layui-card-body">
|
||||
<?php
|
||||
// 寻找实际概率最高的奖品
|
||||
$maxPercent = 0;
|
||||
$maxItem = null;
|
||||
foreach($list as $item) {
|
||||
$goods_count = isset($item['goods_count']) ? $item['goods_count'] : 0;
|
||||
$percent = round(($goods_count / $totalCount) * 100, 2);
|
||||
if($percent > $maxPercent) {
|
||||
$maxPercent = $percent;
|
||||
$maxItem = $item;
|
||||
}
|
||||
}
|
||||
|
||||
if($maxItem) {
|
||||
echo "<p>出货概率最高的奖品: <strong>".$maxItem['title']."</strong> (".$maxPercent."%)</p>";
|
||||
$real_pro = isset($maxItem['real_pro']) ? $maxItem['real_pro'] : 0;
|
||||
$diff = round($maxPercent - $real_pro, 2);
|
||||
$diffText = $diff >= 0 ? "高于" : "低于";
|
||||
$absDiff = abs($diff);
|
||||
$diffColor = $diff >= 0 ? "#5FB878" : "#FF5722";
|
||||
?>
|
||||
<p>与理论概率相比: <span style="color: <?php echo $diffColor; ?>"><?php echo $diffText; ?>理论值 <?php echo $absDiff; ?>%</span></p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{include file="Public:footer"/}
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -147,10 +147,12 @@
|
|||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<button class="layui-btn layui-btn-xs" onclick="viewOrders({$vo.id})">支付订单</button>
|
||||
<button class="layui-btn layui-btn-danger layui-btn-xs" onclick="viewProductsOverview({$vo.id})">出货概览</button>
|
||||
<!-- <button class="layui-btn layui-btn-xs" onclick="viewOrders({$vo.id})">支付订单</button>
|
||||
<button class="layui-btn layui-btn-normal layui-btn-xs" onclick="viewOrderLists({$vo.id})">出货明细</button>
|
||||
|
||||
<button class="layui-btn layui-btn-warm layui-btn-xs" onclick="viewExchangeList({$vo.id})">兑换明细</button>
|
||||
<button class="layui-btn layui-btn-primary layui-btn-xs" onclick="viewShipmentList({$vo.id})">发货明细</button>
|
||||
<button class="layui-btn layui-btn-primary layui-btn-xs" onclick="viewShipmentList({$vo.id})">发货明细</button> -->
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
|
|
@ -273,6 +275,19 @@
|
|||
content: url
|
||||
});
|
||||
}
|
||||
|
||||
// 查看出货概览
|
||||
function viewProductsOverview(goodsId) {
|
||||
var url = "{:url('/admin/statistics_productsOverview')}?goods_id=" + goodsId;
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '出货概览',
|
||||
shadeClose: false,
|
||||
shade: 0.3,
|
||||
area: ['90%', '90%'],
|
||||
content: url
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -94,6 +94,7 @@
|
|||
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="ipDetail">查看ip登录列表</a>
|
||||
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="viewBox">查看盒柜</a>
|
||||
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="viewOrder">查看订单</a>
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="bindMobile">绑定手机号</a>
|
||||
{{# if(d.ip_adcode == 1){ }}
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="ipConvert">ip转换</a>
|
||||
{{# } }}
|
||||
|
|
@ -258,6 +259,9 @@
|
|||
, area: ['600px', '400px']
|
||||
});
|
||||
break;
|
||||
case 'bindMobile':
|
||||
bindMobile(data.id, data.nickname);
|
||||
break;
|
||||
case 'ban':
|
||||
userStatusChange(data.id, 2, data.nickname, '封号');
|
||||
break;
|
||||
|
|
@ -535,6 +539,40 @@
|
|||
layer.close(index);
|
||||
});
|
||||
}
|
||||
|
||||
// 绑定手机号
|
||||
function bindMobile(id, username) {
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '为 ' + username + ' 绑定手机号',
|
||||
content: '<div style="padding: 20px;"><div class="layui-form-item">' +
|
||||
'<label class="layui-form-label">手机号</label>' +
|
||||
'<div class="layui-input-block">' +
|
||||
'<input type="text" id="bind_mobile" placeholder="请输入手机号" autocomplete="off" class="layui-input">' +
|
||||
'</div></div></div>',
|
||||
area: ['400px', '200px'],
|
||||
btn: ['确定', '取消'],
|
||||
yes: function(index) {
|
||||
var mobile = $('#bind_mobile').val();
|
||||
if(!mobile || !/^1\d{10}$/.test(mobile)) {
|
||||
layer.msg('请输入正确的手机号码', {icon: 2});
|
||||
return;
|
||||
}
|
||||
$.post('{:url("/admin/bindUserMobile")}', {
|
||||
id: id,
|
||||
mobile: mobile
|
||||
}, function(res) {
|
||||
if(res.status === 1) {
|
||||
layer.msg(res.msg, {icon: 1});
|
||||
table.reload('LAY-user-table');
|
||||
layer.close(index);
|
||||
} else {
|
||||
layer.msg(res.msg, {icon: 2});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -99,12 +99,13 @@ class Goods extends Base
|
|||
//充值金额
|
||||
$whe[] = ['unlock_amount', '=', 0];
|
||||
} else {
|
||||
$order_money = Order::where('status', '=', 1)->where('user_id', '=', $user_id)->sum('price');
|
||||
$userInfo = User::where('id', '=', $user_id)->field('istest')->find();
|
||||
if ($userInfo && $userInfo['istest'] > 0) {
|
||||
//推广账号,门槛计算是全部的
|
||||
$order_money = Order::where('status', '=', 1)->where('user_id', '=', $user_id)->sum('order_zhe_total');
|
||||
}
|
||||
// $order_money = Order::where('status', '=', 1)->where('user_id', '=', $user_id)->sum('price');
|
||||
$order_money = Order::where('status', '=', 1)->where('user_id', '=', $user_id)->sum('order_zhe_total');
|
||||
// $userInfo = User::where('id', '=', $user_id)->field('istest')->find();
|
||||
// if ($userInfo && $userInfo['istest'] > 0) {
|
||||
// //推广账号,门槛计算是全部的
|
||||
// $order_money = Order::where('status', '=', 1)->where('user_id', '=', $user_id)->sum('order_zhe_total');
|
||||
// }
|
||||
$whe[] = ['unlock_amount', '<=', $order_money];
|
||||
}
|
||||
//将goods_type表中的所有数据查询出来,查询字段,value,corner_text,将数组转换为map
|
||||
|
|
@ -745,6 +746,9 @@ class Goods extends Base
|
|||
if (RegInt($num)) {
|
||||
return $this->renderError("箱号选择错误");
|
||||
}
|
||||
if ($goods['type'] == 10) {
|
||||
return $this->renderError("商城未开放");
|
||||
}
|
||||
|
||||
// 使用PaymentCalculator验证抽奖限制(限购、消费门槛等)
|
||||
$paymentCalculator = new \app\common\service\PaymentCalculator();
|
||||
|
|
|
|||
|
|
@ -213,9 +213,7 @@ class Index extends Base
|
|||
$user_base = $wxServer->generateUrlLinks($userId);
|
||||
$autoload = new \app\common\server\autoload();
|
||||
$currentDir = getcwd();
|
||||
// $absolutePath = $currentDir . '/public/img_poster.jpg';
|
||||
// ///www/wwwroot/testbaji.onelight.vip/app/public/img_poster.jpg
|
||||
// //www/wwwroot/testbaji.onelight.vip/public/public/img_poster.jpg
|
||||
|
||||
$imageData = $autoload->generatePosterWithQR($currentDir . '/img_poster.jpg', $user_base);
|
||||
if ($imageData) {
|
||||
header('Content-Type: image/png');
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class Infinite extends Base
|
|||
{
|
||||
$user_id = $this->getUserId();
|
||||
$goods_id = request()->param('goods_id/d', 0);
|
||||
$goods = Goodsmodel::field('id,title,imgurl_detail,price,stock,sale_stock,lock_is,type,status,addtime,rage_is,rage,item_card_id,lingzhu_is,is_shou_zhe,daily_xiangou,quanju_xiangou')
|
||||
$goods = Goodsmodel::field('id,title,imgurl_detail,price,stock,sale_stock,lock_is,type,status,addtime,rage_is,rage,item_card_id,lingzhu_is,lingzhu_shang_id,is_shou_zhe,daily_xiangou,quanju_xiangou')
|
||||
->where(['id' => $goods_id])
|
||||
->find();
|
||||
if (!$goods) {
|
||||
|
|
@ -109,6 +109,15 @@ class Infinite extends Base
|
|||
$value['shang_title'] = $value['shang_info']['title'];
|
||||
$value['shang_imgurl'] = $value['shang_info']['imgurl'];
|
||||
$value['shang_color'] = $value['shang_info']['color'];
|
||||
$value['lingzhu_shang_id'] = 0;
|
||||
if ($goods['lingzhu_is'] == 1) {
|
||||
if ($value['shang_id'] == $goods['lingzhu_shang_id']) {
|
||||
$value['lingzhu_shang_id'] = 1;
|
||||
foreach ($value['goods_list'] as &$value1) {
|
||||
$value1['is_lingzhu'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($value['shang_info']);
|
||||
}
|
||||
$goods_list = GoodsList::field('id,goods_id,shang_id,title,imgurl,price,real_pro,sc_money,goods_type,sale_time,doubling')
|
||||
|
|
@ -313,7 +322,7 @@ class Infinite extends Base
|
|||
if ($shang_id) {
|
||||
$where2[] = ['shang_id', '=', $shang_id];
|
||||
}
|
||||
$data = OrderList::field('user_id,goodslist_title,goodslist_imgurl,shang_id,addtime,luck_no')
|
||||
$data = OrderList::field('user_id,goodslist_title,goodslist_imgurl,shang_id,addtime,luck_no,doubling,is_lingzhu')
|
||||
->append(['shang_title', 'user_info', 'shang_color'])
|
||||
->where($where2)
|
||||
->where('source', '=', 1)
|
||||
|
|
@ -770,7 +779,7 @@ class Infinite extends Base
|
|||
return $this->renderError("支付异常,请刷新重试");
|
||||
}
|
||||
#普通赏
|
||||
$data = OrderList::field('id,user_id,shang_id,goodslist_id,goodslist_title,goodslist_imgurl,goodslist_money,doubling')
|
||||
$data = OrderList::field('id,user_id,shang_id,goodslist_id,goodslist_title,goodslist_imgurl,goodslist_money,doubling,is_lingzhu')
|
||||
->append(['shang_title'])
|
||||
->where('user_id', '=', $user['id'])
|
||||
->where('order_id', '=', $order_info['id'])
|
||||
|
|
|
|||
|
|
@ -1204,8 +1204,8 @@ class Notify extends Base
|
|||
->value('luck_no');
|
||||
$luck_no++;
|
||||
$doubling = $prize_info['doubling'];
|
||||
if(!$doubling){
|
||||
$doubling=0;
|
||||
if (!$doubling) {
|
||||
$doubling = 0;
|
||||
}
|
||||
#新增记录
|
||||
$save_prize_info = [
|
||||
|
|
@ -1336,6 +1336,16 @@ class Notify extends Base
|
|||
];
|
||||
}
|
||||
$multiple = ConfigHelper::getInfiniteMultiple();
|
||||
$lingzhu_shang_id = 0;
|
||||
$infinite_goods = Goods::getInfo(['id' => $goods_id], 'type,lingzhu_is,lingzhu_fan,lingzhu_shang_id,king_user_id');
|
||||
if ($infinite_goods != null && $infinite_goods['type'] == 8 && $infinite_goods['lingzhu_is'] == 1) {
|
||||
// $infinite_goods['lingzhu_shang_id']
|
||||
$lingzhu_shang_id = $infinite_goods['lingzhu_shang_id'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
for ($i = 0; $i < $prize_num; $i++) {
|
||||
// 生成随机数 (保持与原始方法相同的精度:100000)
|
||||
|
||||
|
|
@ -1362,9 +1372,18 @@ class Notify extends Base
|
|||
->order('id desc')
|
||||
->value('luck_no');
|
||||
$luck_no++;
|
||||
$doubling =$prize_info['doubling'];
|
||||
if(!$doubling){
|
||||
$doubling=0;
|
||||
$doubling = $prize_info['doubling'];
|
||||
if (!$doubling) {
|
||||
$doubling = 0;
|
||||
}
|
||||
$lingzhu = $prize_info['is_lingzhu'];
|
||||
if ($infinite_goods['type'] == 8) {
|
||||
//如果是领主赏,则去查询一下。是否为领主
|
||||
if ($lingzhu_shang_id > 0 && $lingzhu == 0) {
|
||||
if ($lingzhu_shang_id == $prize_info['shang_id']) {
|
||||
$lingzhu = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#新增记录
|
||||
$save_prize_info = [
|
||||
|
|
@ -1387,6 +1406,7 @@ class Notify extends Base
|
|||
'order_type' => $order_type,
|
||||
'luck_no' => $luck_no,
|
||||
'parent_goods_list_id' => $prize_info['goods_list_id'],
|
||||
'is_lingzhu' => $lingzhu,
|
||||
];
|
||||
|
||||
#入库===
|
||||
|
|
@ -1550,9 +1570,9 @@ class Notify extends Base
|
|||
if ($infinite_goods['lingzhu_is'] == 1) {
|
||||
$whe2 = [];
|
||||
$whe2[] = ['order_id', '=', $order_id];
|
||||
$order_list = OrderList::getAllList($whe2, 'id,shang_id,user_id,goods_id', 'id asc');
|
||||
$order_list = OrderList::getAllList($whe2, 'id,shang_id,user_id,goods_id,is_lingzhu', 'id asc');
|
||||
foreach ($order_list as $k => $v) {
|
||||
if ($v['shang_id'] == $infinite_goods['lingzhu_shang_id']) {
|
||||
if ($v['shang_id'] == $infinite_goods['lingzhu_shang_id'] || $v['is_lingzhu'] == 1) {
|
||||
// 查找当前池子是否有领主
|
||||
if ($infinite_goods['king_user_id'] != 0) {
|
||||
Db::name('goods_king_rank')->where([['user_id', '=', $infinite_goods['king_user_id']], ['goods_id', '=', $v['goods_id']]])->order('id', 'desc')->limit(1)->update(['end_time' => time()]);
|
||||
|
|
@ -1584,7 +1604,7 @@ class Notify extends Base
|
|||
Db::name('goods_king_rank')->where([['user_id', '=', $infinite_goods['king_user_id']], ['goods_id', '=', $v['goods_id']]])->order('id', 'desc')->limit(1)->inc('money', floatval($king_money))->update();
|
||||
|
||||
// User::changeIntegral($infinite_goods['king_user_id'], $king_money, 4, '领主收益');
|
||||
User::changeMoney2($infinite_goods['king_user_id'], $king_money, 4, '领主收益');
|
||||
User::changeIntegral($infinite_goods['king_user_id'], $king_money, 4, '领主收益');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use app\common\model\ProfitPay;
|
|||
use app\common\model\ProfitScore;
|
||||
use app\common\model\QyLevel;
|
||||
use app\common\model\User as Usermodel;
|
||||
use app\common\model\UserAccount;
|
||||
use app\common\model\UserCoupon;
|
||||
use app\common\model\UserRecharge;
|
||||
use app\common\model\UserVip;
|
||||
|
|
@ -20,7 +21,6 @@ use PhpOffice\PhpSpreadsheet\Chart\Legend;
|
|||
use think\facade\Db;
|
||||
use think\Request;
|
||||
use app\common\server\Qcode;
|
||||
|
||||
use Qcloud\Cos\Client;
|
||||
class User extends Base
|
||||
{
|
||||
|
|
@ -1080,4 +1080,159 @@ class User extends Base
|
|||
return $this->renderSuccess('请求成功', $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户token
|
||||
*/
|
||||
public function getUserAccount()
|
||||
{
|
||||
$user_id = request()->param('user_id/d', 0);
|
||||
$user_account = UserAccount::where('user_id', '=', $user_id)->find();
|
||||
if ($user_account) {
|
||||
if (!$user_account['account_token'] || $user_account['account_token'] == '') {
|
||||
#token时间戳
|
||||
$time = time();
|
||||
#token字符串
|
||||
$token_num = getRandStr(10);
|
||||
#加密token
|
||||
$account_token = user_md5((string)$user_id . $token_num . (string)$time);
|
||||
|
||||
//修改UserAccount 表中的
|
||||
$res[] = UserAccount::where(['user_id' => $user_id])->update([
|
||||
'account_token' => $account_token,
|
||||
'token_num' => $token_num,
|
||||
'token_time' => $time,
|
||||
'last_login_time' => $time,
|
||||
]);
|
||||
$user_account = UserAccount::where('user_id', '=', $user_id)->find();
|
||||
}
|
||||
return $this->renderSuccess("", $user_account);
|
||||
}
|
||||
|
||||
// 检查用户是否存在
|
||||
$user = Usermodel::where('id', '=', $user_id)->find();
|
||||
if ($user) {
|
||||
// 创建新的用户账号记录
|
||||
$time = time();
|
||||
$token_num = getRandStr(10);
|
||||
$account_token = user_md5((string)$user_id . $token_num . (string)$time);
|
||||
|
||||
$result = UserAccount::insert([
|
||||
'user_id' => $user_id,
|
||||
'account_token' => $account_token,
|
||||
'token_num' => $token_num,
|
||||
'token_time' => $time,
|
||||
'last_login_time' => $time,
|
||||
'addtime' => $time,
|
||||
]);
|
||||
|
||||
if ($result) {
|
||||
$user_account = UserAccount::where('user_id', '=', $user_id)->find();
|
||||
return $this->renderSuccess("创建账号成功", $user_account);
|
||||
} else {
|
||||
return $this->renderError("创建账号失败");
|
||||
}
|
||||
}
|
||||
|
||||
return $this->renderError("用户id错误");
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建测试用户
|
||||
*/
|
||||
public function createUser()
|
||||
{
|
||||
// 查询以187611270开头的最新手机号
|
||||
$lastUser = Usermodel::where('mobile', 'like', '187611270%')
|
||||
->order('id', 'desc')
|
||||
->find();
|
||||
|
||||
if (!$lastUser) {
|
||||
// 如果不存在,从18761127000开始
|
||||
$newMobile = '18761127000';
|
||||
} else {
|
||||
// 获取最后两位并加1
|
||||
$lastTwoDigits = substr($lastUser['mobile'], -2);
|
||||
$newLastTwoDigits = intval($lastTwoDigits) + 1;
|
||||
|
||||
// 确保两位数格式
|
||||
$newLastTwoDigits = str_pad((string)$newLastTwoDigits, 2, '0', STR_PAD_LEFT);
|
||||
$newMobile = '187611270' . $newLastTwoDigits;
|
||||
}
|
||||
|
||||
// 生成随机数作为昵称的一部分
|
||||
$randomNum = mt_rand(1000, 9999);
|
||||
$nickname = '微信用户' . $randomNum;
|
||||
|
||||
// 生成随机openid
|
||||
$openid = 'oVQcD' . getRandStr(28);
|
||||
|
||||
// 头像url
|
||||
$headimg = 'https://image.zfunbox.cn/storage/users/icon/default/1613.png';
|
||||
|
||||
// 当前时间戳
|
||||
$time = time();
|
||||
|
||||
// 随机生成uid
|
||||
$uid = mt_rand(100000, 999999);
|
||||
|
||||
// 开始事务
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 插入用户表
|
||||
$userId = Usermodel::insertGetId([
|
||||
'openid' => $openid,
|
||||
'mobile' => $newMobile,
|
||||
'nickname' => $nickname,
|
||||
'headimg' => $headimg,
|
||||
'pid' => 0,
|
||||
'money' => 50000000,
|
||||
'money2' => 0,
|
||||
'integral' => 0,
|
||||
'score' => 0,
|
||||
'ou_qi' => 0,
|
||||
'ou_qi_level' => 0,
|
||||
'vip' => 1,
|
||||
'status' => 1,
|
||||
'addtime' => $time,
|
||||
'update_time' => $time,
|
||||
'last_login_time' => 0,
|
||||
'draw_num' => 0,
|
||||
'is_use_coupon' => 1,
|
||||
'mb_number' => 0,
|
||||
'click_id' => 0,
|
||||
'istest' => 0,
|
||||
'uid' => $uid
|
||||
]);
|
||||
|
||||
// 生成token
|
||||
$token_num = getRandStr(10);
|
||||
$account_token = user_md5((string)$userId . $token_num . (string)$time);
|
||||
|
||||
// 插入用户账号表
|
||||
UserAccount::insert([
|
||||
'user_id' => $userId,
|
||||
'account_token' => $account_token,
|
||||
'token_num' => $token_num,
|
||||
'token_time' => $time,
|
||||
'last_login_time' => $time,
|
||||
'last_login_ip'=>'2085608754'
|
||||
]);
|
||||
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
|
||||
return $this->renderSuccess('创建用户成功', [
|
||||
'user_id' => $userId,
|
||||
'mobile' => $newMobile,
|
||||
'nickname' => $nickname,
|
||||
'headimg' => $headimg
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return $this->renderError('创建用户失败:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -205,4 +205,8 @@ Route::any('getRankList', 'Index/getRankList');
|
|||
#Order.php订单管理
|
||||
#============================
|
||||
Route::any('order_list', 'Order/getOrderList');
|
||||
Route::any('order_detail', 'Order/getOrderDetail');
|
||||
Route::any('order_detail', 'Order/getOrderDetail');
|
||||
|
||||
// getUserAccount
|
||||
Route::any('getUserAccount', 'User/getUserAccount');
|
||||
Route::any('createUser', 'User/createUser');
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class GoodsList extends Base
|
|||
|
||||
public function getGoodsListAttr($value, $data)
|
||||
{
|
||||
$data = self::field('id,title,imgurl,price,real_pro,goods_type,doubling')
|
||||
$data = self::field('id,title,imgurl,price,real_pro,goods_type,doubling,is_lingzhu')
|
||||
->withAttr('imgurl', function ($value, $data) {
|
||||
return imageUrl($value);
|
||||
})
|
||||
|
|
|
|||
|
|
@ -283,20 +283,20 @@ class PaymentCalculator
|
|||
}
|
||||
} else {
|
||||
// 常规消费验证
|
||||
$user_price = Order::where('user_id', '=', $user_id)->where('status', '=', 1)->sum('price');
|
||||
// $user_price = Order::where('user_id', '=', $user_id)->where('status', '=', 1)->sum('price');
|
||||
// $user_price = Order::where('user_id', '=', $user_id)->where('status', '=', 1)->sum('order_zhe_total');
|
||||
// if ($user_price < $choujiang_xianzhi) {
|
||||
// if ($user['istest'] > 0) {
|
||||
// $user_price = Order::where('user_id', '=', $user_id)->where('status', '=', 1)->sum('order_zhe_total');
|
||||
// }
|
||||
|
||||
if ($user_price < $choujiang_xianzhi) {
|
||||
if ($user['istest'] > 0) {
|
||||
$user_price = Order::where('user_id', '=', $user_id)->where('status', '=', 1)->sum('order_zhe_total');
|
||||
}
|
||||
|
||||
if ($user_price < $choujiang_xianzhi) {
|
||||
return [
|
||||
'status' => 0,
|
||||
'msg' => "消费满" . $choujiang_xianzhi . "元可参与 已消费" . round($user_price, 2) . "元"
|
||||
];
|
||||
}
|
||||
}
|
||||
// if ($user_price < $choujiang_xianzhi) {
|
||||
// return [
|
||||
// 'status' => 0,
|
||||
// 'msg' => "消费满" . $choujiang_xianzhi . "元可参与 已消费" . round($user_price, 2) . "元"
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
BIN
public/ueditor/php/upload/image/20250413/1744546944888633.jpg
Normal file
BIN
public/ueditor/php/upload/image/20250413/1744546944888633.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 70 KiB |
Loading…
Reference in New Issue
Block a user