Merge branch 'refs/heads/dev'
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/target/
|
||||
@@ -55,8 +55,7 @@ public class LoginFilter implements Filter {
|
||||
"cashierService/product/productInfo",
|
||||
"cashierService/notify/**",//登录部分接口不校验
|
||||
"notify/**",
|
||||
"cashierService/table/**",//回调部分接口不校验
|
||||
"cashierService/pay/**"
|
||||
"cashierService/table/**" //回调部分接口不校验
|
||||
);
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -29,6 +29,7 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@RestController
|
||||
@@ -60,32 +61,18 @@ public class LoginContoller {
|
||||
RedisUtil redisUtil;
|
||||
|
||||
|
||||
// @RequestMapping("/wx/business/login")
|
||||
@RequestMapping("/wx/business/login")
|
||||
public Result wxBusinessLogin(@RequestParam(value = "code", required = false) String code,
|
||||
@RequestParam(value = "rawData", required = false) String rawData,
|
||||
@RequestParam(value = "signature", required = false) String signature
|
||||
@RequestParam(value = "shopId", required = false) String shopId
|
||||
) {
|
||||
|
||||
|
||||
// 用户非敏感信息:rawData
|
||||
// 签名:signature
|
||||
JSONObject rawDataJson = JSON.parseObject(rawData);
|
||||
// 1.接收小程序发送的code
|
||||
// 2.开发者服务器 登录凭证校验接口 appi + appsecret + code
|
||||
JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, businessAppId, businessSecrete);
|
||||
// 3.接收微信接口服务 获取返回的参数
|
||||
String openid = SessionKeyOpenId.getString("openid");
|
||||
String sessionKey = SessionKeyOpenId.getString("session_key");
|
||||
|
||||
// 4.校验签名 小程序发送的签名signature与服务器端生成的签名signature2 = sha1(rawData + sessionKey)
|
||||
String signature2 = DigestUtils.sha1Hex(rawData + sessionKey);
|
||||
if (!signature.equals(signature2)) {
|
||||
return Result.fail("签名校验失败");
|
||||
if(Objects.isNull(openid)){
|
||||
return Result.fail("获取微信id失败");
|
||||
}
|
||||
|
||||
|
||||
return Result.success(CodeEnum.ENCRYPT);
|
||||
|
||||
return loginService.wxBusinessLogin(openid,shopId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,9 +7,11 @@ import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbMerchantAccountMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbUserInfoMapper;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbMerchantAccount;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopUser;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbUserInfo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.AuthUserDto;
|
||||
@@ -55,6 +57,8 @@ public class UserContoller {
|
||||
@Autowired
|
||||
private TbShopUserMapper shopUserMapper;
|
||||
@Autowired
|
||||
private TbShopInfoMapper shopInfoMapper;
|
||||
@Autowired
|
||||
private TbUserInfoMapper userInfoMapper;
|
||||
|
||||
// @GetMapping("/userInfo")
|
||||
@@ -80,6 +84,7 @@ public class UserContoller {
|
||||
@GetMapping("/shopUserInfo")
|
||||
public Result shopUserInfo(@RequestParam("userId") String userId ,@RequestHeader("openId") String openId,@RequestParam("shopId") String shopId ) throws Exception {
|
||||
TbShopUser shopUser=new TbShopUser();
|
||||
TbShopInfo tbShopInfo = shopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
|
||||
if (StringUtils.isNotBlank(shopId) && !shopId.equals("null")) {
|
||||
shopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId);
|
||||
if (ObjectUtil.isEmpty(shopUser)) {
|
||||
@@ -116,6 +121,7 @@ public class UserContoller {
|
||||
}else {
|
||||
shopUser.setAmount(BigDecimal.ZERO);
|
||||
}
|
||||
shopUser.setShopName(tbShopInfo.getShopName());
|
||||
return Result.success(CodeEnum.SUCCESS,shopUser);
|
||||
}
|
||||
|
||||
@@ -148,4 +154,10 @@ public class UserContoller {
|
||||
// String userSign = jsonObject.getString("userSign");
|
||||
return userService.userAll(integralFlowVo,"userSign");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.ShopGroupInfoVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
@@ -34,4 +35,9 @@ public interface TbProductMapper {
|
||||
|
||||
|
||||
void upGroupRealSalesNumber(@Param("id") String id,@Param("number") Integer number);
|
||||
}
|
||||
|
||||
void updateStockById(@Param("productId") String productId, @Param("num") Integer num);
|
||||
|
||||
@Update("update tb_product set stock_number=stock_number-#{num} WHERE id=#{id} and stock_number-#{num} > 0")
|
||||
int decrStock(@Param("id") String id, @Param("num") Integer num);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.HomeVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
@@ -39,4 +40,7 @@ public interface TbProductSkuMapper {
|
||||
|
||||
List<TbProductSku> selectSkus(@Param("list") List<String> productId);
|
||||
List<TbProductSku> selectSku(@Param("productId") String productId);
|
||||
}
|
||||
|
||||
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id} and stock_number-#{num} > 0")
|
||||
int decrStock(@Param("id") String id, @Param("num") Integer num);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopOpenId;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_shop_open_id(商家openid信息表)】的数据库操作Mapper
|
||||
* @createDate 2024-07-02 14:21:02
|
||||
* @Entity com.chaozhanggui.system.cashierservice.entity.TbShopOpenId
|
||||
*/
|
||||
public interface TbShopOpenIdMapper {
|
||||
|
||||
int deleteByPrimaryKey(Long id);
|
||||
|
||||
int insert(TbShopOpenId record);
|
||||
|
||||
int insertSelective(TbShopOpenId record);
|
||||
|
||||
TbShopOpenId selectByPrimaryKey(Long id);
|
||||
|
||||
int updateByPrimaryKeySelective(TbShopOpenId record);
|
||||
|
||||
int updateByPrimaryKey(TbShopOpenId record);
|
||||
|
||||
@Select("select * from tb_shop_open_id where open_id=#{openId}")
|
||||
TbShopOpenId countByOpenId(@Param("openId") String openId);
|
||||
|
||||
@Select("select * from tb_shop_open_id where shop_id=#{shopId} and status=1")
|
||||
List<TbShopOpenId> selectByShopId(@Param("shopId") Integer shopId);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_user_shop_msg】的数据库操作Mapper
|
||||
* @createDate 2024-06-28 09:55:30
|
||||
* @Entity com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg
|
||||
*/
|
||||
@Component
|
||||
@Mapper
|
||||
public interface TbUserShopMsgMapper {
|
||||
int deleteByPrimaryKey(Integer shopId);
|
||||
|
||||
int deleteByPrimaryKey(Long id);
|
||||
|
||||
int insert(TbUserShopMsg record);
|
||||
|
||||
int insertSelective(TbUserShopMsg record);
|
||||
|
||||
TbUserShopMsg selectByPrimaryKey(Integer shopId);
|
||||
TbUserShopMsg selectByPrimaryKey(Long id);
|
||||
|
||||
int updateByPrimaryKeySelective(TbUserShopMsg record);
|
||||
|
||||
int updateByPrimaryKey(TbUserShopMsg record);
|
||||
|
||||
@Select("select * from tb_user_shop_msg where shop_id=#{shopId}")
|
||||
TbUserShopMsg selectByShopId(@Param("shopId") String shopId);
|
||||
}
|
||||
|
||||
@@ -66,6 +66,9 @@ public class TbProduct implements Serializable {
|
||||
|
||||
private String typeEnum;
|
||||
|
||||
/**
|
||||
* 是否共享库存
|
||||
*/
|
||||
private Byte isDistribute;
|
||||
|
||||
private Byte isDel;
|
||||
@@ -131,6 +134,8 @@ public class TbProduct implements Serializable {
|
||||
private String cartNumber="0";
|
||||
private String groupCategoryId;
|
||||
|
||||
private Integer stockNumber;
|
||||
|
||||
|
||||
public String getImages() {
|
||||
return images;
|
||||
@@ -650,4 +655,12 @@ public class TbProduct implements Serializable {
|
||||
public void setSpecTableHeaders(String specTableHeaders) {
|
||||
this.specTableHeaders = specTableHeaders == null ? null : specTableHeaders.trim();
|
||||
}
|
||||
}
|
||||
|
||||
public void setStockNumber(Integer stockNumber) {
|
||||
this.stockNumber = stockNumber;
|
||||
}
|
||||
|
||||
public Integer getStockNumber() {
|
||||
return this.stockNumber;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ public class TbProductSku implements Serializable {
|
||||
|
||||
private Long updatedAt;
|
||||
|
||||
private Integer isPauseSale = 0;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Integer getId() {
|
||||
@@ -215,4 +217,12 @@ public class TbProductSku implements Serializable {
|
||||
public void setUpdatedAt(Long updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getIsPauseSale() {
|
||||
return isPauseSale;
|
||||
}
|
||||
|
||||
public void setIsPauseSale(Integer isPauseSale) {
|
||||
this.isPauseSale = isPauseSale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商家openid信息表
|
||||
* @TableName tb_shop_open_id
|
||||
*/
|
||||
@Data
|
||||
public class TbShopOpenId implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Integer shopId;
|
||||
|
||||
/**
|
||||
* 已经订阅消息的商家微信号
|
||||
*/
|
||||
private String openId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
TbShopOpenId other = (TbShopOpenId) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
|
||||
&& (this.getOpenId() == null ? other.getOpenId() == null : this.getOpenId().equals(other.getOpenId()))
|
||||
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
|
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
|
||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
|
||||
result = prime * result + ((getOpenId() == null) ? 0 : getOpenId().hashCode());
|
||||
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
|
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", shopId=").append(shopId);
|
||||
sb.append(", openId=").append(openId);
|
||||
sb.append(", status=").append(status);
|
||||
sb.append(", createTime=").append(createTime);
|
||||
sb.append(", updateTime=").append(updateTime);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,7 @@ public class TbShopUser implements Serializable {
|
||||
private Long updatedAt;
|
||||
|
||||
private String miniOpenId;
|
||||
private String shopName;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -295,6 +296,14 @@ public class TbShopUser implements Serializable {
|
||||
return miniOpenId;
|
||||
}
|
||||
|
||||
public String getShopName() {
|
||||
return shopName;
|
||||
}
|
||||
|
||||
public void setShopName(String shopName) {
|
||||
this.shopName = shopName;
|
||||
}
|
||||
|
||||
public void setMiniOpenId(String miniOpenId) {
|
||||
this.miniOpenId = miniOpenId == null ? null : miniOpenId.trim();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class TbUserShopMsg implements Serializable {
|
||||
private Integer shopId;
|
||||
|
||||
private String openId;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String status;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Integer getShopId() {
|
||||
return shopId;
|
||||
}
|
||||
|
||||
public void setShopId(Integer shopId) {
|
||||
this.shopId = shopId;
|
||||
}
|
||||
|
||||
public String getOpenId() {
|
||||
return openId;
|
||||
}
|
||||
|
||||
public void setOpenId(String openId) {
|
||||
this.openId = openId == null ? null : openId.trim();
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark == null ? null : remark.trim();
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status == null ? null : status.trim();
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
||||
@@ -96,4 +96,43 @@ public class RabbitConfig {
|
||||
public Binding bindingPrint_Register() {
|
||||
return BindingBuilder.bind(queuePrint_Register()).to(printExchange_Register()).with(RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public DirectExchange consExchange_Register() {
|
||||
return new DirectExchange(RabbitConstants.CONS_COLLECT_PUT);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue queuecons_Register() {
|
||||
return new Queue(RabbitConstants.CONS_COLLECT_QUEUE_PUT, true); //队列持久
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding bindingcons_Register() {
|
||||
return BindingBuilder.bind(queuecons_Register()).to(consExchange_Register()).with(RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public DirectExchange cons_msg_Exchange_Register() {
|
||||
return new DirectExchange(RabbitConstants.CONS_MSG_COLLECT_PUT);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue queuecons_msg_Register() {
|
||||
return new Queue(RabbitConstants.CONS_MSG_COLLECT_QUEUE_PUT, true); //队列持久
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding bindingcons_msg_Register() {
|
||||
return BindingBuilder.bind(queuecons_msg_Register()).to(cons_msg_Exchange_Register()).with(RabbitConstants.CONS_MSG_COLLECT_ROUTINGKEY_PUT);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -38,4 +38,25 @@ public interface RabbitConstants {
|
||||
|
||||
|
||||
public static final String INTEGRAL_ROUTINGKEY_PUT = "integral_routingkey_put1";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static final String CONS_COLLECT_PUT="cons_collect_put";
|
||||
|
||||
public static final String CONS_COLLECT_QUEUE_PUT = "cons_collect_queue_put";
|
||||
|
||||
|
||||
public static final String CONS_COLLECT_ROUTINGKEY_PUT = "cons_collect_routingkey_put";
|
||||
|
||||
|
||||
public static final String CONS_MSG_COLLECT_PUT="cons_msg_collect_put";
|
||||
|
||||
public static final String CONS_MSG_COLLECT_QUEUE_PUT = "cons_msg_collect_queue_put";
|
||||
|
||||
|
||||
public static final String CONS_MSG_COLLECT_ROUTINGKEY_PUT = "cons_msg_collect_routingkey_put";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -42,6 +42,20 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
|
||||
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.INTEGRAL_PUT, RabbitConstants.INTEGRAL_ROUTINGKEY_PUT, content, correlationId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void cons(String content){
|
||||
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT, content, correlationId);
|
||||
}
|
||||
|
||||
public void con_msg(String content){
|
||||
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.CONS_MSG_COLLECT_PUT, RabbitConstants.CONS_MSG_COLLECT_ROUTINGKEY_PUT, content, correlationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
|
||||
logger.info(" 回调id:" + correlationData);
|
||||
|
||||
@@ -22,4 +22,6 @@ public class RedisCst {
|
||||
public static final String COUPONS_COIN_KEY = "COUPONS:COIN:KEY";
|
||||
|
||||
public static final String OUT_NUMBER="ORDER:NUMBER:";
|
||||
// 创建订单锁
|
||||
public static final String CREATE_ORDER_LOCK = "CREATE_ORDER_LOCK:";
|
||||
}
|
||||
|
||||
@@ -7,14 +7,19 @@ import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.netty.PushToAppChannelHandlerAdapter;
|
||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
||||
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.LockUtils;
|
||||
import com.chaozhanggui.system.cashierservice.util.N;
|
||||
import com.chaozhanggui.system.cashierservice.wxUtil.WechatUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -23,6 +28,7 @@ import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
@@ -53,6 +59,32 @@ public class CartService {
|
||||
private TbUserCouponsMapper userCouponsMapper;
|
||||
@Autowired
|
||||
private TbSystemCouponsMapper systemCouponsMapper;
|
||||
private final TbUserShopMsgMapper tbUserShopMsgMapper;
|
||||
private final WechatUtil wechatUtil;
|
||||
|
||||
private final TbShopOpenIdMapper shopOpenIdMapper;
|
||||
|
||||
@Autowired
|
||||
private RabbitProducer producer;
|
||||
@Qualifier("tbShopInfoMapper")
|
||||
@Autowired
|
||||
private TbShopInfoMapper tbShopInfoMapper;
|
||||
|
||||
|
||||
private final ProductService productService;
|
||||
|
||||
private final TbProductMapper tbProductMapper;
|
||||
|
||||
private final RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
public CartService(TbUserShopMsgMapper tbUserShopMsgMapper, WechatUtil wechatUtil, TbShopOpenIdMapper shopOpenIdMapper, ProductService productService, TbProductMapper tbProductMapper, RedisTemplate<String, Object> redisTemplate) {
|
||||
this.tbUserShopMsgMapper = tbUserShopMsgMapper;
|
||||
this.wechatUtil = wechatUtil;
|
||||
this.shopOpenIdMapper = shopOpenIdMapper;
|
||||
this.productService = productService;
|
||||
this.tbProductMapper = tbProductMapper;
|
||||
this.redisTemplate = redisTemplate;
|
||||
}
|
||||
|
||||
public void initCart(JSONObject jsonObject) {
|
||||
String tableId = jsonObject.getString("tableId");
|
||||
@@ -88,64 +120,238 @@ public class CartService {
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加入购物车
|
||||
* @param jsonObject 商品信息
|
||||
*/
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void createCart(JSONObject jsonObject) {
|
||||
// try {
|
||||
// String tableId = jsonObject.getString("tableId");
|
||||
// String shopId = jsonObject.getString("shopId");
|
||||
// String productId = jsonObject.getString("productId");
|
||||
//
|
||||
// String key = tableId + "-" + shopId;
|
||||
// TbProduct tbProduct = productMapper.selectById(Integer.valueOf(productId));
|
||||
// if (tbProduct == null) {
|
||||
// JSONObject jsonObject1 = new JSONObject();
|
||||
// jsonObject1.put("status", "fail");
|
||||
// jsonObject1.put("msg", "该商品不存在");
|
||||
// jsonObject1.put("data", new ArrayList<>());
|
||||
// PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
||||
// log.error("该商品不存在 productId:{}", productId);
|
||||
// throw new MsgException("该商品不存在");
|
||||
// }
|
||||
//
|
||||
// String skuId = jsonObject.getString("skuId");
|
||||
// JSONArray jsonArray = new JSONArray();
|
||||
// BigDecimal amount = BigDecimal.ZERO;
|
||||
// TbProductSkuWithBLOBs tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// JSONObject objectMsg=new JSONObject();
|
||||
// objectMsg.put("skuId",tbProductSkuWithBLOBs.getId());
|
||||
// objectMsg.put("shopId",Integer.valueOf(shopId));
|
||||
//
|
||||
//
|
||||
// producer.con_msg(objectMsg.toString());
|
||||
//
|
||||
//
|
||||
// if (Integer.valueOf(tbProduct.getIsPauseSale()).equals(1)) {
|
||||
// JSONObject jsonObject1 = new JSONObject();
|
||||
// jsonObject1.put("status", "fail");
|
||||
// jsonObject1.put("msg", "该商品已售罄");
|
||||
// jsonObject1.put("data", new ArrayList<>());
|
||||
// PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
||||
// log.error("该商品已售罄 productId:{}", productId);
|
||||
// throw new MsgException("该商品已售罄");
|
||||
// }
|
||||
//
|
||||
// String skuNum;
|
||||
//
|
||||
// // 1:共享库存 0:独立库存
|
||||
// if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {
|
||||
// boolean exist = redisUtil.exists(RedisCst.PRODUCT + shopId + ":product" + productId);
|
||||
// if (!exist) {
|
||||
// redisUtil.saveMessage(RedisCst.PRODUCT + shopId + ":product" + productId, tbProduct.getStockNumber() + "");
|
||||
// }
|
||||
// skuNum = redisUtil.getMessage(RedisCst.PRODUCT + shopId + ":product" + productId);
|
||||
//
|
||||
// if (!skuNum.equals(tbProduct.getStockNumber() + "")) {
|
||||
// skuNum = tbProduct.getStockNumber() + "";
|
||||
// redisUtil.saveMessage(RedisCst.PRODUCT + shopId + ":product" + productId, skuNum);
|
||||
// }
|
||||
// } else {
|
||||
// boolean exist = redisUtil.exists(RedisCst.PRODUCT + shopId + ":" + skuId);
|
||||
// if (!exist) {
|
||||
// Double stock = tbProductSkuWithBLOBs.getStockNumber();
|
||||
// redisUtil.saveMessage(RedisCst.PRODUCT + shopId + ":" + skuId, Math.round(stock) + "");
|
||||
// }
|
||||
// skuNum = redisUtil.getMessage(RedisCst.PRODUCT + shopId + ":" + skuId);
|
||||
//
|
||||
// if (!skuNum.equals(Math.round(tbProductSkuWithBLOBs.getStockNumber()) + "")) {
|
||||
// skuNum = Math.round(tbProductSkuWithBLOBs.getStockNumber()) + "";
|
||||
// redisUtil.saveMessage(RedisCst.PRODUCT + shopId + ":product" + productId, skuNum);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Integer buyNum = jsonObject.getInteger("num");
|
||||
// if (tbProduct.getIsStock() == 1) {
|
||||
// boolean flag = false;
|
||||
//
|
||||
// String id = skuId;
|
||||
// if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {
|
||||
// if (tbProduct.getStockNumber() < 1 && buyNum > 0) {
|
||||
// flag = true;
|
||||
// id = productId;
|
||||
// }
|
||||
// } else {
|
||||
// if (tbProductSkuWithBLOBs.getIsPauseSale().equals(1)) {
|
||||
// flag = true;
|
||||
// } else if (Integer.valueOf(skuNum) < 1 && buyNum > 0) {
|
||||
// flag = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (flag) {
|
||||
// JSONObject jsonObject1 = new JSONObject();
|
||||
// jsonObject1.put("status", "fail");
|
||||
// jsonObject1.put("msg", "该商品库存已售罄");
|
||||
// jsonObject1.put("data", new ArrayList<>());
|
||||
// PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
||||
// log.error("该商品库存已售罄 skuId:{}", id);
|
||||
// throw new MsgException("该商品库存已售罄");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (redisUtil.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))) {
|
||||
// JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
|
||||
// if (Objects.isNull(array) || array.isEmpty()) {
|
||||
// if (buyNum > 0) {
|
||||
// TbCashierCart cashierCart = addCart(jsonObject.getString("productId"), skuId,
|
||||
// jsonObject.getInteger("userId"), buyNum, tableId, shopId);
|
||||
// jsonArray.add(cashierCart);
|
||||
// amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
//
|
||||
// updateProductStock(tbProduct, tbProductSkuWithBLOBs, buyNum);
|
||||
// }
|
||||
// } else {
|
||||
// boolean flag = true;
|
||||
// for (int i = 0; i < array.size(); i++) {
|
||||
// JSONObject object = array.getJSONObject(i);
|
||||
// TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
|
||||
// if (cashierCart.getSkuId().equals(skuId)) {
|
||||
// cashierCart.setTotalNumber(cashierCart.getTotalNumber() + buyNum);
|
||||
// cashierCart.setNumber(cashierCart.getNumber() + buyNum);
|
||||
// updateProductStock(tbProduct, tbProductSkuWithBLOBs, buyNum);
|
||||
// if (cashierCart.getNumber() > 0) {
|
||||
// cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
// cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
// cashierCartMapper.updateByPrimaryKeySelective(cashierCart);
|
||||
// } else {
|
||||
// cashierCartMapper.deleteByPrimaryKey(cashierCart.getId());
|
||||
// continue;
|
||||
// }
|
||||
// flag = false;
|
||||
// }
|
||||
// jsonArray.add(cashierCart);
|
||||
// amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
// }
|
||||
// if (flag && buyNum > 0) {
|
||||
// TbCashierCart cashierCart = addCart(jsonObject.getString("productId"), skuId,
|
||||
// jsonObject.getInteger("userId"), buyNum, tableId, jsonObject.getString("shopId"));
|
||||
// jsonArray.add(cashierCart);
|
||||
// amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
// updateProductStock(tbProduct, tbProductSkuWithBLOBs, buyNum);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// if (buyNum > 0) {
|
||||
// TbCashierCart cashierCart = addCart(jsonObject.getString("productId"), skuId,
|
||||
// jsonObject.getInteger("userId"), buyNum, tableId, jsonObject.getString("shopId"));
|
||||
// jsonArray.add(cashierCart);
|
||||
// amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
// updateProductStock(tbProduct, tbProductSkuWithBLOBs, buyNum);
|
||||
// }
|
||||
// }
|
||||
// redisUtil.saveMessage(RedisCst.TABLE_CART.concat(tableId).concat("-").concat(shopId), jsonArray.toJSONString());
|
||||
// JSONObject jsonObject1 = new JSONObject();
|
||||
// jsonObject1.put("status", "success");
|
||||
// jsonObject1.put("msg", "成功");
|
||||
// jsonObject1.put("type", jsonObject.getString("type"));
|
||||
// jsonObject1.put("data", jsonArray);
|
||||
// jsonObject1.put("amount", amount);
|
||||
// PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false);
|
||||
// } catch (Exception e) {
|
||||
// log.error("长链接错误 createCart{}", e.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
public void createCart(JSONObject jsonObject) {
|
||||
try {
|
||||
String tableId = jsonObject.getString("tableId");
|
||||
String shopId = jsonObject.getString("shopId");
|
||||
String productId = jsonObject.getString("productId");
|
||||
String key = tableId + "-" + shopId;
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
boolean exist = redisUtil.exists(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"));
|
||||
if (!exist) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(jsonObject.getString("skuId")));
|
||||
Double stock = tbProductSkuWithBLOBs.getStockNumber();
|
||||
redisUtil.saveMessage(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), Math.round(stock) + "");
|
||||
}
|
||||
String skuNum = redisUtil.getMessage(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"));
|
||||
TbProduct tbProduct = productMapper.selectById(Integer.valueOf(productId));
|
||||
if (tbProduct == null) {
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "该商品不存在");
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
||||
log.error("该商品不存在 productId:{}", productId);
|
||||
throw new MsgException("该商品不存在");
|
||||
}
|
||||
String skuId = jsonObject.getString("skuId");
|
||||
if (tbProduct.getIsStock() == 1) {
|
||||
if (Integer.valueOf(skuNum) < 1 && jsonObject.getInteger("num") > 0) {
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "该商品库存已售罄");
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
||||
log.error("该商品库存已售罄 skuId:{}", jsonObject.getString("skuId"));
|
||||
throw new MsgException("该商品库存已售罄");
|
||||
// 1:共享库存 0:独立库存
|
||||
if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {
|
||||
if (tbProduct.getIsPauseSale().equals(1)) {//是否售罄
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "该商品已售罄");
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
||||
log.error("该商品已售罄 productId:{}", productId);
|
||||
throw new MsgException("该商品已售罄");
|
||||
}
|
||||
} else {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
|
||||
if(tbProductSkuWithBLOBs.getIsPauseSale().equals(1)){//是否售罄
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "该商品已售罄");
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
||||
log.error("该商品已售罄 productId:{}", productId);
|
||||
throw new MsgException("该商品已售罄");
|
||||
}
|
||||
}
|
||||
}
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
Integer buyNum = jsonObject.getInteger("num");
|
||||
|
||||
if (redisUtil.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))) {
|
||||
JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
|
||||
if (Objects.isNull(array) || array.isEmpty() || array.size() < 1) {
|
||||
if (jsonObject.getInteger("num") > 0) {
|
||||
TbCashierCart cashierCart = addCart(jsonObject.getString("productId"), jsonObject.getString("skuId"),
|
||||
jsonObject.getInteger("userId"), jsonObject.getInteger("num"), tableId, jsonObject.getString("shopId"));
|
||||
if (Objects.isNull(array) || array.isEmpty()) {
|
||||
if (buyNum > 0) {
|
||||
TbCashierCart cashierCart = addCart(jsonObject.getString("productId"), skuId,
|
||||
jsonObject.getInteger("userId"), buyNum, tableId, shopId);
|
||||
jsonArray.add(cashierCart);
|
||||
amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
if (jsonObject.getInteger("num") > 0) {
|
||||
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "1");
|
||||
} else {
|
||||
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "2");
|
||||
}
|
||||
productSkuMapper.updateStockById(jsonObject.getString("skuId"), jsonObject.getInteger("num"));
|
||||
}
|
||||
} else {
|
||||
boolean flag = true;
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JSONObject object = array.getJSONObject(i);
|
||||
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
|
||||
if (cashierCart.getSkuId().equals(jsonObject.getString("skuId"))) {
|
||||
cashierCart.setTotalNumber(cashierCart.getTotalNumber() + jsonObject.getInteger("num"));
|
||||
cashierCart.setNumber(cashierCart.getNumber() + jsonObject.getInteger("num"));
|
||||
if (jsonObject.getInteger("num") > 0) {
|
||||
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "1");
|
||||
} else {
|
||||
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "2");
|
||||
}
|
||||
productSkuMapper.updateStockById(jsonObject.getString("skuId"), jsonObject.getInteger("num"));
|
||||
if (cashierCart.getSkuId().equals(skuId)) {
|
||||
cashierCart.setTotalNumber(cashierCart.getTotalNumber() + buyNum);
|
||||
cashierCart.setNumber(cashierCart.getNumber() + buyNum);
|
||||
if (cashierCart.getNumber() > 0) {
|
||||
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
@@ -159,27 +365,19 @@ public class CartService {
|
||||
jsonArray.add(cashierCart);
|
||||
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
}
|
||||
if (flag && jsonObject.getInteger("num") > 0) {
|
||||
TbCashierCart cashierCart = addCart(jsonObject.getString("productId"), jsonObject.getString("skuId"),
|
||||
jsonObject.getInteger("userId"), jsonObject.getInteger("num"), tableId, jsonObject.getString("shopId"));
|
||||
if (flag && buyNum > 0) {
|
||||
TbCashierCart cashierCart = addCart(jsonObject.getString("productId"), skuId,
|
||||
jsonObject.getInteger("userId"), buyNum, tableId, jsonObject.getString("shopId"));
|
||||
jsonArray.add(cashierCart);
|
||||
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
if (jsonObject.getInteger("num") > 0) {
|
||||
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "1");
|
||||
} else {
|
||||
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "2");
|
||||
}
|
||||
productSkuMapper.updateStockById(jsonObject.getString("skuId"), jsonObject.getInteger("num"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (jsonObject.getInteger("num") > 0) {
|
||||
TbCashierCart cashierCart = addCart(jsonObject.getString("productId"), jsonObject.getString("skuId"),
|
||||
jsonObject.getInteger("userId"), jsonObject.getInteger("num"), tableId, jsonObject.getString("shopId"));
|
||||
if (buyNum > 0) {
|
||||
TbCashierCart cashierCart = addCart(jsonObject.getString("productId"), skuId,
|
||||
jsonObject.getInteger("userId"), buyNum, tableId, jsonObject.getString("shopId"));
|
||||
jsonArray.add(cashierCart);
|
||||
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||
redisUtil.getIncrNum(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), "1");
|
||||
productSkuMapper.updateStockById(jsonObject.getString("skuId"), jsonObject.getInteger("num"));
|
||||
}
|
||||
}
|
||||
redisUtil.saveMessage(RedisCst.TABLE_CART.concat(tableId).concat("-").concat(shopId), jsonArray.toJSONString());
|
||||
@@ -194,8 +392,72 @@ public class CartService {
|
||||
log.error("长链接错误 createCart{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 修改库存并根据警告线发送消息
|
||||
*
|
||||
* @param product 商品
|
||||
* @param productSku sku
|
||||
* @param num 库存数
|
||||
*/
|
||||
private void updateProductStock(TbProduct product, TbProductSkuWithBLOBs productSku, Integer num) {
|
||||
String key = RedisCst.PRODUCT + product.getShopId() + ":product" + product.getId();
|
||||
double stock = num;
|
||||
if (product.getIsDistribute() == 1) {
|
||||
productMapper.updateStockById(product.getId().toString(), num);
|
||||
stock = (double) (product.getStockNumber() - num);
|
||||
} else {
|
||||
key = RedisCst.PRODUCT + product.getShopId() + ":" + productSku.getId();
|
||||
productSkuMapper.updateStockById(productSku.getId().toString(), num);
|
||||
stock = productSku.getStockNumber() - num;
|
||||
}
|
||||
|
||||
private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num, String tableId, String shopId) throws Exception {
|
||||
if (num > 0) {
|
||||
redisUtil.getIncrNum(key, "1");
|
||||
} else {
|
||||
redisUtil.getIncrNum(key, "2");
|
||||
}
|
||||
|
||||
CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(productSku, product, num));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验商品库存警戒线并通知商户
|
||||
*
|
||||
* @param productSku sku
|
||||
*/
|
||||
private void checkWarnLineAndSendMsg(TbProductSku productSku, TbProduct product, Integer num) {
|
||||
if (productSku.getWarnLine() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(product.getShopId()));
|
||||
if (shopInfo == null) {
|
||||
log.info("商品库存预警发送失败,店铺不存在,店铺id:{}", product.getShopId());
|
||||
return;
|
||||
}
|
||||
|
||||
if (productSku.getStockNumber() == null) {
|
||||
productSku.setStockNumber((double) 0);
|
||||
}
|
||||
|
||||
if (product.getStockNumber() == null) {
|
||||
product.setStockNumber(0);
|
||||
}
|
||||
if (
|
||||
(product.getIsDistribute() == 1 && product.getStockNumber() <= productSku.getWarnLine())
|
||||
|| (product.getIsDistribute() != 1) && productSku.getStockNumber() <= productSku.getWarnLine()
|
||||
) {
|
||||
List<TbShopOpenId> shopOpenIds = shopOpenIdMapper.selectByShopId(Integer.valueOf(product.getShopId()));
|
||||
shopOpenIds.forEach(item -> {
|
||||
wechatUtil.sendStockWarnMsg(shopInfo.getShopName(), product.getName(),
|
||||
product.getIsDistribute() == 1 ? String.valueOf(product.getStockNumber() - num) : String.valueOf(productSku.getStockNumber() - num),
|
||||
"耗材库存不足,请及时补充。", item.getOpenId());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num, String tableId, String shopId) throws RuntimeException {
|
||||
try {
|
||||
TbProduct product = productMapper.selectById(Integer.valueOf(productId));
|
||||
String key = tableId + "-" + shopId;
|
||||
@@ -205,7 +467,7 @@ public class CartService {
|
||||
jsonObject1.put("msg", "该商品不存在");
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, userId.toString(), true);
|
||||
log.error("购物车添加商品异常,该商品不存在:{}",productId);
|
||||
log.error("购物车添加商品异常,该商品不存在:{}", productId);
|
||||
throw new MsgException("该商品不存在");
|
||||
}
|
||||
TbProductSkuWithBLOBs productSku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
|
||||
@@ -215,7 +477,7 @@ public class CartService {
|
||||
jsonObject1.put("msg", "该商品规格不存在");
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, userId.toString(), true);
|
||||
log.error("购物车添加商品异常,该商品sku不存在:{}",productId);
|
||||
log.error("购物车添加商品异常,该商品sku不存在:{}", productId);
|
||||
throw new MsgException("该商品规格不存在");
|
||||
}
|
||||
TbCashierCart cashierCart = new TbCashierCart();
|
||||
@@ -241,6 +503,15 @@ public class CartService {
|
||||
cashierCart.setRefundNumber(0);
|
||||
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(productSku.getSalePrice().add(cashierCart.getPackFee())));
|
||||
cashierCartMapper.insert(cashierCart);
|
||||
|
||||
|
||||
//修改耗材数据
|
||||
// JSONObject jsonObject=new JSONObject();
|
||||
// jsonObject.put("cartId",cashierCart.getId());
|
||||
// jsonObject.put("type","create");
|
||||
// producer.cons(jsonObject.toString());
|
||||
|
||||
|
||||
return cashierCart;
|
||||
} catch (Exception e) {
|
||||
log.error("长链接错误 addCart{}", e.getMessage());
|
||||
@@ -278,6 +549,22 @@ public class CartService {
|
||||
JSONObject object = array.getJSONObject(i);
|
||||
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
|
||||
TbProductSkuWithBLOBs tbProduct = productSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));
|
||||
TbProduct tbProduct1 = tbProductMapper.selectById(Integer.valueOf(tbProduct.getProductId()));
|
||||
log.info("开始修改库存,商品id:{},商品名:{}", tbProduct1.getId(), tbProduct1.getName());
|
||||
// 修改库存
|
||||
try {
|
||||
productService.updateStock(tbProduct.getProductId(), tbProduct.getId(), cashierCart.getNumber(), tbProduct1.getIsDistribute() == 1);
|
||||
}catch (Exception e) {
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "商品库存不足" + tbProduct1.getName());
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
||||
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
|
||||
return;
|
||||
}
|
||||
|
||||
totalAmount = totalAmount.add(cashierCart.getTotalAmount());
|
||||
packAMount = packAMount.add(cashierCart.getPackFee());
|
||||
originAmount = originAmount.add(cashierCart.getTotalAmount());
|
||||
@@ -420,6 +707,7 @@ public class CartService {
|
||||
orderInfo.setIsUseCoupon(isuseYhq);
|
||||
// orderInfo.setRemark(StringUtils.isBlank(jsonObject.getString("remark"))?"":jsonObject.getString("remark"));
|
||||
orderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
|
||||
} else {
|
||||
orderInfo = getOrder(totalAmount, packAMount, shopTable, tbMerchantAccount.getId().toString(), jsonObject, originAmount);
|
||||
orderInfo.setMerchantId(String.valueOf(tbMerchantAccount.getId()));
|
||||
@@ -429,26 +717,28 @@ public class CartService {
|
||||
orderInfo.setIsUseCoupon(isuseYhq);
|
||||
orderInfo.setUserCouponAmount(couponAmount);
|
||||
|
||||
JSONObject object=new JSONObject();
|
||||
String outNumber= redisUtil.getMessage(RedisCst.OUT_NUMBER.concat(jsonObject.getString("shopId")));
|
||||
Integer number=1;
|
||||
if(Objects.isNull(outNumber)){
|
||||
object.put("outNumber",number);
|
||||
object.put("times",DateUtils.getDay());
|
||||
}else {
|
||||
object=JSONObject.parseObject(outNumber);
|
||||
if(object.getString("times").equals(DateUtils.getDay())){
|
||||
number=object.getInteger("outNumber")+1;
|
||||
object.put("outNumber",number);
|
||||
}else {
|
||||
object.put("outNumber",number);
|
||||
object.put("times",DateUtils.getDay());
|
||||
JSONObject object = new JSONObject();
|
||||
String outNumber = redisUtil.getMessage(RedisCst.OUT_NUMBER.concat(jsonObject.getString("shopId")));
|
||||
Integer number = 1;
|
||||
if (Objects.isNull(outNumber)) {
|
||||
object.put("outNumber", number);
|
||||
object.put("times", DateUtils.getDay());
|
||||
} else {
|
||||
object = JSONObject.parseObject(outNumber);
|
||||
if (object.getString("times").equals(DateUtils.getDay())) {
|
||||
number = object.getInteger("outNumber") + 1;
|
||||
object.put("outNumber", number);
|
||||
} else {
|
||||
object.put("outNumber", number);
|
||||
object.put("times", DateUtils.getDay());
|
||||
}
|
||||
}
|
||||
orderInfo.setOutNumber(number+"");
|
||||
redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(jsonObject.getString("shopId")),object.toString());
|
||||
orderInfo.setOutNumber(number + "");
|
||||
redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(jsonObject.getString("shopId")), object.toString());
|
||||
orderInfoMapper.insert(orderInfo);
|
||||
orderId = orderInfo.getId();
|
||||
|
||||
|
||||
}
|
||||
for (TbOrderDetail orderDetail : orderDetails) {
|
||||
orderDetail.setOrderId(orderId);
|
||||
@@ -463,6 +753,14 @@ public class CartService {
|
||||
cashierCartMapper.updateByPrimaryKeySelective(cashierCart);
|
||||
object.put("updatedAt", System.currentTimeMillis());
|
||||
object.put("orderId", orderId + "");
|
||||
|
||||
// 发送mq消息
|
||||
JSONObject jsonObject2 = new JSONObject();
|
||||
jsonObject2.put("orderId", orderInfo.getId());
|
||||
jsonObject2.put("type", "create");
|
||||
jsonObject2.put("cartId", cashierCart.getId());
|
||||
log.info("开始发送mq消息,消耗库存,消息内容:{}", jsonObject2);
|
||||
producer.cons(jsonObject2.toString());
|
||||
}
|
||||
redisUtil.saveMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId), array.toJSONString());
|
||||
orderInfo.setDetailList(orderDetails);
|
||||
@@ -482,6 +780,8 @@ public class CartService {
|
||||
jsonObject12.put("data", new JSONArray());
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject12.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false);
|
||||
redisUtil.saveMessage(RedisCst.ORDER_EXPIRED.concat(orderId.toString()), orderId.toString(), 60 * 16L);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info("长链接错误 addCart{}", e.getMessage());
|
||||
e.printStackTrace();
|
||||
@@ -529,17 +829,20 @@ public class CartService {
|
||||
public void clearCart(JSONObject jsonObject) {
|
||||
try {
|
||||
String shopId = jsonObject.getString("shopId");
|
||||
if (redisUtil.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))) {
|
||||
JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
|
||||
if (Objects.isNull(array) || array.isEmpty() || array.size() < 1) {
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(array.get(i).toString(), TbCashierCart.class);
|
||||
redisUtil.secAdd(RedisCst.PRODUCT+shopId+":"+jsonObject.getString("skuId"),cashierCart.getNumber().toString());
|
||||
productSkuMapper.updateAddStockById(jsonObject.getString("skuId"), cashierCart.getNumber());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// List<String> skuIds=new ArrayList<>();
|
||||
// if (redisUtil.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))) {
|
||||
// JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
|
||||
// if (Objects.isNull(array) || array.isEmpty() || array.size() < 1) {
|
||||
// for (int i = 0; i < array.size(); i++) {
|
||||
// TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(array.get(i).toString(), TbCashierCart.class);
|
||||
// redisUtil.secAdd(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), cashierCart.getNumber().toString());
|
||||
// productSkuMapper.updateAddStockById(jsonObject.getString("skuId"), cashierCart.getNumber());
|
||||
// skuIds.add(cashierCart.getSkuId());
|
||||
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
cashierCartMapper.updateStatusByTableId(jsonObject.getString("tableId"), "closed");
|
||||
redisUtil.saveMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)), new JSONArray().toJSONString());
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
@@ -548,6 +851,12 @@ public class CartService {
|
||||
jsonObject1.put("type", "clearCart");
|
||||
jsonObject1.put("amount", BigDecimal.ZERO);
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
// //修改耗材数据
|
||||
// JSONObject jsonObject2=new JSONObject();
|
||||
// jsonObject2.put("type","delete");
|
||||
// jsonObject2.put("skuIds",skuIds);
|
||||
// jsonObject2.put("shopId",shopId);
|
||||
// producer.cons(jsonObject2.toString());
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false);
|
||||
} catch (Exception e) {
|
||||
log.info("长链接错误 clearCart{}", e.getMessage());
|
||||
@@ -737,24 +1046,24 @@ public class CartService {
|
||||
orderInfo.setIsUseCoupon(isuseYhq);
|
||||
orderInfo.setUserCouponAmount(couponAmount);
|
||||
|
||||
JSONObject object=new JSONObject();
|
||||
String outNumber= redisUtil.getMessage(RedisCst.OUT_NUMBER.concat(jsonObject.getString("shopId")));
|
||||
Integer number=1;
|
||||
if(Objects.isNull(outNumber)){
|
||||
object.put("outNumber",number);
|
||||
object.put("times",DateUtils.getDay());
|
||||
}else {
|
||||
object=JSONObject.parseObject(outNumber);
|
||||
if(object.getString("times").equals(DateUtils.getDay())){
|
||||
number=object.getInteger("outNumber")+1;
|
||||
object.put("outNumber",number);
|
||||
}else {
|
||||
object.put("outNumber",number);
|
||||
object.put("times",DateUtils.getDay());
|
||||
JSONObject object = new JSONObject();
|
||||
String outNumber = redisUtil.getMessage(RedisCst.OUT_NUMBER.concat(jsonObject.getString("shopId")));
|
||||
Integer number = 1;
|
||||
if (Objects.isNull(outNumber)) {
|
||||
object.put("outNumber", number);
|
||||
object.put("times", DateUtils.getDay());
|
||||
} else {
|
||||
object = JSONObject.parseObject(outNumber);
|
||||
if (object.getString("times").equals(DateUtils.getDay())) {
|
||||
number = object.getInteger("outNumber") + 1;
|
||||
object.put("outNumber", number);
|
||||
} else {
|
||||
object.put("outNumber", number);
|
||||
object.put("times", DateUtils.getDay());
|
||||
}
|
||||
}
|
||||
orderInfo.setOutNumber(number+"");
|
||||
redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(jsonObject.getString("shopId")),object.toString());
|
||||
orderInfo.setOutNumber(number + "");
|
||||
redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(jsonObject.getString("shopId")), object.toString());
|
||||
|
||||
|
||||
orderInfoMapper.insert(orderInfo);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -53,6 +54,47 @@ public class LoginService {
|
||||
RedisUtil redisUtil;
|
||||
|
||||
|
||||
@Autowired
|
||||
TbUserShopMsgMapper tbUserShopMsgMapper;
|
||||
|
||||
private final TbShopOpenIdMapper shopOpenIdMapper;
|
||||
|
||||
public LoginService(TbShopOpenIdMapper shopOpenIdMapper) {
|
||||
this.shopOpenIdMapper = shopOpenIdMapper;
|
||||
}
|
||||
|
||||
|
||||
public Result wxBusinessLogin(String openId,String shopId){
|
||||
TbUserShopMsg shopMsg= tbUserShopMsgMapper.selectByPrimaryKey(Integer.valueOf(shopId));
|
||||
if(Objects.isNull(shopMsg)){
|
||||
shopMsg=new TbUserShopMsg();
|
||||
|
||||
shopMsg.setShopId(Integer.valueOf(shopId));
|
||||
shopMsg.setOpenId(openId);
|
||||
shopMsg.setCreateTime(new Date());
|
||||
shopMsg.setStatus("1");
|
||||
|
||||
|
||||
tbUserShopMsgMapper.insert(shopMsg);
|
||||
}else {
|
||||
shopMsg.setOpenId(openId);
|
||||
shopMsg.setUpdateTime(new Date());
|
||||
tbUserShopMsgMapper.updateByPrimaryKey(shopMsg);
|
||||
}
|
||||
// 为商家绑定openid
|
||||
if (shopOpenIdMapper.countByOpenId(openId) == null) {
|
||||
TbShopOpenId shopOpenId = new TbShopOpenId();
|
||||
shopOpenId.setOpenId(openId);
|
||||
shopOpenId.setCreateTime(DateUtil.date());
|
||||
shopOpenId.setShopId(Integer.valueOf(shopId));
|
||||
shopOpenId.setStatus(1);
|
||||
shopOpenIdMapper.insert(shopOpenId);
|
||||
}
|
||||
return Result.success(CodeEnum.SUCCESS,shopMsg);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result wxCustomLogin(String openId, String headImage, String nickName, String telephone, String ip) throws Exception {
|
||||
TbUserInfo userInfo = new TbUserInfo();
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.HomeDto;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.*;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.*;
|
||||
@@ -433,4 +434,35 @@ public class ProductService {
|
||||
}
|
||||
return Result.success(CodeEnum.SUCCESS, confirmVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 库存修改
|
||||
*
|
||||
* @param tbProduct 商品
|
||||
* @param tbProductSkuWithBLOBs sku
|
||||
* @param buyNum 购买数量
|
||||
*/
|
||||
public void updateStock(TbProduct tbProduct, TbProductSkuWithBLOBs tbProductSkuWithBLOBs, Integer buyNum) {
|
||||
if (tbProduct.getIsDistribute() == 1) {
|
||||
if (tbProductMapper.decrStock(String.valueOf(tbProduct.getId()), buyNum) < 1) {
|
||||
throw new MsgException("库存修改失败,请稍后再试");
|
||||
}
|
||||
}else {
|
||||
if (tbProductSkuMapper.decrStock(String.valueOf(tbProductSkuWithBLOBs.getId()), buyNum) < 1) {
|
||||
throw new MsgException("库存修改失败,请稍后再试");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateStock(String id, Integer skuId, Integer buyNum, boolean isDistribute) {
|
||||
if (isDistribute) {
|
||||
if (tbProductMapper.decrStock(String.valueOf(id), buyNum) < 1) {
|
||||
throw new MsgException("库存不足,下单失败");
|
||||
}
|
||||
}else {
|
||||
if (tbProductSkuMapper.decrStock(String.valueOf(skuId), buyNum) < 1) {
|
||||
throw new MsgException("库存不足,下单失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class FeieyunPrintUtil {
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.chaozhanggui.system.cashierservice.util;
|
||||
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Slf4j
|
||||
public class LockUtils {
|
||||
|
||||
public static<T> T runFunAndCheckKey(Supplier<T> supplier, RedisTemplate<String, Object> redisTemplate, String lockKey) {
|
||||
try{
|
||||
// 创建线程id, 用作判断
|
||||
String clientId = UUID.randomUUID().toString();
|
||||
// 设置分布式锁
|
||||
boolean lock = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent(lockKey, clientId, 30, TimeUnit.SECONDS));
|
||||
int count = 0;
|
||||
while (!lock) {
|
||||
if (count++ > 100) {
|
||||
throw new RuntimeException("系统繁忙, 稍后再试");
|
||||
}
|
||||
Thread.sleep(20);
|
||||
lock = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent(lockKey, clientId, 30, TimeUnit.SECONDS));
|
||||
}
|
||||
return supplier.get();
|
||||
} catch (Exception e){
|
||||
log.info("执行出错:{}", e.getMessage());
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}finally{
|
||||
redisTemplate.delete(lockKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,10 @@ public class PrinterUtils {
|
||||
|
||||
sb.append("<C><B>"+detailPO.getMerchantName()+"</B></C><BR><BR>");
|
||||
sb.append("<C><BOLD>"+type+"【"+detailPO.getMasterId()+"】</BOLD></C><BR><BR>");
|
||||
sb.append("<CB><BOLD>"+detailPO.getOutNumber()+"</BOLD></CB><BR><BR>");
|
||||
if(Objects.nonNull(detailPO.getOutNumber())){
|
||||
sb.append("<CB><BOLD>"+detailPO.getOutNumber()+"</BOLD></CB><BR><BR>");
|
||||
}
|
||||
|
||||
sb.append("<S><L>订单号: "+detailPO.getOrderNo()+" </L></S><BR>");
|
||||
sb.append("<S><L>交易时间: "+detailPO.getTradeDate()+" </L></S><BR>");
|
||||
sb.append("<S><L>收银员: "+detailPO.getOperator()+" </L></S><BR><BR><BR>");
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
package com.chaozhanggui.system.cashierservice.wxUtil;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.util.HttpClientUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class WechatUtil {
|
||||
|
||||
public static JSONObject getSessionKeyOrOpenId(String code, String appId, String secrete) {
|
||||
@@ -70,4 +77,87 @@ public class WechatUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Value("${wx.msg.appId}")
|
||||
private String appId;
|
||||
|
||||
@Value("${wx.msg.secrete}")
|
||||
private String secrete;
|
||||
|
||||
@Value("${wx.msg.warnMsgTmpId}")
|
||||
private String msgTmpId;
|
||||
|
||||
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
|
||||
|
||||
static {
|
||||
|
||||
linkedHashMap.put("40001","获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口");
|
||||
linkedHashMap.put("40003","不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID");
|
||||
linkedHashMap.put("40014","不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口");
|
||||
linkedHashMap.put("40037","不合法的 template_id");
|
||||
linkedHashMap.put("43101","用户未订阅消息");
|
||||
linkedHashMap.put("43107","订阅消息能力封禁");
|
||||
linkedHashMap.put("43108","并发下发消息给同一个粉丝");
|
||||
linkedHashMap.put("45168","命中敏感词");
|
||||
linkedHashMap.put("47003","参数错误");
|
||||
|
||||
}
|
||||
|
||||
public JSONObject getAccessToken(){
|
||||
String requestUrl = "https://api.weixin.qq.com/cgi-bin/token";
|
||||
Map<String, String> requestUrlParam = new HashMap<>();
|
||||
//小程序appId
|
||||
requestUrlParam.put("appid", appId);
|
||||
//小程序secret
|
||||
requestUrlParam.put("secret", secrete);
|
||||
//默认参数
|
||||
requestUrlParam.put("grant_type", "client_credential");
|
||||
JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doGet(requestUrl,requestUrlParam));
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
public JSONObject sendStockWarnMsg(String shopName, String productName, String stock, String note, String toUserOpenId) {
|
||||
Map<String, Object> data = new HashMap<String, Object>() {{
|
||||
put("thing1", new HashMap<String, Object>(){{
|
||||
put("value", shopName);
|
||||
}});
|
||||
put("thing6", new HashMap<String, Object>(){{
|
||||
put("value", productName);
|
||||
}});
|
||||
put("number7", new HashMap<String, Object>(){{
|
||||
put("value", stock);
|
||||
}});
|
||||
put("thing5", new HashMap<String, Object>(){{
|
||||
put("value", note);
|
||||
}});
|
||||
}};
|
||||
log.info("开始发送库存预警消息, 接收用户openId: {}, 消息数据: {}", toUserOpenId, data);
|
||||
return sendTempMsg(msgTmpId, toUserOpenId, data);
|
||||
}
|
||||
|
||||
|
||||
public JSONObject sendTempMsg(String tempId, String toUserOpenId, Map<String, Object> data) {
|
||||
log.info("开始发送微信模板消息, 接收用户openId: {}, 消息数据: {}", toUserOpenId, data);
|
||||
JSONObject object= getAccessToken();
|
||||
String accessToken=object.get("access_token")+"";
|
||||
|
||||
JSONObject object1=new JSONObject();
|
||||
|
||||
object1.put("template_id", tempId);
|
||||
object1.put("touser", toUserOpenId);
|
||||
object1.put("data",data);
|
||||
|
||||
object1.put("miniprogram_state","trial");
|
||||
object1.put("lang","zh_CN");
|
||||
|
||||
String response= HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=".concat(accessToken)).body(object1.toString()).execute().body();
|
||||
log.info("微信模板消息发送成功,相应内容:{}",response);
|
||||
JSONObject resObj=JSONObject.parseObject(response);
|
||||
if(ObjectUtil.isNotEmpty(resObj)&&ObjectUtil.isNotNull(resObj)&&"0".equals(resObj.get("errcode")+"")){
|
||||
return resObj;
|
||||
}
|
||||
|
||||
throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,12 +40,6 @@ spring:
|
||||
port: 5672
|
||||
username: admin
|
||||
password: Czg666888
|
||||
#分页配置
|
||||
pagehelper:
|
||||
supportMethodsArguments: true
|
||||
reasonable: true
|
||||
helperDialect: mysql
|
||||
params: count=countSql
|
||||
|
||||
mybatis:
|
||||
configuration:
|
||||
@@ -65,6 +59,9 @@ server:
|
||||
port: 9888
|
||||
prod: dev1
|
||||
queue: cart_queue_putdev1
|
||||
subscribe:
|
||||
message:
|
||||
miniprogramState: trial
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -37,12 +37,7 @@ spring:
|
||||
port: 5672
|
||||
username: admin
|
||||
password: Czg666888
|
||||
#分页配置
|
||||
pagehelper:
|
||||
supportMethodsArguments: true
|
||||
reasonable: true
|
||||
helperDialect: mysql
|
||||
params: count=countSql
|
||||
|
||||
|
||||
mybatis:
|
||||
configuration:
|
||||
|
||||
@@ -39,12 +39,6 @@ spring:
|
||||
port: 5672
|
||||
username: admin
|
||||
password: Czg666888
|
||||
#分页配置
|
||||
pagehelper:
|
||||
supportMethodsArguments: true
|
||||
reasonable: true
|
||||
helperDialect: mysql
|
||||
params: count=countSql
|
||||
|
||||
mybatis:
|
||||
configuration:
|
||||
|
||||
@@ -39,12 +39,6 @@ spring:
|
||||
port: 5672
|
||||
username: admin
|
||||
password: Czg666888
|
||||
#分页配置
|
||||
pagehelper:
|
||||
supportMethodsArguments: true
|
||||
reasonable: true
|
||||
helperDialect: mysql
|
||||
params: count=countSql
|
||||
|
||||
mybatis:
|
||||
configuration:
|
||||
@@ -62,6 +56,9 @@ thirdPay:
|
||||
callFSTBack: https://cashier.sxczgkj.cn${server.servlet.context-path}notify/notifyfstCallBack
|
||||
prod: prod1
|
||||
queue: cart_queue_putprod1
|
||||
subscribe:
|
||||
message:
|
||||
miniprogramState: formal
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -39,12 +39,6 @@ spring:
|
||||
port: 5672
|
||||
username: admin
|
||||
password: Czg666888
|
||||
#分页配置
|
||||
pagehelper:
|
||||
supportMethodsArguments: true
|
||||
reasonable: true
|
||||
helperDialect: mysql
|
||||
params: count=countSql
|
||||
|
||||
mybatis:
|
||||
configuration:
|
||||
|
||||
@@ -37,12 +37,6 @@ spring:
|
||||
port: 5672
|
||||
username: admin
|
||||
password: Czg666888
|
||||
#分页配置
|
||||
pagehelper:
|
||||
supportMethodsArguments: true
|
||||
reasonable: true
|
||||
helperDialect: mysql
|
||||
params: count=countSql
|
||||
|
||||
mybatis:
|
||||
configuration:
|
||||
|
||||
@@ -5,8 +5,8 @@ server:
|
||||
wx:
|
||||
login:
|
||||
business:
|
||||
appId:
|
||||
secrete:
|
||||
appId: wxcf0fe8cdba153fd6
|
||||
secrete: c33e06467c6879a62af633d50ed6b720
|
||||
custom:
|
||||
appId: wxd88fffa983758a30
|
||||
secrete: a34a61adc0602118b49400baa8812454
|
||||
@@ -15,6 +15,10 @@ wx:
|
||||
# 卓尔
|
||||
# appId: wx0dcea6001b0a8fb4
|
||||
# secrete: ba42423cce61f93f02519ff3030ceb1c
|
||||
msg:
|
||||
appId: wxcf0fe8cdba153fd6
|
||||
secrete: c33e06467c6879a62af633d50ed6b720
|
||||
warnMsgTmpId: IZ-l9p9yBgcvhRR0uN6cBQPkWJ5i05zyWMkfeCPaAmY
|
||||
#
|
||||
spring:
|
||||
profiles:
|
||||
@@ -34,7 +38,12 @@ netty:
|
||||
parent-group-threads: 10
|
||||
# 客户端的线程数
|
||||
child-group-threads: 10
|
||||
|
||||
#分页配置
|
||||
pagehelper:
|
||||
supportMethodsArguments: true
|
||||
reasonable: false
|
||||
helperDialect: mysql
|
||||
params: count=countSql
|
||||
logging:
|
||||
level:
|
||||
# web日志
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
<result column="tax_config_id" jdbcType="VARCHAR" property="taxConfigId" />
|
||||
<result column="spec_table_headers" jdbcType="VARCHAR" property="specTableHeaders" />
|
||||
<result column="group_category_id" jdbcType="VARCHAR" property="groupCategoryId" />
|
||||
<result column="stock_number" jdbcType="INTEGER" property="stockNumber" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs">
|
||||
<result column="images" jdbcType="LONGVARCHAR" property="images" />
|
||||
@@ -73,21 +74,21 @@
|
||||
<result column="select_spec" jdbcType="LONGVARCHAR" property="selectSpec" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, category_id, spec_id, source_path, brand_id, merchant_id, shop_id, name, short_title,
|
||||
id, category_id, spec_id, source_path, brand_id, merchant_id, shop_id, name, short_title,
|
||||
type, pack_fee, low_price, low_member_price, unit_id, unit_snap, cover_img, share_img, images,
|
||||
video_cover_img, sort, limit_number, product_score, status, fail_msg, is_recommend,
|
||||
is_hot, is_new, is_on_sale, is_show, type_enum, is_distribute, is_del, is_stock,
|
||||
is_pause_sale, is_free_freight, freight_id, strategy_type, strategy_id, is_vip, is_delete,
|
||||
created_at, updated_at, base_sales_number, real_sales_number, sales_number, thumb_count,
|
||||
store_count, furnish_meal, furnish_express, furnish_draw, furnish_vir, is_combo,
|
||||
is_show_cash, is_show_mall, is_need_examine, show_on_mall_status, show_on_mall_time,
|
||||
show_on_mall_error_msg, enable_label, tax_config_id, spec_table_headers,group_category_id
|
||||
video_cover_img, sort, limit_number, product_score, status, fail_msg, is_recommend,
|
||||
is_hot, is_new, is_on_sale, is_show, type_enum, is_distribute, is_del, is_stock,
|
||||
is_pause_sale, is_free_freight, freight_id, strategy_type, strategy_id, is_vip, is_delete,
|
||||
created_at, updated_at, base_sales_number, real_sales_number, sales_number, thumb_count,
|
||||
store_count, furnish_meal, furnish_express, furnish_draw, furnish_vir, is_combo,
|
||||
is_show_cash, is_show_mall, is_need_examine, show_on_mall_status, show_on_mall_time,
|
||||
show_on_mall_error_msg, enable_label, tax_config_id, spec_table_headers,group_category_id,stock_number
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
images, video, notice, group_snap, spec_info, select_spec
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="ResultMapWithBLOBs">
|
||||
select
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
,
|
||||
<include refid="Blob_Column_List" />
|
||||
@@ -99,51 +100,53 @@
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs">
|
||||
insert into tb_product (id, category_id, spec_id,
|
||||
source_path, brand_id, merchant_id,
|
||||
shop_id, name, short_title,
|
||||
type, pack_fee, low_price,
|
||||
low_member_price, unit_id, unit_snap,
|
||||
cover_img, share_img, video_cover_img,
|
||||
sort, limit_number, product_score,
|
||||
status, fail_msg, is_recommend,
|
||||
is_hot, is_new, is_on_sale,
|
||||
is_show, type_enum, is_distribute,
|
||||
is_del, is_stock, is_pause_sale,
|
||||
is_free_freight, freight_id, strategy_type,
|
||||
strategy_id, is_vip, is_delete,
|
||||
created_at, updated_at, base_sales_number,
|
||||
real_sales_number, sales_number, thumb_count,
|
||||
store_count, furnish_meal, furnish_express,
|
||||
furnish_draw, furnish_vir, is_combo,
|
||||
is_show_cash, is_show_mall, is_need_examine,
|
||||
show_on_mall_status, show_on_mall_time, show_on_mall_error_msg,
|
||||
enable_label, tax_config_id, spec_table_headers,
|
||||
images, video, notice,
|
||||
group_snap, spec_info, select_spec
|
||||
insert into tb_product (id, category_id, spec_id,
|
||||
source_path, brand_id, merchant_id,
|
||||
shop_id, name, short_title,
|
||||
type, pack_fee, low_price,
|
||||
low_member_price, unit_id, unit_snap,
|
||||
cover_img, share_img, video_cover_img,
|
||||
sort, limit_number, product_score,
|
||||
status, fail_msg, is_recommend,
|
||||
is_hot, is_new, is_on_sale,
|
||||
is_show, type_enum, is_distribute,
|
||||
is_del, is_stock, is_pause_sale,
|
||||
is_free_freight, freight_id, strategy_type,
|
||||
strategy_id, is_vip, is_delete,
|
||||
created_at, updated_at, base_sales_number,
|
||||
real_sales_number, sales_number, thumb_count,
|
||||
store_count, furnish_meal, furnish_express,
|
||||
furnish_draw, furnish_vir, is_combo,
|
||||
is_show_cash, is_show_mall, is_need_examine,
|
||||
show_on_mall_status, show_on_mall_time, show_on_mall_error_msg,
|
||||
enable_label, tax_config_id, spec_table_headers,
|
||||
images, video, notice,
|
||||
group_snap, spec_info, select_spec,group_category_id,stock_number
|
||||
)
|
||||
values (#{id,jdbcType=INTEGER}, #{categoryId,jdbcType=VARCHAR}, #{specId,jdbcType=INTEGER},
|
||||
#{sourcePath,jdbcType=VARCHAR}, #{brandId,jdbcType=INTEGER}, #{merchantId,jdbcType=VARCHAR},
|
||||
#{shopId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{shortTitle,jdbcType=VARCHAR},
|
||||
#{type,jdbcType=VARCHAR}, #{packFee,jdbcType=DECIMAL}, #{lowPrice,jdbcType=DECIMAL},
|
||||
#{lowMemberPrice,jdbcType=DECIMAL}, #{unitId,jdbcType=VARCHAR}, #{unitSnap,jdbcType=VARCHAR},
|
||||
#{coverImg,jdbcType=VARCHAR}, #{shareImg,jdbcType=VARCHAR}, #{videoCoverImg,jdbcType=VARCHAR},
|
||||
#{sort,jdbcType=INTEGER}, #{limitNumber,jdbcType=INTEGER}, #{productScore,jdbcType=INTEGER},
|
||||
#{status,jdbcType=TINYINT}, #{failMsg,jdbcType=VARCHAR}, #{isRecommend,jdbcType=TINYINT},
|
||||
#{isHot,jdbcType=TINYINT}, #{isNew,jdbcType=TINYINT}, #{isOnSale,jdbcType=TINYINT},
|
||||
#{isShow,jdbcType=TINYINT}, #{typeEnum,jdbcType=VARCHAR}, #{isDistribute,jdbcType=TINYINT},
|
||||
#{isDel,jdbcType=TINYINT}, #{isStock,jdbcType=TINYINT}, #{isPauseSale,jdbcType=TINYINT},
|
||||
#{isFreeFreight,jdbcType=TINYINT}, #{freightId,jdbcType=BIGINT}, #{strategyType,jdbcType=VARCHAR},
|
||||
#{strategyId,jdbcType=INTEGER}, #{isVip,jdbcType=TINYINT}, #{isDelete,jdbcType=TINYINT},
|
||||
#{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, #{baseSalesNumber,jdbcType=DOUBLE},
|
||||
#{realSalesNumber,jdbcType=INTEGER}, #{salesNumber,jdbcType=INTEGER}, #{thumbCount,jdbcType=INTEGER},
|
||||
#{storeCount,jdbcType=INTEGER}, #{furnishMeal,jdbcType=INTEGER}, #{furnishExpress,jdbcType=INTEGER},
|
||||
#{furnishDraw,jdbcType=INTEGER}, #{furnishVir,jdbcType=INTEGER}, #{isCombo,jdbcType=TINYINT},
|
||||
#{isShowCash,jdbcType=TINYINT}, #{isShowMall,jdbcType=TINYINT}, #{isNeedExamine,jdbcType=TINYINT},
|
||||
#{showOnMallStatus,jdbcType=TINYINT}, #{showOnMallTime,jdbcType=BIGINT}, #{showOnMallErrorMsg,jdbcType=VARCHAR},
|
||||
#{enableLabel,jdbcType=TINYINT}, #{taxConfigId,jdbcType=VARCHAR}, #{specTableHeaders,jdbcType=VARCHAR},
|
||||
#{images,jdbcType=LONGVARCHAR}, #{video,jdbcType=LONGVARCHAR}, #{notice,jdbcType=LONGVARCHAR},
|
||||
#{groupSnap,jdbcType=LONGVARCHAR}, #{specInfo,jdbcType=LONGVARCHAR}, #{selectSpec,jdbcType=LONGVARCHAR}
|
||||
values (#{id,jdbcType=INTEGER}, #{categoryId,jdbcType=VARCHAR}, #{specId,jdbcType=INTEGER},
|
||||
#{sourcePath,jdbcType=VARCHAR}, #{brandId,jdbcType=INTEGER}, #{merchantId,jdbcType=VARCHAR},
|
||||
#{shopId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{shortTitle,jdbcType=VARCHAR},
|
||||
#{type,jdbcType=VARCHAR}, #{packFee,jdbcType=DECIMAL}, #{lowPrice,jdbcType=DECIMAL},
|
||||
#{lowMemberPrice,jdbcType=DECIMAL}, #{unitId,jdbcType=VARCHAR}, #{unitSnap,jdbcType=VARCHAR},
|
||||
#{coverImg,jdbcType=VARCHAR}, #{shareImg,jdbcType=VARCHAR}, #{videoCoverImg,jdbcType=VARCHAR},
|
||||
#{sort,jdbcType=INTEGER}, #{limitNumber,jdbcType=INTEGER}, #{productScore,jdbcType=INTEGER},
|
||||
#{status,jdbcType=TINYINT}, #{failMsg,jdbcType=VARCHAR}, #{isRecommend,jdbcType=TINYINT},
|
||||
#{isHot,jdbcType=TINYINT}, #{isNew,jdbcType=TINYINT}, #{isOnSale,jdbcType=TINYINT},
|
||||
#{isShow,jdbcType=TINYINT}, #{typeEnum,jdbcType=VARCHAR}, #{isDistribute,jdbcType=TINYINT},
|
||||
#{isDel,jdbcType=TINYINT}, #{isStock,jdbcType=TINYINT}, #{isPauseSale,jdbcType=TINYINT},
|
||||
#{isFreeFreight,jdbcType=TINYINT}, #{freightId,jdbcType=BIGINT}, #{strategyType,jdbcType=VARCHAR},
|
||||
#{strategyId,jdbcType=INTEGER}, #{isVip,jdbcType=TINYINT}, #{isDelete,jdbcType=TINYINT},
|
||||
#{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, #{baseSalesNumber,jdbcType=DOUBLE},
|
||||
#{realSalesNumber,jdbcType=INTEGER}, #{salesNumber,jdbcType=INTEGER}, #{thumbCount,jdbcType=INTEGER},
|
||||
#{storeCount,jdbcType=INTEGER}, #{furnishMeal,jdbcType=INTEGER}, #{furnishExpress,jdbcType=INTEGER},
|
||||
#{furnishDraw,jdbcType=INTEGER}, #{furnishVir,jdbcType=INTEGER}, #{isCombo,jdbcType=TINYINT},
|
||||
#{isShowCash,jdbcType=TINYINT}, #{isShowMall,jdbcType=TINYINT}, #{isNeedExamine,jdbcType=TINYINT},
|
||||
#{showOnMallStatus,jdbcType=TINYINT}, #{showOnMallTime,jdbcType=BIGINT}, #{showOnMallErrorMsg,jdbcType=VARCHAR},
|
||||
#{enableLabel,jdbcType=TINYINT}, #{taxConfigId,jdbcType=VARCHAR}, #{specTableHeaders,jdbcType=VARCHAR},
|
||||
#{images,jdbcType=LONGVARCHAR}, #{video,jdbcType=LONGVARCHAR}, #{notice,jdbcType=LONGVARCHAR},
|
||||
#{groupSnap,jdbcType=LONGVARCHAR}, #{specInfo,jdbcType=LONGVARCHAR}, #{selectSpec,jdbcType=LONGVARCHAR},
|
||||
#{groupCategoryId,jdbcType=VARCHAR},#{stockNumber,jdbcType=INTEGER},
|
||||
#{groupCategoryId,jdbcType=VARCHAR},#{stockNumber,jdbcType=INTEGER}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs">
|
||||
@@ -347,6 +350,12 @@
|
||||
<if test="selectSpec != null">
|
||||
select_spec,
|
||||
</if>
|
||||
<if test="groupCategoryId != null">
|
||||
group_category_id,
|
||||
</if>
|
||||
<if test="stockNumber != null">
|
||||
stock_number,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
@@ -547,6 +556,12 @@
|
||||
<if test="selectSpec != null">
|
||||
#{selectSpec,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="groupCategoryId != null">
|
||||
#{groupCategoryId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="stockNumber != null">
|
||||
#{stockNumber,jdbcType=INTEGER},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs">
|
||||
@@ -747,6 +762,12 @@
|
||||
<if test="selectSpec != null">
|
||||
select_spec = #{selectSpec,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="groupCategoryId != null">
|
||||
group_category_id = #{groupCategoryId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="stockNumber != null">
|
||||
stock_number = #{stockNumber,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
@@ -816,7 +837,9 @@
|
||||
notice = #{notice,jdbcType=LONGVARCHAR},
|
||||
group_snap = #{groupSnap,jdbcType=LONGVARCHAR},
|
||||
spec_info = #{specInfo,jdbcType=LONGVARCHAR},
|
||||
select_spec = #{selectSpec,jdbcType=LONGVARCHAR}
|
||||
select_spec = #{selectSpec,jdbcType=LONGVARCHAR},
|
||||
group_category_id = #{groupCategoryId,jdbcType=VARCHAR},
|
||||
stock_number = #{stockNumber,jdbcType=INTEGER}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProduct">
|
||||
@@ -879,7 +902,9 @@
|
||||
show_on_mall_error_msg = #{showOnMallErrorMsg,jdbcType=VARCHAR},
|
||||
enable_label = #{enableLabel,jdbcType=TINYINT},
|
||||
tax_config_id = #{taxConfigId,jdbcType=VARCHAR},
|
||||
spec_table_headers = #{specTableHeaders,jdbcType=VARCHAR}
|
||||
spec_table_headers = #{specTableHeaders,jdbcType=VARCHAR},
|
||||
group_category_id = #{groupCategoryId,jdbcType=VARCHAR},
|
||||
stock_number = #{stockNumber,jdbcType=INTEGER}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="upGroupRealSalesNumber">
|
||||
@@ -888,6 +913,12 @@
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
|
||||
<update id="updateStockById">
|
||||
update tb_product
|
||||
set stock_number = stock_number - #{num,jdbcType=INTEGER}
|
||||
where id = #{productId}
|
||||
</update>
|
||||
|
||||
<select id="selectByIdIn" resultMap="BaseResultMap">
|
||||
select *
|
||||
from tb_product
|
||||
@@ -1025,4 +1056,4 @@
|
||||
group by `order`.pro_id
|
||||
ORDER BY number desc
|
||||
</select>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
@@ -23,21 +23,22 @@
|
||||
<result column="second_shared" jdbcType="DECIMAL" property="secondShared" />
|
||||
<result column="created_at" jdbcType="BIGINT" property="createdAt" />
|
||||
<result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
|
||||
<result column="is_pause_sale" jdbcType="INTEGER" property="isPauseSale" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs">
|
||||
<result column="spec_info" jdbcType="LONGVARCHAR" property="specInfo" />
|
||||
<result column="spec_snap" jdbcType="LONGVARCHAR" property="specSnap" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, shop_id, bar_code, product_id, origin_price, cost_price, member_price, meal_price,
|
||||
sale_price, guide_price, strategy_price, stock_number, cover_img, warn_line, weight,
|
||||
volume, real_sales_number, first_shared, second_shared, created_at, updated_at
|
||||
id, shop_id, bar_code, product_id, origin_price, cost_price, member_price, meal_price,
|
||||
sale_price, guide_price, strategy_price, stock_number, cover_img, warn_line, weight,
|
||||
volume, real_sales_number, first_shared, second_shared, created_at, updated_at, is_pause_sale
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
spec_info, spec_snap
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="ResultMapWithBLOBs">
|
||||
select
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
,
|
||||
<include refid="Blob_Column_List" />
|
||||
@@ -54,22 +55,23 @@
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs">
|
||||
insert into tb_product_sku (id, shop_id, bar_code,
|
||||
product_id, origin_price, cost_price,
|
||||
member_price, meal_price, sale_price,
|
||||
guide_price, strategy_price, stock_number,
|
||||
cover_img, warn_line, weight,
|
||||
volume, real_sales_number, first_shared,
|
||||
second_shared, created_at, updated_at,
|
||||
spec_info, spec_snap)
|
||||
values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=VARCHAR}, #{barCode,jdbcType=VARCHAR},
|
||||
#{productId,jdbcType=VARCHAR}, #{originPrice,jdbcType=DECIMAL}, #{costPrice,jdbcType=DECIMAL},
|
||||
#{memberPrice,jdbcType=DECIMAL}, #{mealPrice,jdbcType=DECIMAL}, #{salePrice,jdbcType=DECIMAL},
|
||||
#{guidePrice,jdbcType=DECIMAL}, #{strategyPrice,jdbcType=DECIMAL}, #{stockNumber,jdbcType=DOUBLE},
|
||||
#{coverImg,jdbcType=VARCHAR}, #{warnLine,jdbcType=INTEGER}, #{weight,jdbcType=DOUBLE},
|
||||
#{volume,jdbcType=REAL}, #{realSalesNumber,jdbcType=DOUBLE}, #{firstShared,jdbcType=DECIMAL},
|
||||
#{secondShared,jdbcType=DECIMAL}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT},
|
||||
#{specInfo,jdbcType=LONGVARCHAR}, #{specSnap,jdbcType=LONGVARCHAR})
|
||||
insert into tb_product_sku (id, shop_id, bar_code,
|
||||
product_id, origin_price, cost_price,
|
||||
member_price, meal_price, sale_price,
|
||||
guide_price, strategy_price, stock_number,
|
||||
cover_img, warn_line, weight,
|
||||
volume, real_sales_number, first_shared,
|
||||
second_shared, created_at, updated_at,
|
||||
spec_info, spec_snap, is_pause_sale)
|
||||
values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=VARCHAR}, #{barCode,jdbcType=VARCHAR},
|
||||
#{productId,jdbcType=VARCHAR}, #{originPrice,jdbcType=DECIMAL}, #{costPrice,jdbcType=DECIMAL},
|
||||
#{memberPrice,jdbcType=DECIMAL}, #{mealPrice,jdbcType=DECIMAL}, #{salePrice,jdbcType=DECIMAL},
|
||||
#{guidePrice,jdbcType=DECIMAL}, #{strategyPrice,jdbcType=DECIMAL}, #{stockNumber,jdbcType=DOUBLE},
|
||||
#{coverImg,jdbcType=VARCHAR}, #{warnLine,jdbcType=INTEGER}, #{weight,jdbcType=DOUBLE},
|
||||
#{volume,jdbcType=REAL}, #{realSalesNumber,jdbcType=DOUBLE}, #{firstShared,jdbcType=DECIMAL},
|
||||
#{secondShared,jdbcType=DECIMAL}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT},
|
||||
#{specInfo,jdbcType=LONGVARCHAR}, #{specSnap,jdbcType=LONGVARCHAR}),
|
||||
#{isPauseSale,jdbcType=INTEGER}
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs">
|
||||
insert into tb_product_sku
|
||||
@@ -143,6 +145,9 @@
|
||||
<if test="specSnap != null">
|
||||
spec_snap,
|
||||
</if>
|
||||
<if test="isPauseSale != null">
|
||||
is_pause_sale,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
@@ -214,6 +219,9 @@
|
||||
<if test="specSnap != null">
|
||||
#{specSnap,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="isPauseSale != null">
|
||||
#{isPauseSale,jdbcType=INTEGER},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs">
|
||||
@@ -285,6 +293,9 @@
|
||||
<if test="specSnap != null">
|
||||
spec_snap = #{specSnap,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="isPauseSale != null">
|
||||
is_pause_sale = #{isPauseSale,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
@@ -311,7 +322,8 @@
|
||||
created_at = #{createdAt,jdbcType=BIGINT},
|
||||
updated_at = #{updatedAt,jdbcType=BIGINT},
|
||||
spec_info = #{specInfo,jdbcType=LONGVARCHAR},
|
||||
spec_snap = #{specSnap,jdbcType=LONGVARCHAR}
|
||||
spec_snap = #{specSnap,jdbcType=LONGVARCHAR},
|
||||
is_pause_sale = #{isPauseSale,jdbcType=INTEGER}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductSku">
|
||||
@@ -335,7 +347,8 @@
|
||||
first_shared = #{firstShared,jdbcType=DECIMAL},
|
||||
second_shared = #{secondShared,jdbcType=DECIMAL},
|
||||
created_at = #{createdAt,jdbcType=BIGINT},
|
||||
updated_at = #{updatedAt,jdbcType=BIGINT}
|
||||
updated_at = #{updatedAt,jdbcType=BIGINT},
|
||||
is_pause_sale = #{isPauseSale,jdbcType=INTEGER}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateStockById">
|
||||
@@ -431,4 +444,4 @@
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
91
src/main/resources/mapper/TbShopOpenIdMapper.xml
Normal file
91
src/main/resources/mapper/TbShopOpenIdMapper.xml
Normal file
@@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbShopOpenIdMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbShopOpenId">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
|
||||
<result property="openId" column="open_id" jdbcType="VARCHAR"/>
|
||||
<result property="status" column="status" jdbcType="TINYINT"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,shop_id,open_id,
|
||||
status,create_time,update_time
|
||||
</sql>
|
||||
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from tb_shop_open_id
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||
delete from tb_shop_open_id
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopOpenId" useGeneratedKeys="true">
|
||||
insert into tb_shop_open_id
|
||||
( id,shop_id,open_id
|
||||
,status,create_time,update_time
|
||||
)
|
||||
values (#{id,jdbcType=INTEGER},#{shopId,jdbcType=INTEGER},#{openId,jdbcType=VARCHAR}
|
||||
,#{status,jdbcType=TINYINT},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopOpenId" useGeneratedKeys="true">
|
||||
insert into tb_shop_open_id
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="shopId != null">shop_id,</if>
|
||||
<if test="openId != null">open_id,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id,jdbcType=INTEGER},</if>
|
||||
<if test="shopId != null">#{shopId,jdbcType=INTEGER},</if>
|
||||
<if test="openId != null">#{openId,jdbcType=VARCHAR},</if>
|
||||
<if test="status != null">#{status,jdbcType=TINYINT},</if>
|
||||
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
|
||||
<if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopOpenId">
|
||||
update tb_shop_open_id
|
||||
<set>
|
||||
<if test="shopId != null">
|
||||
shop_id = #{shopId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="openId != null">
|
||||
open_id = #{openId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopOpenId">
|
||||
update tb_shop_open_id
|
||||
set
|
||||
shop_id = #{shopId,jdbcType=INTEGER},
|
||||
open_id = #{openId,jdbcType=VARCHAR},
|
||||
status = #{status,jdbcType=TINYINT},
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
update_time = #{updateTime,jdbcType=TIMESTAMP}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
||||
106
src/main/resources/mapper/TbUserShopMsgMapper.xml
Normal file
106
src/main/resources/mapper/TbUserShopMsgMapper.xml
Normal file
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbUserShopMsgMapper">
|
||||
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
|
||||
<id column="shop_id" jdbcType="INTEGER" property="shopId" />
|
||||
<result column="open_id" jdbcType="VARCHAR" property="openId" />
|
||||
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
||||
<result column="status" jdbcType="VARCHAR" property="status" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
shop_id, open_id, remark, status, create_time, update_time
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from tb_user_shop_msg
|
||||
where shop_id = #{shopId,jdbcType=INTEGER}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from tb_user_shop_msg
|
||||
where shop_id = #{shopId,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
|
||||
insert into tb_user_shop_msg (shop_id, open_id, remark,
|
||||
status, create_time, update_time
|
||||
)
|
||||
values (#{shopId,jdbcType=INTEGER}, #{openId,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
|
||||
#{status,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
|
||||
insert into tb_user_shop_msg
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="shopId != null">
|
||||
shop_id,
|
||||
</if>
|
||||
<if test="openId != null">
|
||||
open_id,
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
remark,
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="shopId != null">
|
||||
#{shopId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="openId != null">
|
||||
#{openId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
#{remark,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
#{status,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
|
||||
update tb_user_shop_msg
|
||||
<set>
|
||||
<if test="openId != null">
|
||||
open_id = #{openId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
remark = #{remark,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</set>
|
||||
where shop_id = #{shopId,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg">
|
||||
update tb_user_shop_msg
|
||||
set open_id = #{openId,jdbcType=VARCHAR},
|
||||
remark = #{remark,jdbcType=VARCHAR},
|
||||
status = #{status,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
update_time = #{updateTime,jdbcType=TIMESTAMP}
|
||||
where shop_id = #{shopId,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user