Merge branch 'test' into dev

# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/controller/MemberController.java
This commit is contained in:
yijiegong 2024-09-06 23:53:05 +08:00
commit a9d0810d1a
8 changed files with 83 additions and 47 deletions

View File

@ -25,7 +25,7 @@ public interface TbOrderDetailMapper {
int updateByPrimaryKey(TbOrderDetail record);
void updateStatusByOrderId(@Param("orderId") int orderId,@Param("status") String status);
void updateStatusByOrderId(@Param("orderId") int orderId,@Param("status") String status,@Param("radio") BigDecimal radio);
void updateStatusByOrderIdAndStatus(@Param("orderId") int orderId,@Param("status") String status);
void deleteByOUrderId(@Param("orderId") int orderId);

View File

@ -186,7 +186,7 @@ public class PrintMechineConsumer {
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), null, null);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getPayAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), null, null);
String printType = "退款单";

View File

@ -92,6 +92,8 @@ public class MemberService {
if(!"1".equals(isFlag)){
isFlag=null;
}
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByShopId(shopId, phone,isFlag);
PageInfo pageInfo = new PageInfo(tbShopUsers);
return Result.success(CodeEnum.SUCCESS, pageInfo);

View File

@ -509,8 +509,7 @@ public class OrderService {
.set(TbCashierCart::getStatus, "create")
.in(TbCashierCart::getId, ids));
if (orderId > 0) {
tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
}
}
@ -635,14 +634,14 @@ public class OrderService {
}
@Transactional(rollbackFor = Exception.class)
public Result createOrder(OrderVo orderVo, String clientType, String token, Integer oldOrderId, boolean isPrint) {
public Result createOrder(OrderVo orderVo, String clientType, String token, Integer oldOrderId, boolean isPost) {
String day = DateUtils.getDay();
TbShopTable shopTable = null;
String currentOrderKey = RedisCst.getCurrentOrderKey(orderVo.getTableId(),
orderVo.getShopId().toString());
String orderIdValue = redisUtil.getMessage(currentOrderKey);
Integer orderId = orderIdValue == null ? 0 : Integer.parseInt(orderIdValue);
Integer orderId = isPost ? orderIdValue == null ? 0 : Integer.parseInt(orderIdValue) : 0;
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, orderVo.getShopId())
@ -755,7 +754,7 @@ public class OrderService {
if (orderInfo == null || !"unpaid".equals(orderInfo.getStatus())) {
redisUtil.deleteByKey(currentOrderKey);
}
if (orderId > 0 && orderInfo != null) {
if (orderInfo != null && orderId > 0) {
// if (!orderInfo.getStatus().equals("unpaid")){
// return Result.fail(CodeEnum.ORDERCREATE);
// }
@ -819,7 +818,7 @@ public class OrderService {
redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(orderInfo.getShopId()),object.toString());
orderId = orderInfo.getId();
if (isPrint) {
if (isPost) {
redisUtil.saveMessage(currentOrderKey, orderInfo.getId().toString());
}
@ -874,7 +873,7 @@ public class OrderService {
}
if (!StrUtil.isBlank(orderVo.getTableId())) {
if (isPrint) {
if (isPost) {
producer.printMechine(String.valueOf(orderId));
}
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
@ -950,11 +949,11 @@ public class OrderService {
orderCode =String.valueOf(Integer.valueOf(code)+1);
}
redisUtil.getIncrNum("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "2");
boolean flag = redisUtil.execsSet("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day,orderCode);
if (flag){
return generateOrderCode(day,clientType,shopId);
}
// 增加计数器
// boolean flag = redisUtil.execsSet("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day,orderCode);
// if (flag){
// return generateOrderCode(day,clientType,shopId);
// }
// 增加计数器
return orderCode;
}
@ -1173,7 +1172,7 @@ public class OrderService {
// cashierCartMapper.updateStatusByMaster(shopId, masterId, "create", day, uuid);
if (orderId > 0) {
tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
}
return Result.success(CodeEnum.SUCCESS);

View File

@ -303,7 +303,7 @@ public class PayService {
log.info("更新购物车:{}", cartCount);
//更新子单状态
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
JSONObject jsonObject = new JSONObject();
jsonObject.put("token", token);
@ -385,8 +385,11 @@ public class PayService {
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
log.info("更新购物车:{}", cartCount);
//更新子单状态
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
}else {
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("token", token);
@ -504,8 +507,11 @@ public class PayService {
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
log.info("更新购物车:{}", cartCount);
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
}else {
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("token", token);
jsonObject.put("type", "create");
@ -639,10 +645,11 @@ public class PayService {
//更新购物车状态
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed");
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
}else {
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
log.info("更新购物车:{}", cartCount);
@ -769,9 +776,13 @@ public class PayService {
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed");
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
}else {
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
log.info("更新购物车:{}", cartCount);
@ -868,14 +879,21 @@ public class PayService {
orderInfo.setPayAmount(orderInfo.getOrderAmount());
}
orderInfo.setPayType("cash");
orderInfo.setPayType("deposit");
orderInfo.setStatus("closed");
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
orderInfo.setPayOrderNo("deposit".concat(SnowFlakeUtil.generateOrderNo()));
orderInfo.setMemberId(vipUserId.toString());
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
//更新购物车状态
int cartCount = tbCashierCartMapper.updateByOrderId(String.valueOf(orderId), "final");
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
}else {
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
log.info("更新购物车:{}", cartCount);
JSONObject jsonObject = new JSONObject();
@ -954,11 +972,17 @@ public class PayService {
orderInfo.setPayType("cash");
orderInfo.setStatus("closed");
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
//更新购物车状态
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
}else {
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
log.info("更新购物车:{}", cartCount);
JSONObject jsonObject = new JSONObject();
@ -1046,10 +1070,14 @@ public class PayService {
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
//更新购物车状态
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
log.info("更新购物车:{}", cartCount);
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
}else {
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("token", token);
jsonObject.put("type", "create");
@ -1096,7 +1124,7 @@ public class PayService {
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
if ("1".equals(shopInfo.getIsReturn())) {
if ("0".equals(shopInfo.getIsReturn())) {
if (ObjectUtil.isEmpty(pwd)) {
return Result.fail(CodeEnum.PARAM);
}
@ -1172,11 +1200,10 @@ public class PayService {
// totalAmount = totalAmount.add(it.getPriceAmount());
totalAmount = totalAmount.add(it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId()))));
saleAmount = saleAmount.add(it.getPrice());
payAmount = payAmount.add(it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN)
.multiply(new BigDecimal(map1.get(it.getId()))));
if (ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio()) && ObjectUtil.isNotNull(orderInfo.getDiscountRatio())) {
payAmount = payAmount.multiply(orderInfo.getDiscountRatio()).setScale(2, BigDecimal.ROUND_DOWN);
}
//
// payAmount=payAmount.add(it.getPriceAmount());
packAMount = packAMount.add(it.getPackAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId()))));
@ -1187,7 +1214,8 @@ public class PayService {
detailPo.setStatus("closed");
}
BigDecimal returnAmount = it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId())));
BigDecimal returnAmount = it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId())));;
detailPo.setReturnNum(map1.get(it.getId()));
detailPos.add(detailPo);
it.setNum(map1.get(it.getId()));
@ -1281,7 +1309,7 @@ public class PayService {
flow.setBizCode("accountReturnPay");
flow.setBizName("会员储值卡退款");
flow.setType("+");
flow.setAmount(newOrderInfo.getOrderAmount());
flow.setAmount(newOrderInfo.getPayAmount());
flow.setBalance(user.getAmount());
flow.setCreateTime(new Date());
flow.setIsReturn("0");
@ -1711,6 +1739,7 @@ public class PayService {
public static void main(String[] args) {
System.out.println(MD5Util.encrypt("123456".concat("13718478323").concat("10")));
}
}

View File

@ -646,7 +646,7 @@ public class RedisUtils {
if (database!=0) {
jedis.select(database);
}
Object result = jedis.eval(secKillScript, Arrays.asList( key,num), new ArrayList<>());
Object result = jedis.eval(secKillScript, Collections.singletonList( key), Collections.singletonList( num));
String reString = String.valueOf(result);
return reString;
@ -684,4 +684,4 @@ public class RedisUtils {
}
return false ;
}
}
}

View File

@ -23,11 +23,11 @@ import java.util.Map;
@Component
public class WxAccountUtil {
@Value("${wx.ysk.appId}")
private static String appId = "wx212769170d2c6b2a";
private String appId = "wx212769170d2c6b2a";
@Value("${wx.ysk.secrete}")
private static String secrete = "8492a7e8d55bbb1b57f5c8276ea1add0";
private String secrete = "8492a7e8d55bbb1b57f5c8276ea1add0";
@Value("${wx.ysk.warnMsgTmpId}")
private static String msgTmpId = "C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0";
private String msgTmpId = "C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0";
private final TbShopMsgStateMapper shopMsgStateMapper;
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
@ -49,7 +49,7 @@ public class WxAccountUtil {
// sendStockWarnMsg("13213", "31123", "234", "ojC-S6n2DDlpj52iVMoiLL0Ry4HI");
}
public static String getRadarQrCode(Integer shopId) {
public String getRadarQrCode(Integer shopId) {
HashMap<String, Object> req = new HashMap<>();
req.put("expire_seconds", 300);
req.put("action_name", "QR_STR_SCENE");
@ -70,7 +70,7 @@ public class WxAccountUtil {
}
public static String getAccessToken() {
public String getAccessToken() {
String resp = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", appId, secrete));
JSONObject respInfo = JSONObject.parseObject(resp);
if (!respInfo.containsKey("access_token")) {
@ -80,7 +80,7 @@ public class WxAccountUtil {
return respInfo.getString("access_token");
}
public static JSONObject sendTemplateMsg(String templateId, String toUserOpenId, Map<String, Object> data) {
public JSONObject sendTemplateMsg(String templateId, String toUserOpenId, Map<String, Object> data) {
log.info("开始发送微信模板消息, 接收用户openId: {}, 消息数据: {}", toUserOpenId, data);
String accessToken = getAccessToken();

View File

@ -205,7 +205,13 @@
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateStatusByOrderId">
update tb_order_detail set status = #{status} where order_id = #{orderId}
update tb_order_detail set status = #{status}
<if test="radio != null">
,price_amount=price_amount*#{radio}
</if>
where order_id = #{orderId}
</update>