1.代客下单相关接口修改
This commit is contained in:
7
pom.xml
7
pom.xml
@@ -69,10 +69,11 @@
|
|||||||
<version>1.9.4</version>
|
<version>1.9.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mybatis.spring.boot</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
<version>2.1.1</version>
|
<version>3.5.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mybatis.generator</groupId>
|
<groupId>org.mybatis.generator</groupId>
|
||||||
<artifactId>mybatis-generator-core</artifactId>
|
<artifactId>mybatis-generator-core</artifactId>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
public enum LogTag {
|
public enum LogTag {
|
||||||
JPUSH("极光"), CLIENT("安卓"),
|
JPUSH("极光"), CLIENT("安卓"),
|
||||||
LOGIN("登录"), SYSTEM("系统"), CART("订单购物车");
|
LOGIN("登录"), SYSTEM("系统"), CART("订单购物车"), PLACE("下单");
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
LogTag(String value) {
|
LogTag(String value) {
|
||||||
|
|||||||
@@ -6,12 +6,15 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.chaozhanggui.system.cashierservice.annotation.MyLog;
|
import com.chaozhanggui.system.cashierservice.annotation.MyLog;
|
||||||
import com.chaozhanggui.system.cashierservice.bean.LogTag;
|
import com.chaozhanggui.system.cashierservice.bean.LogTag;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.OrderVo;
|
import com.chaozhanggui.system.cashierservice.entity.OrderVo;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.UpdateVipDTO;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
|
import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
|
||||||
import com.chaozhanggui.system.cashierservice.service.OrderService;
|
import com.chaozhanggui.system.cashierservice.service.OrderService;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
@@ -24,6 +27,14 @@ public class OrderController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private OrderService orderService;
|
private OrderService orderService;
|
||||||
|
|
||||||
|
@PutMapping("/updateVip")
|
||||||
|
@MyLog(value = "代客下单 修改会员", tag = LogTag.PLACE)
|
||||||
|
public ResponseEntity<Object> updateVip(
|
||||||
|
@Validated @RequestBody UpdateVipDTO updateVipDTO
|
||||||
|
) {
|
||||||
|
return ResponseEntity.ok(orderService.updateVip(updateVipDTO));
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/createCart")
|
@PostMapping("/createCart")
|
||||||
public Result createCart(@RequestHeader("token") String token,
|
public Result createCart(@RequestHeader("token") String token,
|
||||||
@RequestHeader("loginName") String loginName,
|
@RequestHeader("loginName") String loginName,
|
||||||
@@ -34,7 +45,7 @@ public class OrderController {
|
|||||||
String userId = jsonObject.getString("accountId");
|
String userId = jsonObject.getString("accountId");
|
||||||
return orderService.createCart(cartVo.getMasterId(),cartVo.getProductId(),cartVo.getShopId(),
|
return orderService.createCart(cartVo.getMasterId(),cartVo.getProductId(),cartVo.getShopId(),
|
||||||
cartVo.getSkuId(),cartVo.getNumber(),userId,clientType,cartVo.getCartId(),cartVo.getIsGift(),
|
cartVo.getSkuId(),cartVo.getNumber(),userId,clientType,cartVo.getCartId(),cartVo.getIsGift(),
|
||||||
cartVo.getIsPack(),cartVo.getUuid(),cartVo.getType());
|
cartVo.getIsPack(),cartVo.getUuid(),cartVo.getType(), cartVo.getVipUserId(), cartVo.getTableId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@MyLog(value = "查询购物车信息", tag = LogTag.CART)
|
@MyLog(value = "查询购物车信息", tag = LogTag.CART)
|
||||||
@@ -44,12 +55,13 @@ public class OrderController {
|
|||||||
@RequestHeader("clientType") String clientType,
|
@RequestHeader("clientType") String clientType,
|
||||||
@RequestParam(value = "masterId", required = false) String masterId,
|
@RequestParam(value = "masterId", required = false) String masterId,
|
||||||
@RequestParam(required = false) String tableId,
|
@RequestParam(required = false) String tableId,
|
||||||
|
@RequestParam(required = false) Integer vipUserId,
|
||||||
@RequestParam("shopId") String shopId
|
@RequestParam("shopId") String shopId
|
||||||
){
|
){
|
||||||
if (tableId == null && StrUtil.isBlank(masterId)) {
|
if (tableId == null && StrUtil.isBlank(masterId)) {
|
||||||
return Result.fail("masterId和tableId不能同时为空");
|
return Result.fail("masterId和tableId不能同时为空");
|
||||||
}
|
}
|
||||||
return orderService.queryCart(masterId,shopId);
|
return orderService.queryCart(masterId,shopId, vipUserId, tableId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -90,7 +102,8 @@ public class OrderController {
|
|||||||
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||||
String userId = jsonObject.getString("accountId");
|
String userId = jsonObject.getString("accountId");
|
||||||
String code = jsonObject.getString("code");
|
String code = jsonObject.getString("code");
|
||||||
return orderService.cartStatus(Integer.valueOf(cartVo.getShopId()),cartVo.getMasterId(),cartVo.getStatus(),userId,cartVo.getUuid(),clientType);
|
return orderService.cartStatus(Integer.valueOf(cartVo.getShopId()),cartVo.getMasterId(),
|
||||||
|
cartVo.getStatus(),userId,cartVo.getUuid(),clientType, cartVo.getVipUserId(), cartVo.getTableId());
|
||||||
}
|
}
|
||||||
@PostMapping("/createOrder")
|
@PostMapping("/createOrder")
|
||||||
public Result createOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
|
public Result createOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
|
||||||
|
|||||||
@@ -12,4 +12,6 @@ public class OrderVo {
|
|||||||
private Integer shopId;
|
private Integer shopId;
|
||||||
private String userId;
|
private String userId;
|
||||||
private Integer merchantId;
|
private Integer merchantId;
|
||||||
|
private String tableId;
|
||||||
|
private Integer vipUserId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.entity;
|
package com.chaozhanggui.system.cashierservice.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -57,7 +58,11 @@ public class TbCashierCart implements Serializable {
|
|||||||
private Long updatedAt;
|
private Long updatedAt;
|
||||||
private Integer userId;
|
private Integer userId;
|
||||||
private String tableId;
|
private String tableId;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
private TbProductSpec tbProductSpec;
|
private TbProductSpec tbProductSpec;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
private String selectSpec="";
|
private String selectSpec="";
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.hibernate.validator.constraints.Range;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UpdateVipDTO {
|
||||||
|
@NotNull
|
||||||
|
private Integer shopId;
|
||||||
|
@NotEmpty
|
||||||
|
private String tableId;
|
||||||
|
@NotNull
|
||||||
|
private String masterId;
|
||||||
|
|
||||||
|
private Integer vipUserId;
|
||||||
|
@NotNull
|
||||||
|
@Range(min = 0, max = 1)
|
||||||
|
private Integer type;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -5,10 +5,6 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class CartVo {
|
public class CartVo {
|
||||||
private String productId;
|
private String productId;
|
||||||
|
|
||||||
// orderId不为空为代客下单
|
|
||||||
private String masterId;
|
|
||||||
private String tableId;
|
|
||||||
private String shopId;
|
private String shopId;
|
||||||
private Integer skuId;
|
private Integer skuId;
|
||||||
private Integer number;
|
private Integer number;
|
||||||
@@ -18,4 +14,7 @@ public class CartVo {
|
|||||||
private String uuid;
|
private String uuid;
|
||||||
private String type;
|
private String type;
|
||||||
private Integer cartId;
|
private Integer cartId;
|
||||||
|
private String masterId;
|
||||||
|
private String tableId;
|
||||||
|
private Integer vipUserId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.mybatis;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
|
||||||
|
|
||||||
|
public interface MPCashierCartMapper extends BaseMapper<TbCashierCart> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.mybatis;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
|
||||||
|
|
||||||
|
public interface MpShopTableMapper extends BaseMapper<TbShopTable> {
|
||||||
|
}
|
||||||
@@ -37,8 +37,6 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void cons(String content){
|
public void cons(String content){
|
||||||
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
||||||
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT, content, correlationId);
|
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT, content, correlationId);
|
||||||
|
|||||||
@@ -1,17 +1,23 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.service;
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateTime;
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.chaozhanggui.system.cashierservice.bean.ShopWxMsgTypeEnum;
|
import com.chaozhanggui.system.cashierservice.bean.ShopWxMsgTypeEnum;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.UpdateVipDTO;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.po.*;
|
import com.chaozhanggui.system.cashierservice.entity.po.*;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
|
import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
|
||||||
|
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||||
|
import com.chaozhanggui.system.cashierservice.mybatis.MPCashierCartMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.mybatis.MpShopTableMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
@@ -26,7 +32,6 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -68,6 +73,7 @@ public class OrderService {
|
|||||||
RedisUtil redisUtil;
|
RedisUtil redisUtil;
|
||||||
|
|
||||||
private final WxAccountUtil wxAccountUtil;
|
private final WxAccountUtil wxAccountUtil;
|
||||||
|
private final MPCashierCartMapper mpCashierCartMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RabbitProducer producer;
|
RabbitProducer producer;
|
||||||
@@ -77,6 +83,7 @@ public class OrderService {
|
|||||||
private final TbUserShopMsgMapper tbUserShopMsgMapper;
|
private final TbUserShopMsgMapper tbUserShopMsgMapper;
|
||||||
|
|
||||||
private final TbShopOpenIdMapper shopOpenIdMapper;
|
private final TbShopOpenIdMapper shopOpenIdMapper;
|
||||||
|
private final MpShopTableMapper mpShopTableMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbProskuConMapper tbProskuConMapper;
|
private TbProskuConMapper tbProskuConMapper;
|
||||||
@@ -90,16 +97,18 @@ public class OrderService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ProductService productService;
|
private ProductService productService;
|
||||||
|
|
||||||
public OrderService(WxAccountUtil wxAccountUtil, WechatUtil wechatUtil, TbUserShopMsgMapper tbUserShopMsgMapper, TbShopOpenIdMapper shopOpenIdMapper) {
|
public OrderService(WxAccountUtil wxAccountUtil, MPCashierCartMapper mpCashierCartMapper, WechatUtil wechatUtil, TbUserShopMsgMapper tbUserShopMsgMapper, TbShopOpenIdMapper shopOpenIdMapper, MpShopTableMapper mpShopTableMapper) {
|
||||||
this.wxAccountUtil = wxAccountUtil;
|
this.wxAccountUtil = wxAccountUtil;
|
||||||
|
this.mpCashierCartMapper = mpCashierCartMapper;
|
||||||
this.wechatUtil = wechatUtil;
|
this.wechatUtil = wechatUtil;
|
||||||
this.tbUserShopMsgMapper = tbUserShopMsgMapper;
|
this.tbUserShopMsgMapper = tbUserShopMsgMapper;
|
||||||
this.shopOpenIdMapper = shopOpenIdMapper;
|
this.shopOpenIdMapper = shopOpenIdMapper;
|
||||||
|
this.mpShopTableMapper = mpShopTableMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result createCart(String masterId, String productId, String shopId, Integer skuId, Integer number,
|
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 userId, String clientType, Integer cartId, String isGift, String isPack, String uuid, String type, Integer vipUserId, String tableId) {
|
||||||
if (Objects.isNull(number) || number < 0) {
|
if (Objects.isNull(number) || number < 0) {
|
||||||
return Result.fail(CodeEnum.NUMBER);
|
return Result.fail(CodeEnum.NUMBER);
|
||||||
}
|
}
|
||||||
@@ -128,10 +137,19 @@ public class OrderService {
|
|||||||
return Result.fail(CodeEnum.PRODUCTSKUERROR);
|
return Result.fail(CodeEnum.PRODUCTSKUERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 台桌点单
|
||||||
|
if ((StrUtil.isNotBlank(tableId))) {
|
||||||
|
TbShopTable shopTable = mpShopTableMapper.selectOne(new LambdaUpdateWrapper<TbShopTable>()
|
||||||
|
.eq(TbShopTable::getQrcode, tableId)
|
||||||
|
.eq(TbShopTable::getStatus, "opening"));
|
||||||
|
|
||||||
|
if (shopTable == null) {
|
||||||
|
return Result.fail("台桌不存在或未开台");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<TbProskuCon> proskuConList = tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(skuId,shopInfo.getId(),product.getId());
|
List<TbProskuCon> proskuConList = tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(skuId,shopInfo.getId(),product.getId());
|
||||||
if(Objects.nonNull(proskuConList)&&proskuConList.size()>0){
|
if(Objects.nonNull(proskuConList) && !proskuConList.isEmpty()){
|
||||||
for (TbProskuCon proskuCon : proskuConList) {
|
for (TbProskuCon proskuCon : proskuConList) {
|
||||||
if("1".equals(proskuCon.getStatus())){
|
if("1".equals(proskuCon.getStatus())){
|
||||||
TbConsInfo consInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId());
|
TbConsInfo consInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId());
|
||||||
@@ -144,16 +162,6 @@ public class OrderService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String exists = redisUtil.getMessage(RedisCst.ORDER_CART_EXISTS + cartId);
|
String exists = redisUtil.getMessage(RedisCst.ORDER_CART_EXISTS + cartId);
|
||||||
|
|
||||||
// 首次加入购物车,并且拥有起售数,设置为起售数
|
// 首次加入购物车,并且拥有起售数,设置为起售数
|
||||||
@@ -191,6 +199,7 @@ public class OrderService {
|
|||||||
masterId = "#" + String.format("%03d", 1);
|
masterId = "#" + String.format("%03d", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TbCashierCart cart = cashierCartMapper.selectByPrimaryKey(cartId);
|
TbCashierCart cart = cashierCartMapper.selectByPrimaryKey(cartId);
|
||||||
if (Objects.nonNull(cart)) {
|
if (Objects.nonNull(cart)) {
|
||||||
|
|
||||||
@@ -201,6 +210,7 @@ public class OrderService {
|
|||||||
cashierCart.setNumber(cashierCart.getNumber()+number);
|
cashierCart.setNumber(cashierCart.getNumber()+number);
|
||||||
cashierCart.setTotalNumber(cashierCart.getNumber()+number);
|
cashierCart.setTotalNumber(cashierCart.getNumber()+number);
|
||||||
cashierCart.setUpdatedAt(System.currentTimeMillis());
|
cashierCart.setUpdatedAt(System.currentTimeMillis());
|
||||||
|
cashierCart.setUserId(vipUserId);
|
||||||
cashierCartMapper.updateByPrimaryKey(cashierCart);
|
cashierCartMapper.updateByPrimaryKey(cashierCart);
|
||||||
|
|
||||||
cashierCartMapper.deleteByPrimaryKey(cart.getId());
|
cashierCartMapper.deleteByPrimaryKey(cart.getId());
|
||||||
@@ -212,6 +222,8 @@ public class OrderService {
|
|||||||
cart.setNumber(number);
|
cart.setNumber(number);
|
||||||
cart.setIsGift(isGift);
|
cart.setIsGift(isGift);
|
||||||
cart.setIsPack(isPack);
|
cart.setIsPack(isPack);
|
||||||
|
cart.setUserId(vipUserId);
|
||||||
|
|
||||||
if (isPack.equals("false")){
|
if (isPack.equals("false")){
|
||||||
cart.setPackFee(BigDecimal.ZERO);
|
cart.setPackFee(BigDecimal.ZERO);
|
||||||
}else {
|
}else {
|
||||||
@@ -227,10 +239,6 @@ public class OrderService {
|
|||||||
cart.setUuid(uuid);
|
cart.setUuid(uuid);
|
||||||
cashierCartMapper.updateByPrimaryKeySelective(cart);
|
cashierCartMapper.updateByPrimaryKeySelective(cart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
List<TbCashierCart> list = cashierCartMapper.selectALlByMasterId(masterId, "create");
|
List<TbCashierCart> list = cashierCartMapper.selectALlByMasterId(masterId, "create");
|
||||||
TbCashierCart cashierCart = cashierCartMapper.selectByDetail(masterId, productId, shopId, skuId.toString(), DateUtils.getDay(), uuid);
|
TbCashierCart cashierCart = cashierCartMapper.selectByDetail(masterId, productId, shopId, skuId.toString(), DateUtils.getDay(), uuid);
|
||||||
@@ -252,6 +260,7 @@ public class OrderService {
|
|||||||
cashierCart.setStatus("create");
|
cashierCart.setStatus("create");
|
||||||
cashierCart.setIsPack(isPack);
|
cashierCart.setIsPack(isPack);
|
||||||
cashierCart.setIsGift(isGift);
|
cashierCart.setIsGift(isGift);
|
||||||
|
cashierCart.setUserId(vipUserId);
|
||||||
if (isGift.equals("false")) {
|
if (isGift.equals("false")) {
|
||||||
cashierCart.setTotalAmount(new BigDecimal(number).multiply(skuWithBLOBs.getSalePrice()));
|
cashierCart.setTotalAmount(new BigDecimal(number).multiply(skuWithBLOBs.getSalePrice()));
|
||||||
} else {
|
} else {
|
||||||
@@ -273,6 +282,7 @@ public class OrderService {
|
|||||||
cashierCartMapper.insert(cashierCart);
|
cashierCartMapper.insert(cashierCart);
|
||||||
cart=cashierCart;
|
cart=cashierCart;
|
||||||
} else {
|
} else {
|
||||||
|
cashierCart.setUserId(vipUserId);
|
||||||
if (type.equals("add")) {
|
if (type.equals("add")) {
|
||||||
cashierCart.setNumber(cashierCart.getNumber() + number);
|
cashierCart.setNumber(cashierCart.getNumber() + number);
|
||||||
|
|
||||||
@@ -284,8 +294,9 @@ public class OrderService {
|
|||||||
}else {
|
}else {
|
||||||
cashierCart.setPackFee(new BigDecimal(number).multiply(product.getPackFee()));
|
cashierCart.setPackFee(new BigDecimal(number).multiply(product.getPackFee()));
|
||||||
}
|
}
|
||||||
|
cashierCart.setUserId(vipUserId);
|
||||||
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getNumber()).multiply(skuWithBLOBs.getSalePrice()).add(cashierCart.getPackFee()));
|
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getNumber()).multiply(skuWithBLOBs.getSalePrice()).add(cashierCart.getPackFee()));
|
||||||
cashierCartMapper.updateByPrimaryKeySelective(cashierCart);
|
mpCashierCartMapper.updateById(cashierCart);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cashierCartMapper.updateStatus(cashierCart.getId(), "close");
|
cashierCartMapper.updateStatus(cashierCart.getId(), "close");
|
||||||
@@ -344,27 +355,48 @@ public class OrderService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result queryCart(String masterId, String shopId) {
|
public Result queryCart(String masterId, String shopId, Integer vipUserId, String tableId) {
|
||||||
if (StringUtils.isEmpty(shopId)) {
|
if (StringUtils.isEmpty(shopId)) {
|
||||||
return Result.fail(CodeEnum.SHOPINFONOEXIST);
|
return Result.fail(CodeEnum.SHOPINFONOEXIST);
|
||||||
}
|
}
|
||||||
String day = DateUtils.getDay();
|
String day = DateUtils.getDay();
|
||||||
List<TbCashierCart> list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId),"create",day);
|
|
||||||
if (list.size() < 1){
|
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||||
list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId), "refund",day);
|
.eq(TbCashierCart::getShopId, shopId);
|
||||||
if (list.size() > 0){
|
|
||||||
if (list.size() < 1) {
|
// 普通点单
|
||||||
|
if (StrUtil.isBlank(tableId)) {
|
||||||
|
queryWrapper.eq(TbCashierCart::getMasterId, masterId);
|
||||||
|
queryWrapper.isNull(TbCashierCart::getTableId);
|
||||||
|
// 台桌点单
|
||||||
|
}else if (StrUtil.isNotBlank(tableId) && vipUserId == null) {
|
||||||
|
queryWrapper.eq(TbCashierCart::getTableId, tableId)
|
||||||
|
.eq(TbCashierCart::getMasterId, masterId);
|
||||||
|
// 会员点单
|
||||||
|
}else {
|
||||||
|
queryWrapper.eq(TbCashierCart::getUserId, vipUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// List<TbCashierCart> list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId),"create",day);
|
||||||
|
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "create"));
|
||||||
|
if (list.isEmpty()){
|
||||||
|
list = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "refund"));
|
||||||
|
// list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId), "refund",day);
|
||||||
|
if (!list.isEmpty()){
|
||||||
|
if (list.isEmpty()) {
|
||||||
return Result.fail(CodeEnum.CARTJH);
|
return Result.fail(CodeEnum.CARTJH);
|
||||||
}
|
}
|
||||||
int orderId = 0;
|
int orderId = 0;
|
||||||
String uuid = "";
|
String uuid = "";
|
||||||
for (TbCashierCart cashierCart : list) {
|
for (TbCashierCart cashierCart : list) {
|
||||||
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
||||||
orderId = Integer.valueOf(cashierCart.getOrderId());
|
orderId = Integer.parseInt(cashierCart.getOrderId());
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
cashierCart.setStatus("create");
|
||||||
}
|
}
|
||||||
cashierCartMapper.updateStatusByMaster(Integer.valueOf(shopId), masterId, "create", day, uuid);
|
mpCashierCartMapper.insertOrUpdate(list);
|
||||||
|
// cashierCartMapper.updateStatusByMaster(Integer.valueOf(shopId), masterId, "create", day, uuid);
|
||||||
if (orderId > 0) {
|
if (orderId > 0) {
|
||||||
tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
|
tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
|
||||||
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
|
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
|
||||||
@@ -446,9 +478,32 @@ public class OrderService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result createOrder(OrderVo orderVo, String clientType, String token) {
|
public Result createOrder(OrderVo orderVo, String clientType, String token) {
|
||||||
String day = DateUtils.getDay();
|
String day = DateUtils.getDay();
|
||||||
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid());
|
|
||||||
if (list.size() < 1) {
|
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||||
list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid());
|
.eq(TbCashierCart::getShopId, orderVo.getShopId())
|
||||||
|
.eq(TbCashierCart::getStatus, "create");
|
||||||
|
|
||||||
|
|
||||||
|
// 普通点单
|
||||||
|
if (StrUtil.isBlank(orderVo.getTableId())) {
|
||||||
|
queryWrapper.eq(TbCashierCart::getMasterId, orderVo.getMasterId())
|
||||||
|
.eq(TbCashierCart::getTradeDay, day);
|
||||||
|
queryWrapper.isNull(TbCashierCart::getTableId);
|
||||||
|
// 台桌点单
|
||||||
|
}else if (StrUtil.isNotBlank(orderVo.getTableId()) && orderVo.getVipUserId() == null) {
|
||||||
|
queryWrapper.eq(TbCashierCart::getTableId, orderVo.getTableId())
|
||||||
|
.eq(TbCashierCart::getTradeDay, day)
|
||||||
|
.eq(TbCashierCart::getMasterId, orderVo.getMasterId());
|
||||||
|
// 会员点单
|
||||||
|
}else {
|
||||||
|
queryWrapper.eq(TbCashierCart::getUserId, orderVo.getVipUserId());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper);
|
||||||
|
// List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid());
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
list = mpCashierCartMapper.selectList(queryWrapper);
|
||||||
|
// list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ObjectUtil.isEmpty(list)||ObjectUtil.isNull(list)||list.size()<=0){
|
if(ObjectUtil.isEmpty(list)||ObjectUtil.isNull(list)||list.size()<=0){
|
||||||
@@ -735,11 +790,34 @@ public class OrderService {
|
|||||||
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result cartStatus(Integer shopId, String masterId, String status, String userId, String uuid, String clientType) {
|
public Result cartStatus(Integer shopId, String masterId, String status, String userId, String uuid,
|
||||||
|
String clientType, Integer vipUserId, String tableId) {
|
||||||
String newUuid = redisUtil.getMessage("CART:UUID:" + shopId + userId)+"";
|
String newUuid = redisUtil.getMessage("CART:UUID:" + shopId + userId)+"";
|
||||||
String day = DateUtils.getDay();
|
String day = DateUtils.getDay();
|
||||||
|
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||||
|
.eq(TbCashierCart::getShopId, shopId);
|
||||||
|
|
||||||
|
|
||||||
|
// 普通点单
|
||||||
|
if (StrUtil.isBlank(tableId)) {
|
||||||
|
queryWrapper.eq(TbCashierCart::getMasterId, masterId);
|
||||||
|
queryWrapper.isNull(TbCashierCart::getTableId);
|
||||||
|
// 台桌点单
|
||||||
|
}else if (StrUtil.isNotBlank(tableId) && vipUserId == null) {
|
||||||
|
queryWrapper.eq(TbCashierCart::getTableId, tableId)
|
||||||
|
.eq(TbCashierCart::getMasterId, masterId);
|
||||||
|
// 会员点单
|
||||||
|
}else {
|
||||||
|
queryWrapper
|
||||||
|
.eq(TbCashierCart::getTableId, tableId)
|
||||||
|
.eq(TbCashierCart::getUserId, vipUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ("true".equals(status)) {
|
if ("true".equals(status)) {
|
||||||
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, day, "create", uuid);
|
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper);
|
||||||
|
// List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, day, "create", uuid);
|
||||||
if (list.size() < 1) {
|
if (list.size() < 1) {
|
||||||
return Result.fail(CodeEnum.CREATEORDER);
|
return Result.fail(CodeEnum.CREATEORDER);
|
||||||
}
|
}
|
||||||
@@ -810,31 +888,34 @@ public class OrderService {
|
|||||||
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
||||||
flag = false;
|
flag = false;
|
||||||
}
|
}
|
||||||
|
cashierCart.setUserId(vipUserId);
|
||||||
cashierCart.setOrderId(orderId + "");
|
cashierCart.setOrderId(orderId + "");
|
||||||
cashierCart.setUpdatedAt(System.currentTimeMillis());
|
cashierCart.setUpdatedAt(System.currentTimeMillis());
|
||||||
cashierCart.setPendingAt(System.currentTimeMillis());
|
cashierCart.setPendingAt(System.currentTimeMillis());
|
||||||
cashierCart.setStatus("refund");
|
cashierCart.setStatus("refund");
|
||||||
cashierCart.setUuid(newUuid);
|
cashierCart.setUuid(newUuid);
|
||||||
cashierCartMapper.updateByPrimaryKeySelective(cashierCart);
|
mpCashierCartMapper.updateById(cashierCart);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
redisUtil.deleteByKey("SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + userId);
|
redisUtil.deleteByKey("SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + userId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper
|
||||||
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, "", "refund", uuid);
|
.eq(TbCashierCart::getStatus, "refund"));
|
||||||
if (list.size() < 1) {
|
// List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, "", "refund", uuid);
|
||||||
|
if (list.isEmpty()) {
|
||||||
return Result.fail(CodeEnum.CARTJH);
|
return Result.fail(CodeEnum.CARTJH);
|
||||||
}
|
}
|
||||||
int orderId = 0;
|
int orderId = 0;
|
||||||
for (TbCashierCart cashierCart : list) {
|
for (TbCashierCart cashierCart : list) {
|
||||||
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
||||||
orderId = Integer.valueOf(cashierCart.getOrderId());
|
orderId = Integer.parseInt(cashierCart.getOrderId());
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
cashierCart.setStatus("create");
|
||||||
}
|
}
|
||||||
cashierCartMapper.updateStatusByMaster(shopId, masterId, "create", day, uuid);
|
mpCashierCartMapper.insertOrUpdate(list);
|
||||||
|
// cashierCartMapper.updateStatusByMaster(shopId, masterId, "create", day, uuid);
|
||||||
if (orderId > 0) {
|
if (orderId > 0) {
|
||||||
tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
|
tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
|
||||||
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
|
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
|
||||||
@@ -881,7 +962,27 @@ public class OrderService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result clearCart(CartVo cartVo) {
|
public Result clearCart(CartVo cartVo) {
|
||||||
String day = DateUtils.getDay();
|
String day = DateUtils.getDay();
|
||||||
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid());
|
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||||
|
.eq(TbCashierCart::getShopId, cartVo.getShopId())
|
||||||
|
.eq(TbCashierCart::getTradeDay, day)
|
||||||
|
.eq(TbCashierCart::getStatus, "create");
|
||||||
|
|
||||||
|
|
||||||
|
// 普通点单
|
||||||
|
if (StrUtil.isBlank(cartVo.getTableId())) {
|
||||||
|
queryWrapper.eq(TbCashierCart::getMasterId, cartVo.getMasterId());
|
||||||
|
queryWrapper.isNull(TbCashierCart::getTableId);
|
||||||
|
// 台桌点单
|
||||||
|
}else if (StrUtil.isNotBlank(cartVo.getTableId()) && cartVo.getVipUserId() == null) {
|
||||||
|
queryWrapper.eq(TbCashierCart::getTableId, cartVo.getTableId())
|
||||||
|
.eq(TbCashierCart::getMasterId, cartVo.getMasterId());
|
||||||
|
// 会员点单
|
||||||
|
}else {
|
||||||
|
queryWrapper.eq(TbCashierCart::getUserId, cartVo.getVipUserId());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper);
|
||||||
|
// List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid());
|
||||||
int orderId = 0;
|
int orderId = 0;
|
||||||
List<ProductSkuPo> productSkuPos = new ArrayList<>();
|
List<ProductSkuPo> productSkuPos = new ArrayList<>();
|
||||||
List<String> skuIds = new ArrayList<>();
|
List<String> skuIds = new ArrayList<>();
|
||||||
@@ -1379,4 +1480,19 @@ public class OrderService {
|
|||||||
JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doGet(requestUrl,requestUrlParam));
|
JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doGet(requestUrl,requestUrlParam));
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object updateVip(UpdateVipDTO updateVipDTO) {
|
||||||
|
LambdaUpdateWrapper<TbCashierCart> queryWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
queryWrapper.eq(TbCashierCart::getTableId, updateVipDTO.getTableId())
|
||||||
|
.eq(TbCashierCart::getShopId, updateVipDTO.getShopId())
|
||||||
|
.eq(TbCashierCart::getMasterId, updateVipDTO.getMasterId());
|
||||||
|
|
||||||
|
if (updateVipDTO.getType().equals(0)) {
|
||||||
|
queryWrapper.set(TbCashierCart::getUserId, null);
|
||||||
|
queryWrapper.eq(TbCashierCart::getUserId, updateVipDTO.getVipUserId());
|
||||||
|
}else {
|
||||||
|
queryWrapper.set(TbCashierCart::getUserId, updateVipDTO.getVipUserId());
|
||||||
|
}
|
||||||
|
return mpCashierCartMapper.update(null, queryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user