Merge branch 'dev'

This commit is contained in:
wangw 2024-07-23 10:02:57 +08:00
commit 5ae24fbbfc
7 changed files with 95 additions and 2 deletions

View File

@ -160,7 +160,7 @@ public class PayController {
@RequestParam("userId") String userId,
@RequestParam("shopId") String shopId
) {
return payService.getShopByMember(userId,shopId,page,pageSize);
return payService.getShopByMember(userId,shopId,page,pageSize);
}
@RequestMapping("queryMemberAccount")

View File

@ -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.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;
@ -38,4 +39,7 @@ public interface TbProductSkuMapper {
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id}")
int decrStockUnCheck(@Param("id") String id, @Param("num") Integer num);
@Select("select * from tb_product_sku where is_grounding=1 and is_del=0 and product_id=#{id}")
List<TbProductSku> selectGroundingByProId(@Param("id") Integer id);
}

View File

@ -50,9 +50,27 @@ public class TbProductSku implements Serializable {
private Integer isPauseSale = 0;
private Integer isDel;
private Integer isGrounding;
private String specSnap;
public String getSpecSnap() {
return specSnap;
}
public void setSpecSnap(String specSnap) {
this.specSnap = specSnap;
}
private static final long serialVersionUID = 1L;
public Integer getIsGrounding() {
return isGrounding;
}
public void setIsGrounding(Integer isGrounding) {
this.isGrounding = isGrounding;
}
public Integer getId() {
return id;
}

View File

@ -310,7 +310,20 @@ public class CartService {
Integer buyNum = jsonObject.getInteger("num");
String skuId = jsonObject.getString("skuId");
// 判断商品是否已下架
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
if (tbProductSkuWithBLOBs ==null || tbProductSkuWithBLOBs.getIsGrounding().equals(0)) {
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "此商品已下架");
jsonObject1.put("data", new ArrayList<>());
jsonObject1.put("reqData", jsonObject);
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
log.error("商品已下架 skuId:{}", skuId);
return;
}
if (tbProduct.getIsStock() == 1) {
// 1:共享库存 0:独立库存
if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {
@ -595,6 +608,16 @@ public class CartService {
TbProductSkuWithBLOBs tbProduct = productSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));
TbProduct tbProduct1 = tbProductMapper.selectById(Integer.valueOf(tbProduct.getProductId()));
// 判断商品是否已下架
if (tbProduct.getIsGrounding().equals(0)) {
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);
return;
}
log.info("下单,开始校验库存预警,购物车id:{}", cashierCart.getId());
CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(tbProduct, tbProduct1, cashierCart.getNumber()));

View File

@ -2,8 +2,10 @@ package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.dto.HomeDto;
@ -144,7 +146,47 @@ public class ProductService {
products.parallelStream().forEach(it -> {
Integer sum = tbProductMapper.selectByQcode(code, it.getId(), it.getShopId());
it.setCartNumber(sum == null ? "0" : String.valueOf(sum));
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId());
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(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 = "";
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);
}
}
}
skuResult.setTagSnap(finalSnap.toJSONString());
}
it.setProductSkuResult(skuResult);
});
g.setProducts(products);

View File

@ -140,6 +140,11 @@ public class PrinterUtils {
sb.append("<S>余额:"+detailPO.getBalance()+"</S><BR>");
sb.append("------------------------<BR>");
if(ObjectUtil.isNotEmpty(detailPO.getRemark())&&ObjectUtil.isNotNull(detailPO.getRemark())){
sb.append("<L>备注:"+detailPO.getRemark()+"</L><BR>");
}
if(Objects.nonNull(detailPO.getOutNumber())){
sb.append("<QR>".concat(detailPO.getOutNumber()).concat("</QR><BR>"));
}

View File

@ -26,6 +26,7 @@
<result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
<result column="is_pause_sale" jdbcType="INTEGER" property="isPauseSale" />
<result column="is_del" jdbcType="INTEGER" property="isDel" />
<result column="is_grounding" jdbcType="INTEGER" property="isGrounding" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs">
<result column="spec_info" jdbcType="LONGVARCHAR" property="specInfo" />
@ -34,7 +35,7 @@
<sql id="Base_Column_List">
id, shop_id, bar_code, product_id, origin_price, cost_price, member_price, meal_price,
sale_price, guide_price,suit, strategy_price, stock_number, cover_img, warn_line, weight,
volume, real_sales_number, first_shared, second_shared, created_at, updated_at, is_pause_sale ,is_del
volume, real_sales_number, first_shared, second_shared, created_at, updated_at, is_pause_sale ,is_del,is_grounding
</sql>
<sql id="Blob_Column_List">
spec_info, spec_snap