Merge remote-tracking branch 'origin/dev' into hph

This commit is contained in:
牛叉闪闪
2024-07-25 10:56:45 +08:00
6 changed files with 192 additions and 9 deletions

View File

@@ -64,6 +64,8 @@ public class OrderService {
@Autowired
RedisUtil redisUtil;
private final WxAccountUtil wxAccountUtil;
@Autowired
RabbitProducer producer;
@@ -79,7 +81,8 @@ public class OrderService {
@Autowired
private ProductService productService;
public OrderService(WechatUtil wechatUtil, TbUserShopMsgMapper tbUserShopMsgMapper, TbShopOpenIdMapper shopOpenIdMapper) {
public OrderService(WxAccountUtil wxAccountUtil, WechatUtil wechatUtil, TbUserShopMsgMapper tbUserShopMsgMapper, TbShopOpenIdMapper shopOpenIdMapper) {
this.wxAccountUtil = wxAccountUtil;
this.wechatUtil = wechatUtil;
this.tbUserShopMsgMapper = tbUserShopMsgMapper;
this.shopOpenIdMapper = shopOpenIdMapper;
@@ -277,9 +280,8 @@ public class OrderService {
) {
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());
wxAccountUtil.sendStockWarnMsg(shopInfo.getShopName(), product.getName(),
product.getIsDistribute() == 1 ? String.valueOf(product.getStockNumber()-num) : String.valueOf(productSku.getStockNumber() - num), item.getOpenId());
});
}
}

View File

@@ -9,6 +9,7 @@ import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.vo.ShopCategoryVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.interceptor.LimitSubmitAspect;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
@@ -18,8 +19,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
@Service
@Slf4j
@@ -41,9 +41,11 @@ public class ProductService {
@Autowired
TbProductSkuResultMapper tbProductSkuResultMapper;
@Autowired
private LimitSubmitAspect limitSubmitAspect;
public Result queryCategory(String shopId,Integer page,Integer pageSize){
public Result queryCategory(String shopId,Integer page,Integer pageSize){
PageHelperUtil.startPage(page, pageSize);
List<TbShopCategory> list=tbShopCategoryMapper.selectByAll(shopId);
PageInfo pageInfo=new PageInfo(list);
@@ -119,12 +121,66 @@ public class ProductService {
it.setTbProductSpec(tbProductSpec);
TbProductSkuResult skuResult=tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
if(ObjectUtil.isEmpty(skuResult)){
skuResult=new TbProductSkuResult();
// 上下架对应的sku
String selectSpec = it.getSelectSpec();
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId());
HashSet<String> specSet = new HashSet<>();
tbProductSkus.forEach(item -> {
String specSnap = item.getSpecSnap();
if (specSnap != null) {
specSet.addAll(Arrays.asList(specSnap.split(",")));
}
});
String tagSnap = skuResult != null ? skuResult.getTagSnap() : null;
if (tagSnap != null) {
JSONArray tagSnaps = JSONObject.parseArray(tagSnap);
JSONObject snapJSON;
JSONArray finalSnap = new JSONArray();
String finalValues = "";
HashMap<String, String> snapMap = new HashMap<>();
for (Object snap : tagSnaps) {
snapJSON = (JSONObject) snap;
String values = snapJSON.getString("value");
if (StrUtil.isNotBlank(values)) {
String[] valueList = values.split(",");
for (String value : valueList) {
if (specSet.contains(value)) {
finalValues = finalValues + (value) + ",";
}
}
if (StrUtil.isNotBlank(finalValues)) {
finalValues = StrUtil.removeSuffix(finalValues, ",");
snapJSON.put("value", finalValues);
finalSnap.add(snapJSON);
snapMap.put(snapJSON.getString("name"), snapJSON.getString("value"));
}
}
}
if (selectSpec != null) {
JSONArray selectSpecJSON = JSONObject.parseArray(selectSpec);
for (Object selectSpecInfo : selectSpecJSON) {
JSONObject specInfo = (JSONObject) selectSpecInfo;
specInfo.put("value", snapMap.get(specInfo.getString("name")).split(","));
specInfo.put("selectSpecResult", snapMap.get(specInfo.getString("name")).split(","));
}
it.setSelectSpec(selectSpecJSON.toJSONString());
}
skuResult.setTagSnap(finalSnap.toJSONString());
}
it.setProductSkuResult(skuResult);
// 查询sku信息
List<TbProductSku> skuWithBLOBs = tbProductSkuMapper.selectByProductCheckGrounding(it.getId());
it.setSkuList(skuWithBLOBs);