修改耗材库存
This commit is contained in:
@@ -11,6 +11,7 @@ import com.chaozhanggui.system.cashierservice.util.HttpClientUtil;
|
|||||||
import com.chaozhanggui.system.cashierservice.util.N;
|
import com.chaozhanggui.system.cashierservice.util.N;
|
||||||
import com.chaozhanggui.system.cashierservice.util.RedisCst;
|
import com.chaozhanggui.system.cashierservice.util.RedisCst;
|
||||||
import com.chaozhanggui.system.cashierservice.util.RedisUtil;
|
import com.chaozhanggui.system.cashierservice.util.RedisUtil;
|
||||||
|
import lombok.Data;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
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.Component;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@@ -192,30 +191,72 @@ 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){
|
public static void main(String[] args){
|
||||||
JSONObject access_token = new ConsMsgConsumer().getAccessToken();
|
|
||||||
|
List<MsgInfo> list=new ArrayList<>();
|
||||||
|
|
||||||
|
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"));
|
String accessToken = String.valueOf(access_token.get("access_token"));
|
||||||
|
|
||||||
JSONObject object1 = new JSONObject();
|
JSONObject object1 = new JSONObject();
|
||||||
|
|
||||||
object1.put("template_id", "IZ-l9p9yBgcvhRR0uN6cBQPkWJ5i05zyWMkfeCPaAmY");
|
object1.put("template_id", "IZ-l9p9yBgcvhRR0uN6cBQPkWJ5i05zyWMkfeCPaAmY");
|
||||||
object1.put("touser", "oeQYq5CAuSpdeX9uZz52DJiSUO9M");
|
object1.put("touser", msgInfo.getOpenId());
|
||||||
|
|
||||||
|
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
|
|
||||||
JSONObject thing1 = new JSONObject();
|
JSONObject thing1 = new JSONObject();
|
||||||
thing1.put("value", "水");
|
thing1.put("value", msgInfo.getShopName());
|
||||||
|
|
||||||
JSONObject thing5 = new JSONObject();
|
JSONObject thing5 = new JSONObject();
|
||||||
thing5.put("value", "耗材库存不足,请及时补充。");
|
thing5.put("value", "耗材库存不足,请及时补充。");
|
||||||
|
|
||||||
JSONObject thing6 = new JSONObject();
|
JSONObject thing6 = new JSONObject();
|
||||||
thing6.put("value", "咖啡");
|
thing6.put("value", msgInfo.getProductName());
|
||||||
|
|
||||||
|
|
||||||
JSONObject thing7 = new JSONObject();
|
JSONObject thing7 = new JSONObject();
|
||||||
thing7.put("value", "3.2");
|
thing7.put("value", msgInfo.getAmount().toPlainString());
|
||||||
|
|
||||||
data.put("thing1", thing1);
|
data.put("thing1", thing1);
|
||||||
data.put("thing6", thing6);
|
data.put("thing6", thing6);
|
||||||
@@ -224,7 +265,7 @@ public class ConsMsgConsumer {
|
|||||||
|
|
||||||
object1.put("data", data);
|
object1.put("data", data);
|
||||||
|
|
||||||
object1.put("miniprogram_state", "trial");
|
object1.put("miniprogram_state", "formal");
|
||||||
object1.put("lang", "zh_CN");
|
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();
|
String response = HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=".concat(accessToken)).body(object1.toString()).execute().body();
|
||||||
@@ -232,5 +273,7 @@ public class ConsMsgConsumer {
|
|||||||
JSONObject resObj = JSONObject.parseObject(response);
|
JSONObject resObj = JSONObject.parseObject(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ public class RabbitConfig {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Binding bindingcons_Register() {
|
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
|
@Bean
|
||||||
public Binding bindingcons_msg_Register() {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -45,9 +45,6 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void con_msg(String content){
|
public void con_msg(String content){
|
||||||
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
||||||
rabbitTemplate.convertAndSend(RabbitConstants.CONS_MSG_COLLECT_PUT, RabbitConstants.CONS_MSG_COLLECT_ROUTINGKEY_PUT, content, correlationId);
|
rabbitTemplate.convertAndSend(RabbitConstants.CONS_MSG_COLLECT_PUT, RabbitConstants.CONS_MSG_COLLECT_ROUTINGKEY_PUT, content, correlationId);
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public class ConsService {
|
|||||||
|
|
||||||
if("delete".equals(type)){
|
if("delete".equals(type)){
|
||||||
|
|
||||||
List jsonArray= Arrays.asList(jsonObject.getJSONArray("skuIds"));
|
List jsonArray= jsonObject.getJSONArray("skuIds").toJavaList(Integer.class);
|
||||||
|
|
||||||
String shopId= jsonObject.getString("shopId");
|
String shopId= jsonObject.getString("shopId");
|
||||||
if(Objects.isNull(jsonArray)||jsonArray.size()<=0){
|
if(Objects.isNull(jsonArray)||jsonArray.size()<=0){
|
||||||
|
|||||||
@@ -188,6 +188,7 @@ public class OrderService {
|
|||||||
cashierCart.setCategoryId(product.getCategoryId());
|
cashierCart.setCategoryId(product.getCategoryId());
|
||||||
list.add(cashierCart);
|
list.add(cashierCart);
|
||||||
cashierCartMapper.insert(cashierCart);
|
cashierCartMapper.insert(cashierCart);
|
||||||
|
cart=cashierCart;
|
||||||
} else {
|
} else {
|
||||||
if (type.equals("add")) {
|
if (type.equals("add")) {
|
||||||
cashierCart.setNumber(cashierCart.getNumber() + number);
|
cashierCart.setNumber(cashierCart.getNumber() + number);
|
||||||
@@ -206,6 +207,8 @@ public class OrderService {
|
|||||||
} else {
|
} else {
|
||||||
cashierCartMapper.updateStatus(cashierCart.getId(), "close");
|
cashierCartMapper.updateStatus(cashierCart.getId(), "close");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cart=cashierCart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -724,12 +727,13 @@ public class OrderService {
|
|||||||
for (TbCashierCart cashierCart : list) {
|
for (TbCashierCart cashierCart : list) {
|
||||||
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
||||||
orderId = Integer.valueOf(cashierCart.getOrderId());
|
orderId = Integer.valueOf(cashierCart.getOrderId());
|
||||||
skuIds.add(cashierCart.getSkuId());
|
|
||||||
}
|
}
|
||||||
TbProductWithBLOBs product= tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
|
TbProductWithBLOBs product= tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
|
||||||
if(ObjectUtil.isNotEmpty(product)&&"1".equals(product.getIsStock().toString())){
|
if(ObjectUtil.isNotEmpty(product)&&"1".equals(product.getIsStock().toString())){
|
||||||
ProductSkuPo skuPo=new ProductSkuPo(Integer.valueOf(cashierCart.getSkuId()),cashierCart.getTotalNumber());
|
ProductSkuPo skuPo=new ProductSkuPo(Integer.valueOf(cashierCart.getSkuId()),cashierCart.getTotalNumber());
|
||||||
productSkuPos.add(skuPo);
|
productSkuPos.add(skuPo);
|
||||||
|
skuIds.add(cashierCart.getSkuId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -163,15 +163,17 @@
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
<insert id="insertBatch">
|
<insert id="insertBatch">
|
||||||
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
|
|
||||||
insert into tb_cons_info_flow (shop_id, cons_id,
|
insert into tb_cons_info_flow (shop_id, cons_id,
|
||||||
con_name, amount, balance,
|
con_name, amount, balance,
|
||||||
biz_code, biz_name, biz_type,
|
biz_code, biz_name, biz_type,
|
||||||
create_time, update_time)
|
create_time)
|
||||||
values #{item.shopId,jdbcType=INTEGER}, #{item.consId,jdbcType=INTEGER},
|
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.conName,jdbcType=VARCHAR}, #{item.amount,jdbcType=DECIMAL}, #{item.balance,jdbcType=DECIMAL},
|
||||||
#{item.bizCode,jdbcType=VARCHAR}, #{item.bizName,jdbcType=VARCHAR}, #{item.bizType,jdbcType=VARCHAR},
|
#{item.bizCode,jdbcType=VARCHAR}, #{item.bizName,jdbcType=VARCHAR}, #{item.bizType,jdbcType=VARCHAR},
|
||||||
#{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP})
|
now())
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|||||||
@@ -119,7 +119,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<select id="selectBySkuIdAndShopId" resultMap="BaseResultMap">
|
<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>
|
||||||
|
|
||||||
<select id="selectIdBySkuIdAndShopId" resultType="java.lang.Integer">
|
<select id="selectIdBySkuIdAndShopId" resultType="java.lang.Integer">
|
||||||
|
|||||||
Reference in New Issue
Block a user