Parcourir la source

FIX: bug修复

xdd il y a 2 semaines
Parent
commit
c3a128e83a

+ 8 - 298
fs-service-system/src/main/java/com/fs/store/domain/FsUser.java

@@ -6,6 +6,8 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fs.common.annotation.Excel;
 import com.fs.common.core.domain.BaseEntity;
 import com.vdurmont.emoji.EmojiParser;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
 import org.apache.commons.lang3.StringUtils;
 
 /**
@@ -14,6 +16,8 @@ import org.apache.commons.lang3.StringUtils;
  * @author fs
  * @date 2022-03-15
  */
+@EqualsAndHashCode(callSuper = true)
+@Data
 public class FsUser extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
@@ -124,150 +128,11 @@ public class FsUser extends BaseEntity
 
     private String userCode;
 
-    public String getUserCode() {
-        return userCode;
-    }
-
-    public void setUserCode(String userCode) {
-        this.userCode = userCode;
-    }
-
-    public String getMaOpenId() {
-        return maOpenId;
-    }
-
-    public void setMaOpenId(String maOpenId) {
-        this.maOpenId = maOpenId;
-    }
-
-    public String getMpOpenId() {
-        return mpOpenId;
-    }
-
-    public void setMpOpenId(String mpOpenId) {
-        this.mpOpenId = mpOpenId;
-    }
-
-    public String getUnionId() {
-        return unionId;
-    }
-
-    public void setUnionId(String unionId) {
-        this.unionId = unionId;
-    }
-
-    public Date getRegisterDate() {
-        return registerDate;
-    }
-
-    public void setRegisterDate(Date registerDate) {
-        this.registerDate = registerDate;
-    }
-
-    public String getRegisterCode() {
-        return registerCode;
-    }
-
-    public void setRegisterCode(String registerCode) {
-        this.registerCode = registerCode;
-    }
-
-    public String getSource() {
-        return source;
-    }
-
-    public void setSource(String source) {
-        this.source = source;
-    }
-
-    public Long getCompanyId() {
-        return companyId;
-    }
-
-    public void setCompanyId(Long companyId) {
-        this.companyId = companyId;
-    }
-
-    public Long getCompanyUserId() {
-        return companyUserId;
-    }
-
-    public void setCompanyUserId(Long companyUserId) {
-        this.companyUserId = companyUserId;
-    }
-
-    public Integer getIsWeixinAuth() {
-        return isWeixinAuth;
-    }
-
-    public void setIsWeixinAuth(Integer isWeixinAuth) {
-        this.isWeixinAuth = isWeixinAuth;
-    }
-
-    public void setUserId(Long userId)
-    {
-        this.userId = userId;
-    }
-
-    public Long getUserId()
-    {
-        return userId;
-    }
-    public void setUsername(String username)
-    {
-        this.username = username;
-    }
-
-    public String getUsername()
-    {
-        return username;
-    }
-    public void setPassword(String password)
-    {
-        this.password = password;
-    }
-
-    public String getPassword()
-    {
-        return password;
-    }
-    public void setRealName(String realName)
-    {
-        this.realName = realName;
-    }
-
-    public String getRealName()
-    {
-        return realName;
-    }
-    public void setBirthday(Long birthday)
-    {
-        this.birthday = birthday;
-    }
-
-    public Long getBirthday()
-    {
-        return birthday;
-    }
-    public void setIdCard(String idCard)
-    {
-        this.idCard = idCard;
-    }
-
-    public String getIdCard()
-    {
-        return idCard;
-    }
 
-    @Override
-    public String getRemark() {
-        return remark;
-    }
-
-    @Override
-    public void setRemark(String remark) {
-        this.remark = remark;
-    }
+    /**
+     * 剩余理赔额度
+     */
+    private BigDecimal remainingClaimLimit;
 
     public void setNickname(String nickname)
     {
@@ -288,160 +153,5 @@ public class FsUser extends BaseEntity
             return nickname;
         }
     }
-    public void setAvatar(String avatar)
-    {
-        this.avatar = avatar;
-    }
-
-    public String getAvatar()
-    {
-        return avatar;
-    }
-    public void setPhone(String phone)
-    {
-        this.phone = phone;
-    }
-
-    public String getPhone()
-    {
-        return phone;
-    }
-    public void setLastIp(String lastIp)
-    {
-        this.lastIp = lastIp;
-    }
-
-    public String getLastIp()
-    {
-        return lastIp;
-    }
-    public void setNowMoney(BigDecimal nowMoney)
-    {
-        this.nowMoney = nowMoney;
-    }
-
-    public BigDecimal getNowMoney()
-    {
-        return nowMoney;
-    }
-    public void setBrokeragePrice(BigDecimal brokeragePrice)
-    {
-        this.brokeragePrice = brokeragePrice;
-    }
-
-    public BigDecimal getBrokeragePrice()
-    {
-        return brokeragePrice;
-    }
-    public void setIntegral(BigDecimal integral)
-    {
-        this.integral = integral;
-    }
-
-    public BigDecimal getIntegral()
-    {
-        return integral;
-    }
-    public void setSignNum(Long signNum)
-    {
-        this.signNum = signNum;
-    }
-
-    public Long getSignNum()
-    {
-        return signNum;
-    }
-    public void setStatus(Integer status)
-    {
-        this.status = status;
-    }
-
-    public Integer getStatus()
-    {
-        return status;
-    }
-    public void setLevel(Integer level)
-    {
-        this.level = level;
-    }
-
-    public Integer getLevel()
-    {
-        return level;
-    }
-    public void setSpreadUserId(Long spreadUserId)
-    {
-        this.spreadUserId = spreadUserId;
-    }
-
-    public Long getSpreadUserId()
-    {
-        return spreadUserId;
-    }
-    public void setSpreadTime(Date spreadTime)
-    {
-        this.spreadTime = spreadTime;
-    }
-
-    public Date getSpreadTime()
-    {
-        return spreadTime;
-    }
-    public void setUserType(String userType)
-    {
-        this.userType = userType;
-    }
-
-    public String getUserType()
-    {
-        return userType;
-    }
-    public void setIsPromoter(Integer isPromoter)
-    {
-        this.isPromoter = isPromoter;
-    }
-
-    public Integer getIsPromoter()
-    {
-        return isPromoter;
-    }
-    public void setPayCount(Long payCount)
-    {
-        this.payCount = payCount;
-    }
-
-    public Long getPayCount()
-    {
-        return payCount;
-    }
-    public void setSpreadCount(Long spreadCount)
-    {
-        this.spreadCount = spreadCount;
-    }
-
-    public Long getSpreadCount()
-    {
-        return spreadCount;
-    }
-    public void setAddres(String addres)
-    {
-        this.addres = addres;
-    }
-
-    public String getAddres()
-    {
-        return addres;
-    }
-
-    public void setIsDel(Integer isDel)
-    {
-        this.isDel = isDel;
-    }
-
-    public Integer getIsDel()
-    {
-        return isDel;
-    }
-
 
 }

+ 6 - 0
fs-service-system/src/main/java/com/fs/store/mapper/FsStoreProductMapper.java

@@ -6,6 +6,8 @@ import java.util.Map;
 import com.fs.store.domain.FsStoreProduct;
 import com.fs.store.param.FsStoreProductQueryParam;
 import com.fs.store.vo.*;
+import io.lettuce.core.dynamic.annotation.Key;
+import org.apache.ibatis.annotations.MapKey;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
@@ -216,4 +218,8 @@ public interface FsStoreProductMapper
             " on sp.warehouse_code=fw.warehouse_code ")
     Map<Long,FsStoreProduct> selectAllProductMappingInfo();
 
+    @Select("select product_id,product_type from fs_store_product")
+    @MapKey("productId")
+    Map<Long, FsStoreProduct> selectAllProductTypeMapping();
+
 }

+ 1 - 0
fs-service-system/src/main/java/com/fs/store/mapper/FsUserMapper.java

@@ -29,6 +29,7 @@ public interface FsUserMapper
      */
     public FsUser selectFsUserById(Long userId);
 
+
     /**
      * 查询用户列表
      *

+ 33 - 2
fs-service-system/src/main/java/com/fs/store/service/impl/FsPrescribeServiceImpl.java

@@ -5,8 +5,7 @@ import java.awt.image.BufferedImage;
 import java.io.*;
 import java.net.URL;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
+import java.util.*;
 import java.util.List;
 
 import cn.hutool.core.util.ObjectUtil;
@@ -21,6 +20,7 @@ import com.fs.common.utils.StringUtils;
 import com.fs.store.domain.*;
 import com.fs.store.dto.FsStoreCartDTO;
 import com.fs.store.dto.MedicalRecordDTO;
+import com.fs.store.mapper.FsStoreProductMapper;
 import com.fs.store.param.*;
 import com.fs.store.service.*;
 import com.fs.store.vo.FsPrescribeVO;
@@ -60,6 +60,8 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
     private IFsStoreOrderService fsStoreOrderService;
     @Autowired
     private FSSysConfig fsSysConfig;
+    @Autowired
+    private FsStoreProductMapper fsStoreProductMapper;
     /**
      * 查询处方
      *
@@ -235,7 +237,21 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
         String itemJson = fsStoreOrder.getItemJson();
         List<FsStoreOrderItem> fsStoreCartDTOS = JSONObject.parseArray(itemJson, FsStoreOrderItem.class);
         List<FsPrescribeDrug> fsPrescribeDrugList = new ArrayList<>();
+        Map<Long,FsStoreProduct> allProductTypeMapping = fsStoreProductMapper.selectAllProductTypeMapping();
         for (FsStoreOrderItem item : fsStoreCartDTOS) {
+            FsStoreProduct fsStoreProduct = allProductTypeMapping.get(item.getProductId());
+            if(fsStoreProduct != null) {
+                Integer productType = fsStoreProduct.getProductType();
+                Set<Integer> includeSet = new HashSet<>();
+                includeSet.add(1);
+                includeSet.add(2);
+                includeSet.add(4);
+
+                // 只对非处方、处方药、器械 进行开方
+                if(!includeSet.contains(productType)) {
+                    continue;
+                }
+            }
             FsStoreCartDTO cartDTO = JSON.parseObject(item.getJsonInfo(),FsStoreCartDTO.class);
             FsPrescribeDrug fsPrescribeDrug = new FsPrescribeDrug();
             fsPrescribeDrug.setDrugName(cartDTO.getProductName());
@@ -465,6 +481,8 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
     public void generateDealImg() {
         // 获取待处理数据
         List<FsPrescribe> list = fsPrescribeMapper.selectPenddingData();
+        Map<Long,FsStoreProduct> allProductTypeMapping = fsStoreProductMapper.selectAllProductTypeMapping();
+
         for (FsPrescribe fsPrescribe : list) {
             String rpUrl = null;
             try{
@@ -510,6 +528,19 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
                 int i=1;
                 prescription.append("\n");
                 for (FsStoreOrderItem item : fsStoreCartDTOS) {
+                    FsStoreProduct fsStoreProduct = allProductTypeMapping.get(item.getProductId());
+                    if(fsStoreProduct != null) {
+                        Integer productType = fsStoreProduct.getProductType();
+                        Set<Integer> includeSet = new HashSet<>();
+                        includeSet.add(1);
+                        includeSet.add(2);
+                        includeSet.add(4);
+
+                        // 只对非处方、处方药、器械 进行开方
+                        if(!includeSet.contains(productType)) {
+                            continue;
+                        }
+                    }
                     FsStoreCartDTO cartDTO = JSON.parseObject(item.getJsonInfo(),FsStoreCartDTO.class);
 
                     prescription.append(i++).append(".").append(cartDTO.getProductName())

+ 20 - 0
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreOrderServiceImpl.java

@@ -269,6 +269,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
     @Autowired
     private FsWarehousesMapper fsWarehousesMapper;
 
+    @Autowired
+    private FsUserMapper fsUserMapper;
+
 
     @Override
     public void syncExpressToWx() {
@@ -1878,6 +1881,23 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
                 prescribe.setGenerateStatus(1);
                 prescribeService.updateFsPrescribe(prescribe);
             }
+
+            // 保险剩余额度处理
+            // 如果 保险剩余额度处理 >= 订单金额
+            // 保险剩余额度处理 -= 订单金额
+            // 否则
+            // 保险剩余额度处理=0
+            FsUser fsUser = fsUserMapper.selectFsUserByIdForUpdate(order.getUserId());
+            if (fsUser == null) {
+                throw new RuntimeException("用户不存在");
+            }
+            int i = fsUser.getRemainingClaimLimit().compareTo(order.getTotalPrice());
+            if(i>=0) {
+                fsUser.setRemainingClaimLimit(fsUser.getRemainingClaimLimit().subtract(order.getTotalPrice()));
+            } else {
+                fsUser.setRemainingClaimLimit(BigDecimal.ZERO);
+            }
+            fsUserMapper.updateFsUser(fsUser);
         }
         catch (Exception e){
             logger.error("payConfirm: {} ",e.getMessage(),e);

+ 5 - 0
fs-service-system/src/main/java/com/fs/store/vo/FsUserListVO.java

@@ -135,4 +135,9 @@ public class FsUserListVO implements Serializable
     private Date createTime;
 
     private String spreadPhone;
+
+    /**
+     * 剩余理赔额度
+     */
+    private BigDecimal remainingClaimLimit;
 }

+ 5 - 1
fs-service-system/src/main/resources/mapper/store/FsUserMapper.xml

@@ -41,10 +41,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="registerCode"    column="register_code"    />
         <result property="source"    column="source"    />
         <result property="userCode"    column="user_code"    />
+        <result property="remainingClaimLimit"    column="remaining_claim_limit"    />
     </resultMap>
 
     <sql id="selectFsUserVo">
-        select user_id, username, password, real_name, birthday, id_card, remark, nickname, avatar, phone, create_time, update_time, last_ip, now_money, brokerage_price, integral, sign_num, status, level, spread_user_id, spread_time, user_type, is_promoter, pay_count, spread_count, addres,ma_open_id,mp_open_id,union_id, is_del,is_weixin_auth,company_id,company_user_id,register_date,register_code,source,user_code from fs_user
+        select user_id, username, password, real_name, birthday, id_card, remark, nickname, avatar, phone, create_time, update_time, last_ip, now_money, brokerage_price, integral, sign_num, status, level, spread_user_id, spread_time, user_type, is_promoter, pay_count, spread_count, addres,ma_open_id,mp_open_id,union_id, is_del,is_weixin_auth,company_id,company_user_id,register_date,register_code,source,user_code,remaining_claim_limit from fs_user
     </sql>
 
     <select id="selectFsUserList" parameterType="FsUser" resultMap="FsUserResult">
@@ -127,6 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="registerCode != null">register_code,</if>
             <if test="source != null">source,</if>
             <if test="userCode != null">user_code,</if>
+            <if test="remainingClaimLimit != null">remaining_claim_limit,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="username != null">#{username},</if>
@@ -165,6 +167,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="registerCode != null">#{registerCode},</if>
             <if test="source != null">#{source},</if>
             <if test="userCode != null">#{userCode},</if>
+            <if test="remainingClaimLimit != null">#{remainingClaimLimit},</if>
          </trim>
     </insert>
 
@@ -207,6 +210,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="registerCode != null">register_code = #{registerCode},</if>
             <if test="source != null">source = #{source},</if>
             <if test="userCode != null">user_code = #{userCode},</if>
+            <if test="remainingClaimLimit != null">remaining_claim_limit = #{remainingClaimLimit},</if>
         </trim>
         where user_id = #{userId}
     </update>