Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1455a7e64e |
@@ -34,7 +34,7 @@ public class OrderController {
|
||||
String userId = jsonObject.getString("accountId");
|
||||
return orderService.createCart(cartVo.getMasterId(),cartVo.getProductId(),cartVo.getShopId(),
|
||||
cartVo.getSkuId(),cartVo.getNumber(),userId,clientType,cartVo.getCartId(),cartVo.getIsGift(),
|
||||
cartVo.getIsPack(),cartVo.getUuid(),cartVo.getType(), cartVo.getTableId());
|
||||
cartVo.getIsPack(),cartVo.getUuid(),cartVo.getType(), cartVo.getTableId(), cartVo.getVipUserId());
|
||||
}
|
||||
|
||||
@MyLog(value = "查询购物车信息", tag = LogTag.CART)
|
||||
@@ -43,13 +43,14 @@ public class OrderController {
|
||||
@RequestHeader("loginName") String loginName,
|
||||
@RequestHeader("clientType") String clientType,
|
||||
@RequestParam(value = "masterId", required = false) String masterId,
|
||||
@RequestParam(required = false) String tableId,
|
||||
@RequestParam(required = false) Integer tableId,
|
||||
@RequestParam(required = false) Integer vipUserId,
|
||||
@RequestParam("shopId") String shopId
|
||||
){
|
||||
if (tableId == null && StrUtil.isBlank(masterId)) {
|
||||
return Result.fail("masterId和tableId不能同 时为空");
|
||||
}
|
||||
return orderService.queryCart(masterId,shopId, tableId);
|
||||
return orderService.queryCart(masterId,shopId, tableId, vipUserId);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,11 +58,10 @@ public class OrderController {
|
||||
public Result delCart(@RequestHeader("token") String token,
|
||||
@RequestHeader("loginName") String loginName,
|
||||
@RequestHeader("clientType") String clientType,
|
||||
@RequestParam(required = false) String tableId,
|
||||
@RequestParam(value = "masterId", required = false) String masterId,
|
||||
@RequestParam("cartId") Integer cartId
|
||||
){
|
||||
return orderService.delCart(masterId,cartId, tableId);
|
||||
return orderService.delCart(masterId,cartId);
|
||||
}
|
||||
@GetMapping("/createCode")
|
||||
public Result createCode(@RequestHeader("token") String token,
|
||||
|
||||
@@ -30,8 +30,8 @@ public interface TbCashierCartMapper {
|
||||
TbCashierCart selectByDetail(@Param("masterId") String masterId, @Param("productId") String productId,
|
||||
@Param("shopId") String shopId, @Param("skuId") String skuId, @Param("day") String day,@Param("uuid") String uuid);
|
||||
|
||||
TbCashierCart selectDetailByQrcode(@Param("tableId") String tableId, @Param("productId") String productId,
|
||||
@Param("shopId") String shopId, @Param("skuId") String skuId, @Param("uuid") String uuid);
|
||||
TbCashierCart selectDetailByQrcode(@Param("tableId") Integer tableId, @Param("productId") String productId,
|
||||
@Param("shopId") String shopId, @Param("skuId") String skuId, @Param("userId") Integer userId);
|
||||
|
||||
List<TbCashierCart> selectByMaskerId(@Param("masterId")String masterId, @Param("shopId")Integer shopId,@Param("status") String status,@Param("day") String day);
|
||||
|
||||
@@ -45,7 +45,12 @@ public interface TbCashierCartMapper {
|
||||
@Param("status") String status, @Param("day") String day, @Param("uuid") String uuid);
|
||||
|
||||
List<TbCashierCart> selectAllCreateOrder(@Param("masterId") String masterId, @Param("shopId") Integer shopId,
|
||||
@Param("day") String day, @Param("status") String status,@Param("uuid") String uuid);
|
||||
@Param("day") String day, @Param("status") String status,
|
||||
@Param("uuid") String uuid);
|
||||
|
||||
List<TbCashierCart> selectAllCreateOrder2(@Param("masterId") String masterId, @Param("shopId") Integer shopId,
|
||||
@Param("day") String day, @Param("status") String status,
|
||||
@Param("uuid") String uuid, @Param("tableId") Integer tableId, @Param("vipUserId") Integer vipUserId);
|
||||
List<CartPo> selectCartList( @Param("cartId") String shopId);
|
||||
|
||||
int updateByOrderId(@Param("orderId") String orderId,@Param("status") String status);
|
||||
@@ -64,7 +69,7 @@ public interface TbCashierCartMapper {
|
||||
|
||||
List<TbCashierCart> selectByOrderId(@Param("orderId") String orderId,@Param("status") String status);
|
||||
|
||||
List<TbCashierCart> selectActivateByQrcode(@Param("tableId") String tableId, @Param("shopId") Integer shopId);
|
||||
List<TbCashierCart> selectActivateByQrcode(@Param("tableId") Integer tableId, @Param("shopId") Integer shopId, @Param("userId") Integer userId);
|
||||
|
||||
QueryCartPo selectProductNumByQrcode(@Param("qrcode") String qrcode, @Param("shopId") Integer shopId);
|
||||
QueryCartPo selectProductNumByQrcode(@Param("tableId") Integer tableId, @Param("shopId") Integer shopId, @Param("vipUserId") Integer vipUserId);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ public class CartVo {
|
||||
|
||||
// orderId不为空为代客下单
|
||||
private String masterId;
|
||||
private String tableId;
|
||||
private Integer tableId;
|
||||
private Integer vipUserId;
|
||||
private String shopId;
|
||||
private Integer skuId;
|
||||
private Integer number;
|
||||
|
||||
@@ -92,7 +92,7 @@ public class OrderService {
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result createCart(String masterId, String productId, String shopId, Integer skuId, Integer number,
|
||||
String userId, String clientType, Integer cartId, String isGift, String isPack, String uuid, String type, String qrcode) {
|
||||
String userId, String clientType, Integer cartId, String isGift, String isPack, String uuid, String type, Integer tableId, Integer vipId) {
|
||||
if (Objects.isNull(number) || number < 0) {
|
||||
return Result.fail(CodeEnum.NUMBER);
|
||||
}
|
||||
@@ -129,7 +129,7 @@ public class OrderService {
|
||||
// 低于起售,删除商品
|
||||
}else if (exists != null && skuWithBLOBs.getSuit() != null && skuWithBLOBs.getSuit() != 0 && number < skuWithBLOBs.getSuit()){
|
||||
redisUtil.deleteByKey(RedisCst.ORDER_CART_EXISTS + cartId);
|
||||
delCart(masterId, cartId, qrcode);
|
||||
delCart(masterId, cartId);
|
||||
return Result.success(CodeEnum.SUCCESS, masterId);
|
||||
}
|
||||
|
||||
@@ -145,7 +145,6 @@ public class OrderService {
|
||||
}
|
||||
}
|
||||
|
||||
if (qrcode == null && StringUtils.isEmpty(masterId)) {
|
||||
boolean flag = redisUtil.exists("SHOP:CODE:" + clientType + ":" + shopId);
|
||||
if (flag) {
|
||||
String code = redisUtil.getMessage("SHOP:CODE:" + clientType + ":" + shopId).toString();
|
||||
@@ -157,7 +156,6 @@ public class OrderService {
|
||||
redisUtil.saveMessage("SHOP:CODE:" + clientType + ":" + shopId, "1");
|
||||
masterId = "#" + String.format("%03d", 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TbCashierCart cart = cashierCartMapper.selectByPrimaryKey(cartId);
|
||||
@@ -182,11 +180,11 @@ public class OrderService {
|
||||
cashierCartMapper.updateByPrimaryKeySelective(cart);
|
||||
|
||||
} else {
|
||||
List<TbCashierCart> list = StrUtil.isNotBlank(masterId) ? cashierCartMapper.selectALlByMasterId(masterId, "create")
|
||||
: cashierCartMapper.selectActivateByQrcode(qrcode, Integer.valueOf(shopId));
|
||||
List<TbCashierCart> list = userId == null && tableId == null ? cashierCartMapper.selectALlByMasterId(masterId, "create")
|
||||
: cashierCartMapper.selectActivateByQrcode(tableId, Integer.valueOf(shopId), vipId);
|
||||
|
||||
TbCashierCart cashierCart = StrUtil.isNotBlank(masterId) ? cashierCartMapper.selectByDetail(masterId, productId, shopId, skuId.toString(), DateUtils.getDay(), uuid)
|
||||
: cashierCartMapper.selectDetailByQrcode(qrcode, productId, shopId, skuId.toString(), uuid);
|
||||
TbCashierCart cashierCart = userId == null && tableId == null ? cashierCartMapper.selectByDetail(masterId, productId, shopId, skuId.toString(), DateUtils.getDay(), uuid)
|
||||
: cashierCartMapper.selectDetailByQrcode(tableId, productId, shopId, skuId.toString(), vipId);
|
||||
|
||||
if (number > 0) {
|
||||
if (Objects.isNull(cashierCart)) {
|
||||
@@ -194,10 +192,9 @@ public class OrderService {
|
||||
cashierCart.setCoverImg(product.getCoverImg());
|
||||
cashierCart.setCreatedAt(System.currentTimeMillis());
|
||||
cashierCart.setIsSku(product.getTypeEnum());
|
||||
if (qrcode != null) {
|
||||
cashierCart.setTableId(qrcode);
|
||||
}else {
|
||||
cashierCart.setMasterId(masterId);
|
||||
if (tableId != null) {
|
||||
cashierCart.setTableId(String.valueOf(tableId));
|
||||
}
|
||||
cashierCart.setUuid(uuid);
|
||||
cashierCart.setMerchantId(userId);
|
||||
@@ -210,6 +207,7 @@ public class OrderService {
|
||||
cashierCart.setStatus("create");
|
||||
cashierCart.setIsPack(isPack);
|
||||
cashierCart.setIsGift(isGift);
|
||||
cashierCart.setUserId(vipId == null ? Integer.valueOf(userId) : vipId);
|
||||
if (isGift.equals("false")) {
|
||||
cashierCart.setTotalAmount(new BigDecimal(number).multiply(skuWithBLOBs.getSalePrice()));
|
||||
} else {
|
||||
@@ -223,7 +221,6 @@ public class OrderService {
|
||||
|
||||
}
|
||||
cashierCart.setTotalNumber(number);
|
||||
cashierCart.setUserId(Integer.valueOf(userId));
|
||||
cashierCart.setNumber(number);
|
||||
cashierCart.setUuid(uuid);
|
||||
cashierCart.setCategoryId(product.getCategoryId());
|
||||
@@ -303,15 +300,15 @@ public class OrderService {
|
||||
}
|
||||
}
|
||||
|
||||
public Result queryCart(String masterId, String shopId, String qrcode) {
|
||||
public Result queryCart(String masterId, String shopId, Integer tableId, Integer vipUserId) {
|
||||
if (StringUtils.isEmpty(shopId)) {
|
||||
return Result.fail(CodeEnum.SHOPINFONOEXIST);
|
||||
}
|
||||
String day = DateUtils.getDay();
|
||||
|
||||
List<TbCashierCart> list;
|
||||
if (StrUtil.isBlank(masterId)) {
|
||||
list = cashierCartMapper.selectActivateByQrcode(qrcode, Integer.valueOf(shopId));
|
||||
if (tableId != null) {
|
||||
list = cashierCartMapper.selectActivateByQrcode(tableId, Integer.valueOf(shopId), vipUserId);
|
||||
}else {
|
||||
list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId),"create",day);
|
||||
}
|
||||
@@ -362,10 +359,10 @@ public class OrderService {
|
||||
}
|
||||
|
||||
QueryCartPo queryCartPo;
|
||||
if (StrUtil.isNotBlank(masterId)) {
|
||||
if (tableId == null) {
|
||||
queryCartPo = cashierCartMapper.selectProductNumByMarketId(day, shopId, masterId);
|
||||
}else {
|
||||
queryCartPo = cashierCartMapper.selectProductNumByQrcode(qrcode, Integer.valueOf(shopId));
|
||||
queryCartPo = cashierCartMapper.selectProductNumByQrcode(tableId, Integer.valueOf(shopId), vipUserId);
|
||||
}
|
||||
queryCartPo.setPackAmount(packAmount);
|
||||
queryCartPo.setTotalAmount(totalAmount);
|
||||
@@ -377,7 +374,7 @@ public class OrderService {
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result delCart(String masterId, Integer cartId, String qrcode) {
|
||||
public Result delCart(String masterId, Integer cartId) {
|
||||
|
||||
|
||||
TbCashierCart cashierCart=cashierCartMapper.selectByPrimaryKey(cartId);
|
||||
@@ -409,7 +406,7 @@ public class OrderService {
|
||||
List<String> skuIds=new ArrayList<>();
|
||||
skuIds.add(cashierCart.getSkuId());
|
||||
|
||||
cashierCartMapper.deleteByCartIdOrTableId(masterId, cartId, qrcode);
|
||||
cashierCartMapper.deleteByCartIdOrTableId(masterId, cartId, null);
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
@@ -854,7 +851,8 @@ public class OrderService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result clearCart(CartVo cartVo) {
|
||||
String day = DateUtils.getDay();
|
||||
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid());
|
||||
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder2(
|
||||
cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid(), cartVo.getTableId(), cartVo.getVipUserId());
|
||||
int orderId = 0;
|
||||
List<ProductSkuPo> productSkuPos=new ArrayList<>();
|
||||
List<String> skuIds=new ArrayList<>();
|
||||
|
||||
@@ -65,8 +65,8 @@
|
||||
<include refid="Base_Column_List"/>
|
||||
from tb_cashier_cart where table_id = #{tableId} and product_id = #{productId} and shop_id = #{shopId} and
|
||||
sku_id = #{skuId}
|
||||
<if test="uuid != null">
|
||||
and uuid = #{uuid}
|
||||
<if test="userId != null">
|
||||
and user_id = #{userId}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByMaskerId" resultType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart">
|
||||
@@ -91,6 +91,27 @@
|
||||
and trade_day = #{day}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectAllCreateOrder2" resultType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from tb_cashier_cart where shop_id = #{shopId} and status = #{status}
|
||||
<if test="uuid != null and uuid != ''">
|
||||
and uuid = #{uuid}
|
||||
</if>
|
||||
<if test="day != null and day !=''">
|
||||
and trade_day = #{day}
|
||||
</if>
|
||||
<if test="tableId != null and vipUserId != null">
|
||||
and (table_id = #{tableId} or user_id=#{vipUserId})
|
||||
</if>
|
||||
<if test="tableId != null and vipUserId == null">
|
||||
and table_id = #{tableId} and master_id = #{masterId}
|
||||
</if>
|
||||
<if test="tableId == null and vipUserId == null">
|
||||
and master_id = #{masterId}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectProductNumByMarketId" resultType="com.chaozhanggui.system.cashierservice.entity.po.QueryCartPo">
|
||||
select ifnull(count(*),0) as productNum,ifnull(sum(number),0)as productSum from (select count(*),number from tb_cashier_cart where trade_day = #{day} and master_id = #{masterId} and shop_id = #{shopId} group by product_id ) a
|
||||
</select>
|
||||
@@ -408,13 +429,22 @@
|
||||
|
||||
<select id="selectActivateByQrcode"
|
||||
resultType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart">
|
||||
select * from tb_cashier_cart where table_id = #{tableId} and shop_id = #{shopId} and status = 'create'
|
||||
select * from tb_cashier_cart where shop_id = #{shopId} and status = 'create'
|
||||
and table_id = #{tableId}
|
||||
<if test="userId != null">
|
||||
and user_id=#{userId}
|
||||
</if>
|
||||
|
||||
</select>
|
||||
<select id="selectProductNumByQrcode"
|
||||
resultType="com.chaozhanggui.system.cashierservice.entity.po.QueryCartPo">
|
||||
select ifnull(count(*),0) as productNum,ifnull(sum(number),0)as productSum
|
||||
from (select count(*),number
|
||||
from tb_cashier_cart where table_id = #{qrcode} and shop_id = #{shopId} group by product_id ) a
|
||||
from tb_cashier_cart where table_id = #{tableId} and shop_id = #{shopId}
|
||||
<if test="vipUserId != null">
|
||||
and user_id=#{vipUserId}
|
||||
</if>
|
||||
group by product_id ) a
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user