修改耗材库存

This commit is contained in:
韩鹏辉
2024-06-28 17:59:41 +08:00
parent fad761b63c
commit 4e27eb87b5
7 changed files with 86 additions and 41 deletions

View File

@@ -11,6 +11,7 @@ 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.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
@@ -19,10 +20,8 @@ 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;
import java.math.BigDecimal;
import java.util.*;
@Slf4j
@Component
@@ -192,44 +191,88 @@ public class ConsMsgConsumer {
JSONObject getAccessToken1() {
String requestUrl = "https://api.weixin.qq.com/cgi-bin/token";
Map<String, String> requestUrlParam = new HashMap<>();
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;
}
@Data
static class MsgInfo{
private String openId;
private String shopName;
private String productName;
private BigDecimal amount;
public MsgInfo(String openId, String shopName, String productName, BigDecimal amount) {
this.openId = openId;
this.shopName = shopName;
this.productName = productName;
this.amount = amount;
}
}
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();
List<MsgInfo> list=new ArrayList<>();
object1.put("template_id", "IZ-l9p9yBgcvhRR0uN6cBQPkWJ5i05zyWMkfeCPaAmY");
object1.put("touser", "oeQYq5CAuSpdeX9uZz52DJiSUO9M");
list.add(new MsgInfo("oeQYq5KEjN1-laurB3oRbqEllVzs","双屿Pisces","茄汁肉酱意面",new BigDecimal(24)));
list.add(new MsgInfo("oeQYq5KEjN1-laurB3oRbqEllVzs","森食界创意轻食(未央店)","番茄鸳鸯锅",new BigDecimal(36)));
for (MsgInfo msgInfo : list) {
JSONObject access_token = new ConsMsgConsumer().getAccessToken1();
String accessToken = String.valueOf(access_token.get("access_token"));
JSONObject object1 = new JSONObject();
object1.put("template_id", "IZ-l9p9yBgcvhRR0uN6cBQPkWJ5i05zyWMkfeCPaAmY");
object1.put("touser", msgInfo.getOpenId());
JSONObject data = new JSONObject();
JSONObject data = new JSONObject();
JSONObject thing1 = new JSONObject();
thing1.put("value", "");
JSONObject thing1 = new JSONObject();
thing1.put("value", msgInfo.getShopName());
JSONObject thing5 = new JSONObject();
thing5.put("value", "耗材库存不足,请及时补充。");
JSONObject thing5 = new JSONObject();
thing5.put("value", "耗材库存不足,请及时补充。");
JSONObject thing6 = new JSONObject();
thing6.put("value", "咖啡");
JSONObject thing6 = new JSONObject();
thing6.put("value", msgInfo.getProductName());
JSONObject thing7 = new JSONObject();
thing7.put("value", "3.2");
JSONObject thing7 = new JSONObject();
thing7.put("value", msgInfo.getAmount().toPlainString());
data.put("thing1", thing1);
data.put("thing6", thing6);
data.put("number7", thing7);
data.put("thing5", thing5);
data.put("thing1", thing1);
data.put("thing6", thing6);
data.put("number7", thing7);
data.put("thing5", thing5);
object1.put("data", data);
object1.put("data", data);
object1.put("miniprogram_state", "trial");
object1.put("lang", "zh_CN");
object1.put("miniprogram_state", "formal");
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);
}
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

@@ -101,7 +101,7 @@ public class RabbitConfig {
@Bean
public Binding bindingcons_Register() {
return BindingBuilder.bind(queuePrint_Register()).to(printExchange_Register()).with(RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT);
return BindingBuilder.bind(queuecons_Register()).to(consExchange_Register()).with(RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT);
}
@@ -120,12 +120,11 @@ public class RabbitConfig {
@Bean
public Binding bindingcons_msg_Register() {
return BindingBuilder.bind(queuePrint_Register()).to(printExchange_Register()).with(RabbitConstants.CONS_MSG_COLLECT_ROUTINGKEY_PUT);
return BindingBuilder.bind(queuecons_msg_Register()).to(cons_msg_Exchange_Register()).with(RabbitConstants.CONS_MSG_COLLECT_ROUTINGKEY_PUT);
}
}

View File

@@ -45,9 +45,6 @@ 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);

View File

@@ -98,7 +98,7 @@ public class ConsService {
if("delete".equals(type)){
List jsonArray= Arrays.asList(jsonObject.getJSONArray("skuIds"));
List jsonArray= jsonObject.getJSONArray("skuIds").toJavaList(Integer.class);
String shopId= jsonObject.getString("shopId");
if(Objects.isNull(jsonArray)||jsonArray.size()<=0){

View File

@@ -188,6 +188,7 @@ public class OrderService {
cashierCart.setCategoryId(product.getCategoryId());
list.add(cashierCart);
cashierCartMapper.insert(cashierCart);
cart=cashierCart;
} else {
if (type.equals("add")) {
cashierCart.setNumber(cashierCart.getNumber() + number);
@@ -206,6 +207,8 @@ public class OrderService {
} else {
cashierCartMapper.updateStatus(cashierCart.getId(), "close");
}
cart=cashierCart;
}
@@ -724,12 +727,13 @@ public class OrderService {
for (TbCashierCart cashierCart : list) {
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
orderId = Integer.valueOf(cashierCart.getOrderId());
skuIds.add(cashierCart.getSkuId());
}
TbProductWithBLOBs product= tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
if(ObjectUtil.isNotEmpty(product)&&"1".equals(product.getIsStock().toString())){
ProductSkuPo skuPo=new ProductSkuPo(Integer.valueOf(cashierCart.getSkuId()),cashierCart.getTotalNumber());
productSkuPos.add(skuPo);
skuIds.add(cashierCart.getSkuId());
}

View File

@@ -163,15 +163,17 @@
</update>
<insert id="insertBatch">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
insert into tb_cons_info_flow (shop_id, cons_id,
con_name, amount, balance,
biz_code, biz_name, biz_type,
create_time, update_time)
values #{item.shopId,jdbcType=INTEGER}, #{item.consId,jdbcType=INTEGER},
create_time)
values
<foreach collection ="list" item="item" separator =",">
( #{item.shopId,jdbcType=INTEGER}, #{item.consId,jdbcType=INTEGER},
#{item.conName,jdbcType=VARCHAR}, #{item.amount,jdbcType=DECIMAL}, #{item.balance,jdbcType=DECIMAL},
#{item.bizCode,jdbcType=VARCHAR}, #{item.bizName,jdbcType=VARCHAR}, #{item.bizType,jdbcType=VARCHAR},
#{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP})
now())
</foreach>
</insert>

View File

@@ -119,7 +119,7 @@
<select id="selectBySkuIdAndShopId" resultMap="BaseResultMap">
select * from tb_prosku_con where product_sku_id=#{shopId} and shop_id=#{shopId} and status=1
select * from tb_prosku_con where product_sku_id=#{skuId} and shop_id=#{shopId} and status=1
</select>
<select id="selectIdBySkuIdAndShopId" resultType="java.lang.Integer">