提交
This commit is contained in:
parent
b2a25c39f9
commit
219ecb0496
|
|
@ -46,6 +46,7 @@
|
|||
<tr>
|
||||
<th>奖品名称</th>
|
||||
<th>奖品图片</th>
|
||||
<th>商品详情图</th>
|
||||
<th>奖品售价</th>
|
||||
<th>奖品兑换价</th>
|
||||
{if $type eq 1 || $type eq 3 || $type eq 5 || $type eq 10 || $type eq 11|| $type eq 15}
|
||||
|
|
@ -70,6 +71,13 @@
|
|||
<td>{$vo['title']}</td>
|
||||
<td><img src="{PHP} echo imageUrl($vo['imgurl']){/php}" style="width:60px;height:60px;">
|
||||
</td>
|
||||
<td>
|
||||
{if condition="!empty($vo['imgurl_detail'])"}
|
||||
<img src="{PHP} echo imageUrl($vo['imgurl_detail']){/php}" style="width:60px;height:60px;">
|
||||
{else/}
|
||||
<span>无</span>
|
||||
{/if}
|
||||
</td>
|
||||
<td>{$vo['price']}</td>
|
||||
<td>{$vo['money']}</td>
|
||||
{if $type eq 1}
|
||||
|
|
|
|||
|
|
@ -126,6 +126,15 @@
|
|||
src="/static/image/upload.jpg">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">商品详情图</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="hidden" name="imgurl_detail" value=""
|
||||
placeholder="请上传商品详情图" autocomplete="off" class="layui-input">
|
||||
<img style="float:left;width:120px;" class="" id="imgurl_detail"
|
||||
src="/static/image/upload.jpg">
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="goods_id" value="{$goods_id}">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
|
|
@ -194,6 +203,27 @@
|
|||
}
|
||||
});
|
||||
|
||||
upload.render({
|
||||
accept: 'imgurl_detail'
|
||||
, elem: '#imgurl_detail' //绑定元素
|
||||
, url: '/admin/picture' //上传接口
|
||||
, done: function (res) {
|
||||
//上传完毕回调
|
||||
if (res.status == 1) { //成功
|
||||
layer.msg("上传成功", { icon: 1, time: 1000 }, function () {
|
||||
$("#imgurl_detail").attr("src", res.data.path); //单图
|
||||
$("input[name=imgurl_detail]").val(res.data.imgurl);
|
||||
});
|
||||
} else { //失败
|
||||
layer.msg(res.msg, { icon: 2, anim: 6, time: 1500 });
|
||||
}
|
||||
}
|
||||
, error: function () {
|
||||
//请求异常回调
|
||||
layer.msg('服务繁忙,请稍后再试', { icon: 2, anim: 6, time: 1500 });
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
async function check() {
|
||||
|
|
|
|||
|
|
@ -130,6 +130,15 @@
|
|||
src="{:imageUrl($goods.imgurl)}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">商品详情图</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="hidden" name="imgurl_detail" value="{$goods.imgurl_detail}"
|
||||
placeholder="请上传商品详情图" autocomplete="off" class="layui-input">
|
||||
<img style="float:left;width:120px;" class="" id="imgurl_detail"
|
||||
src="{if condition="$goods.imgurl_detail neq ''"}{:imageUrl($goods.imgurl_detail)}{else}/static/image/upload.jpg{/if}">
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="id" value="{$goods.id}">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
|
|
@ -198,6 +207,27 @@
|
|||
}
|
||||
});
|
||||
|
||||
upload.render({
|
||||
accept: 'imgurl_detail'
|
||||
, elem: '#imgurl_detail' //绑定元素
|
||||
, url: '/admin/picture' //上传接口
|
||||
, done: function (res) {
|
||||
//上传完毕回调
|
||||
if (res.status == 1) { //成功
|
||||
layer.msg("上传成功", { icon: 1, time: 1000 }, function () {
|
||||
$("#imgurl_detail").attr("src", res.data.path); //单图
|
||||
$("input[name=imgurl_detail]").val(res.data.imgurl);
|
||||
});
|
||||
} else { //失败
|
||||
layer.msg(res.msg, { icon: 2, anim: 6, time: 1500 });
|
||||
}
|
||||
}
|
||||
, error: function () {
|
||||
//请求异常回调
|
||||
layer.msg('服务繁忙,请稍后再试', { icon: 2, anim: 6, time: 1500 });
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
async function check() {
|
||||
|
|
|
|||
|
|
@ -225,7 +225,138 @@ class Goods extends Base
|
|||
return $this->renderSuccess('请求成功', $new_data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 福利屋详情
|
||||
* @param \think\Request $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function goods_fuliwu_detail(Request $request)
|
||||
{
|
||||
$goods_id = request()->param('goods_id/d', 0);
|
||||
$goods = GoodsModel::where(['id' => $goods_id])->find();
|
||||
if (!$goods) {
|
||||
return $this->renderError("盒子不存在");
|
||||
}
|
||||
if ($goods['status'] != 1 && $goods['status'] != 3) {
|
||||
return $this->renderError("盒子已下架");
|
||||
}
|
||||
|
||||
// 检查类型是否为福利屋
|
||||
if ($goods['type'] != 15) {
|
||||
return $this->renderError("该盒子不是福利屋类型");
|
||||
}
|
||||
|
||||
// 获取用户信息
|
||||
$user_id = $this->getUserId();
|
||||
// 检查用户是否可以查看该福利屋(解锁金额限制)
|
||||
if ($user_id > 0) {
|
||||
$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');
|
||||
}
|
||||
|
||||
if ($goods['unlock_amount'] > $order_money) {
|
||||
return $this->renderError("您需要充值满" . $goods['unlock_amount'] . "元才能查看此福利屋");
|
||||
}
|
||||
} else if ($goods['unlock_amount'] > 0) {
|
||||
return $this->renderError("您需要登录并充值满" . $goods['unlock_amount'] . "元才能查看此福利屋");
|
||||
}
|
||||
|
||||
// 获取福利屋详细信息
|
||||
$goods_detail = GoodsModel::field("id,title,imgurl,imgurl_detail,price,type,new_is,quanju_xiangou,choujiang_xianzhi,flw_start_time,flw_end_time,open_time,goods_describe,is_open,unlock_amount,sort")
|
||||
->where(['id' => $goods_id])
|
||||
->find();
|
||||
|
||||
// 处理图片地址和时间格式
|
||||
$goods_detail['imgurl'] = imageUrl($goods_detail['imgurl']);
|
||||
if (!empty($goods_detail['imgurl_detail'])) {
|
||||
$goods_detail['imgurl_detail'] = imageUrl($goods_detail['imgurl_detail']);
|
||||
}
|
||||
|
||||
// 获取福利屋中的奖品列表
|
||||
$goodslist = GoodsList::where('goods_id', '=', $goods_id)
|
||||
->where('num', '=', 0)
|
||||
->field('id,title,imgurl,imgurl_detail,stock,price,sc_money,shang_id,surplus_stock,sort')
|
||||
->order('sort asc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 处理奖品列表,添加图片地址
|
||||
foreach ($goodslist as &$item) {
|
||||
$item['imgurl'] = imageUrl($item['imgurl']);
|
||||
$item['imgurl_detail'] = imageUrl($item['imgurl_detail']);
|
||||
// 获取奖品类型信息
|
||||
$shang_info = Shang::field('title,color')->where(['id' => $item['shang_id']])->find();
|
||||
$item['shang_title'] = $shang_info ? $shang_info['title'] : '';
|
||||
$item['shang_color'] = $shang_info ? $shang_info['color'] : '';
|
||||
}
|
||||
|
||||
// 统计参与人数
|
||||
$join_count = OrderList::field('id')
|
||||
->where('goods_id', '=', $goods_id)
|
||||
->where('order_type', '=', $goods_detail['type'])
|
||||
->count();
|
||||
// 统计参与人数
|
||||
$user_count = OrderList::
|
||||
where('goods_id', '=', $goods_id)
|
||||
->where('user_id', '=', $user_id)
|
||||
->where('order_type', '=', $goods_detail['type'])
|
||||
->field('id')
|
||||
->count();
|
||||
//余额充值
|
||||
|
||||
// 获取用户在该福利屋活动期间的消费情况
|
||||
$consumptionData = $this->getUserConsumptionByTimeRange(
|
||||
$user_id,
|
||||
$goods_detail['flw_start_time'],
|
||||
$goods_detail['flw_end_time']
|
||||
);
|
||||
|
||||
$goods_detail['flw_start_time'] = date('Y-m-d H:i', $goods_detail['flw_start_time']);
|
||||
$goods_detail['flw_end_time'] = date('Y-m-d H:i', $goods_detail['flw_end_time']);
|
||||
$goods_detail['open_time'] = date('Y-m-d H:i', $goods_detail['open_time']);
|
||||
|
||||
|
||||
// 组装返回数据
|
||||
$data = [
|
||||
'goods' => $goods_detail,
|
||||
'goodslist' => $goodslist,
|
||||
'join_count' => $join_count,
|
||||
'current_time' => date('Y-m-d H:i:s'),
|
||||
'user_status' => $user_count > 0 ? true : false,
|
||||
'user_consumption' => $consumptionData
|
||||
];
|
||||
|
||||
// 判断福利屋状态
|
||||
$now = time();
|
||||
$start_time = strtotime($goods_detail['flw_start_time']);
|
||||
$end_time = strtotime($goods_detail['flw_end_time']);
|
||||
$open_time = strtotime($goods_detail['open_time']);
|
||||
|
||||
if ($now < $start_time) {
|
||||
$data['status'] = 'waiting'; // 等待开始
|
||||
$data['status_text'] = '即将开始';
|
||||
} else if ($now >= $start_time && $now < $end_time) {
|
||||
$data['status'] = 'ongoing'; // 进行中
|
||||
$data['status_text'] = '进行中';
|
||||
} else if ($now >= $end_time && $now < $open_time) {
|
||||
$data['status'] = 'ended'; // 已结束,等待开奖
|
||||
$data['status_text'] = '已结束,等待开奖';
|
||||
} else if ($now >= $open_time) {
|
||||
if ($goods_detail['is_open'] == 1) {
|
||||
$data['status'] = 'opened'; // 已开奖
|
||||
$data['status_text'] = '已开奖';
|
||||
} else {
|
||||
$data['status'] = 'to_open'; // 待开奖(超过开奖时间但未开奖)
|
||||
$data['status_text'] = '待开奖';
|
||||
}
|
||||
}
|
||||
|
||||
return $this->renderSuccess('请求成功', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品详情
|
||||
* @param $goods_id 盒子id
|
||||
|
|
@ -1498,5 +1629,37 @@ class Goods extends Base
|
|||
return $this->renderError('同步失败: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户在指定时间范围内的消费情况
|
||||
*
|
||||
* @param int $userId 用户ID
|
||||
* @param int $startTime 开始时间戳
|
||||
* @param int $endTime 结束时间戳
|
||||
* @return array 包含余额消费和微信支付消费的数组
|
||||
*/
|
||||
public function getUserConsumptionByTimeRange($userId, $startTime, $endTime)
|
||||
{
|
||||
// 查询用户在指定时间范围内的订单消费情况
|
||||
$consumptionData = Order::where('user_id', '=', $userId)
|
||||
->where(function ($query) {
|
||||
$query->where('price', '>', 0)
|
||||
->whereOr('use_money', '>', 0);
|
||||
})
|
||||
->where('status', '=', 1)
|
||||
->where('pay_time', '>=', $startTime)
|
||||
->where('pay_time', '<=', $endTime)
|
||||
->field('sum(use_money) as balance_consumed, sum(price) as wechat_consumed')
|
||||
->find();
|
||||
|
||||
// 处理查询结果
|
||||
$result = [
|
||||
'money_consumed' => round(floatval($consumptionData['balance_consumed'] ?? 0), 2), // 余额消费
|
||||
'wechat_consumed' => round(floatval($consumptionData['wechat_consumed'] ?? 0), 2), // 微信支付消费
|
||||
'total_consumed' => round(floatval(($consumptionData['balance_consumed'] ?? 0) + ($consumptionData['wechat_consumed'] ?? 0)), 2) // 总消费
|
||||
];
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ Route::any('quan_yi_ling', 'QuanYi/quan_yi_ling');
|
|||
#============================
|
||||
Route::any('goods', 'Goods/goods');
|
||||
Route::any('goods_fuliwu', 'Goods/goods_fuliwu');
|
||||
Route::any('goods_fuliwu_detail', 'Goods/goods_fuliwu_detail');
|
||||
|
||||
Route::any('goodsdetail', 'Goods/goodsdetail');
|
||||
Route::any('goodslist_count', 'Goods/goodslist_count');
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user