微信小程序优化

This commit is contained in:
lifenlong
2021-06-01 15:51:19 +08:00
parent 7fa0fb75b1
commit 0324951d9a
14 changed files with 81 additions and 63 deletions

View File

@@ -0,0 +1,27 @@
package cn.lili.modules.broadcast.entity.enums;
/**
* 直播间状态
* @author Bulbasaur
* @date: 2021/5/31 10:32 上午
*
*/
public enum StudioStatusEnum {
NEW("新建"), START("开始"), END("结束");
private final String clientName;
StudioStatusEnum(String des) {
this.clientName = des;
}
public String clientName() {
return this.clientName;
}
public String value() {
return this.name();
}
}

View File

@@ -8,15 +8,15 @@ import lombok.Data;
import java.util.List;
/**
* @author liushuai(liushuai711 @ gmail.com)
* @version v4.1
* @Description:
* @since 2021/5/17 3:04 下
* 直播间VO
*
* @author Bulbasaur
* @date: 2021/5/31 11:58 上
*/
@Data
public class StudioVO extends Studio {
@ApiModelProperty(value = "直播间商品列表")
private List<Commodity> CommodityList;
private List<Commodity> commodityList;
}

View File

@@ -26,8 +26,8 @@ public interface CommodityMapper extends BaseMapper<Commodity> {
@Select("SELECT * FROM li_commodity c INNER JOIN li_studio_commodity sc ON sc.goods_id = c.live_goods_id WHERE sc.room_id =#{roomId}")
List<Commodity> getCommodityByRoomId(Integer roomId);
@Select("SELECT name,goods_image FROM li_commodity c INNER JOIN li_studio_commodity sc ON sc.goods_id = c.live_goods_id WHERE sc.room_id =#{roomId}")
List<SimpleCommodity> getSimpleCommodityByRoomId(Integer roomId);
@Select("SELECT goods_image FROM li_commodity c INNER JOIN li_studio_commodity sc ON sc.goods_id = c.live_goods_id WHERE sc.room_id =#{roomId}")
List<String> getSimpleCommodityByRoomId(Integer roomId);
@Select("SELECT c.*,gs.quantity,s.store_name FROM li_commodity c INNER JOIN li_goods_sku gs ON c.sku_id = gs.id INNER JOIN li_store s ON s.id=c.store_id ${ew.customSqlSegment}")
IPage<CommodityVO> commodityVOList(IPage<CommodityVO> page, @Param(Constants.WRAPPER) Wrapper<CommodityVO> queryWrapper);

View File

@@ -78,7 +78,7 @@ public class CommodityServiceImpl extends ServiceImpl<CommodityMapper, Commodity
public boolean deleteCommodity(String goodsId) {
JSONObject json = wechatLivePlayerUtil.deleteGoods(goodsId);
if (json.getStr("errcode").equals("0")) {
return this.remove(this.lambdaQuery().eq(Commodity::getLiveGoodsId, goodsId));
return this.remove(new LambdaQueryWrapper<Commodity>().eq(Commodity::getLiveGoodsId, goodsId));
}
return false;
}
@@ -106,6 +106,7 @@ public class CommodityServiceImpl extends ServiceImpl<CommodityMapper, Commodity
return this.baseMapper.commodityVOList(PageUtil.initPage(pageVO),
new QueryWrapper<CommodityVO>().like(name != null, "c.name", name)
.eq(auditStatus != null, "c.audit_status", auditStatus)
.eq(UserContext.getCurrentUser().getRole().equals(UserEnums.STORE), "c.store_id", UserContext.getCurrentUser().getStoreId()));
.eq(UserContext.getCurrentUser().getRole().equals(UserEnums.STORE), "c.store_id", UserContext.getCurrentUser().getStoreId())
.orderByDesc("create_time"));
}
}

View File

@@ -7,6 +7,7 @@ import cn.lili.common.security.context.UserContext;
import cn.lili.common.utils.BeanUtil;
import cn.lili.common.utils.PageUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.broadcast.entity.StudioStatusEnum;
import cn.lili.modules.broadcast.entity.dos.Studio;
import cn.lili.modules.broadcast.entity.dos.StudioCommodity;
import cn.lili.modules.broadcast.entity.vos.StudioVO;
@@ -49,6 +50,7 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> impleme
studio.setRoomId(Integer.parseInt(roomMap.get("roomId")));
studio.setQrCodeUrl(roomMap.get("qrcodeUrl"));
studio.setStoreId(UserContext.getCurrentUser().getStoreId());
studio.setStatus(StudioStatusEnum.NEW.name());
return this.save(studio);
} catch (Exception e) {
e.printStackTrace();
@@ -98,7 +100,6 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> impleme
//设置直播间默认的商品(前台展示)只展示两个
if (studio.getRoomGoodsNum() < 3) {
studio.setRoomGoodsList(JSONUtil.toJsonStr(commodityMapper.getSimpleCommodityByRoomId(roomId)));
;
}
return this.updateById(studio);
}
@@ -116,7 +117,6 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> impleme
//设置直播间默认的商品(前台展示)只展示两个
if (studio.getRoomGoodsNum() < 3) {
studio.setRoomGoodsList(JSONUtil.toJsonStr(commodityMapper.getSimpleCommodityByRoomId(roomId)));
;
}
return this.updateById(studio);
}
@@ -127,7 +127,8 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> impleme
public IPage<Studio> studioList(PageVO pageVO, Integer recommend, String status) {
return this.page(PageUtil.initPage(pageVO), new QueryWrapper<Studio>()
.eq(recommend != null, "recommend", true)
.eq(status!=null,"status",status));
.eq(status!=null,"status",status)
.orderByDesc("create_time"));
}

View File

@@ -196,7 +196,7 @@ public class WechatLivePlayerUtil {
String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/delete?access_token=" + token;
Map<String, Object> map = new HashMap<>();
map.put("goodsId", goodsId);
String content = HttpUtils.doPostWithJson(url, goodsId);
String content = HttpUtils.doPostWithJson(url, map);
JSONObject json = new JSONObject(content);
log.info("微信小程序删除直播商品结果:" + content);
return json;

View File

@@ -13,22 +13,8 @@ public enum OrderTypeEnum {
*/
NORMAL,
/**
* 赠品订单
*/
GIFT,
/**
* 虚拟订单
*/
VIRTUAL,
/**
* 拼团订单
*/
PINTUAN,
/**
* 积分订单
*/
POINT
VIRTUAL;
}

View File

@@ -201,7 +201,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
@OrderLogPoint(description = "'订单['+#orderSn+']取消,原因为:'+#reason", orderSn = "#orderSn")
public Order cancel(String orderSn, String reason) {
Order order = OperationalJudgment.judgment(this.getBySn(orderSn));
if (order.getOrderType().equals(OrderTypeEnum.PINTUAN.name()) && !order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name())) {
if (order.getOrderPromotionType().equals(OrderPromotionTypeEnum.PINTUAN.name()) && !order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name())) {
throw new ServiceException("未成团订单不可取消");
}
if (CharSequenceUtil.equalsAny(order.getOrderStatus(),
@@ -635,7 +635,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
//寻找拼团的所有订单
LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Order::getPromotionId, pintuanId)
.eq(Order::getOrderType, OrderTypeEnum.PINTUAN.name())
.eq(Order::getOrderPromotionType, OrderPromotionTypeEnum.PINTUAN.name())
.eq(Order::getPayStatus, PayStatusEnum.PAID.name());
// 拼团sn=开团订单sn 或者 参团订单的开团订单sn
queryWrapper.and(i -> i.eq(Order::getSn, parentOrderSn)
@@ -692,7 +692,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
BeanUtil.copyProperties(priceDetailDTO, order, "id");
order.setSn(SnowFlake.createStr("G"));
order.setTradeSn(tradeDTO.getSn());
order.setOrderType(OrderTypeEnum.GIFT.name());
order.setOrderType(OrderPromotionTypeEnum.GIFT.name());
order.setOrderStatus(OrderStatusEnum.UNPAID.name());
order.setPayStatus(PayStatusEnum.UNPAID.name());
order.setDeliverStatus(DeliverStatusEnum.UNDELIVERED.name());
@@ -772,7 +772,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
*/
private void checkOrder(Order order) {
//订单类型为拼团订单,检测购买数量是否超过了限购数量
if (OrderTypeEnum.PINTUAN.name().equals(order.getOrderType())) {
if (OrderPromotionTypeEnum.PINTUAN.name().equals(order.getOrderPromotionType())) {
Pintuan pintuan = pintuanService.getPintuanById(order.getPromotionId());
Integer limitNum = pintuan.getLimitNum();
if (limitNum != 0 && order.getGoodsNum() > limitNum) {

View File

@@ -17,7 +17,6 @@ import cn.lili.modules.member.entity.dos.Member;
import cn.lili.modules.member.service.MemberService;
import cn.lili.modules.order.order.entity.dos.Order;
import cn.lili.modules.order.order.entity.enums.OrderStatusEnum;
import cn.lili.modules.order.order.entity.enums.OrderTypeEnum;
import cn.lili.modules.order.order.entity.enums.PayStatusEnum;
import cn.lili.modules.order.order.service.OrderService;
import cn.lili.modules.promotion.entity.dos.Pintuan;
@@ -103,8 +102,10 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
return new ArrayList<>();
}
LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Order::getPromotionId, pintuanId).eq(Order::getOrderType, OrderTypeEnum.PINTUAN.name())
.eq(Order::getOrderStatus, OrderStatusEnum.PAID.name()).eq(Order::getParentOrderSn, "");
queryWrapper.eq(Order::getPromotionId, pintuanId)
.eq(Order::getOrderPromotionType, PromotionTypeEnum.PINTUAN.name())
.eq(Order::getOrderStatus, OrderStatusEnum.PAID.name())
.eq(Order::getParentOrderSn, "");
List<Order> orders = orderService.list(queryWrapper);
// 遍历订单状态为已支付,为团长的拼团订单
for (Order order : orders) {
@@ -266,7 +267,7 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
} else {
pintuan.setPromotionStatus(PromotionStatusEnum.END.name());
LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Order::getOrderType, OrderTypeEnum.PINTUAN.name());
queryWrapper.eq(Order::getOrderPromotionType, PromotionTypeEnum.PINTUAN.name());
queryWrapper.eq(Order::getPromotionId, pintuanId);
queryWrapper.nested(i -> i.eq(Order::getPayStatus, PayStatusEnum.PAID.name()).or().eq(Order::getOrderStatus, OrderStatusEnum.PAID.name()));
// 过滤父级拼团订单,根据父级拼团订单分组
@@ -323,7 +324,7 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
pintuanShareVO.setPintuanMemberVOS(new ArrayList<>());
LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<>();
// 查找团长订单和已和当前拼团订单拼团的订单
queryWrapper.eq(Order::getOrderType, OrderTypeEnum.PINTUAN.name())
queryWrapper.eq(Order::getOrderPromotionType, PromotionTypeEnum.PINTUAN.name())
.eq(Order::getPayStatus, OrderStatusEnum.PAID.name())
.and(i -> i.eq(Order::getParentOrderSn, parentOrderSn).or(j -> j.eq(Order::getSn, parentOrderSn)));
List<Order> orders = orderService.list(queryWrapper);
@@ -332,7 +333,7 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
if (!orders.isEmpty() && pintuanShareVO.getPromotionGoods() == null) {
LambdaQueryWrapper<Order> orderLambdaQueryWrapper = new LambdaQueryWrapper<>();
// 查找团长订单和已和当前拼团订单拼团的订单
orderLambdaQueryWrapper.eq(Order::getOrderType, OrderTypeEnum.PINTUAN.name())
orderLambdaQueryWrapper.eq(Order::getOrderPromotionType, PromotionTypeEnum.PINTUAN.name())
.eq(Order::getPayStatus, OrderStatusEnum.PAID.name())
.ne(Order::getSn, parentOrderSn)
.and(i -> i.eq(Order::getParentOrderSn, orders.get(0).getParentOrderSn()).or(j -> j.eq(Order::getSn, orders.get(0).getParentOrderSn())));
@@ -424,7 +425,7 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
if (Boolean.FALSE.equals(pintuan.getFictitious()) && entry.getValue().size() < requiredNum) {
// 如果未开启虚拟成团且已参团人数小于成团人数,则自动取消订单
LambdaUpdateWrapper<Order> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(Order::getOrderType, OrderTypeEnum.PINTUAN.name());
updateWrapper.eq(Order::getOrderPromotionType, PromotionTypeEnum.PINTUAN.name());
updateWrapper.eq(Order::getPromotionId, pintuan.getId());
updateWrapper.eq(Order::getParentOrderSn, entry.getKey());
updateWrapper.set(Order::getOrderStatus, OrderStatusEnum.CANCELLED.name());