yuhongqi 1 день тому
батько
коміт
86810c077e
23 змінених файлів з 361 додано та 77 видалено
  1. 10 1
      fs-admin/src/main/java/com/fs/live/controller/LiveMsgController.java
  2. 8 1
      fs-company/src/main/java/com/fs/company/controller/live/LiveMsgController.java
  3. 2 0
      fs-live-socket/src/main/java/com/fs/live/websocket/bean/SendMsgVo.java
  4. 56 17
      fs-live-socket/src/main/java/com/fs/live/websocket/service/WebSocketServer.java
  5. 16 2
      fs-service-system/src/main/java/com/fs/erp/service/impl/JSTErpOrderServiceImpl.java
  6. 6 0
      fs-service-system/src/main/java/com/fs/live/domain/LiveOrderItem.java
  7. 1 1
      fs-service-system/src/main/java/com/fs/live/mapper/LiveOrderItemMapper.java
  8. 8 0
      fs-service-system/src/main/java/com/fs/live/mapper/LiveOrderMapper.java
  9. 114 46
      fs-service-system/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java
  10. 3 0
      fs-service-system/src/main/java/com/fs/live/vo/LiveOrderItemListUVO.java
  11. 3 0
      fs-service-system/src/main/java/com/fs/live/vo/LiveOrderItemVo.java
  12. 6 0
      fs-service-system/src/main/java/com/fs/store/domain/FsStoreOrderItem.java
  13. 2 0
      fs-service-system/src/main/java/com/fs/store/service/IFsUserService.java
  14. 1 1
      fs-service-system/src/main/java/com/fs/store/service/channel/HfPaymentHandler.java
  15. 1 1
      fs-service-system/src/main/java/com/fs/store/service/channel/TzbkPaymentHandler.java
  16. 1 1
      fs-service-system/src/main/java/com/fs/store/service/channel/YbPaymentHandler.java
  17. 60 2
      fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreOrderServiceImpl.java
  18. 26 0
      fs-service-system/src/main/java/com/fs/store/service/impl/FsUserServiceImpl.java
  19. 5 0
      fs-service-system/src/main/java/com/fs/store/vo/FsStoreOrderItemVO.java
  20. 7 3
      fs-service-system/src/main/resources/mapper/live/LiveOrderItemMapper.xml
  21. 13 0
      fs-service-system/src/main/resources/mapper/live/LiveOrderMapper.xml
  22. 5 1
      fs-service-system/src/main/resources/mapper/store/FsStoreOrderItemMapper.xml
  23. 7 0
      fs-user-app/src/main/java/com/fs/app/controller/WxUserController.java

+ 10 - 1
fs-admin/src/main/java/com/fs/live/controller/LiveMsgController.java

@@ -13,6 +13,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Arrays;
 
 /**
  * 直播讨论Controller
@@ -86,12 +87,20 @@ public class LiveMsgController extends BaseController
 
     /**
      * 删除直播讨论
+     * 只对数据库已有的消息(msgId>0)删库;临时 id(未入库)不删库,由聊天室服务在收到 WebSocket deleteMsg 时从队列移除并广播。
+     * 始终返回成功,以便前端发送 WebSocket deleteMsg 做广播。
      */
 //    @PreAuthorize("@ss.hasPermi('live:liveMsg:remove')")
     @Log(title = "直播讨论", businessType = BusinessType.DELETE)
 	@DeleteMapping("/{msgIds}")
     public AjaxResult remove(@PathVariable Long[] msgIds)
     {
-        return toAjax(liveMsgService.deleteLiveMsgByMsgIds(msgIds));
+        if (msgIds != null && msgIds.length > 0) {
+            Long[] realIds = Arrays.stream(msgIds).filter(id -> id != null && id > 0).toArray(Long[]::new);
+            if (realIds.length > 0) {
+                liveMsgService.deleteLiveMsgByMsgIds(realIds);
+            }
+        }
+        return AjaxResult.success();
     }
 }

+ 8 - 1
fs-company/src/main/java/com/fs/company/controller/live/LiveMsgController.java

@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -95,7 +96,13 @@ public class LiveMsgController extends BaseController
 	@DeleteMapping("/{msgIds}")
     public AjaxResult remove(@PathVariable Long[] msgIds)
     {
-        return toAjax(liveMsgService.deleteLiveMsgByMsgIds(msgIds));
+        if (msgIds != null && msgIds.length > 0) {
+            Long[] realIds = Arrays.stream(msgIds).filter(id -> id != null && id > 0).toArray(Long[]::new);
+            if (realIds.length > 0) {
+                liveMsgService.deleteLiveMsgByMsgIds(realIds);
+            }
+        }
+        return AjaxResult.success();
     }
 
 }

+ 2 - 0
fs-live-socket/src/main/java/com/fs/live/websocket/bean/SendMsgVo.java

@@ -23,6 +23,8 @@ public class SendMsgVo {
     private Long userType;
     @ApiModelProperty("消息代码")
     private String cmd;
+    @ApiModelProperty("消息ID(删除时必传,用于删库或从待入库队列移除)")
+    private Long msgId;
     @ApiModelProperty("发送消息")
     private String msg;
     @ApiModelProperty("消息")

+ 56 - 17
fs-live-socket/src/main/java/com/fs/live/websocket/service/WebSocketServer.java

@@ -119,12 +119,18 @@ public class WebSocketServer {
     private final static BlockingQueue<LiveMsg> liveMsgQueue = new LinkedBlockingQueue<>();
     // 聊天消息批量插入阈值:500条
     private final static int LIVE_MSG_BATCH_SIZE = 500;
-    // 聊天消息批量插入定时器间隔:10
-    private final static long LIVE_MSG_BATCH_INTERVAL = 10000; // 10
+    // 聊天消息批量插入定时器间隔:5
+    private final static long LIVE_MSG_BATCH_INTERVAL = 5000; // 5
     // Redis key:被禁言用户Set(按直播间)
     private final static String BLOCKED_USERS_KEY = "live:blocked:users:%s";
     private final static String MUTED_USERS_KEY = "live:muted:users:%s";
 
+    /** 临时消息ID生成器(负数,与数据库自增正数区分) */
+    private final static AtomicLong tempMsgIdCounter = new AtomicLong(0);
+    /** 已入库消息的 临时ID -> 数据库msgId 映射,用于删除时按临时ID找到真实ID */
+    private final static ConcurrentHashMap<Long, Long> tempIdToRealId = new ConcurrentHashMap<>();
+    private final static int TEMP_ID_MAP_MAX_SIZE = 100000;
+
     private final RedisCache redisCache = SpringUtils.getBean(RedisCache.class);
     private final StringRedisTemplate stringRedisTemplate = SpringUtils.getBean(StringRedisTemplate.class);
     private final ILiveMsgService liveMsgService = SpringUtils.getBean(ILiveMsgService.class);
@@ -398,6 +404,9 @@ public class WebSocketServer {
                         Integer replayFlag = flagMap.get("replayFlag");
                         liveMsg.setLiveFlag(liveFlag);
                         liveMsg.setReplayFlag(replayFlag);
+                        // 分配临时 msgId(负数),便于前端删除未入库消息及广播删除
+                        long tempId = -tempMsgIdCounter.incrementAndGet();
+                        liveMsg.setMsgId(tempId);
                         // 将消息加入批量插入队列
                         try {
                             liveMsgQueue.offer(liveMsg);
@@ -481,11 +490,34 @@ public class WebSocketServer {
     }
 
     private void deleteMsg(long liveId,SendMsgVo msg) {
+        Long msgId = msg.getMsgId();
+        if (msgId == null && StringUtils.isNotEmpty(msg.getMsg())) {
+            try {
+                msgId = Long.parseLong(msg.getMsg().trim());
+            } catch (NumberFormatException ignored) {
+                // 兼容旧版:msg 可能是文本
+            }
+        }
+        final Long resolvedMsgId = msgId;
+        if (resolvedMsgId != null) {
+            if (resolvedMsgId > 0) {
+                // 真实 msgId:本服务与后台可能不同库或后台未调用,此处统一删库(幂等),再广播
+                liveMsgService.deleteLiveMsgByMsgId(resolvedMsgId);
+            } else {
+                // 临时 msgId:从队列移除,若已入库则按映射删库,再广播
+                liveMsgQueue.removeIf(m -> resolvedMsgId.equals(m.getMsgId()));
+                Long realId = tempIdToRealId.remove(resolvedMsgId);
+                if (realId != null) {
+                    liveMsgService.deleteLiveMsgByMsgId(realId);
+                }
+            }
+        }
         SendMsgVo sendMsgVo = new SendMsgVo();
         sendMsgVo.setLiveId(liveId);
         sendMsgVo.setUserType(0L);
         sendMsgVo.setCmd("deleteMsg");
         sendMsgVo.setMsg(msg.getMsg());
+        sendMsgVo.setMsgId(resolvedMsgId);
         enqueueMessage(liveId, JSONObject.toJSONString(R.ok().put("data", sendMsgVo)), true);
     }
 
@@ -1060,7 +1092,7 @@ public class WebSocketServer {
         lastLikeCountCache.keySet().removeIf(liveId -> !activeLiveIds.contains(liveId));
     }
 
-    @Scheduled(fixedRate = LIVE_MSG_BATCH_INTERVAL) // 每10秒执行一次
+    @Scheduled(fixedRate = LIVE_MSG_BATCH_INTERVAL) // 每5秒执行一次
     public void batchInsertLiveMsg() {
         flushLiveMsgQueue();
     }
@@ -1096,31 +1128,38 @@ public class WebSocketServer {
     }
 
     /**
-     * 批量插入聊天消息队列
+     * 批量插入聊天消息队列:逐条插入以获取每条消息的 msgId,并维护临时ID到真实ID的映射,便于删除时按临时ID删库。
      */
     private void flushLiveMsgQueue() {
         if (liveMsgQueue.isEmpty()) {
             return;
         }
-        
+
         List<LiveMsg> batchList = new ArrayList<>();
-        // 从队列中取出所有消息(最多500条)
         int count = liveMsgQueue.drainTo(batchList, LIVE_MSG_BATCH_SIZE);
-        
+
         if (count > 0) {
-            try {
-                int inserted = liveMsgService.insertLiveMsgBatch(batchList);
-                log.debug("[聊天消息批量插入] 成功插入 {} 条消息", inserted);
-            } catch (Exception e) {
-                log.error("[聊天消息批量插入] 插入失败, 条数: {}, error: {}", count, e.getMessage(), e);
-                // 插入失败,将消息重新放回队列(避免消息丢失)
-                batchList.forEach(msg -> {
+            for (LiveMsg liveMsg : batchList) {
+                try {
+                    Long tempId = liveMsg.getMsgId();
+                    liveMsg.setMsgId(null);
+                    liveMsgService.insertLiveMsg(liveMsg);
+                    Long realId = liveMsg.getMsgId();
+                    if (tempId != null && realId != null) {
+                        tempIdToRealId.put(tempId, realId);
+                        if (tempIdToRealId.size() > TEMP_ID_MAP_MAX_SIZE) {
+                            tempIdToRealId.clear();
+                        }
+                    }
+                } catch (Exception e) {
+                    log.error("[聊天消息批量插入] 单条插入失败, liveId: {}, userId: {}, error: {}",
+                            liveMsg.getLiveId(), liveMsg.getUserId(), e.getMessage(), e);
                     try {
-                        liveMsgQueue.offer(msg);
+                        liveMsgQueue.offer(liveMsg);
                     } catch (Exception ex) {
-                        log.error("[聊天消息队列] 重新入队失败, liveId: {}, userId: {}", msg.getLiveId(), msg.getUserId());
+                        log.error("[聊天消息队列] 重新入队失败, liveId: {}, userId: {}", liveMsg.getLiveId(), liveMsg.getUserId());
                     }
-                });
+                }
             }
         }
     }

+ 16 - 2
fs-service-system/src/main/java/com/fs/erp/service/impl/JSTErpOrderServiceImpl.java

@@ -135,7 +135,13 @@ public class JSTErpOrderServiceImpl implements IErpOrderService {
 
             FsStoreProduct fsStoreProduct = fsStoreProductService.selectFsStoreProductById(item.getProductId());
 
-            orderItemDTO.setAmount(fsStoreProduct.getPrice());
+//            orderItemDTO.setAmount(fsStoreProduct.getPrice());
+            if (ObjectUtil.isNull(item.getNetPrice())) {
+                orderItemDTO.setAmount(fsStoreProduct.getPrice().multiply(BigDecimal.valueOf(item.getNum())));
+
+            } else {
+                orderItemDTO.setAmount(item.getNetPrice().multiply(BigDecimal.valueOf(item.getNum())));
+            }
 
             orderItemDTO.setQty(item.getNum().intValue());
             orderItemDTO.setOuterOiId(String.format("%s%s",item.getOrderCode(),item.getItemId()));
@@ -547,7 +553,15 @@ public class JSTErpOrderServiceImpl implements IErpOrderService {
 
             FsStoreProduct fsStoreProduct = fsStoreProductService.selectFsStoreProductById(item.getProductId());
 
-            orderItemDTO.setAmount(fsStoreProduct.getPrice());
+//            orderItemDTO.setAmount(fsStoreProduct.getPrice());
+//            orderItemDTO.setAmount(fsStoreProduct.getPrice().multiply(BigDecimal.valueOf(item.getNum())));
+
+            if (ObjectUtil.isNull(item.getNetPrice())) {
+                orderItemDTO.setAmount(fsStoreProduct.getPrice().multiply(BigDecimal.valueOf(item.getNum())));
+            } else {
+                orderItemDTO.setAmount(item.getNetPrice().multiply(BigDecimal.valueOf(item.getNum())));
+            }
+
 
             orderItemDTO.setQty(item.getNum().intValue());
             orderItemDTO.setOuterOiId(String.format("%s%s",item.getOrderCode(),item.getItemId()));

+ 6 - 0
fs-service-system/src/main/java/com/fs/live/domain/LiveOrderItem.java

@@ -3,6 +3,8 @@ package com.fs.live.domain;
 import com.fs.common.annotation.Excel;
 import lombok.Data;
 
+import java.math.BigDecimal;
+
 /**
  * 订单详情对象 live_order_item
  *
@@ -68,4 +70,8 @@ public class LiveOrderItem{
     private String warehouseCode;
 
 
+    /** 出库价(净价) */
+    @Excel(name = "出库价")
+    private BigDecimal netPrice;
+
 }

+ 1 - 1
fs-service-system/src/main/java/com/fs/live/mapper/LiveOrderItemMapper.java

@@ -85,7 +85,7 @@ public interface LiveOrderItemMapper {
 
     List<LiveOrderItemVo> selectCheckedByUserId(@Param("userId") String userId);
 
-    @Select("select product_id,json_info,order_code,item_id,num from live_order_item where order_id=#{orderId}")
+    @Select("select product_id,json_info,order_code,item_id,num,net_price from live_order_item where order_id=#{orderId}")
     List<LiveOrderItemListUVO> selectLiveOrderItemListUVOByOrderId(Long orderId);
 
     @Update("update live_order_item set order_code=#{orderCode} where order_id=#{orderId} ")

+ 8 - 0
fs-service-system/src/main/java/com/fs/live/mapper/LiveOrderMapper.java

@@ -60,6 +60,14 @@ public interface LiveOrderMapper {
      */
     int updateLiveOrder(LiveOrder liveOrder);
 
+    /**
+     * 批量修改订单价格
+     *
+     * @param list 待更新的订单列表
+     * @return 更新条数
+     */
+    int updateBatchLiveOrder(@Param("list") List<LiveOrder> list);
+
     /**
      * 删除订单
      *

+ 114 - 46
fs-service-system/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -1,6 +1,7 @@
 package com.fs.live.service.impl;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.sql.Timestamp;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -71,6 +72,7 @@ import com.fs.store.service.*;
 import com.fs.store.service.channel.PaymentHandler;
 import com.fs.store.service.channel.PaymentHandlerHolder;
 import com.fs.store.service.channel.param.PayProcessContext;
+import com.fs.store.vo.FsStoreProductActivityListVO;
 import com.fs.system.config.SnowflakeUtils;
 import com.fs.system.service.ISysConfigService;
 import com.fs.wx.domain.FsWxExpressTask;
@@ -986,16 +988,6 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 order.setDeliveryType(null);
             }
 
-            // 商品合计 = totalPrice + discountMoney - payDelivery (全部转为Double再相加减,保留两位小数)
-            Double totalPrice = order.getTotalPrice() != null ? Double.parseDouble(order.getTotalPrice().toString()) : 0d;
-            Double discountMoney = order.getDiscountMoney() != null ? Double.parseDouble(order.getDiscountMoney().toString()) : 0d;
-            double payDelivery = order.getPayDelivery() != null ? Double.parseDouble(order.getPayDelivery().toString()) : 0d;
-            double goodsAmount = totalPrice + discountMoney - payDelivery;
-            // 保留两位小数,进行四舍五入
-            goodsAmount = new java.math.BigDecimal(goodsAmount).setScale(2, java.math.RoundingMode.HALF_UP).doubleValue();
-
-            order.setPayPrice(order.getTotalPrice());
-            order.setTotalPrice(BigDecimal.valueOf(goodsAmount));
 
             LiveOrderPayment liveOrderPayment = paymentMap.get(String.valueOf(order.getOrderId()));
             if (ObjectUtil.isNotNull(liveOrderPayment)) {
@@ -1141,12 +1133,20 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         liveOrder.setPayType("1");
         liveOrder.setTotalPrice(totalPrice);
         liveOrder.setPayMoney(liveOrder.getTotalPrice());
+        liveOrder.setPayPrice(liveOrder.getTotalPrice());
 
 
         if (baseMapper.insertLiveOrder(liveOrder) > 0) {
             for (LiveOrderItem liveOrderItem : liveOrderItemList) {
                 liveOrderItem.setOrderId(liveOrder.getOrderId());
             }
+            //计算出库价(净价)
+            List<BigDecimal> netPrices = calcLiveItemNetPrices(liveOrder.getPayPrice(), liveOrderItemList);
+            for (int i = 0; i < liveOrderItemList.size(); i++) {
+                if (i < netPrices.size()) {
+                    liveOrderItemList.get(i).setNetPrice(netPrices.get(i));
+                }
+            }
             liveOrderItemMapper.insertBatchList(liveOrderItemList);
             // list Long  转为Long数组
 
@@ -1884,34 +1884,38 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 }
             }
         }
-        BigDecimal totalPrice = BigDecimal.ZERO;
-        BigDecimal payPrice = fsStoreProduct.getPrice().multiply(new BigDecimal(param.getTotalNum()));
+        // totalPrice = 商品总价(不含邮费)
+        BigDecimal totalPrice = fsStoreProduct.getPrice().multiply(new BigDecimal(param.getTotalNum()));
         if (fsStoreProductAttrValue != null) {
-            payPrice = fsStoreProductAttrValue.getPrice().multiply(new BigDecimal(param.getTotalNum()));
+            totalPrice = fsStoreProductAttrValue.getPrice().multiply(new BigDecimal(param.getTotalNum()));
         }
-        totalPrice = totalPrice.add(payPrice);
-        BigDecimal payDelivery = BigDecimal.ZERO;
-        BigDecimal deductionPrice = BigDecimal.ZERO;
+
+        // payPostage = 应付邮费
+        BigDecimal payPostage = BigDecimal.ZERO;
         if (param.getCityId() != null) {
-            payDelivery = handleDeliveryMoney(param.getCityId(), fsStoreProduct, param.getTotalNum(), fsStoreProductAttrValue);
-            payPrice = payPrice.add(payDelivery);
+            payPostage = handleDeliveryMoney(param.getCityId(), fsStoreProduct, param.getTotalNum(), fsStoreProductAttrValue);
         }
 
+        // payPrice = 支付总价(商品总价 + 邮费 - 优惠券)
+        BigDecimal payPrice = totalPrice.add(payPostage);
+        BigDecimal deductionPrice = BigDecimal.ZERO;
         if (param.getCouponUserId() != null) {
             LiveCouponUser couponUser = liveCouponUserService.selectLiveCouponUserById(param.getCouponUserId());
             if (couponUser != null && couponUser.getStatus() == 0) {
                 if (couponUser.getUseMinPrice().compareTo(payPrice) < 1) {
-                    payPrice = payPrice.subtract(couponUser.getCouponPrice());
                     deductionPrice = couponUser.getCouponPrice();
+                    payPrice = payPrice.subtract(deductionPrice);
                 }
             }
         }
 
 
-        return LiveOrderComputeDTO.builder().payPrice(payPrice)
-                .payDelivery(payDelivery)
-                .deductionPrice(deductionPrice)
+        return LiveOrderComputeDTO.builder()
                 .totalPrice(totalPrice)
+                .payPrice(payPrice)
+                .payPostage(payPostage)
+                .payDelivery(payPostage)
+                .deductionPrice(deductionPrice)
                 .build();
     }
 
@@ -2713,6 +2717,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         liveOrder.setPayType("1");
         liveOrder.setTotalPrice(totalPrice);
         liveOrder.setPayMoney(BigDecimal.ZERO);
+        liveOrder.setPayPrice(totalPrice);
         try {
             if (baseMapper.insertLiveOrder(liveOrder) > 0) {
                 liveUserLotteryRecord.setOrderId(liveOrder.getOrderId());
@@ -2738,6 +2743,14 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 liveOrderItem.setProductId(liveOrder.getProductId());
                 liveOrderItem.setNum(Long.valueOf(liveOrder.getTotalNum()));
                 liveOrderItem.setJsonInfo(JSON.toJSONString(dto));
+                //计算出库价(净价)- 单个商品情况
+                BigDecimal productTotal = fsStoreProduct.getPrice().multiply(new BigDecimal(liveOrder.getTotalNum()));
+                BigDecimal netPrice = BigDecimal.ZERO;
+                if (productTotal.compareTo(BigDecimal.ZERO) > 0 && liveOrder.getPayPrice() != null) {
+                    BigDecimal discountRate = liveOrder.getPayPrice().divide(productTotal, 10, RoundingMode.HALF_UP);
+                    netPrice = fsStoreProduct.getPrice().multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
+                }
+                liveOrderItem.setNetPrice(netPrice);
                 liveOrderItemMapper.insertLiveOrderItem(liveOrderItem);
                 redisCache.deleteObject("orderKey:" + liveOrder.getOrderKey());
                 return R.ok("下单成功").put("order", liveOrder);
@@ -3179,38 +3192,33 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
             }
         }
         
-        // 计算价格:如果有规格,使用规格价格;否则使用商品价格
-        BigDecimal payPrice = fsStoreProduct.getPrice().multiply(new BigDecimal(liveOrder.getTotalNum()));
+        // 计算价格(仿照 FsStoreOrderServiceImpl):
+        // totalPrice = 商品总价(不含邮费)
+        // payPostage = 应付邮费
+        // payPrice = 应付价格(商品总价 + 邮费 - 优惠券)
+        // payMoney = 实付价格(下单时等于应付价格)
+        BigDecimal totalPrice = fsStoreProduct.getPrice().multiply(new BigDecimal(liveOrder.getTotalNum()));
         if (fsStoreProductAttrValue != null) {
-            payPrice = fsStoreProductAttrValue.getPrice().multiply(new BigDecimal(liveOrder.getTotalNum()));
+            totalPrice = fsStoreProductAttrValue.getPrice().multiply(new BigDecimal(liveOrder.getTotalNum()));
         }
-        
-        // 直播不需要服务费 0915 1735 左
-//        String config=configService.selectConfigByKey("store.config");
-//        StoreConfig storeConfig= JSONUtil.toBean(config,StoreConfig.class);
-//        BigDecimal serviceFee=new BigDecimal(0);
-//        if(storeConfig.getServiceFee()!=null){
-//            if(liveOrder.getCompanyUserId()==null||liveOrder.getCompanyUserId()==0){
-//                serviceFee=storeConfig.getServiceFee();
-//            }
-//        }
-//        payPrice = payPrice.add(serviceFee);
-        // 生成
-        BigDecimal deliveryMoney = handleDeliveryMoney(liveOrder.getCityId(), fsStoreProduct, liveOrder.getTotalNum(), fsStoreProductAttrValue);
-        payPrice = payPrice.add(deliveryMoney);
-        liveOrder.setDiscountMoney(BigDecimal.ZERO);
+        liveOrder.setTotalPrice(totalPrice);
 
-        //优惠券处理
+        BigDecimal payPostage = handleDeliveryMoney(liveOrder.getCityId(), fsStoreProduct, liveOrder.getTotalNum(), fsStoreProductAttrValue);
+        liveOrder.setPayPostage(payPostage);
+        liveOrder.setPayDelivery(payPostage);
+
+        liveOrder.setDiscountMoney(BigDecimal.ZERO);
+        // 优惠券处理
         if (liveOrder.getCouponUserId() != null) {
             LiveCouponUser couponUser = liveCouponUserService.selectLiveCouponUserById(liveOrder.getCouponUserId());
             if (couponUser != null && couponUser.getStatus() == 0) {
                 if (!couponUser.getUserId().toString().equals(liveOrder.getUserId())) {
                     return R.error("非法操作");
                 }
-                if (couponUser.getUseMinPrice().compareTo(payPrice) < 1) {
+                BigDecimal payPriceBeforeCoupon = totalPrice.add(payPostage);
+                if (couponUser.getUseMinPrice().compareTo(payPriceBeforeCoupon) < 1) {
                     liveOrder.setUserCouponId(couponUser.getId());
                     liveOrder.setDiscountMoney(couponUser.getCouponPrice());
-                    //更新优惠券状态
                     couponUser.setStatus(1);
                     couponUser.setUseTime(new Date());
                     liveCouponUserService.updateLiveCouponUser(couponUser);
@@ -3218,15 +3226,18 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
             }
         }
 
+        // payPrice = 应付价格 = 商品总价 + 邮费 - 优惠券
+        BigDecimal payPrice = totalPrice.add(payPostage).subtract(liveOrder.getDiscountMoney() != null ? liveOrder.getDiscountMoney() : BigDecimal.ZERO);
+        liveOrder.setPayPrice(payPrice);
+        // payMoney = 实付价格(下单时等于应付价格)
+        liveOrder.setPayMoney(payPrice);
+
         liveOrder.setItemJson(JSON.toJSONString(fsStoreProduct));
         liveOrder.setCreateTime(new Date());
         liveOrder.setUpdateTime(new Date());
-        liveOrder.setPayDelivery(deliveryMoney);
         liveOrder.setProductId(fsStoreProduct.getProductId());
         liveOrder.setStatus(OrderInfoEnum.STATUS_1.getValue());
         liveOrder.setPayType("1");
-        liveOrder.setTotalPrice(payPrice);
-        liveOrder.setPayMoney(liveOrder.getTotalPrice().subtract(liveOrder.getDiscountMoney()));
         try {
             if (baseMapper.insertLiveOrder(liveOrder) > 0) {
                 LiveOrderItemDTO dto = new LiveOrderItemDTO();
@@ -3253,6 +3264,14 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 liveOrderItem.setProductId(liveOrder.getProductId());
                 liveOrderItem.setNum(Long.valueOf(liveOrder.getTotalNum()));
                 liveOrderItem.setJsonInfo(JSON.toJSONString(dto));
+                //计算出库价(净价)- 单个商品情况
+                BigDecimal productTotal = fsStoreProduct.getPrice().multiply(new BigDecimal(liveOrder.getTotalNum()));
+                BigDecimal netPrice = BigDecimal.ZERO;
+                if (productTotal.compareTo(BigDecimal.ZERO) > 0 && liveOrder.getPayPrice() != null) {
+                    BigDecimal discountRate = liveOrder.getPayPrice().divide(productTotal, 10, RoundingMode.HALF_UP);
+                    netPrice = fsStoreProduct.getPrice().multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
+                }
+                liveOrderItem.setNetPrice(netPrice);
                 liveOrderItemMapper.insertLiveOrderItem(liveOrderItem);
                 redisCache.deleteObject("orderKey:" + liveOrder.getOrderKey());
                 return R.ok("下单成功").put("order", liveOrder);
@@ -3348,6 +3367,55 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         return storePostage;
     }
 
+    /**
+     * 按前端 productOrder.vue 逻辑计算每个订单项的出库价(净价)
+     * 折扣率 = 应付金额/产品合计;前 n-1 项:净价=单价*折扣率(保留2位);最后一项:净价=(应付-前项净价*数量之和)/数量
+     */
+    private List<BigDecimal> calcLiveItemNetPrices(BigDecimal orderPayPrice, List<LiveOrderItem> liveOrderItemList) {
+        int n = liveOrderItemList.size();
+        List<BigDecimal> netPrices = new ArrayList<>(n);
+        if (n == 0 || orderPayPrice == null || orderPayPrice.compareTo(BigDecimal.ZERO) <= 0) {
+            for (int i = 0; i < n; i++) {
+                netPrices.add(BigDecimal.ZERO);
+            }
+            return netPrices;
+        }
+        BigDecimal productTotal = BigDecimal.ZERO;
+        for (LiveOrderItem item : liveOrderItemList) {
+            LiveOrderItemDTO dto = JSON.parseObject(item.getJsonInfo(), LiveOrderItemDTO.class);
+            BigDecimal price = dto.getPrice() != null ? dto.getPrice() : BigDecimal.ZERO;
+            long num = item.getNum() != null ? item.getNum() : 0;
+            productTotal = productTotal.add(price.multiply(BigDecimal.valueOf(num)));
+        }
+        if (productTotal.compareTo(BigDecimal.ZERO) <= 0) {
+            for (int i = 0; i < n; i++) {
+                netPrices.add(BigDecimal.ZERO);
+            }
+            return netPrices;
+        }
+        BigDecimal discountRate = orderPayPrice.divide(productTotal, 10, RoundingMode.HALF_UP);
+        BigDecimal previousTotal = BigDecimal.ZERO;
+        for (int i = 0; i < n; i++) {
+            LiveOrderItem item = liveOrderItemList.get(i);
+            LiveOrderItemDTO dto = JSON.parseObject(item.getJsonInfo(), LiveOrderItemDTO.class);
+            BigDecimal price = dto.getPrice() != null ? dto.getPrice() : BigDecimal.ZERO;
+            long num = item.getNum() != null ? item.getNum() : 0;
+            if (n == 1) {
+                netPrices.add(price.multiply(discountRate).setScale(2, RoundingMode.HALF_UP));
+                break;
+            }
+            if (i == n - 1) {
+                BigDecimal lastNet = num > 0 ? orderPayPrice.subtract(previousTotal).divide(BigDecimal.valueOf(num), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
+                netPrices.add(lastNet);
+            } else {
+                BigDecimal net = price.multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
+                netPrices.add(net);
+                previousTotal = previousTotal.add(net.multiply(BigDecimal.valueOf(num)));
+            }
+        }
+        return netPrices;
+    }
+
     @Override
     public R confirmOrder(LiveOrderConfirmParam param) {
         String uuid = IdUtil.randomUUID();

+ 3 - 0
fs-service-system/src/main/java/com/fs/live/vo/LiveOrderItemListUVO.java

@@ -3,6 +3,7 @@ package com.fs.live.vo;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 
 @Data
 public class LiveOrderItemListUVO implements Serializable {
@@ -18,5 +19,7 @@ public class LiveOrderItemListUVO implements Serializable {
     /** 数量 */
     private Long num;
 
+    private BigDecimal netPrice;
+
 
 }

+ 3 - 0
fs-service-system/src/main/java/com/fs/live/vo/LiveOrderItemVo.java

@@ -76,4 +76,7 @@ public class LiveOrderItemVo {
 
     private String productIntroduce;
 
+    /** 出库价(净价) */
+    private BigDecimal netPrice;
+
 }

+ 6 - 0
fs-service-system/src/main/java/com/fs/store/domain/FsStoreOrderItem.java

@@ -5,6 +5,8 @@ import com.fs.common.core.domain.BaseEntity;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.math.BigDecimal;
+
 /**
  * 订单详情对象 fs_store_order_item
  *
@@ -53,4 +55,8 @@ public class FsStoreOrderItem extends BaseEntity
     private Integer isPrescribe;
 
 
+    /** 出库价(净价) */
+    @Excel(name = "出库价")
+    private BigDecimal netPrice;
+
 }

+ 2 - 0
fs-service-system/src/main/java/com/fs/store/service/IFsUserService.java

@@ -140,4 +140,6 @@ public interface IFsUserService
     HisFsUserVO getHisUserIntegralWithLogs(FsUser user);
 
     FsUser selectWsFsUserById(long userId);
+
+    R loginByApp(FsUser param);
 }

+ 1 - 1
fs-service-system/src/main/java/com/fs/store/service/channel/HfPaymentHandler.java

@@ -103,7 +103,7 @@ public class HfPaymentHandler extends PaymentHandler{
             mt.setPaymentId(context.getPaymentId());
             mt.setTradeNo(result.getHf_seq_id());
             this.liveOrderPaymentService.updateLiveOrderPayment(mt);
-            return R.ok().put("payType", context.getPayType()).put("result", result.getPay_info());
+            return R.ok().put("payType", context.getPayType()).put("result", result.getPay_info()).put("type","hf");
         }
         else{
             return R.error(result.getResp_desc());

+ 1 - 1
fs-service-system/src/main/java/com/fs/store/service/channel/TzbkPaymentHandler.java

@@ -220,7 +220,7 @@ public class TzbkPaymentHandler extends PaymentHandler{
                     this.liveOrderPaymentService.updateLiveOrderPayment(mt);
                     TzMiniProgramCodeRespDTO result = miniProgramCode.getBody();
                     result.setPayCode(context.getPayCode());
-                    return R.ok().put("payType",context.getPayType()).put("result",result);
+                    return R.ok().put("payType",context.getPayType()).put("result",result).put("type","tz");
                 } else {
                     return R.error(miniProgramCode.getRetMsg());
                 }

+ 1 - 1
fs-service-system/src/main/java/com/fs/store/service/channel/YbPaymentHandler.java

@@ -92,7 +92,7 @@ public class YbPaymentHandler extends PaymentHandler{
             ment.setPaymentId(context.getPaymentId());
             ment.setTradeNo(wxOrder.getUpOrderId());
             this.liveOrderPaymentService.updateLiveOrderPayment(ment);
-            return R.ok().put("payType",context.getPayType()).put("result",wxOrder.getPay_info());
+            return R.ok().put("payType",context.getPayType()).put("result",wxOrder.getPay_info()).put("type","yb");
         }
         else{
             throw new CustomException(String.format("支付出现异常: {}",wxOrder.getMessage()));

+ 60 - 2
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreOrderServiceImpl.java

@@ -921,10 +921,13 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
             }
             //减库存加销量
             this.deStockIncSale(carts);
+            //按前端逻辑计算出库价(净价)
+            List<BigDecimal> netPrices = calcItemNetPrices(storeOrder.getPayPrice(), carts);
             //保存OrderItem
             List<FsStoreOrderItem> listOrderItem=new ArrayList<>();
             //保存购物车商品信息
-            for(FsStoreCartQueryVO vo:carts){
+            for(int i = 0; i < carts.size(); i++){
+                FsStoreCartQueryVO vo = carts.get(i);
                 FsStoreCartDTO fsStoreCartDTO=new FsStoreCartDTO();
                 fsStoreCartDTO.setProductId(vo.getProductId());
                 fsStoreCartDTO.setPrice(vo.getPrice());
@@ -958,6 +961,10 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
                 if(vo.getProductType().equals(2)){
                     item.setIsPrescribe(1);
                 }
+                //设置出库价(净价)
+                if(i < netPrices.size()){
+                    item.setNetPrice(netPrices.get(i));
+                }
                 fsStoreOrderItemMapper.insertFsStoreOrderItem(item);
                 listOrderItem.add(item);
             }
@@ -1018,6 +1025,50 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 
     }
 
+    /**
+     * 按前端 productOrder.vue 逻辑计算每个订单项的出库价(净价)
+     * 折扣率 = 应付金额/产品合计;前 n-1 项:净价=单价*折扣率(保留2位);最后一项:净价=(应付-前项净价*数量之和)/数量
+     */
+    private List<BigDecimal> calcItemNetPrices(BigDecimal orderPayPrice, List<FsStoreCartQueryVO> carts) {
+        int n = carts.size();
+        List<BigDecimal> netPrices = new ArrayList<>(n);
+        if (n == 0 || orderPayPrice == null || orderPayPrice.compareTo(BigDecimal.ZERO) <= 0) {
+            return netPrices;
+        }
+        BigDecimal productTotal = BigDecimal.ZERO;
+        for (FsStoreCartQueryVO vo : carts) {
+            BigDecimal price = vo.getPrice() != null ? vo.getPrice() : BigDecimal.ZERO;
+            int num = vo.getCartNum() != null ? vo.getCartNum() : 0;
+            productTotal = productTotal.add(price.multiply(BigDecimal.valueOf(num)));
+        }
+        if (productTotal.compareTo(BigDecimal.ZERO) <= 0) {
+            for (int i = 0; i < n; i++) {
+                netPrices.add(BigDecimal.ZERO);
+            }
+            return netPrices;
+        }
+        BigDecimal discountRate = orderPayPrice.divide(productTotal, 10, RoundingMode.HALF_UP);
+        BigDecimal previousTotal = BigDecimal.ZERO;
+        for (int i = 0; i < n; i++) {
+            FsStoreCartQueryVO vo = carts.get(i);
+            BigDecimal price = vo.getPrice() != null ? vo.getPrice() : BigDecimal.ZERO;
+            int num = vo.getCartNum() != null ? vo.getCartNum() : 0;
+            if (n == 1) {
+                netPrices.add(price.multiply(discountRate).setScale(2, RoundingMode.HALF_UP));
+                break;
+            }
+            if (i == n - 1) {
+                BigDecimal lastNet = num > 0 ? orderPayPrice.subtract(previousTotal).divide(BigDecimal.valueOf(num), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
+                netPrices.add(lastNet);
+            } else {
+                BigDecimal net = price.multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
+                netPrices.add(net);
+                previousTotal = previousTotal.add(net.multiply(BigDecimal.valueOf(num)));
+            }
+        }
+        return netPrices;
+    }
+
     public void deStockIncSale(List<FsStoreCartQueryVO> cartInfo) {
         for (FsStoreCartQueryVO storeCartVO : cartInfo) {
             productService.decProductStock(storeCartVO.getProductId(),
@@ -1657,8 +1708,11 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
             }
             //减库存加销量
             this.deStockIncSale(carts);
+            //计算出库价(净价)
+            List<BigDecimal> netPrices = calcItemNetPrices(storeOrder.getPayPrice(), carts);
             //保存购物车商品信息
-            for(FsStoreCartQueryVO vo:carts){
+            for(int i = 0; i < carts.size(); i++){
+                FsStoreCartQueryVO vo = carts.get(i);
                 FsStoreCartDTO fsStoreCartDTO=new FsStoreCartDTO();
                 fsStoreCartDTO.setProductId(vo.getProductId());
                 fsStoreCartDTO.setPrice(vo.getPrice());
@@ -1685,6 +1739,10 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
                 if(vo.getProductType().equals(2)){
                     item.setIsPrescribe(1);
                 }
+                //设置出库价(净价)
+                if(i < netPrices.size()){
+                    item.setNetPrice(netPrices.get(i));
+                }
                 fsStoreOrderItemMapper.insertFsStoreOrderItem(item);
             }
             //删除缓存

+ 26 - 0
fs-service-system/src/main/java/com/fs/store/service/impl/FsUserServiceImpl.java

@@ -440,6 +440,32 @@ public class FsUserServiceImpl implements IFsUserService
         return fsUserTuiMoneyRankMapper.selectFsUserShareList(type);
     }
 
+
+    @Override
+    public R loginByApp(FsUser param) {
+        if (param == null) {
+            return null;
+        }
+        if (param.getUnionId() == null && param.getMaOpenId() == null) {
+            return null;
+        }
+        FsUser user=fsUserMapper.selectFsUserByMaOpenIdOrUnionId(param.getMaOpenId(),param.getUnionId());
+        if (user == null) {
+            //写入
+            user=new FsUser();
+            user.setPhone(param.getPhone());
+            user.setNickname("微信用户");
+            user.setStatus(1);
+            user.setMaOpenId(param.getMaOpenId());
+            user.setIsWeixinAuth(0);
+            user.setCreateTime(new Date());
+            user.setUnionId(param.getUnionId());
+            this.insertFsUser(user);
+        }
+        String token = jwtUtils.generateToken(user.getUserId());
+        return R.ok("登录成功").put("token",token);
+    }
+
     @Override
     public R loginByMiniApp(LoginMpWxParam param) {
         if (StringUtils.isBlank(param.getCode())) {

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

@@ -4,6 +4,7 @@ import com.fs.common.annotation.Excel;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 
 @Data
 public class FsStoreOrderItemVO  implements Serializable
@@ -46,4 +47,8 @@ public class FsStoreOrderItemVO  implements Serializable
     @Excel(name = "是否为处方")
     private Integer isPrescribe;
 
+    /** 出库价(净价) */
+    @Excel(name = "出库价")
+    private BigDecimal netPrice;
+
 }

+ 7 - 3
fs-service-system/src/main/resources/mapper/live/LiveOrderItemMapper.xml

@@ -18,6 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="isPrescribe"    column="is_prescribe"    />
         <result property="storeId"    column="store_id"    />
         <result property="isGift"    column="is_gift"    />
+        <result property="netPrice"    column="net_price"    />
     </resultMap>
     <resultMap id="liveOrderItemVoMap" type="com.fs.live.vo.LiveOrderItemVo">
         <result property="itemId" column="item_id"/>
@@ -43,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
     <sql id="selectLiveOrderItemVo">
-        select item_id, order_id, order_code, cart_id, goods_id, product_id, product_attr_value_id, json_info, num, is_after_sales, is_prescribe, store_id, is_gift from live_order_item
+        select item_id, order_id, order_code, cart_id, goods_id, product_id, product_attr_value_id, json_info, num, is_after_sales, is_prescribe, store_id, is_gift, net_price from live_order_item
     </sql>
 
     <select id="selectLiveOrderItemList" parameterType="LiveOrderItem" resultMap="LiveOrderItemResult">
@@ -93,6 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isPrescribe != null">is_prescribe,</if>
             <if test="storeId != null">store_id,</if>
             <if test="isGift != null">is_gift,</if>
+            <if test="netPrice != null">net_price,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="orderId != null and orderId != ''">#{orderId},</if>
@@ -107,15 +109,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isPrescribe != null">#{isPrescribe},</if>
             <if test="storeId != null">#{storeId},</if>
             <if test="isGift != null">#{isGift},</if>
+            <if test="netPrice != null">#{netPrice},</if>
          </trim>
     </insert>
 
     <insert id="insertBatchList" parameterType="java.util.List">
         insert into live_order_item
-        ( order_id, order_code, cart_id, goods_id, product_id, product_attr_value_id, json_info, num, is_after_sales, is_prescribe, store_id, is_gift)
+        ( order_id, order_code, cart_id, goods_id, product_id, product_attr_value_id, json_info, num, is_after_sales, is_prescribe, store_id, is_gift, net_price)
         values
         <foreach collection="liveOrderItemList" item="item" separator=",">
-            ( #{item.orderId}, #{item.orderCode}, #{item.cartId}, #{item.goodsId}, #{item.productId}, #{item.productAttrValueId}, #{item.jsonInfo}, #{item.num}, #{item.isAfterSales}, #{item.isPrescribe}, #{item.storeId}, #{item.isGift})
+            ( #{item.orderId}, #{item.orderCode}, #{item.cartId}, #{item.goodsId}, #{item.productId}, #{item.productAttrValueId}, #{item.jsonInfo}, #{item.num}, #{item.isAfterSales}, #{item.isPrescribe}, #{item.storeId}, #{item.isGift}, #{item.netPrice})
         </foreach>
     </insert>
 
@@ -134,6 +137,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isPrescribe != null">is_prescribe = #{isPrescribe},</if>
             <if test="storeId != null">store_id = #{storeId},</if>
             <if test="isGift != null">is_gift = #{isGift},</if>
+            <if test="netPrice != null">net_price = #{netPrice},</if>
         </trim>
         where item_id = #{itemId}
     </update>

+ 13 - 0
fs-service-system/src/main/resources/mapper/live/LiveOrderMapper.xml

@@ -433,6 +433,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where order_id = #{orderId}
     </update>
 
+    <update id="updateBatchLiveOrder" parameterType="java.util.List">
+        <foreach collection="list" item="item" separator=";">
+            update live_order
+            set total_price = #{item.totalPrice},
+                pay_price = #{item.payPrice},
+                pay_money = #{item.payMoney},
+                pay_delivery = #{item.payDelivery},
+                pay_postage = #{item.payPostage},
+                store_id = #{item.storeId}
+            where order_id = #{item.orderId}
+        </foreach>
+    </update>
+
     <delete id="deleteLiveOrderByOrderId" parameterType="String">
         delete from live_order where order_id = #{orderId}
     </delete>

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

@@ -14,10 +14,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="num"    column="num"    />
         <result property="isAfterSales"    column="is_after_sales"    />
         <result property="isPrescribe"    column="is_prescribe"    />
+        <result property="netPrice"    column="net_price"    />
     </resultMap>
 
     <sql id="selectFsStoreOrderItemVo">
-        select item_id, order_id, order_code, cart_id, product_id, json_info, num, is_after_sales,is_prescribe from fs_store_order_item
+        select item_id, order_id, order_code, cart_id, product_id, json_info, num, is_after_sales, is_prescribe, net_price from fs_store_order_item
     </sql>
 
     <select id="selectFsStoreOrderItemList" parameterType="FsStoreOrderItem" resultMap="FsStoreOrderItemResult">
@@ -50,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="num != null">num,</if>
             <if test="isAfterSales != null">is_after_sales,</if>
             <if test="isPrescribe != null">is_prescribe,</if>
+            <if test="netPrice != null">net_price,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="orderId != null">#{orderId},</if>
@@ -60,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="num != null">#{num},</if>
             <if test="isAfterSales != null">#{isAfterSales},</if>
             <if test="isPrescribe != null">#{isPrescribe},</if>
+            <if test="netPrice != null">#{netPrice},</if>
          </trim>
     </insert>
 
@@ -74,6 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="num != null">num = #{num},</if>
             <if test="isAfterSales != null">is_after_sales = #{isAfterSales},</if>
             <if test="isPrescribe != null">is_prescribe = #{isPrescribe},</if>
+            <if test="netPrice != null">net_price = #{netPrice},</if>
         </trim>
         where item_id = #{itemId}
     </update>

+ 7 - 0
fs-user-app/src/main/java/com/fs/app/controller/WxUserController.java

@@ -158,6 +158,13 @@ public class WxUserController extends AppBaseController{
         logger.info("小程序登录 {}",param);
         return userService.loginByMiniApp(param);
     }
+
+    @ApiOperation("小程序登录")
+    @PostMapping("/loginByApp")
+    public R loginByApp( @RequestBody FsUser param) {
+        logger.info("小程序登录 {}",param);
+        return userService.loginByApp(param);
+    }
     @ApiOperation("公众号登录")
     @PostMapping("/loginByMp")
     @Synchronized