修改耗材库存

This commit is contained in:
韩鹏辉
2024-06-28 09:39:14 +08:00
parent e91636a188
commit 75ec8fc9e5
36 changed files with 788 additions and 83 deletions

View File

@@ -1,6 +1,7 @@
package com.chaozhanggui.system.cashierservice;
import com.chaozhanggui.system.cashierservice.task.ConsInfoTask;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,6 +45,7 @@ public class Shell {
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
return (args) -> {
// ctx.getBean(ConsInfoTask.class).init();
logger.info("=========================启动完成==========================");
};
}

View File

@@ -0,0 +1,125 @@
package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.dao.TbUserShopMsgMapper;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
import me.chanjar.weixin.mp.api.WxMpQrcodeService;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.util.*;
@CrossOrigin(origins = "*")
@RestController
@Slf4j
@RequestMapping("qrcode")
public class QrCodeController {
@Autowired
TbUserShopMsgMapper tbUserShopMsgMapper;
// public Result scanCode(){
//
// }
@RequestMapping("/getscanCode")
public void getscanCode(HttpServletRequest request, HttpServletResponse response) throws Exception {
log.info("****************来自微信服务器的请求:{}", request.getMethod().toUpperCase());
//微信服务器POST请求时,用的是UTF-8编码,在接收时也要用同样的编码,否则中文乱码
request.setCharacterEncoding("UTF-8");
//响应消息时,也要设置同样的编码
response.setCharacterEncoding("UTF-8");
//判断请求方式是否是post
boolean isPost = Objects.equals("POST", request.getMethod().toUpperCase());
if(isPost){
Map map= request.getParameterMap();
log.info("map:{}",JSONUtil.toJSONString(map));
}else {
String signature=request.getParameter("signature");
String timestamp=request.getParameter("timestamp");
String nonce=request.getParameter("nonce");
String echostr=request.getParameter("echostr");
if (StringUtils.isEmpty(signature) || StringUtils.isEmpty(timestamp) || StringUtils.isEmpty(nonce) || StringUtils.isEmpty(echostr)) {
return ;
}
String token="chaozhanggui123";
List<String> list= Arrays.asList(token,timestamp,nonce);
Collections.sort(list);
StringBuffer sb=new StringBuffer();
for(String s: list){
sb.append(s);
}
try {
MessageDigest instance = MessageDigest.getInstance("sha1");
//使用sha1进行加密获得byte数组
byte[] digest = instance.digest(sb.toString().getBytes());
StringBuilder sum = new StringBuilder();
for (byte b : digest) {
sum.append(Integer.toHexString((b >> 4) & 15));
sum.append(Integer.toHexString(b & 15));
}
// 3开发者获得加密后的字符串可与 signature 对比,标识该请求来源于微信
if (!StringUtils.isEmpty(signature) && signature.equals(sum.toString())) {
response.getWriter().write(echostr);
return;
}
response.getWriter().write("");
return;
}catch (Exception e){
e.printStackTrace();
}
response.getWriter().write("");
return;
}
}
public static void main(String[] args){
WxMpInMemoryConfigStorage configStorage=new WxMpInMemoryConfigStorage();
configStorage.setAppId("wxdd2b72cc2c40c979");
configStorage.setSecret("4d909d8dbe3e6e7ac31055fa03dcee4b");
// configStorage.setAccessToken("");
// configStorage.setAesKey("");
WxMpService wxMpService=new WxMpServiceImpl();
wxMpService.setWxMpConfigStorage(configStorage);
try {
WxMpQrCodeTicket ticket= wxMpService.getQrcodeService().qrCodeCreateLastTicket("哈哈哈哈哈哈哈哈哈哈哈哈");
System.out.println(JSONUtil.toJSONString(ticket));
} catch (WxErrorException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -2,12 +2,14 @@ package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbConsInfo;
import com.chaozhanggui.system.cashierservice.entity.po.ConsInfoPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Mapper
public interface TbConsInfoMapper {
int deleteByPrimaryKey(Integer id);
@@ -22,4 +24,7 @@ public interface TbConsInfoMapper {
int updateByPrimaryKey(TbConsInfo record);
void batchStock(@Param("list")List<ConsInfoPO> list);
int countAll();
List<TbConsInfo> selectAllInfo();
}

View File

@@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbProduct;
import com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs;
import com.chaozhanggui.system.cashierservice.entity.po.ProConsSkuInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
@@ -37,4 +38,7 @@ public interface TbProductMapper {
Integer countOrderByshopIdAndProductId(@Param("shopId") String shopId, @Param("productId") String productId, @Param("masterId") String masterId,@Param("day") String day);
void updateStockById(@Param("productId")Integer productId, @Param("num")Integer num);
List<ProConsSkuInfo> selectBySkuId(Integer skuId);
}

View File

@@ -22,5 +22,13 @@ public interface TbProskuConMapper {
int updateByPrimaryKey(TbProskuCon record);
List<TbProskuCon> selectBySkuIdAndShopId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId);
List<Integer> selectIdBySkuIdAndShopId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId);
}

View File

@@ -21,10 +21,10 @@ public class TbConsInfo implements Serializable {
private String conUnit;
private BigDecimal surplusStock;
private BigDecimal lasterInStock;
private BigDecimal conWarning;
private Date createTime;
private Date updateTime;
@@ -95,14 +95,6 @@ public class TbConsInfo implements Serializable {
this.conUnit = conUnit == null ? null : conUnit.trim();
}
public BigDecimal getSurplusStock() {
return surplusStock;
}
public void setSurplusStock(BigDecimal surplusStock) {
this.surplusStock = surplusStock;
}
public BigDecimal getLasterInStock() {
return lasterInStock;
}
@@ -111,6 +103,14 @@ public class TbConsInfo implements Serializable {
this.lasterInStock = lasterInStock;
}
public BigDecimal getConWarning() {
return conWarning;
}
public void setConWarning(BigDecimal conWarning) {
this.conWarning = conWarning;
}
public Date getCreateTime() {
return createTime;
}

View File

@@ -1,6 +1,7 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
public class TbProskuCon implements Serializable {
@@ -12,6 +13,8 @@ public class TbProskuCon implements Serializable {
private Integer conInfoId;
private BigDecimal surplusStock;
private String status;
private Date createTime;
@@ -50,6 +53,14 @@ public class TbProskuCon implements Serializable {
this.conInfoId = conInfoId;
}
public BigDecimal getSurplusStock() {
return surplusStock;
}
public void setSurplusStock(BigDecimal surplusStock) {
this.surplusStock = surplusStock;
}
public String getStatus() {
return status;
}

View File

@@ -0,0 +1,35 @@
package com.chaozhanggui.system.cashierservice.entity.po;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class ProConsSkuInfo implements Serializable {
private String shopId;
private String productSkuId;
private String status;
private String conId;
private String conCode;
private String conName;
private BigDecimal surplusStock;
private BigDecimal stockNumber;
private BigDecimal conWarning;
private String productId;
private String productName;
private String specSnap;
}

View File

@@ -23,6 +23,7 @@ public class WebAppConfigurer implements WebMvcConfigurer {
.excludePathPatterns("/data/handoverData")
.excludePathPatterns("/order/scanSendMessage")
.excludePathPatterns("/order/getsendMessage")
.excludePathPatterns("/qrcode/getscanCode")
.excludePathPatterns("/order/sendMessage");
}
}

View File

@@ -1,15 +1,6 @@
package com.chaozhanggui.system.cashierservice.rabbit;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.TbCashierCartMapper;
import com.chaozhanggui.system.cashierservice.dao.TbConsInfoMapper;
import com.chaozhanggui.system.cashierservice.dao.TbProskuConMapper;
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
import com.chaozhanggui.system.cashierservice.entity.TbConsInfo;
import com.chaozhanggui.system.cashierservice.entity.TbProskuCon;
import com.chaozhanggui.system.cashierservice.entity.po.ConsInfoPO;
import com.chaozhanggui.system.cashierservice.service.ConsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
@@ -18,13 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@Slf4j
@Component
@RabbitListener(queues = {RabbitConstants.CONS_COLLECT_QUEUE_PUT})

View File

@@ -0,0 +1,236 @@
package com.chaozhanggui.system.cashierservice.rabbit;
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.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.util.HttpClientUtil;
import com.chaozhanggui.system.cashierservice.util.N;
import com.chaozhanggui.system.cashierservice.util.RedisCst;
import com.chaozhanggui.system.cashierservice.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Slf4j
@Component
@RabbitListener(queues = {RabbitConstants.CONS_MSG_COLLECT_QUEUE_PUT})
@Service
public class ConsMsgConsumer {
@Autowired
TbConsInfoMapper tbConsInfoMapper;
@Autowired
TbUserShopMsgMapper tbUserShopMsgMapper;
@Autowired
TbShopInfoMapper tbShopInfoMapper;
@Autowired
TbProductSkuMapper tbProductSkuMapper;
@Autowired
TbProskuConMapper tbProskuConMapper;
@Autowired
TbProductMapper tbProductMapper;
@Autowired
RedisUtil redisUtil;
@Value("${wx.msg.appId}")
private String appId;
@Value("${wx.msg.secrete}")
private String secrete;
@Value("${subscribe.message.miniprogramState}")
private String miniprogramState;
@RabbitHandler
public void listener(String message) {
JSONObject object = JSONObject.parseObject(message);
if (Objects.isNull(object) || !object.containsKey("skuId") || !object.containsKey("shopId") || Objects.isNull(object.getInteger("skuId")) || Objects.isNull(object.getInteger("shopId"))) {
log.info("接收的信息为空");
return;
}
Integer skuId = object.getInteger("skuId");
Integer shopId = object.getInteger("shopId");
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(shopId);
if (Objects.isNull(shopInfo)) {
log.info("店铺信息不存在");
return;
}
List<TbProskuCon> tbProskuCons = tbProskuConMapper.selectBySkuIdAndShopId(skuId, shopId);
if (Objects.isNull(tbProskuCons) || tbProskuCons.size() <= 0) {
log.info("耗材信息未配置");
return;
}
TbProductSkuWithBLOBs skuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(skuId);
if (Objects.isNull(skuWithBLOBs)) {
log.info("规格信息不存在");
return;
}
TbProductWithBLOBs product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(skuWithBLOBs.getProductId()));
if (Objects.isNull(product)) {
log.info("商品信息不存在");
return;
}
tbProskuCons.parallelStream().forEach(it -> {
TbConsInfo tbConsInfo = tbConsInfoMapper.selectByPrimaryKey(it.getConInfoId());
if (Objects.isNull(tbConsInfo)) {
return;
}
if (Objects.nonNull(tbConsInfo)) {
if (N.gt(tbConsInfo.getConWarning(), tbConsInfo.getStockNumber())) {
String key = redisUtil.getMessage(RedisCst.ORDER_MESSAGE.concat(tbConsInfo.getShopId().toString()).concat("#").concat(tbConsInfo.getId().toString()));
if (Objects.isNull(key)) {
TbUserShopMsg tbUserShopMsg = tbUserShopMsgMapper.selectByPrimaryKey(tbConsInfo.getShopId());
if (Objects.nonNull(tbUserShopMsg) && Objects.nonNull(tbUserShopMsg.getOpenId())) {
JSONObject access_token = getAccessToken();
String accessToken = String.valueOf(access_token.get("access_token"));
JSONObject object1 = new JSONObject();
object1.put("template_id", "IZ-l9p9yBgcvhRR0uN6cBQPkWJ5i05zyWMkfeCPaAmY");
object1.put("touser", tbUserShopMsg.getOpenId());
JSONObject data = new JSONObject();
JSONObject thing1 = new JSONObject();
thing1.put("value", shopInfo.getShopName());
JSONObject thing5 = new JSONObject();
thing5.put("value", "耗材库存不足,请及时补充。");
JSONObject thing6 = new JSONObject();
thing6.put("value", product.getName());
JSONObject thing7 = new JSONObject();
thing7.put("value", tbConsInfo.getStockNumber().toPlainString());
data.put("thing1", thing1);
data.put("thing6", thing6);
data.put("number7", thing7);
data.put("thing5", thing5);
object1.put("data", data);
object1.put("miniprogram_state", miniprogramState);
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(String.valueOf(resObj.get("errcode")))) {
redisUtil.saveMessage(key, object1.toString(),10*60*1000);
}
}
}
}
}
});
}
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("appid", "wxcf0fe8cdba153fd6");
// //小程序secret
// requestUrlParam.put("secret", "c33e06467c6879a62af633d50ed6b720");
//默认参数
requestUrlParam.put("grant_type", "client_credential");
JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doGet(requestUrl, requestUrlParam));
return jsonObject;
}
public static void main(String[] args){
JSONObject access_token = new ConsMsgConsumer().getAccessToken();
String accessToken = String.valueOf(access_token.get("access_token"));
JSONObject object1 = new JSONObject();
object1.put("template_id", "IZ-l9p9yBgcvhRR0uN6cBQPkWJ5i05zyWMkfeCPaAmY");
object1.put("touser", "oeQYq5CAuSpdeX9uZz52DJiSUO9M");
JSONObject data = new JSONObject();
JSONObject thing1 = new JSONObject();
thing1.put("value", "");
JSONObject thing5 = new JSONObject();
thing5.put("value", "耗材库存不足,请及时补充。");
JSONObject thing6 = new JSONObject();
thing6.put("value", "咖啡");
JSONObject thing7 = new JSONObject();
thing7.put("value", "3.2");
data.put("thing1", thing1);
data.put("thing6", thing6);
data.put("number7", thing7);
data.put("thing5", thing5);
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);
}
}

View File

@@ -108,6 +108,22 @@ public class RabbitConfig {
@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(queuePrint_Register()).to(printExchange_Register()).with(RabbitConstants.CONS_MSG_COLLECT_ROUTINGKEY_PUT);
}

View File

@@ -31,4 +31,18 @@ public interface RabbitConstants {
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";
}

View File

@@ -44,6 +44,16 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
}
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);

View File

@@ -1,7 +1,6 @@
package com.chaozhanggui.system.cashierservice.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.TbCashierCartMapper;
import com.chaozhanggui.system.cashierservice.dao.TbConsInfoFlowMapper;
@@ -17,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
@Slf4j
@@ -70,15 +68,15 @@ public class ConsService {
for (TbProskuCon tbProskuCon : tbProskuCons) {
TbConsInfo tbConsInfo= tbConsInfoMapper.selectByPrimaryKey(tbProskuCon.getConInfoId());
if(Objects.nonNull(tbConsInfo)){
ConsInfoPO consInfoPO=new ConsInfoPO(tbConsInfo.getId(),tbConsInfo.getSurplusStock());
ConsInfoPO consInfoPO=new ConsInfoPO(tbConsInfo.getId(),tbProskuCon.getSurplusStock());
consInfoPOS.add(consInfoPO);
TbConsInfoFlow flow=new TbConsInfoFlow();
flow.setConsId(tbConsInfo.getId());
flow.setShopId(tbConsInfo.getShopId());
flow.setConName(tbConsInfo.getConName());
flow.setAmount(tbConsInfo.getSurplusStock());
flow.setBalance(tbConsInfo.getStockNumber().subtract(tbConsInfo.getSurplusStock()));
flow.setAmount(tbProskuCon.getSurplusStock());
flow.setBalance(tbConsInfo.getStockNumber().subtract(tbProskuCon.getSurplusStock()));
flow.setBizCode("createCart");
flow.setBizName("加入购物陈消耗");
flow.setBizType("-");
@@ -121,15 +119,15 @@ public class ConsService {
for (TbProskuCon tbProskuCon : tbProskuCons) {
TbConsInfo tbConsInfo= tbConsInfoMapper.selectByPrimaryKey(tbProskuCon.getConInfoId());
if(Objects.nonNull(tbConsInfo)){
ConsInfoPO consInfoPO=new ConsInfoPO(tbConsInfo.getId(),tbConsInfo.getSurplusStock().negate());
ConsInfoPO consInfoPO=new ConsInfoPO(tbConsInfo.getId(),tbProskuCon.getSurplusStock().negate());
consInfoPOS.add(consInfoPO);
TbConsInfoFlow flow=new TbConsInfoFlow();
flow.setConsId(tbConsInfo.getId());
flow.setShopId(tbConsInfo.getShopId());
flow.setConName(tbConsInfo.getConName());
flow.setAmount(tbConsInfo.getSurplusStock());
flow.setBalance(tbConsInfo.getStockNumber().add(tbConsInfo.getSurplusStock()));
flow.setAmount(tbProskuCon.getSurplusStock());
flow.setBalance(tbConsInfo.getStockNumber().add(tbProskuCon.getSurplusStock()));
flow.setBizCode("cancelCart");
flow.setBizName("取消购物车返回");
flow.setBizType("+");

View File

@@ -75,7 +75,7 @@ public class MemberService {
public Result queryMember(String shopId, String phone, int page, int pageSize) {
PageHelper.startPage(page, pageSize);
PageHelperUtil.startPage(page, pageSize);
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByShopId(shopId, phone);
PageInfo pageInfo = new PageInfo(tbShopUsers);
return Result.success(CodeEnum.SUCCESS, pageInfo);
@@ -619,7 +619,7 @@ public class MemberService {
if (ObjectUtil.isEmpty(memberId)) {
return Result.fail(CodeEnum.PARAM);
}
PageHelper.startPage(page, pageSize);
PageHelperUtil.startPage(page, pageSize);
List<Map<String, Object>> list = tbShopUserFlowMapper.selectByMemberAccountFlow(memberId);
PageInfo pageInfo = new PageInfo(list);
return Result.success(CodeEnum.SUCCESS, pageInfo);

View File

@@ -12,7 +12,6 @@ import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -25,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.CARTEXIST;
@@ -63,6 +63,8 @@ public class OrderService {
@Autowired
RabbitProducer producer;
private static ConcurrentHashMap<String, HashSet<Integer>> codeMap = new ConcurrentHashMap<>();
private static ConcurrentHashMap<String, HashSet<String>> userMap = new ConcurrentHashMap<>();
@@ -106,6 +108,13 @@ public class OrderService {
}
}
JSONObject objectMsg=new JSONObject();
objectMsg.put("skuId",skuWithBLOBs.getId());
objectMsg.put("shopId",shopInfo.getId());
producer.con_msg(objectMsg.toString());
if (StringUtils.isEmpty(masterId)) {
boolean flag = redisUtil.exists("SHOP:CODE:" + clientType + ":" + shopId);
if (flag) {
@@ -755,7 +764,7 @@ public class OrderService {
public Result findOrder(Integer shopId, String status, Integer page, Integer size, String orderNo) {
String day = DateUtils.getDay();
PageHelper.startPage(page, size);
PageHelperUtil.startPage(page, size);
String orderType = "";
if (StringUtils.isNotEmpty(status)) {
if (status.equals("refund")) {
@@ -949,6 +958,9 @@ public class OrderService {
private String secrete;
@Value("${subscribe.message.miniprogramState}")
private String miniprogramState;
public Result sendMassage(String orderId){
if(ObjectUtil.isEmpty(orderId)){
return Result.fail(CodeEnum.ERRMASTER);
@@ -1009,7 +1021,7 @@ public class OrderService {
object1.put("data",data);
object1.put("miniprogram_state","trial");
object1.put("miniprogram_state",miniprogramState);
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();
@@ -1097,7 +1109,7 @@ public class OrderService {
object1.put("data",data);
object1.put("miniprogram_state","trial");
object1.put("miniprogram_state",miniprogramState);
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();
@@ -1130,7 +1142,7 @@ public class OrderService {
public Result getOutNumber(String shopId,Integer page,Integer pageSize){
PageHelper.startPage(page, pageSize);
PageHelperUtil.startPage(page, pageSize);
List<TbOrderOutNumber> list= tbOrderOutNumberMapper.selectAll(shopId);
PageInfo pageInfo=new PageInfo(list);
return Result.success(CodeEnum.SUCCESS,pageInfo);

View File

@@ -1099,7 +1099,7 @@ public class PayService {
String shopId = info.getString("shopId");
String staffId = info.getString("staffId");
PageHelper.startPage(pageNo, pageSize);
PageHelperUtil.startPage(pageNo, pageSize);
List<TbQuickPay> list = tbQuickPayMapper.selectByShopIdAndStaffId(Integer.valueOf(shopId), Integer.valueOf(staffId));

View File

@@ -7,7 +7,7 @@ import com.chaozhanggui.system.cashierservice.entity.vo.ShopCategoryVo;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import com.github.pagehelper.PageHelper;
import com.chaozhanggui.system.cashierservice.util.PageHelperUtil;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -38,14 +38,14 @@ public class ProductService {
public Result queryCategory(String shopId,Integer page,Integer pageSize){
PageHelper.startPage(page, pageSize);
PageHelperUtil.startPage(page, pageSize);
List<TbShopCategory> list=tbShopCategoryMapper.selectByAll(shopId);
PageInfo pageInfo=new PageInfo(list);
return Result.success(CodeEnum.SUCCESS,pageInfo);
}
public Result queryAllCategory(String shopId,Integer page,Integer pageSize){
PageHelper.startPage(page, pageSize);
PageHelperUtil.startPage(page, pageSize);
List<ShopCategoryVo> list=tbShopCategoryMapper.queryAllCategory(shopId);
PageInfo pageInfo=new PageInfo(list);
return Result.success(CodeEnum.SUCCESS,pageInfo);
@@ -94,8 +94,7 @@ public class ProductService {
public Result queryNewCommodityInfo(String shopId, String categoryId, String commdityName, int page, int pageSize, String masterId) {
List<TbProductWithBLOBs> tbProductWithBLOBs=null;
PageHelper.startPage(page,pageSize);
PageHelper.startPage(page,pageSize);
PageHelperUtil.startPage(page,pageSize);
if(ObjectUtil.isEmpty(categoryId)){
tbProductWithBLOBs=tbProductMapper.selectByShopId(shopId,commdityName);
}else {

View File

@@ -7,6 +7,7 @@ import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import com.chaozhanggui.system.cashierservice.util.PageHelperUtil;
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@@ -44,7 +45,7 @@ public class ShopInfoService {
return Result.fail(CodeEnum.PARAM);
}
PageHelper.startPage(page, pageSize);
PageHelperUtil.startPage(page, pageSize);
List<TbShopTable> shopTables=tbShopTableMapper.selectByShopIdAndStatus(shopId,areaId,status);
PageInfo pageInfo=new PageInfo(shopTables);
return Result.success(CodeEnum.SUCCESS,pageInfo);
@@ -64,7 +65,7 @@ public class ShopInfoService {
// ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByShopIdAndTrade(shopId,day);
// List<String> list = shopUserDutyMapper.selectByShopIdAndTradeAll(shopId,day,tbToken.getId());
if (Objects.nonNull(shopUserDuty)){
// PageHelper.startPage(page, pageSize);
// PageHelperUtil.startPage(page, pageSize);
List<ShopUserDutyDetail> shopTables=shopUserDutyDetailMapper.selectAllByDuctId(shopUserDuty.getId());
// PageInfo pageInfo=new PageInfo(shopTables);
shopUserDuty.setDetailList(shopTables);
@@ -82,7 +83,7 @@ public class ShopInfoService {
public Result queryDutyFlow(String token, String shopId, int page, int pageSize) {
// JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
// String userId = jsonObject.getString("accountId");
PageHelper.startPage(page, pageSize);
PageHelperUtil.startPage(page, pageSize);
PageHelper.orderBy("login_out_time desc");
List<ShopUserDuty> list = shopUserDutyMapper.selectByShopId(shopId);
PageInfo pageInfo=new PageInfo(list);

View File

@@ -13,7 +13,7 @@ import com.chaozhanggui.system.cashierservice.entity.vo.ProductVo;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
import com.github.pagehelper.PageHelper;
import com.chaozhanggui.system.cashierservice.util.PageHelperUtil;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -109,7 +109,7 @@ public class TbGroupOrderInfoService {
}
public Result queryByPage(GroupOrderDto param) {
PageHelper.startPage(param.getPage(), param.getSize());
PageHelperUtil.startPage(param.getPage(), param.getSize());
return Result.success(CodeEnum.SUCCESS, new PageInfo(tbGroupOrderInfoMapper.queryList(param)));
}

View File

@@ -8,7 +8,7 @@ import com.chaozhanggui.system.cashierservice.entity.dto.PrintMachineDto;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
import com.github.pagehelper.PageHelper;
import com.chaozhanggui.system.cashierservice.util.PageHelperUtil;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
@@ -60,7 +60,7 @@ public class TbPrintPCMachineService {
* @return 查询结果
*/
public Result queryByPage(TbPrintPCMachine tbPrintMachine) {
PageHelper.startPage(tbPrintMachine.getPage(), tbPrintMachine.getPageSize());
PageHelperUtil.startPage(tbPrintMachine.getPage(), tbPrintMachine.getPageSize());
tbPrintMachine.setContentType("local");
List<TbPrintPCMachine> tbPrintMachines = this.tbPrintMachineMapper.queryAll(tbPrintMachine);

View File

@@ -96,6 +96,9 @@ public enum CodeEnum {
ISNOTAPPORDER("100035",false,"不是小程序订单","fail"),
CONSERROR("100036",false,"商品已售罄","fail"),

View File

@@ -0,0 +1,127 @@
package com.chaozhanggui.system.cashierservice.task;
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.dao.TbConsInfoMapper;
import com.chaozhanggui.system.cashierservice.dao.TbUserShopMsgMapper;
import com.chaozhanggui.system.cashierservice.entity.TbConsInfo;
import com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg;
import com.chaozhanggui.system.cashierservice.util.HttpClientUtil;
import com.chaozhanggui.system.cashierservice.util.N;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@Component
@Slf4j
public class ConsInfoTask {
private ScheduledExecutorService executorService=Executors.newScheduledThreadPool(100);
@Value("${wx.appId}")
private String appId;
@Value("${wx.secrete}")
private String secrete;
@Autowired
TbConsInfoMapper tbConsInfoMapper;
@Autowired
TbUserShopMsgMapper tbUserShopMsgMapper;
public void init(){
executorService.scheduleWithFixedDelay(timerTask(),0,10,TimeUnit.MINUTES);
}
public TimerTask timerTask () {
return new TimerTask() {
@Override
public void run() {
try {
List<TbConsInfo> tbShopInfos= tbConsInfoMapper.selectAllInfo();
if(Objects.nonNull(tbShopInfos)&&tbShopInfos.size()>0){
tbShopInfos.parallelStream().forEach(it->{
if(N.gt(it.getConWarning(),it.getStockNumber())){
TbUserShopMsg tbUserShopMsg=tbUserShopMsgMapper.selectByPrimaryKey(it.getShopId());
if(Objects.nonNull(tbUserShopMsg)&&Objects.nonNull(tbUserShopMsg.getOpenId())){
JSONObject object= getAccessToken();
String accessToken=object.get("access_token")+"";
JSONObject object1=new JSONObject();
object1.put("template_id","BKTcsYHW1xnUaE-CFmF7pOglJH0aLEyW9e4r5nWKUIU");
object1.put("touser",tbUserShopMsg.getOpenId());
JSONObject data=new JSONObject();
JSONObject tabname=new JSONObject();
tabname.put("value",it.getConName());
JSONObject thing21=new JSONObject();
thing21.put("value",it.getStockNumber().toPlainString());
JSONObject thing8=new JSONObject();
thing8.put("value","耗材库存不足,请及时补充。");
data.put("thing1.",tabname);
data.put("thing2",thing21);
data.put("thing3",thing8);
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")+"")){
}
}
}
});
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
}
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;
}
}

View File

@@ -0,0 +1,13 @@
package com.chaozhanggui.system.cashierservice.util;
import com.github.pagehelper.PageHelper;
public class PageHelperUtil {
/**
* 解决页数超限 仍返回数据问题
*/
public static void startPage(int page, int pageSize) {
PageHelper.startPage(page, pageSize, true, false, false);
}
}

View File

@@ -16,4 +16,6 @@ public class RedisCst {
public static final Object PRODUCT = "PRODUCT:";
public static final String OUT_NUMBER="ORDER:NUMBER:";
public static final String ORDER_MESSAGE="ORDER:MESSAGE:";
}

View File

@@ -41,12 +41,20 @@ spring:
port: 5672
username: admin
password: Czg666888
#分页配置
pagehelper:
supportMethodsArguments: true
reasonable: true
helperDialect: mysql
params: count=countSql
mybatis:
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath:mapper/*.xml
subscribe:
message:
miniprogramState: trial

View File

@@ -39,6 +39,12 @@ spring:
port: 5672
username: admin
password: Czg666888
#分页配置
pagehelper:
supportMethodsArguments: true
reasonable: true
helperDialect: mysql
params: count=countSql
mybatis:
configuration:

View File

@@ -42,12 +42,21 @@ spring:
port: 5672
username: admin
password: Czg666888
#分页配置
pagehelper:
supportMethodsArguments: true
reasonable: true
helperDialect: mysql
params: count=countSql
mybatis:
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath:mapper/*.xml
subscribe:
message:
miniprogramState: formal

View File

@@ -42,6 +42,12 @@ spring:
port: 5672
username: admin
password: Czg666888
#分页配置
pagehelper:
supportMethodsArguments: true
reasonable: true
helperDialect: mysql
params: count=countSql
mybatis:
configuration:

View File

@@ -39,6 +39,12 @@ spring:
port: 5672
username: admin
password: Czg666888
#分页配置
pagehelper:
supportMethodsArguments: true
reasonable: true
helperDialect: mysql
params: count=countSql
mybatis:
configuration:

View File

@@ -4,12 +4,6 @@ spring:
server:
servlet:
context-path: /cashier-client/
#分页配置
pagehelper:
supportMethodsArguments: true
reasonable: false
helperDialect: mysql
params: count=countSql
# 日志配置
logging:
level:
@@ -51,6 +45,10 @@ thirdPay:
wx:
appId: wxd88fffa983758a30
secrete: a34a61adc0602118b49400baa8812454
msg:
appId: wxcf0fe8cdba153fd6
secrete: c33e06467c6879a62af633d50ed6b720

View File

@@ -52,6 +52,13 @@
<!-- 要生成的表tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
<!-- <table tableName="%" schema="fycashier" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>-->
<table tableName="tb_cons_info" domainObjectName="TbConsInfo"
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false" >
</table>
<table tableName="tb_prosku_con" domainObjectName="TbProskuCon"
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false" >

View File

@@ -10,14 +10,14 @@
<result column="con_name" jdbcType="VARCHAR" property="conName" />
<result column="stock_number" jdbcType="DECIMAL" property="stockNumber" />
<result column="con_unit" jdbcType="VARCHAR" property="conUnit" />
<result column="surplus_stock" jdbcType="DECIMAL" property="surplusStock" />
<result column="laster_in_stock" jdbcType="DECIMAL" property="lasterInStock" />
<result column="con_warning" jdbcType="DECIMAL" property="conWarning" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
id, shop_id, con_type_id, con_type_name, con_code, con_name, stock_number, con_unit,
surplus_stock, laster_in_stock, create_time, update_time
laster_in_stock, con_warning, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
@@ -32,13 +32,13 @@
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbConsInfo">
insert into tb_cons_info (id, shop_id, con_type_id,
con_type_name, con_code, con_name,
stock_number, con_unit, surplus_stock,
laster_in_stock, create_time, update_time
stock_number, con_unit, laster_in_stock,
con_warning, create_time, update_time
)
values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{conTypeId,jdbcType=INTEGER},
#{conTypeName,jdbcType=VARCHAR}, #{conCode,jdbcType=VARCHAR}, #{conName,jdbcType=VARCHAR},
#{stockNumber,jdbcType=DECIMAL}, #{conUnit,jdbcType=VARCHAR}, #{surplusStock,jdbcType=DECIMAL},
#{lasterInStock,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
#{stockNumber,jdbcType=DECIMAL}, #{conUnit,jdbcType=VARCHAR}, #{lasterInStock,jdbcType=DECIMAL},
#{conWarning,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbConsInfo">
@@ -68,12 +68,12 @@
<if test="conUnit != null">
con_unit,
</if>
<if test="surplusStock != null">
surplus_stock,
</if>
<if test="lasterInStock != null">
laster_in_stock,
</if>
<if test="conWarning != null">
con_warning,
</if>
<if test="createTime != null">
create_time,
</if>
@@ -106,12 +106,12 @@
<if test="conUnit != null">
#{conUnit,jdbcType=VARCHAR},
</if>
<if test="surplusStock != null">
#{surplusStock,jdbcType=DECIMAL},
</if>
<if test="lasterInStock != null">
#{lasterInStock,jdbcType=DECIMAL},
</if>
<if test="conWarning != null">
#{conWarning,jdbcType=DECIMAL},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
@@ -144,12 +144,12 @@
<if test="conUnit != null">
con_unit = #{conUnit,jdbcType=VARCHAR},
</if>
<if test="surplusStock != null">
surplus_stock = #{surplusStock,jdbcType=DECIMAL},
</if>
<if test="lasterInStock != null">
laster_in_stock = #{lasterInStock,jdbcType=DECIMAL},
</if>
<if test="conWarning != null">
con_warning = #{conWarning,jdbcType=DECIMAL},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
@@ -168,13 +168,21 @@
con_name = #{conName,jdbcType=VARCHAR},
stock_number = #{stockNumber,jdbcType=DECIMAL},
con_unit = #{conUnit,jdbcType=VARCHAR},
surplus_stock = #{surplusStock,jdbcType=DECIMAL},
laster_in_stock = #{lasterInStock,jdbcType=DECIMAL},
con_warning = #{conWarning,jdbcType=DECIMAL},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="countAll" resultType="int">
select count(id) from tb_cons_info
</select>
<select id="selectAllInfo" resultType="com.chaozhanggui.system.cashierservice.entity.TbConsInfo">
select * from tb_cons_info order by id desc
</select>
<update id="batchStock">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">

View File

@@ -935,4 +935,29 @@
set stock_number = stock_number - #{number,jdbcType=INTEGER}
where id = #{productId}
</update>
<select id="selectBySkuId" resultType="com.chaozhanggui.system.cashierservice.entity.po.ProConsSkuInfo">
SELECT
c.shop_id,
c.product_sku_id,
c.`status`,
i.id as con_id,
i.con_code,
i.con_name,
i.surplus_stock,
i.stock_number,
p.id as product_id,
p.`name` as product_name,
i.con_warning,
s.spec_snap
FROM
tb_prosku_con c
LEFT JOIN tb_cons_info i ON c.con_info_id = i.id
left join tb_product_sku s on c.product_sku_id=s.id
left join tb_product p on s.product_id=p.id
where c.`status`=1
and c.product_sku_id=#{skuId}
group by i.id
order by i.id
</select>
</mapper>

View File

@@ -6,11 +6,12 @@
<result column="shop_id" jdbcType="INTEGER" property="shopId" />
<result column="product_sku_id" jdbcType="INTEGER" property="productSkuId" />
<result column="con_info_id" jdbcType="INTEGER" property="conInfoId" />
<result column="surplus_stock" jdbcType="DECIMAL" property="surplusStock" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
id, shop_id, product_sku_id, con_info_id, status, create_time
id, shop_id, product_sku_id, con_info_id, surplus_stock, status, create_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
@@ -24,11 +25,11 @@
</delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProskuCon">
insert into tb_prosku_con (id, shop_id, product_sku_id,
con_info_id, status, create_time
)
con_info_id, surplus_stock, status,
create_time)
values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{productSkuId,jdbcType=INTEGER},
#{conInfoId,jdbcType=INTEGER}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
)
#{conInfoId,jdbcType=INTEGER}, #{surplusStock,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProskuCon">
insert into tb_prosku_con
@@ -45,6 +46,9 @@
<if test="conInfoId != null">
con_info_id,
</if>
<if test="surplusStock != null">
surplus_stock,
</if>
<if test="status != null">
status,
</if>
@@ -65,6 +69,9 @@
<if test="conInfoId != null">
#{conInfoId,jdbcType=INTEGER},
</if>
<if test="surplusStock != null">
#{surplusStock,jdbcType=DECIMAL},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
@@ -85,6 +92,9 @@
<if test="conInfoId != null">
con_info_id = #{conInfoId,jdbcType=INTEGER},
</if>
<if test="surplusStock != null">
surplus_stock = #{surplusStock,jdbcType=DECIMAL},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
@@ -99,12 +109,28 @@
set shop_id = #{shopId,jdbcType=INTEGER},
product_sku_id = #{productSkuId,jdbcType=INTEGER},
con_info_id = #{conInfoId,jdbcType=INTEGER},
surplus_stock = #{surplusStock,jdbcType=DECIMAL},
status = #{status,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectBySkuIdAndShopId" resultMap="BaseResultMap">
select * from tb_prosku_con where product_sku_id=#{shopId} and shop_id=#{shopId} and status=1
</select>
</select>
<select id="selectIdBySkuIdAndShopId" resultType="java.lang.Integer">
SELECT
p.con_info_id
FROM
tb_prosku_con p
WHERE
p.shop_id = #{shopId}
AND p.product_sku_id = #{skuId}
AND p.`status` = 1
group by p.con_info_id
</select>
</mapper>