Browse Source

Merge remote-tracking branch 'origin/ScrmStores' into ScrmStores

zhangqin 4 days ago
parent
commit
72b1f6fdec
35 changed files with 2763 additions and 54 deletions
  1. 1 1
      fs-company/src/main/resources/application.yml
  2. 0 2
      fs-service/src/main/java/com/fs/course/service/impl/FsCourseTrafficLogServiceImpl.java
  3. 3 0
      fs-service/src/main/java/com/fs/hisStore/domain/FsStoreOrderScrm.java
  4. 1 0
      fs-service/src/main/java/com/fs/hisStore/domain/FsStorePaymentScrm.java
  5. 3 0
      fs-service/src/main/java/com/fs/hisStore/domain/FsStoreProductAttrValueScrm.java
  6. 4 0
      fs-service/src/main/java/com/fs/hisStore/dto/FsStoreCartDTO.java
  7. 75 0
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreCartScrmMapper.java
  8. 5 0
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderScrmMapper.java
  9. 3 0
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStorePaymentScrmMapper.java
  10. 15 0
      fs-service/src/main/java/com/fs/hisStore/param/FsStoreConfirmOrderGroupStoreParam.java
  11. 24 0
      fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderComputedGroupStoreParam.java
  12. 52 0
      fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderCreateGroupStoreParam.java
  13. 5 0
      fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderCreateParam.java
  14. 22 0
      fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderOtherPayCombinationIdParam.java
  15. 21 0
      fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderPayCombinationIdParam.java
  16. 6 1
      fs-service/src/main/java/com/fs/hisStore/service/IFsStoreCartScrmService.java
  17. 12 0
      fs-service/src/main/java/com/fs/hisStore/service/IFsStoreOrderScrmService.java
  18. 4 0
      fs-service/src/main/java/com/fs/hisStore/service/IFsStorePaymentScrmService.java
  19. 3 1
      fs-service/src/main/java/com/fs/hisStore/service/IFsStoreProductPackageScrmService.java
  20. 34 0
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreCartScrmServiceImpl.java
  21. 812 36
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java
  22. 31 0
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStorePaymentScrmServiceImpl.java
  23. 9 7
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductScrmServiceImpl.java
  24. 13 0
      fs-service/src/main/java/com/fs/hisStore/vo/FsHuiFuPayInfo.java
  25. 15 0
      fs-service/src/main/java/com/fs/hisStore/vo/FsOrderMoneyDetailsVo.java
  26. 12 0
      fs-service/src/main/java/com/fs/hisStore/vo/FsStoreCartGroupStoreVO.java
  27. 16 0
      fs-service/src/main/java/com/fs/hisStore/vo/FsStoreCartQueryGroupStoreVO.java
  28. 1006 0
      fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderGroupStoreVO.java
  29. 6 0
      fs-service/src/main/java/com/fs/store/vo/FsStoreCartScrmQueryVO.java
  30. 3 0
      fs-service/src/main/java/com/fs/store/vo/FsStoreCartScrmVO.java
  31. 9 1
      fs-service/src/main/resources/mapper/hisStore/FsStoreOrderScrmMapper.xml
  32. 3 0
      fs-service/src/main/resources/mapper/hisStore/FsStoreProductAttrValueScrmMapper.xml
  33. 22 0
      fs-user-app/src/main/java/com/fs/app/controller/store/PayScrmController.java
  34. 9 5
      fs-user-app/src/main/java/com/fs/app/controller/store/ProductScrmController.java
  35. 504 0
      fs-user-app/src/main/java/com/fs/app/controller/store/StoreOrderScrmController.java

+ 1 - 1
fs-company/src/main/resources/application.yml

@@ -4,7 +4,7 @@ server:
 spring:
 spring:
   profiles:
   profiles:
 #    active: druid-fcky-test
 #    active: druid-fcky-test
-    active: druid-jnmy-test
+    active: dev-yjb
 #    active: druid-jzzx-test
 #    active: druid-jzzx-test
 #    active: druid-hdt
 #    active: druid-hdt
 #    active: druid-sxjz
 #    active: druid-sxjz

+ 0 - 2
fs-service/src/main/java/com/fs/course/service/impl/FsCourseTrafficLogServiceImpl.java

@@ -185,8 +185,6 @@ public class FsCourseTrafficLogServiceImpl implements IFsCourseTrafficLogService
         }
         }
         if (ObjectUtils.isNotEmpty(param.getTabType())&&param.getTabType().equals("common")){
         if (ObjectUtils.isNotEmpty(param.getTabType())&&param.getTabType().equals("common")){
             param.setCommon(param.getTabType());
             param.setCommon(param.getTabType());
-        }else if(ObjectUtils.isNotNull(param.getCompanyId())){
-            param.setCommon("company");
         }
         }
         List<FsCourseTrafficLogListVO> fsCourseTrafficLogListVOS = fsCourseTrafficLogMapper.selectTrafficNew(param);
         List<FsCourseTrafficLogListVO> fsCourseTrafficLogListVOS = fsCourseTrafficLogMapper.selectTrafficNew(param);
         for (FsCourseTrafficLogListVO log : fsCourseTrafficLogListVOS) {
         for (FsCourseTrafficLogListVO log : fsCourseTrafficLogListVOS) {

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreOrderScrm.java

@@ -351,4 +351,7 @@ public class FsStoreOrderScrm extends BaseEntity
     private BigDecimal billPrice;
     private BigDecimal billPrice;
     private String erpPhone;
     private String erpPhone;
 
 
+    //组合订单标识
+    private String combinationOrderId;
+
 }
 }

+ 1 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStorePaymentScrm.java

@@ -101,5 +101,6 @@ public class FsStorePaymentScrm extends BaseEntity
     private BigDecimal shareMoney;
     private BigDecimal shareMoney;
     private Integer isShare;
     private Integer isShare;
 
 
+    private String paySubCode;
 
 
 }
 }

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreProductAttrValueScrm.java

@@ -100,4 +100,7 @@ public class FsStoreProductAttrValueScrm extends BaseEntity
     /** 需要多少积分兑换 */
     /** 需要多少积分兑换 */
     @Excel(name = "需要多少积分兑换")
     @Excel(name = "需要多少积分兑换")
     private Integer giveIntegral;
     private Integer giveIntegral;
+
+    //店铺ID
+    private Long storeId;
 }
 }

+ 4 - 0
fs-service/src/main/java/com/fs/hisStore/dto/FsStoreCartDTO.java

@@ -31,4 +31,8 @@ import java.math.BigDecimal;
 
 
     private BigDecimal brokerageThree;
     private BigDecimal brokerageThree;
 
 
+    private String erpCode;
+
+    private String erpSkuName;
+
 }
 }

+ 75 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreCartScrmMapper.java

@@ -4,9 +4,12 @@ import java.util.List;
 
 
 import com.fs.hisStore.config.MedicalMallConfig;
 import com.fs.hisStore.config.MedicalMallConfig;
 import com.fs.hisStore.domain.FsStoreCartScrm;
 import com.fs.hisStore.domain.FsStoreCartScrm;
+import com.fs.hisStore.domain.FsStoreScrm;
 import com.fs.hisStore.param.FsStoreCartCountParam;
 import com.fs.hisStore.param.FsStoreCartCountParam;
 import com.fs.hisStore.vo.FsStoreCartQueryVO;
 import com.fs.hisStore.vo.FsStoreCartQueryVO;
 import com.fs.hisStore.vo.FsStoreCartVO;
 import com.fs.hisStore.vo.FsStoreCartVO;
+import com.fs.store.vo.FsStoreCartScrmQueryVO;
+import com.fs.store.vo.FsStoreCartScrmVO;
 import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Select;
@@ -112,4 +115,76 @@ public interface FsStoreCartScrmMapper
             "</if>" +
             "</if>" +
             "</script>"})
             "</script>"})
     Integer selectFsStoreCartCount(@Param("maps") FsStoreCartCountParam param);
     Integer selectFsStoreCartCount(@Param("maps") FsStoreCartCountParam param);
+
+    @Select({"<script> " +
+            "select q.* FROM (" +
+            "select c.*,p.cate_id,p.product_name,p.image as product_image,p.temp_id,p.product_type,v.price,v.ot_price," +
+            "v.sku as product_attr_name,v.image as product_attr_image,v.stock,v.cost,v.integral,v.weight," +
+            "v.volume,v.bar_code,v.group_bar_code,v.brokerage,v.brokerage_two," +
+            "v.brokerage_three,s.store_id,s.store_name from fs_store_cart_scrm c left join fs_store_product_scrm p " +
+            "on p.product_id=c.product_id left join fs_store_product_attr_value_scrm v on v.id=c.product_attr_value_id " +
+            "left join fs_store_scrm s on v.store_id=s.store_id " +
+            "where find_in_set(c.id,#{ids})" +
+            ") q where 1= 1" +
+            "<if test = 'storeId != null    '> " +
+//                "and q.store_id =#{storeId} " +
+//                "</if>" +
+//                "<if test = 'storeId == -1    '> " +
+//                "and q.store_id IS NULL " +
+            "<choose>" +
+            "<when test='storeId == -1'>" +
+            "and q.store_id IS NULL" +
+            "</when>" +
+            "<otherwise>" +
+            "and q.store_id =#{storeId} " +
+            "</otherwise>" +
+            "</choose>" +
+            "</if>" +
+            "</script>"})
+    List<FsStoreCartScrmQueryVO> selectFsStoreCartMultiStoreListByIds(@Param("ids") String ids, @Param("storeId")Long storeId);
+
+    @Select(
+//            "select s.*" +
+//                    "from fs_store_cart c " +
+//                    "inner join fs_store_product p on p.product_id=c.product_id " +
+//                    "inner join fs_store_product_attr_value v on v.id=c.product_attr_value_id " +
+//                    "left join fs_store s on v.store_id = s.store_id " +
+//                    "where c.is_pay=0 and c.is_del=0 and c.is_buy=0 and p.is_show=1 and p.is_del=0 and c.user_id= #{uid} GROUP BY s.store_id"
+            "SELECT sorted.store_id, sorted.store_name" +
+                    " FROM (" +
+                    "SELECT c.id, c.product_id, c.product_attr_value_id, c.user_id, c.create_time AS cart_create_time," +
+                    "s.store_id, s.store_name " +
+                    "FROM fs_store_cart_scrm c " +
+                    "INNER JOIN fs_store_product_scrm p ON p.product_id = c.product_id " +
+                    "INNER JOIN fs_store_product_attr_value_scrm v ON v.id = c.product_attr_value_id " +
+                    "LEFT JOIN fs_store_scrm s ON v.store_id = s.store_id " +
+                    "WHERE c.is_pay = 0 AND c.is_del = 0 AND c.is_buy = 0 AND p.is_show = 1 AND p.is_del = 0 AND c.user_id= #{uid} " +
+                    "ORDER BY c.create_time DESC " +
+                    ") sorted " +
+                    "GROUP BY sorted.store_id;"
+    )
+    List<FsStoreScrm> selectFsStoreByUid(long uid);
+
+    @Select({"<script> " +
+            "select q.* FROM (" +
+            "select c.*,p.product_type,p.product_name,p.image as product_image,v.price,v.sku as product_attr_name," +
+            "v.image as product_attr_image,v.stock,s.store_id,s.store_name " +
+            "from fs_store_cart_scrm c " +
+            "inner join fs_store_product_scrm p on p.product_id=c.product_id " +
+            "inner join fs_store_product_attr_value_scrm v on v.id=c.product_attr_value_id " +
+            "left join fs_store_scrm s on v.store_id = s.store_id " +
+            "where c.is_pay=0 and c.is_del=0 and c.is_buy=0 and p.is_show=1 and p.is_del=0 and c.user_id= #{uid}" +
+            ") q where 1= 1" +
+            "<if test = 'storeId != null    '> " +
+            "<choose>" +
+            "<when test='storeId == -1'>" +
+            "and q.store_id IS NULL" +
+            "</when>" +
+            "<otherwise>" +
+            "and q.store_id =#{storeId} " +
+            "</otherwise>" +
+            "</choose>" +
+            "</if>" +
+            "</script>"})
+    List<FsStoreCartScrmVO> selectFsStoreCartListByUidMultiStore(@Param("uid") long uid, @Param("storeId") Long storeId);
 }
 }

+ 5 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderScrmMapper.java

@@ -1217,4 +1217,9 @@ public interface FsStoreOrderScrmMapper
             "        where order_code = #{orderCode}"+
             "        where order_code = #{orderCode}"+
             "</script>"})
             "</script>"})
     int updateFsStoreOrderByOrderCode(FsStoreOrderScrm fsStoreOrder);
     int updateFsStoreOrderByOrderCode(FsStoreOrderScrm fsStoreOrder);
+
+    List<FsStoreOrderScrm> getStoreOrderByCombinationId(String combinationId);
+
+    @Select("select * from fs_store_order_scrm where id in (#{orderIds})")
+    List<FsStoreOrderScrm> selectFsStoreOrderByOrderIds(String orderIds);
 }
 }

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsStorePaymentScrmMapper.java

@@ -352,4 +352,7 @@ public interface FsStorePaymentScrmMapper
 
 
     @Select("select * from fs_store_payment_scrm where pay_code=#{payCode}")
     @Select("select * from fs_store_payment_scrm where pay_code=#{payCode}")
     FsStorePaymentScrm selectFsStorePaymentByPaymentCode(String payCode);
     FsStorePaymentScrm selectFsStorePaymentByPaymentCode(String payCode);
+
+    @Select("select * from fs_store_payment_scrm where pay_code=#{payCode}")
+    List<FsStorePaymentScrm> selectFsStorePaymentByPaymentCodeList(String payCode);
 }
 }

+ 15 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreConfirmOrderGroupStoreParam.java

@@ -0,0 +1,15 @@
+package com.fs.hisStore.param;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class FsStoreConfirmOrderGroupStoreParam {
+//    @NotBlank(message = "请提交购买的商品")
+//    @ApiModelProperty(value = "购物车ID 多个,分隔")
+    private Long storeId;
+//    @NotBlank(message = "购买类型不能为空")
+//    @ApiModelProperty(value = "buy cart")
+    private FsStoreConfirmOrderParam data;
+}

+ 24 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderComputedGroupStoreParam.java

@@ -0,0 +1,24 @@
+package com.fs.hisStore.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class FsStoreOrderComputedGroupStoreParam {
+//    @ApiModelProperty(value = "orderKey")
+//    private String orderKey;
+    @ApiModelProperty(value = "orderKeys")
+    private List<String> orderKeys;
+    //@NotBlank(message = "请选择地址")
+    @ApiModelProperty(value = "地址ID")
+    private Long addressId;
+
+    @ApiModelProperty(value = "使用积分 1使用")
+    private Integer useIntegral;
+    @ApiModelProperty(value = "优惠券")
+    private Long couponUserId;
+
+    private String createOrderKey;
+}

+ 52 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderCreateGroupStoreParam.java

@@ -0,0 +1,52 @@
+package com.fs.hisStore.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+public class FsStoreOrderCreateGroupStoreParam {
+    private Long companyId;
+    private Long companyUserId;
+    private Long userId;
+
+    @ApiModelProperty(value = "orderKeys")
+    @NotNull(message = "orderKeys不能为空")
+    private List<String> orderKeys;
+
+    @ApiModelProperty(value = "地址ID")
+    @NotNull(message = "地址不能为空")
+    private Long addressId;
+
+    @ApiModelProperty(value = "来源")
+    private String from;
+
+    @Size(max = 200,message = "长度超过了限制")
+    @ApiModelProperty(value = "备注")
+    private List<String> mark;
+
+    @NotBlank(message="请选择支付方式")
+    @ApiModelProperty(value = "支付方式")
+    private String payType;
+
+    @ApiModelProperty(value = "使用积分 1使用")
+    private Integer useIntegral;
+    private BigDecimal payPrice;
+    private Long paymentId;
+
+    @ApiModelProperty(value = "优惠券")
+    private Long couponUserId;
+
+    private Long tuiUserId;
+
+    private String createOrderKey;
+    //订单创建类型 1普通订单 2套餐订单 3制单
+    private Integer orderCreateType;
+
+    private Long storeId;
+}

+ 5 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderCreateParam.java

@@ -56,4 +56,9 @@ public class FsStoreOrderCreateParam implements Serializable
     private Integer orderMedium; //媒体来源
     private Integer orderMedium; //媒体来源
 
 
     private Boolean isUserApp = true;
     private Boolean isUserApp = true;
+
+    private Long storeId;
+
+    //组合订单唯一标识
+    private String combinationOrderId;
 }
 }

+ 22 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderOtherPayCombinationIdParam.java

@@ -0,0 +1,22 @@
+package com.fs.hisStore.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+public class FsStoreOrderOtherPayCombinationIdParam {
+    @ApiModelProperty(value = "combinationOrderId")
+    @NotNull(message = "组合订单标识不能为空")
+    private String combinationOrderId;
+
+    @ApiModelProperty(value = "code")
+    @NotNull(message = "code")
+    private String code;
+
+    /**
+     * 小程序APPID
+     * **/
+    private String appId;
+}

+ 21 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderPayCombinationIdParam.java

@@ -0,0 +1,21 @@
+package com.fs.hisStore.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+@Data
+public class FsStoreOrderPayCombinationIdParam implements Serializable {
+    @ApiModelProperty(value = "combinationOrderId")
+    @NotNull(message = "组合订单标识不能为空")
+    private String combinationOrderId;
+
+    @ApiModelProperty(value = "payType")
+    @NotNull(message = "支付类型不能为空")
+    private Integer payType;
+
+    //多商城小程序
+    private String appId;
+}

+ 6 - 1
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreCartScrmService.java

@@ -8,6 +8,7 @@ import com.fs.hisStore.param.FsStoreCartCountParam;
 import com.fs.hisStore.param.FsStoreCartDelParam;
 import com.fs.hisStore.param.FsStoreCartDelParam;
 import com.fs.hisStore.param.FsStoreCartNumParam;
 import com.fs.hisStore.param.FsStoreCartNumParam;
 import com.fs.hisStore.param.FsStoreCartParam;
 import com.fs.hisStore.param.FsStoreCartParam;
+import com.fs.hisStore.vo.FsStoreCartGroupStoreVO;
 import com.fs.hisStore.vo.FsStoreCartVO;
 import com.fs.hisStore.vo.FsStoreCartVO;
 
 
 /**
 /**
@@ -76,9 +77,13 @@ public interface IFsStoreCartScrmService
     R changeNum(long userId, FsStoreCartNumParam cartParam);
     R changeNum(long userId, FsStoreCartNumParam cartParam);
 
 
     void checkProductStock( Long productId, Long productAttrValueId);
     void checkProductStock( Long productId, Long productAttrValueId);
-
     Integer selectFsStoreCartCountByUserId(long userId);
     Integer selectFsStoreCartCountByUserId(long userId);
 
 
     Integer selectFsStoreCartCount(FsStoreCartCountParam param);
     Integer selectFsStoreCartCount(FsStoreCartCountParam param);
 
 
+
+    void checkProductStocks( Long productId, Long productAttrValueId,Integer cartNum);
+
+    List<FsStoreCartGroupStoreVO> selectFsStoreCartListByUidMultiStore(long parseLong);
+
 }
 }

+ 12 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreOrderScrmService.java

@@ -282,4 +282,16 @@ public interface IFsStoreOrderScrmService
      * @param dtoList 订单数据
      * @param dtoList 订单数据
      * **/
      * **/
     R importDeliveryNoteExpress(List<FsOrderDeliveryNoteDTO> dtoList);
     R importDeliveryNoteExpress(List<FsOrderDeliveryNoteDTO> dtoList);
+
+    R createOrderMultiStore(long userId, FsStoreOrderCreateParam param);
+
+    String payConfirmMultiStore(Integer type, Long orderId, String payCode, String tradeNo, String bankTransactionId, String bankSerialNo);
+
+    String payRemainConfirmMultiStore(String payCode, String tradeNo, String bankTransactionId, String bankSerialNo);
+
+    List<FsStoreOrderScrm> getStoreOrderByCombinationId(String combinationId);
+
+    R confirmOrderMultiStore(long uid, List<FsStoreConfirmOrderGroupStoreParam> cartParamList);
+
+    List<FsStoreOrderComputeDTO> computedOrders(long parseLong, FsStoreOrderComputedGroupStoreParam param);
 }
 }

+ 4 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsStorePaymentScrmService.java

@@ -116,4 +116,8 @@ public interface IFsStorePaymentScrmService
     R getWxaCodeByPayment(FsStorePaymentGetWxaCodeParam param);
     R getWxaCodeByPayment(FsStorePaymentGetWxaCodeParam param);
 
 
     R paymentByWxaCode(FsStorePaymentPayParam param);
     R paymentByWxaCode(FsStorePaymentPayParam param);
+
+    List<FsStorePaymentScrm> selectFsStorePaymentByPaymentCode(String payCode);
+
+    String payConfirmMultiStore(String payCode,String tradeNo,String bankTransactionId,String bankSerialNo);
 }
 }

+ 3 - 1
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreProductPackageScrmService.java

@@ -68,7 +68,9 @@ public interface IFsStoreProductPackageScrmService
     /**
     /**
      * 批量修改商品组合套餐
      * 批量修改商品组合套餐
      *
      *
-     * @param packageIds 需要修改的数据ID
+     * @param orderIds 需要修改的数据ID
+     * @param status 状态
+     * @param companyId 企业id
      * @return 结果
      * @return 结果
      */
      */
     public int updateFsStoreProductPackages(Long[] orderIds,Long status,Long companyId);
     public int updateFsStoreProductPackages(Long[] orderIds,Long status,Long companyId);

+ 34 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreCartScrmServiceImpl.java

@@ -16,6 +16,7 @@ import com.fs.hisStore.config.MedicalMallConfig;
 import com.fs.hisStore.domain.FsStoreCartScrm;
 import com.fs.hisStore.domain.FsStoreCartScrm;
 import com.fs.hisStore.domain.FsStoreProductAttrValueScrm;
 import com.fs.hisStore.domain.FsStoreProductAttrValueScrm;
 import com.fs.hisStore.domain.FsStoreProductGroupScrm;
 import com.fs.hisStore.domain.FsStoreProductGroupScrm;
+import com.fs.hisStore.domain.FsStoreScrm;
 import com.fs.hisStore.dto.StoreProductGroupDTO;
 import com.fs.hisStore.dto.StoreProductGroupDTO;
 import com.fs.hisStore.mapper.FsStoreCartScrmMapper;
 import com.fs.hisStore.mapper.FsStoreCartScrmMapper;
 import com.fs.hisStore.mapper.FsStoreProductAttrValueScrmMapper;
 import com.fs.hisStore.mapper.FsStoreProductAttrValueScrmMapper;
@@ -33,7 +34,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
+import com.fs.hisStore.vo.FsStoreCartGroupStoreVO;
 
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
@@ -323,6 +326,37 @@ public class FsStoreCartScrmServiceImpl implements IFsStoreCartScrmService
         return  fsStoreCartMapper.selectFsStoreCartCount(param);
         return  fsStoreCartMapper.selectFsStoreCartCount(param);
     }
     }
 
 
+    @Override
+    public void checkProductStocks(Long productId, Long productAttrValueId,Integer cartNum) {
+        int stock=valueMapper.selectFsStoreProductStockById(productAttrValueId);
+        if (stock < cartNum) {
+            throw new CustomException(  "库存不足");
+        }
+    }
+
+    @Override
+    public List<FsStoreCartGroupStoreVO> selectFsStoreCartListByUidMultiStore(long uid) {
+//        return fsStoreCartMapper.selectFsStoreCartListByUid(uid);
+        //分组展示购物车信息
+        List<FsStoreCartGroupStoreVO> carts = new ArrayList<>();
+        //查询店铺id
+//        List<FsStore> store = fsStoreCartMapper.selectFsStoreListByIds(cartParam.getCartIds());
+        List<FsStoreScrm> store = fsStoreCartMapper.selectFsStoreByUid(uid);
+        for (FsStoreScrm fsStore : store) {
+            FsStoreCartGroupStoreVO vo = new FsStoreCartGroupStoreVO();
+            ////todo 目前存在商品属性没有storeid的脏数据 暂且会查询为null的
+            if (fsStore == null) {
+                vo.setStoreName("null");
+                vo.setList(fsStoreCartMapper.selectFsStoreCartListByUidMultiStore(uid, -1L));
+            } else {
+                vo.setStoreName(fsStore.getStoreName());
+                vo.setList(fsStoreCartMapper.selectFsStoreCartListByUidMultiStore(uid, fsStore.getStoreId()));
+            }
+            carts.add(vo);
+        }
+        return carts;
+    }
+
     private IErpGoodsService getErpService(){
     private IErpGoodsService getErpService(){
         //判断是否开启erp
         //判断是否开启erp
         IErpGoodsService goodsService = null;
         IErpGoodsService goodsService = null;

+ 812 - 36
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -79,8 +79,10 @@ import com.fs.hisStore.constants.StoreConstants;
 import com.fs.hisStore.domain.*;
 import com.fs.hisStore.domain.*;
 import com.fs.hisStore.enums.*;
 import com.fs.hisStore.enums.*;
 import com.fs.hisStore.service.*;
 import com.fs.hisStore.service.*;
+import com.fs.store.vo.FsStoreCartScrmQueryVO;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.service.ISysConfigService;
 import com.fs.system.service.ISysConfigService;
+import com.fs.utils.TwelveDigitSnowflake;
 import com.fs.ybPay.domain.RefundResult;
 import com.fs.ybPay.domain.RefundResult;
 import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
 import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
 import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
 import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
@@ -985,6 +987,12 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
 
 
     }
     }
 
 
+    public void deStockIncSales(List<FsStoreCartScrmQueryVO> cartInfo) {
+        for (FsStoreCartScrmQueryVO storeCartVO : cartInfo) {
+            productService.decProductStock(storeCartVO.getProductId(),
+                    storeCartVO.getProductAttrValueId(), storeCartVO.getCartNum());
+        }
+    }
     public void deStockIncSale(List<FsStoreCartQueryVO> cartInfo) {
     public void deStockIncSale(List<FsStoreCartQueryVO> cartInfo) {
         for (FsStoreCartQueryVO storeCartVO : cartInfo) {
         for (FsStoreCartQueryVO storeCartVO : cartInfo) {
             productService.decProductStock(storeCartVO.getProductId(),
             productService.decProductStock(storeCartVO.getProductId(),
@@ -2086,7 +2094,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             List<FsStorePaymentScrm> payments = paymentService.selectFsStorePaymentByOrderId(order.getId());
             List<FsStorePaymentScrm> payments = paymentService.selectFsStorePaymentByOrderId(order.getId());
             if (payments != null) {
             if (payments != null) {
                 String json;
                 String json;
-                if (CloudHostUtils.hasCloudHostName("康年堂")) {
+                if (CloudHostUtils.hasCloudHostName("康年堂") || CloudHostUtils.hasCloudHostName("医健宝")) {
                     json = configService.selectConfigByKey("his.pay");
                     json = configService.selectConfigByKey("his.pay");
                 } else {
                 } else {
                     json = configService.selectConfigByKey("store.pay");
                     json = configService.selectConfigByKey("store.pay");
@@ -2129,7 +2137,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                         request.setHuifuId(fsPayConfig.getHuifuId());
                         request.setHuifuId(fsPayConfig.getHuifuId());
                         request.setOrdAmt(payment.getPayMoney().toString());
                         request.setOrdAmt(payment.getPayMoney().toString());
                         request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
                         request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
-                        request.setReqSeqId("refund-" + payment.getPayCode());
+                        request.setReqSeqId("refund-" + new TwelveDigitSnowflake(1).nextId());
                         Map<String, Object> extendInfoMap = new HashMap<>();
                         Map<String, Object> extendInfoMap = new HashMap<>();
                         extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
                         extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
                         request.setExtendInfo(extendInfoMap);
                         request.setExtendInfo(extendInfoMap);
@@ -3687,50 +3695,818 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         }
         }
     }
     }
 
 
-    private static final DateTimeFormatter CST_FORMATTER = DateTimeFormatter
-            .ofPattern("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US)
-            .withZone(ZoneId.of("Asia/Shanghai"));
+    @Override
+    @Transactional
+    @Synchronized
+    public String payConfirmMultiStore(Integer type, Long orderId, String payCode, String tradeNo, String bankTransactionId, String bankSerialNo) {
+        //支付订单
+//        FsStoreOrder order = null;
+        try {
+            List<FsStoreOrderScrm> orders = new ArrayList<>();
+            if (type.equals(1)) {
+                List<FsStorePaymentScrm> storePayments = paymentService.selectFsStorePaymentByPaymentCode(payCode);
+                if (storePayments != null && !storePayments.isEmpty()) {
+                    for (FsStorePaymentScrm storePayment : storePayments) {
+                        if (storePayment == null || !storePayment.getStatus().equals(0)) {
+                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                            return "";
+                        }
+                        storePayment.setStatus(1);
+                        storePayment.setPayTime(new Date());
+                        storePayment.setTradeNo(tradeNo);
+                        storePayment.setBankSerialNo(bankSerialNo);
+                        storePayment.setBankTransactionId(bankTransactionId);
+                        paymentService.updateFsStorePayment(storePayment);
+                        if (storePayment.getBusinessOrderId() != null && storePayment.getBusinessOrderId().length() > 30) {
+                            orders.addAll(fsStoreOrderMapper.getStoreOrderByCombinationId(storePayment.getBusinessOrderId()));
+                        } else {
+                            orders.add(fsStoreOrderMapper.selectFsStoreOrderById(storePayment.getOrderId()));
 
 
-    private static final DateTimeFormatter STANDARD_FORMATTER = DateTimeFormatter
-            .ofPattern("yyyy-MM-dd HH:mm:ss");
+                        }
+                    }
+                }
 
 
-    public static LocalDateTime parseCstToLocalDateTime(String cstDateStr) {
-        if (cstDateStr == null || cstDateStr.trim().isEmpty()) {
-            return null;
+
+                for (FsStoreOrderScrm order : orders) {
+                    if (order != null && !order.getStatus().equals(OrderInfoEnum.STATUS_0.getValue())) {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return "";
+                    }
+                    if (order != null && !order.getPaid().equals(0)) {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return "";
+                    }
+                }
+
+            } else if (type.equals(2)) {
+                //货到付款
+                FsStoreOrderScrm order = fsStoreOrderMapper.selectFsStoreOrderById(orderId);
+                if (!order.getStatus().equals(OrderInfoEnum.STATUS_0.getValue())) {
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return "";
+                }
+                orders.add(order);
+            }
+            //写入公司佣金
+            if (orders.size() > 0) {
+                for (FsStoreOrderScrm order : orders) {
+                    if (order.getCompanyId() != null && order.getCompanyId() > 0) {
+                        companyService.addCompanyTuiMoney(order);
+                    }
+                    //增加用户购买次数
+                    userService.incPayCount(order.getUserId());
+                    //增加状态
+                    orderStatusService.create(order.getId(), OrderLogEnum.PAY_ORDER_SUCCESS.getValue(),
+                            OrderLogEnum.PAY_ORDER_SUCCESS.getDesc());
+                    //        FsUser user=userService.selectFsUserById(order.getUserId());
+                    //        //增加流水
+                    //        String payTypeMsg = PayTypeEnum.WEIXIN.getDesc();
+                    //        billService.addBill(user.getUserId(),
+                    //                BillDetailEnum.CATEGORY_1.getValue(),
+                    //                0,
+                    //                BillDetailEnum.TYPE_1.getDesc(),
+                    //                order.getPayPrice().doubleValue(), user.getNowMoney().doubleValue(),
+                    //                payTypeMsg + order.getPayPrice() + "元购买商品",order.getId().toString());
+
+                    FsStoreOrderScrm storeOrder = new FsStoreOrderScrm();
+                    storeOrder.setId(order.getId());
+                    storeOrder.setPaid(OrderInfoEnum.PAY_STATUS_1.getValue());
+                    storeOrder.setStatus(OrderInfoEnum.STATUS_1.getValue());
+                    storeOrder.setPayTime(new Date());
+                    fsStoreOrderMapper.updateFsStoreOrder(storeOrder);
+                    //非处方直接提交OMS
+                    if (order.getIsPrescribe().equals(0)) {
+                        createOmsOrder(order.getId());
+                    } else if (order.getIsPrescribe().equals(1)) {
+                        //是否已开方
+                        FsPrescribeScrm prescribe = prescribeService.selectFsPrescribeByOrderId(order.getId());
+                        if (prescribe != null && prescribe.getStatus() == 1) {
+                            createOmsOrder(order.getId());
+                        }
+                    }
+                    //处理佣金 套餐不分佣金
+                    if (order.getIsPackage() != 1 && order.getTuiUserId() != null && order.getTuiUserId() > 0) {
+                        FsStoreOrderItemScrm orderItemMap = new FsStoreOrderItemScrm();
+                        orderItemMap.setOrderId(order.getId());
+                        List<FsStoreOrderItemScrm> items = storeOrderItemService.selectFsStoreOrderItemList(orderItemMap);
+                        userService.addTuiMoney(order, items);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.getStackTrace();
+            logger.info("payConfirm:" + e.getMessage());
+            logger.info("payConfirm:" + e.getLocalizedMessage());
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            return "";
         }
         }
+        return "success";
+    }
 
 
-        try {
-            // 解析为带时区的日期时间
-            ZonedDateTime zonedDateTime = ZonedDateTime.parse(cstDateStr, CST_FORMATTER);
-            // 转换为本地日期时间(忽略时区,仅保留年月日时分秒)
-            return zonedDateTime.toLocalDateTime();
-        } catch (DateTimeParseException e) {
-            System.err.println("日期解析失败: " + e.getMessage());
-            return null;
+    @Override
+    public String payRemainConfirmMultiStore(String payCode, String tradeNo, String bankTransactionId, String bankSerialNo) {
+        //支付订单
+//        FsStoreOrder order = null;
+        String orderIds = "";
+        List<FsStorePaymentScrm> storePayments = paymentService.selectFsStorePaymentByPaymentCode(payCode);
+        if (storePayments != null && !storePayments.isEmpty()) {
+            for (int i = 0; i < storePayments.size(); i++) {
+                if (storePayments.get(i) == null || !storePayments.get(i).getStatus().equals(0)) {
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return "";
+                }
+                storePayments.get(i).setStatus(1);
+                storePayments.get(i).setPayTime(new Date());
+                storePayments.get(i).setTradeNo(tradeNo);
+                storePayments.get(i).setBankSerialNo(bankSerialNo);
+                storePayments.get(i).setBankTransactionId(bankTransactionId);
+                storePayments.get(i).setIsPayRemain(1);
+                paymentService.updateFsStorePayment(storePayments.get(i));
+                if (i == 0) {
+                    orderIds = orderIds + (storePayments.get(i).getOrderId());
+                } else {
+                    orderIds = orderIds + "," + storePayments.get(i).getOrderId();
+                }
+            }
+        }
+
+//        order = fsStoreOrderMapper.selectFsStoreOrderById(storePayment.getOrderId());
+        List<FsStoreOrderScrm> orders = fsStoreOrderMapper.selectFsStoreOrderByOrderIds(orderIds);
+        for (FsStoreOrderScrm order : orders) {
+            //增加状态
+            orderStatusService.create(order.getId(), OrderLogEnum.PAY_REMAIN_ORDER_SUCCESS.getValue(),
+                    OrderLogEnum.PAY_REMAIN_ORDER_SUCCESS.getDesc());
+
+            FsStoreOrderScrm storeOrder = new FsStoreOrderScrm();
+            storeOrder.setId(order.getId());
+            storeOrder.setIsPayRemain(1);
+            fsStoreOrderMapper.updateFsStoreOrder(storeOrder);
         }
         }
+
+
+        return "success";
     }
     }
 
 
-    public static String parseCstToDateOnlyString(String cstDateStr) {
-        LocalDateTime dateTime = parseCstToLocalDateTime(cstDateStr);
-        return dateTime != null ? dateTime.format(DateTimeFormatter
-                .ofPattern("yyyy-MM-dd")) : null;
+    @Override
+    public List<FsStoreOrderScrm> getStoreOrderByCombinationId(String combinationId) {
+        return fsStoreOrderMapper.getStoreOrderByCombinationId(combinationId);
     }
     }
 
 
-    public Map<String, String> buildExpressDeliveryMap() {
-        Map<String, String> map = new HashMap<>();
-        map.put("SF", "顺丰");
-        map.put("EMS", "邮政");
-        map.put("ZTO", "中通");
-        map.put("JD", "京东");
-        map.put("DBL", "德邦");
-        return map;
+    @Override
+    public R confirmOrderMultiStore(long uid, List<FsStoreConfirmOrderGroupStoreParam> cartParamList) {
+        FsUserAddressScrm address = null;
+        List<String> uuids = new ArrayList<>();
+        List<FsStoreCartQueryGroupStoreVO> list = new ArrayList<>();
+        for (FsStoreConfirmOrderGroupStoreParam cartGroupStoreParam : cartParamList) {
+            FsStoreConfirmOrderParam cartParam = cartGroupStoreParam.getData();
+            //获取地址信息和购物车信息
+            address = userAddressMapper.selectFsUserAddressByDefaultAddress(uid);
+//        List<FsStoreCartQueryVO>  carts=cartMapper.selectFsStoreCartListByIds(cartParam.getCartIds());
+            //分组展示购物车信息
+            List<FsStoreCartQueryGroupStoreVO> carts = new ArrayList<>();
+            List<FsStoreCartScrmQueryVO> redisCarts = new ArrayList<>();
+            //查询店铺id
+            FsStoreScrm fsStore = fsStoreMapper.selectFsStoreByStoreId(cartGroupStoreParam.getStoreId());
+//            List<FsStore> store = cartMapper.selectFsStoreListByIds(cartParam.getCartIds());
+//            for (FsStore fsStore : store) {
+            FsStoreCartQueryGroupStoreVO vo = new FsStoreCartQueryGroupStoreVO();
+            ////todo 目前存在商品属性没有storeid的脏数据 暂且会查询为null的
+            List<FsStoreCartScrmQueryVO> cartQueryVo = null;
+            if (fsStore == null) {
+                vo.setStoreName("null");
+                cartQueryVo = cartMapper.selectFsStoreCartMultiStoreListByIds(cartParam.getCartIds(), -1L);
+                vo.setList(cartQueryVo);
+            } else {
+                vo.setStoreName(fsStore.getStoreName());
+                cartQueryVo = cartMapper.selectFsStoreCartMultiStoreListByIds(cartParam.getCartIds(), cartGroupStoreParam.getStoreId());
+
+            }
+            vo.setList(cartQueryVo);
+            carts.add(vo);
+            redisCarts.addAll(cartQueryVo);
+//            }
+
+            list.addAll(carts);
+            String uuid = IdUtil.randomUUID();
+            uuids.add(uuid);
+            redisCache.setCacheObject("orderKey:" + uuid, cartParam.getCartIds(), 300, TimeUnit.SECONDS);
+//            redisCache.setCacheObject("orderCarts:" + uuid, carts, 300, TimeUnit.SECONDS);
+            redisCache.setCacheObject("orderCarts:" + uuid, redisCarts, 300, TimeUnit.SECONDS);
+        }
+
+        return R.ok().put("orderKeys", uuids).put("address", address).put("carts", list);
     }
     }
 
 
-    // 抽取的资质检查方法
-    private boolean isStoreQualificationExpired(FsStoreScrm store, LocalDate today) {
-        return store.getBusinessLicenseExpireEnd().isBefore(today) ||
-                store.getDrugLicenseExpiryEnd().isBefore(today) ||
-                store.getMedicalDevice2ExpiryEnd().isBefore(today) ||
-                store.getMedicalLicenseExpiryEnd().isBefore(today);
+    @Override
+    @Transactional
+    public R createOrderMultiStore(long userId, FsStoreOrderCreateParam param) {
+
+        FsStoreOrderComputedParam computedParam = new FsStoreOrderComputedParam();
+        BeanUtils.copyProperties(param, computedParam);
+        //计算金额
+        FsStoreOrderComputeDTO dto = this.computedOrderMultiStore(userId, computedParam);
+        String cartIds = redisCache.getCacheObject("orderKey:" + param.getOrderKey());
+        Integer totalNum = 0;
+        BigDecimal integral = BigDecimal.ZERO;
+        if (cartIds != null) {
+            //获取购物车列表
+            List<FsStoreCartScrmQueryVO> carts = redisCache.getCacheObject("orderCarts:" + param.getOrderKey());
+            //获取地址
+            FsUserAddressScrm address = userAddressMapper.selectFsUserAddressById(param.getAddressId());
+            //检测库存
+            //如果是美乳产品,发武汉仓库
+            Integer meiruCount = 0;
+
+            for (FsStoreCartScrmQueryVO cart : carts) {
+                cartService.checkProductStocks(cart.getProductId(), cart.getProductAttrValueId(), cart.getCartNum());
+                totalNum += cart.getCartNum();
+                integral = NumberUtil.add(integral,
+                        NumberUtil.mul(cart.getCartNum(), cart.getIntegral()));
+                if (cart.getCateId() != null && cart.getCateId().equals(176L)) {
+                    meiruCount++;
+                }
+            }
+            //生成分布式唯一值
+            String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
+            //是否使用积分
+            Boolean isIntegral = false;
+            //组合数据
+            FsStoreOrderScrm storeOrder = new FsStoreOrderScrm();
+            //修改默认仓库
+            if (meiruCount.equals(carts.size())) {
+                storeOrder.setStoreHouseCode("WHSP001");
+            } else {
+                storeOrder.setStoreHouseCode("CQDS001");
+            }
+            storeOrder.setCompanyId(param.getCompanyId());
+            storeOrder.setCompanyUserId(param.getCompanyUserId());
+            if (param.getCompanyUserId() != null) {
+                CompanyUser companyUser = companyUserService.selectCompanyUserById(param.getCompanyUserId());
+                if (companyUser != null) {
+                    storeOrder.setDeptId(companyUser.getDeptId());
+                }
+            }
+            storeOrder.setUserId(userId);
+            storeOrder.setOrderCode(orderSn);
+            storeOrder.setRealName(address.getRealName());
+            storeOrder.setUserPhone(address.getPhone());
+            storeOrder.setUserAddress(address.getProvince() + " " + address.getCity() +
+                    " " + address.getDistrict() + " " + address.getDetail().trim());
+            storeOrder.setCartId(cartIds);
+//            storeOrder.setTotalNum(Long.parseLong(String.valueOf(carts.size())));
+            storeOrder.setTotalNum(Long.valueOf(totalNum));
+            storeOrder.setTotalPrice(dto.getTotalPrice());
+            storeOrder.setTotalPostage(dto.getPayPostage());
+
+            if (param.getStoreId() != null) {
+                storeOrder.setStoreId(param.getStoreId());
+            }
+
+            //优惠券处理
+            if (param.getCouponUserId() != null) {
+                FsStoreCouponUserScrm couponUser = couponUserService.selectFsStoreCouponUserById(param.getCouponUserId());
+                if (couponUser != null && couponUser.getStatus() == 0) {
+                    storeOrder.setCouponId(couponUser.getId());
+                    storeOrder.setCouponPrice(couponUser.getCouponPrice());
+                    //更新优惠券状态
+                    couponUser.setStatus(1);
+                    couponUser.setUseTime(new Date());
+                    couponUserService.updateFsStoreCouponUser(couponUser);
+                }
+            }
+            //处理推荐人
+            FsUserScrm user = userService.selectFsUserById(storeOrder.getUserId());
+            if (user.getSpreadUserId() != null && user.getSpreadUserId() > 0) {
+                storeOrder.setTuiUserId(user.getSpreadUserId());
+            } else {
+                if (param.getTuiUserId() != null) {
+                    FsUserScrm tuiUser = userService.selectFsUserById(param.getTuiUserId());
+                    if (tuiUser != null && tuiUser.getIsPromoter() == 1) {
+                        storeOrder.setTuiUserId(param.getTuiUserId());
+                    }
+                }
+            }
+            storeOrder.setPayPostage(dto.getPayPostage());
+            storeOrder.setDeductionPrice(dto.getDeductionPrice());
+            storeOrder.setPaid(0);
+            storeOrder.setPayType(param.getPayType());
+            if (isIntegral) {
+                storeOrder.setPayIntegral(integral);
+            }
+            storeOrder.setUseIntegral(BigDecimal.valueOf(dto.getUsedIntegral()));
+            storeOrder.setBackIntegral(BigDecimal.ZERO);
+            storeOrder.setGainIntegral(BigDecimal.ZERO);
+            storeOrder.setMark(param.getMark());
+            //todo 获取成本价
+            BigDecimal costPrice = this.getOrderSumPriceMultiStore(carts, "costPrice");
+            storeOrder.setCost(costPrice);
+            storeOrder.setIsChannel(1);
+            storeOrder.setShippingType(1);
+            storeOrder.setCreateTime(new Date());
+            if (param.getPayType().equals("1")) {
+                //全款支付
+                storeOrder.setStatus(0);
+            } else if (param.getPayType().equals("2")) {
+                //货到付款
+                storeOrder.setStatus(1);
+            }
+            //后台制单处理
+            if (param.getPayPrice() != null && param.getPayPrice().compareTo(BigDecimal.ZERO) > 0) {
+                storeOrder.setPayPrice(param.getPayPrice());
+            } else {
+                storeOrder.setPayPrice(dto.getPayPrice());
+            }
+            storeOrder.setOrderCreateType(param.getOrderCreateType());
+            long prescribe = carts.stream().filter(item -> item.getProductType() != null && item.getProductType() == 2).count();
+            if (prescribe > 0) {
+                storeOrder.setIsPrescribe(1);
+            }
+
+            storeOrder.setCombinationOrderId(param.getCombinationOrderId());
+
+            int flag = fsStoreOrderMapper.insertFsStoreOrder(storeOrder);
+            if (flag == 0) {
+                return R.error("订单创建失败");
+            }
+            //收款单更新
+//            if(param.getPaymentId()!=null&&param.getPaymentId()>0){
+//                FsStorePayment payment=new FsStorePayment();
+//                payment.setOrderId(storeOrder.getId());
+//                payment.setPaymentId(param.getPaymentId());
+//                paymentService.updateFsStorePayment(payment);
+//            }
+            //使用了积分扣积分
+            if (dto.getUsedIntegral() > 0) {
+                this.decIntegral(userId, dto.getUsedIntegral(), dto.getDeductionPrice().doubleValue(), storeOrder.getId().toString());
+            }
+            //减库存加销量
+            this.deStockIncSales(carts);
+            //保存OrderItem
+            List<FsStoreOrderItemScrm> listOrderItem = new ArrayList<>();
+            //保存购物车商品信息
+            for (FsStoreCartScrmQueryVO vo : carts) {
+                FsStoreCartDTO fsStoreCartDTO = new FsStoreCartDTO();
+                fsStoreCartDTO.setProductId(vo.getProductId());
+                fsStoreCartDTO.setPrice(vo.getPrice());
+                fsStoreCartDTO.setSku(vo.getProductAttrName());
+                fsStoreCartDTO.setProductName(vo.getProductName());
+                fsStoreCartDTO.setNum(vo.getCartNum());
+                fsStoreCartDTO.setErpCode(vo.getErpCode());
+                fsStoreCartDTO.setErpSkuName(vo.getErpSkuName());
+                fsStoreCartDTO.setBarCode(vo.getBarCode());
+                fsStoreCartDTO.setGroupBarCode(vo.getGroupBarCode());
+                fsStoreCartDTO.setBrokerage(vo.getBrokerage());
+                fsStoreCartDTO.setBrokerageTwo(vo.getBrokerageTwo());
+                fsStoreCartDTO.setBrokerageThree(vo.getBrokerageThree());
+                if (StringUtils.isEmpty(vo.getProductAttrImage())) {
+                    fsStoreCartDTO.setImage(vo.getProductImage());
+                } else {
+                    fsStoreCartDTO.setImage(vo.getProductAttrImage());
+                }
+                FsStoreOrderItemScrm item = new FsStoreOrderItemScrm();
+                item.setOrderId(storeOrder.getId());
+                item.setOrderCode(orderSn);
+                item.setCartId(vo.getId());
+                item.setProductId(vo.getProductId());
+                item.setJsonInfo(JSONUtil.toJsonStr(fsStoreCartDTO));
+                item.setNum(vo.getCartNum());
+                item.setIsAfterSales(0);
+                //处方药
+                if (vo.getProductType().equals(2)) {
+                    item.setIsPrescribe(1);
+                }
+                fsStoreOrderItemMapper.insertFsStoreOrderItem(item);
+                listOrderItem.add(item);
+            }
+            if (listOrderItem.size() > 0) {
+                String itemJson = JSONUtil.toJsonStr(listOrderItem);
+                storeOrder.setItemJson(itemJson);
+                fsStoreOrderMapper.updateFsStoreOrder(storeOrder);
+            }
+
+            //购物车状态修改
+            cartMapper.updateIsPay(cartIds);
+
+            //删除缓存
+            redisCache.deleteObject("orderKey:" + param.getOrderKey());
+            redisCache.deleteObject("orderCarts:" + param.getOrderKey());
+
+            //添加记录
+            orderStatusService.create(storeOrder.getId(), OrderLogEnum.CREATE_ORDER.getValue(),
+                    OrderLogEnum.CREATE_ORDER.getDesc());
+
+            //加入redis,24小时自动取消
+            String redisKey = String.valueOf(StrUtil.format("{}{}",
+                    StoreConstants.REDIS_ORDER_OUTTIME_UNPAY, storeOrder.getId()));
+            String json = configService.selectConfigByKey("store.config");
+            com.fs.store.config.StoreConfig config = JSONUtil.toBean(json, com.fs.store.config.StoreConfig.class);
+            if (config.getUnPayTime() != null && config.getUnPayTime() > 0) {
+                redisCache.setCacheObject(redisKey, storeOrder.getId(), config.getUnPayTime(), TimeUnit.MINUTES);
+            } else {
+                redisCache.setCacheObject(redisKey, storeOrder.getId(), 30, TimeUnit.MINUTES);
+            }
+            //添加支付到期时间
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(storeOrder.getCreateTime());
+            calendar.add(Calendar.MINUTE, config.getUnPayTime());
+            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String payLimitTime = format.format(calendar.getTime());
+            //删除推荐订单KEY
+            if (StringUtils.isNotEmpty(param.getCreateOrderKey())) {
+                redisCache.deleteObject("createOrderKey:" + param.getCreateOrderKey());
+                redisCache.deleteObject("orderCarts:" + param.getCreateOrderKey());
+                redisCache.deleteObject("createOrderMoney:" + param.getCreateOrderKey());
+                redisCache.deleteObject("createOrderMoneyDetails:" + param.getCreateOrderKey());
+            }
+            return R.ok().put("order", storeOrder).put("payLimitTime", payLimitTime);
+        } else {
+            return R.error("订单已过期");
+        }
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public List<FsStoreOrderComputeDTO> computedOrders(long uid, FsStoreOrderComputedGroupStoreParam params) {
+        //返回值
+        List<FsStoreOrderComputeDTO> dtos = new ArrayList<>();
+        List<String> orderKeys = params.getOrderKeys();
+        //总数
+        BigDecimal payPriceTotal = BigDecimal.ZERO;
+        BigDecimal totalPriceTotal = BigDecimal.ZERO;
+        Double usedIntegralTotal = 0.;
+        BigDecimal payIntegralTotal = BigDecimal.ZERO;
+        BigDecimal payPostageTotal = BigDecimal.ZERO;
+        BigDecimal deductionPriceTotal = BigDecimal.ZERO;
+
+
+        List<String> createOrderKeys = null;
+        if (params.getCreateOrderKey() == null) {
+            createOrderKeys = orderKeys;
+        } else {
+            createOrderKeys = Arrays.asList(params.getCreateOrderKey().split(","));
+        }
+
+
+        for (int i = 0; i < orderKeys.size(); i++) {
+//        for (String orderKey : orderKeys) {
+            FsStoreOrderComputedParam computedParam = new FsStoreOrderComputedParam();
+            BeanUtils.copyProperties(computedParam, params);
+            computedParam.setOrderKey(orderKeys.get(i));
+            if (!createOrderKeys.isEmpty() && createOrderKeys.get(i) != null) {
+                computedParam.setCreateOrderKey(createOrderKeys.get(i));
+            }
+
+            FsStoreOrderComputeDTO dto = this.computedOrderMultiStore(uid, computedParam);
+            payPriceTotal = NumberUtil.add(payPriceTotal, dto.getPayPrice());
+            totalPriceTotal = NumberUtil.add(totalPriceTotal, dto.getTotalPrice());
+            usedIntegralTotal += dto.getUsedIntegral();
+            payIntegralTotal = NumberUtil.add(payIntegralTotal, dto.getPayIntegral());
+            payPostageTotal = NumberUtil.add(payPostageTotal, dto.getPayPostage());
+            deductionPriceTotal = NumberUtil.add(deductionPriceTotal, dto.getDeductionPrice());
+            dtos.add(dto);
+        }
+//
+        dtos.add(FsStoreOrderComputeDTO.builder()
+                .totalPrice(totalPriceTotal)
+                .payPrice(payPriceTotal)
+                .payPostage(payPostageTotal)
+                .deductionPrice(deductionPriceTotal)
+                .usedIntegral(usedIntegralTotal)
+                .payIntegral(payIntegralTotal)
+                .build());
+        return dtos;
+    }
+
+    private static final DateTimeFormatter CST_FORMATTER = DateTimeFormatter
+            .ofPattern("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US)
+            .withZone(ZoneId.of("Asia/Shanghai"));
+
+    private static final DateTimeFormatter STANDARD_FORMATTER = DateTimeFormatter
+            .ofPattern("yyyy-MM-dd HH:mm:ss");
+
+    public static LocalDateTime parseCstToLocalDateTime(String cstDateStr) {
+        if (cstDateStr == null || cstDateStr.trim().isEmpty()) {
+            return null;
+        }
+
+        try {
+            // 解析为带时区的日期时间
+            ZonedDateTime zonedDateTime = ZonedDateTime.parse(cstDateStr, CST_FORMATTER);
+            // 转换为本地日期时间(忽略时区,仅保留年月日时分秒)
+            return zonedDateTime.toLocalDateTime();
+        } catch (DateTimeParseException e) {
+            System.err.println("日期解析失败: " + e.getMessage());
+            return null;
+        }
+    }
+
+    public static String parseCstToDateOnlyString(String cstDateStr) {
+        LocalDateTime dateTime = parseCstToLocalDateTime(cstDateStr);
+        return dateTime != null ? dateTime.format(DateTimeFormatter
+                .ofPattern("yyyy-MM-dd")) : null;
+    }
+
+    public Map<String, String> buildExpressDeliveryMap() {
+        Map<String, String> map = new HashMap<>();
+        map.put("SF", "顺丰");
+        map.put("EMS", "邮政");
+        map.put("ZTO", "中通");
+        map.put("JD", "京东");
+        map.put("DBL", "德邦");
+        return map;
+    }
+
+    // 抽取的资质检查方法
+    private boolean isStoreQualificationExpired(FsStoreScrm store, LocalDate today) {
+        return store.getBusinessLicenseExpireEnd().isBefore(today) ||
+                store.getDrugLicenseExpiryEnd().isBefore(today) ||
+                store.getMedicalDevice2ExpiryEnd().isBefore(today) ||
+                store.getMedicalLicenseExpiryEnd().isBefore(today);
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public FsStoreOrderComputeDTO computedOrderMultiStore(long uid, FsStoreOrderComputedParam param) {
+        String cartIds = redisCache.getCacheObject("orderKey:" + param.getOrderKey());
+        if (ObjectUtil.isNull(cartIds)) {
+            throw new CustomException("订单已过期", 501);
+        }
+        List<FsStoreCartScrmQueryVO> carts = redisCache.getCacheObject("orderCarts:" + param.getOrderKey());
+        BigDecimal payPrice = getOrderSumPriceMultiStore(carts, "truePrice");
+        if (StringUtils.isNotEmpty(param.getCreateOrderKey())) {
+//            BigDecimal money = redisCache.getCacheObject("createOrderMoney:" + param.getCreateOrderKey());
+//            if (money != null) {
+//                payPrice = money;
+//            }
+
+            FsOrderMoneyDetailsVo detailsVo = redisCache.getCacheObject("createOrderMoneyDetails:" + param.getCreateOrderKey());
+            if (detailsVo != null) {
+                BigDecimal money = detailsVo.getTotalPrice();
+                payPrice = detailsVo.getPayPrice();
+            }
+
+
+        }
+        FsUserAddressScrm userAddress = null;
+        if (param.getAddressId() != null) {
+            userAddress = userAddressMapper.selectFsUserAddressById(param.getAddressId());
+        }
+        FsStoreOrderPriceDTO priceGroup = this.getOrderPriceGroupMultiStore(carts, userAddress);
+        BigDecimal payPostage = priceGroup.getStorePostage();
+        payPrice = NumberUtil.add(payPrice, payPostage);
+        FsUserScrm user = userService.selectFsUserById(uid);
+        // 积分抵扣
+        BigDecimal deductionPrice = BigDecimal.ZERO; //积分抵扣金额
+        double usedIntegral = 0; //使用了多少积分
+        if (param.getUseIntegral() != null && param.getUseIntegral() == 1 && user.getIntegral().intValue() > 0) {
+            //如果积分总和小于用户积分 抵扣比例 计算抵扣价格
+            //默认配置
+            Double integralMax = Double.valueOf(100);
+            BigDecimal integralFull = new BigDecimal(100);
+            Double integralRatio = Double.valueOf(1);
+            String json = configService.selectConfigByKey("store.integral");
+            if (StringUtils.isEmpty(json)) {
+
+            } else {
+                StoreIntegralConfig integralConfig = JSONUtil.toBean(json, StoreIntegralConfig.class);
+                integralMax = integralConfig.getIntegralMax();
+                integralFull = integralConfig.getIntegralFull();
+                integralRatio = integralConfig.getIntegralRatio();
+            }
+            if (priceGroup.getTotalPrice().compareTo(integralFull) >= 0) {
+                Double userIntegral = user.getIntegral().doubleValue();
+                if (integralMax.intValue() > 0 && Double.compare(userIntegral, integralMax) >= 0) {
+                    userIntegral = integralMax;
+                }
+                deductionPrice = BigDecimal.valueOf(NumberUtil.mul(userIntegral, integralRatio));
+                if (deductionPrice.compareTo(payPrice) < 0) {
+                    payPrice = NumberUtil.sub(payPrice, deductionPrice);
+                    usedIntegral = userIntegral;
+                } else {
+                    deductionPrice = payPrice;
+                    payPrice = BigDecimal.ZERO;
+                    usedIntegral = NumberUtil.round(NumberUtil.div(deductionPrice,
+                            BigDecimal.valueOf(integralRatio)), 2).doubleValue();
+                }
+            }
+        }
+
+        if (payPrice.compareTo(BigDecimal.ZERO) <= 0) {
+            payPrice = BigDecimal.ZERO;
+        }
+        //优惠券
+        if (param.getCouponUserId() != null) {
+            FsStoreCouponUserScrm couponUser = couponUserService.selectFsStoreCouponUserById(param.getCouponUserId());
+            if (couponUser != null && couponUser.getStatus() == 0) {
+                if (couponUser.getUseMinPrice().compareTo(priceGroup.getTotalPrice()) == -1) {
+                    payPrice = payPrice.subtract(couponUser.getCouponPrice());
+                }
+            }
+        }
+
+        return FsStoreOrderComputeDTO.builder()
+                .totalPrice(priceGroup.getTotalPrice())
+                .payPrice(payPrice)
+                .payPostage(payPostage)
+                .deductionPrice(deductionPrice)
+                .usedIntegral(usedIntegral)
+                .payIntegral(priceGroup.getPayIntegral())
+                .build();
+    }
+
+
+    /**
+     * 获取某字段价格
+     *
+     * @param cartInfo 购物车
+     * @param key      key值
+     * @return Double
+     */
+    private BigDecimal getOrderSumPriceMultiStore(List<FsStoreCartScrmQueryVO> cartInfo, String key) {
+        BigDecimal sumPrice = BigDecimal.ZERO;
+
+        if ("truePrice".equals(key)) {
+            for (FsStoreCartScrmQueryVO storeCart : cartInfo) {
+                sumPrice = NumberUtil.add(sumPrice, NumberUtil.mul(storeCart.getCartNum(), storeCart.getPrice()));
+            }
+        } else if ("costPrice".equals(key)) {
+            for (FsStoreCartScrmQueryVO storeCart : cartInfo) {
+                sumPrice = NumberUtil.add(sumPrice,
+                        NumberUtil.mul(storeCart.getCartNum(), storeCart.getCost()));
+            }
+        } else if ("payIntegral".equals(key)) {
+            for (FsStoreCartScrmQueryVO storeCart : cartInfo) {
+                if (storeCart.getIntegral() != null) {
+                    sumPrice = NumberUtil.add(sumPrice,
+                            NumberUtil.mul(storeCart.getCartNum(), storeCart.getIntegral()));
+                }
+
+            }
+        }
+        return sumPrice;
+    }
+
+    /**
+     * 获取订单价格
+     */
+    private FsStoreOrderPriceDTO getOrderPriceGroupMultiStore(List<FsStoreCartScrmQueryVO> cartInfo, FsUserAddressScrm userAddress) {
+        BigDecimal storePostage = BigDecimal.ZERO;
+        //免运费设置
+        BigDecimal storeFreePostage = BigDecimal.ZERO;
+
+        BigDecimal totalPrice = this.getOrderSumPriceMultiStore(cartInfo, "truePrice");//获取订单总金额
+        BigDecimal costPrice = this.getOrderSumPriceMultiStore(cartInfo, "costPrice");//获取订单成本价
+        BigDecimal payIntegral = this.getOrderSumPriceMultiStore(cartInfo, "payIntegral");//获取订单需要的积分
+
+        //如果设置满包邮0 表示全局包邮,如果设置大于0表示满这价格包邮,否则走运费模板算法
+        if (storeFreePostage.compareTo(BigDecimal.ZERO) != 0 && totalPrice.compareTo(storeFreePostage) <= 0) {
+            storePostage = this.handlePostageMultiStore(cartInfo, userAddress);
+        }
+        FsStoreOrderPriceDTO priceGroupDTO = new FsStoreOrderPriceDTO();
+        priceGroupDTO.setStorePostage(storePostage);
+        priceGroupDTO.setStoreFreePostage(storeFreePostage);
+        priceGroupDTO.setTotalPrice(totalPrice);
+        priceGroupDTO.setCostPrice(costPrice);
+        priceGroupDTO.setPayIntegral(payIntegral);
+        return priceGroupDTO;
+    }
+
+    /**
+     * 根据运费模板算法返回邮费
+     *
+     * @param cartInfo    购物车
+     * @param userAddress 地址
+     * @return double
+     */
+    private BigDecimal handlePostageMultiStore(List<FsStoreCartScrmQueryVO> cartInfo, FsUserAddressScrm userAddress) {
+//    private BigDecimal handlePostage(List<FsStoreCartQueryGroupStoreVO> cartInfo, FsUserAddress userAddress) {
+        BigDecimal storePostage = BigDecimal.ZERO;
+        if (userAddress != null) {
+            if (userAddress.getCityId() == null) {
+                return storePostage;
+            }
+            String cityId = userAddress.getCityId();
+            List<Long> citys = new ArrayList<>();
+            citys.add(Long.valueOf(cityId));
+            citys.add(0l);//城市包括默认
+            //获取商品所有的TEMPID
+            List<Long> tempIds = cartInfo
+                    .stream()
+                    .map(FsStoreCartScrmQueryVO::getTempId)
+                    .collect(Collectors.toList());
+
+            //获取商品用到的运费模板
+            List<FsShippingTemplatesScrm> shippingTemplatesList = shippingTemplatesService.selectFsShippingTemplatesByIds(StringUtils.join(tempIds, ","));
+
+            //获取运费模板区域列表按照城市排序
+            List<FsShippingTemplatesRegionScrm> shippingTemplatesRegionList = shippingTemplatesRegionService.selectFsShippingTemplatesRegionListByTempIdsAndCityIds(StringUtils.join(tempIds, ","), StringUtils.join(citys, ","));
+
+            //提取运费模板类型
+            Map<Long, Integer> shippingTemplatesMap = shippingTemplatesList
+                    .stream()
+                    .collect(Collectors.toMap(FsShippingTemplatesScrm::getId,
+                            FsShippingTemplatesScrm::getType));
+            //提取运费模板有相同值覆盖
+            Map<Long, FsShippingTemplatesRegionScrm> shippingTemplatesRegionMap =
+                    shippingTemplatesRegionList.stream()
+                            .collect(Collectors.toMap(FsShippingTemplatesRegionScrm::getTempId,
+                                    YxShippingTemplatesRegion -> YxShippingTemplatesRegion,
+                                    (key1, key2) -> key2));
+
+
+            Map<Long, TemplateDTO> templateDTOMap = new HashMap<>();
+            for (FsStoreCartScrmQueryVO storeCartVO : cartInfo) {
+                Long tempId = storeCartVO.getTempId();
+                //根据模板类型获取相应的数量
+                double num = 0d;
+                if (ShippingTempEnum.TYPE_1.getValue().equals(shippingTemplatesMap.get(tempId))) {
+                    num = storeCartVO.getCartNum().doubleValue();
+                } else if (ShippingTempEnum.TYPE_2.getValue().equals(shippingTemplatesMap.get(tempId))) {
+                    num = NumberUtil.mul(storeCartVO.getCartNum(),
+                            storeCartVO.getWeight()).doubleValue();
+                } else if (ShippingTempEnum.TYPE_3.getValue().equals(shippingTemplatesMap.get(tempId))) {
+                    num = NumberUtil.mul(storeCartVO.getCartNum(),
+                            storeCartVO.getVolume()).doubleValue();
+                }
+
+                FsShippingTemplatesRegionScrm shippingTemplatesRegion = shippingTemplatesRegionMap.get(tempId);
+                BigDecimal price = NumberUtil.round(NumberUtil.mul(storeCartVO.getCartNum(),
+                        storeCartVO.getPrice()), 2);
+                if (!templateDTOMap.containsKey(tempId)) {
+                    TemplateDTO templateDTO = TemplateDTO.builder()
+                            .number(num)
+                            .price(price)
+                            .first(shippingTemplatesRegion.getFirst().doubleValue())
+                            .firstPrice(shippingTemplatesRegion.getFirstPrice())
+                            .continues(shippingTemplatesRegion.getContinues().doubleValue())
+                            .continuePrice(shippingTemplatesRegion.getContinuePrice())
+                            .tempId(tempId)
+                            .cityId(cityId)
+                            .build();
+                    templateDTOMap.put(tempId, templateDTO);
+                } else {
+                    TemplateDTO templateDTO = templateDTOMap.get(tempId);
+                    templateDTO.setNumber(templateDTO.getNumber() + num);
+                    templateDTO.setPrice(NumberUtil.add(templateDTO.getPrice().doubleValue(), price));
+                }
+            }
+
+
+            //处理包邮情况
+            free:
+            for (Map.Entry<Long, TemplateDTO> entry : templateDTOMap.entrySet()) {
+                Long mapKey = entry.getKey();
+                TemplateDTO mapValue = entry.getValue();
+                int count = shippingTemplatesFreeService.selectCountByTemplateDTO(mapValue);
+                //满足包邮条件剔除
+                if (count > 0) {
+                    templateDTOMap.remove(mapKey);
+                    break free;
+                }
+            }
+
+            //处理区域邮费
+            boolean isFirst = true; //用来是否多个产品的标识 false表示数量大于1
+            for (TemplateDTO templateDTO : templateDTOMap.values()) {
+                if (isFirst) {//首件
+                    //只满足首件
+                    if (Double.compare(templateDTO.getNumber(), templateDTO.getFirst()) <= 0) {
+                        storePostage = NumberUtil.round(NumberUtil.add(storePostage,
+                                templateDTO.getFirstPrice()), 2);
+                    } else {
+                        BigDecimal firstPrice = NumberUtil.add(storePostage, templateDTO.getFirstPrice());
+
+                        if (templateDTO.getContinues() <= 0) {
+                            storePostage = firstPrice;
+                        } else {
+                            //续件平均值且向上取整数
+                            double average = Math.ceil(NumberUtil.div(NumberUtil.sub(templateDTO.getNumber(),
+                                            templateDTO.getFirst()),
+                                    templateDTO.getContinues().doubleValue()));
+                            //最终邮费
+                            storePostage = NumberUtil.add(firstPrice, NumberUtil.mul(average,
+                                    templateDTO.getContinuePrice()));
+                        }
+
+                    }
+
+                    isFirst = false;
+                } else {
+                    //多件直接在以前的基数继续续建
+                    if (templateDTO.getContinues() > 0) {
+                        //续件平均值且向上取整数
+                        double average = Math.ceil(
+                                NumberUtil.div(
+                                        templateDTO.getNumber(),
+                                        templateDTO.getContinues()
+                                )
+                        );
+                        //最终邮费
+                        storePostage = NumberUtil.add(storePostage.doubleValue(), NumberUtil.mul(average,
+                                templateDTO.getContinuePrice()));
+                    }
+                }
+            }
+        }
+        return storePostage;
     }
     }
 }
 }

+ 31 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStorePaymentScrmServiceImpl.java

@@ -66,6 +66,7 @@ import com.github.binarywang.wxpay.service.WxPayService;
 import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
 import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
 import com.google.common.reflect.TypeToken;
 import com.google.common.reflect.TypeToken;
 import com.google.gson.Gson;
 import com.google.gson.Gson;
+import lombok.Synchronized;
 import me.chanjar.weixin.common.error.WxErrorException;
 import me.chanjar.weixin.common.error.WxErrorException;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
@@ -906,4 +907,34 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
             return R.error(result.getResp_desc());
             return R.error(result.getResp_desc());
         }
         }
     }
     }
+
+    @Override
+    public List<FsStorePaymentScrm> selectFsStorePaymentByPaymentCode(String payCode) {
+        return fsStorePaymentMapper.selectFsStorePaymentByPaymentCodeList(payCode);
+    }
+
+    @Override
+    @Transactional
+    public String payConfirmMultiStore(String payCode, String tradeNo, String bankTransactionId, String bankSerialNo) {
+        //更新订单状态
+        List<FsStorePaymentScrm> storePayments = fsStorePaymentMapper.selectFsStorePaymentByPaymentCodeList(payCode);
+        if (storePayments != null && !storePayments.isEmpty()) {
+            for (FsStorePaymentScrm storePayment : storePayments) {
+                if (!storePayment.getStatus().equals(0)) {
+                    return "";
+                }
+                storePayment.setStatus(1);
+                storePayment.setPayTime(new Date());
+                storePayment.setTradeNo(tradeNo);
+                storePayment.setBankSerialNo(bankSerialNo);
+                storePayment.setBankTransactionId(bankTransactionId);
+                fsStorePaymentMapper.updateFsStorePayment(storePayment);
+                //增加佣金
+                if (storePayment.getCompanyId() != null && storePayment.getCompanyId() > 0) {
+                    companyService.addCompanyPaymentMoney(storePayment);
+                }
+            }
+        }
+        return "success";
+    }
 }
 }

+ 9 - 7
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductScrmServiceImpl.java

@@ -389,7 +389,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
         product.setStock(Long.parseLong(countDto.getStock().toString()));
         product.setStock(Long.parseLong(countDto.getStock().toString()));
         product.setCompanyIds(param.getCompanyIds());
         product.setCompanyIds(param.getCompanyIds());
         product.setVideo(param.getVideo());
         product.setVideo(param.getVideo());
-        product.setStoreId(param.getStoreId());
+        Long storeId = param.getStoreId();
+        product.setStoreId(storeId);
         product.setIsDrug(param.getIsDrug().toString());
         product.setIsDrug(param.getIsDrug().toString());
         //校验店铺资质信息
         //校验店铺资质信息
         //获取店铺
         //获取店铺
@@ -459,9 +460,9 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                 List<ProductArrtDTO> items=new ArrayList<>();
                 List<ProductArrtDTO> items=new ArrayList<>();
                 items.add(fromatDetailDto);
                 items.add(fromatDetailDto);
                 param.getValues().get(0).setSku("默认");
                 param.getValues().get(0).setSku("默认");
-                addProductAttr(product.getProductId(),items,param.getValues());
+                addProductAttr(product.getProductId(),items,param.getValues(),storeId);
             } else {
             } else {
-                addProductAttr(product.getProductId(),param.getItems(),param.getValues());
+                addProductAttr(product.getProductId(),param.getItems(),param.getValues(),storeId);
             }
             }
         }
         }
         else{
         else{
@@ -476,15 +477,15 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
             List<ProductArrtDTO> items=new ArrayList<>();
             List<ProductArrtDTO> items=new ArrayList<>();
             items.add(fromatDetailDto);
             items.add(fromatDetailDto);
             param.getValues().get(0).setSku("默认");
             param.getValues().get(0).setSku("默认");
-            addProductAttr(product.getProductId(),items,param.getValues());
+            addProductAttr(product.getProductId(),items,param.getValues(),storeId);
         } else {
         } else {
-            addProductAttr(product.getProductId(),param.getItems(),param.getValues());
+            addProductAttr(product.getProductId(),param.getItems(),param.getValues(),storeId);
         }
         }
         return R.ok();
         return R.ok();
     }
     }
 
 
 
 
-    private void addProductAttr(Long productId, List<ProductArrtDTO> items, List<FsStoreProductAttrValueScrm> values){
+    private void addProductAttr(Long productId, List<ProductArrtDTO> items, List<FsStoreProductAttrValueScrm> values,Long storeId){
         //清空attr
         //清空attr
         fsStoreProductAttrMapper.clear(productId);
         fsStoreProductAttrMapper.clear(productId);
         //清空values
         //清空values
@@ -512,6 +513,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                 val.setSku(StrUtil.join(",",stringList));
                 val.setSku(StrUtil.join(",",stringList));
             }
             }
             val.setProductId(productId);
             val.setProductId(productId);
+            val.setStoreId(storeId);
             fsStoreProductAttrValueMapper.insertFsStoreProductAttrValue(val);
             fsStoreProductAttrValueMapper.insertFsStoreProductAttrValue(val);
             if(attrValues!=null&&attrValues.size()>0){
             if(attrValues!=null&&attrValues.size()>0){
                 for(FsStoreProductAttrValueScrm attrValue:attrValues){
                 for(FsStoreProductAttrValueScrm attrValue:attrValues){
@@ -1194,7 +1196,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
                     List<ProductArrtDTO> items=new ArrayList<>();
                     List<ProductArrtDTO> items=new ArrayList<>();
                     items.add(fromatDetailDto);
                     items.add(fromatDetailDto);
                     param.get(0).setSku("默认");
                     param.get(0).setSku("默认");
-                    addProductAttr(product.getProductId(),items,param);
+                    addProductAttr(product.getProductId(),items,param,product.getStoreId());
                 } else {
                 } else {
                     List<FsStoreProductAttrScrm> items = fsStoreProductAttrMapper.selectFsStoreProductAttrByProductId(product.getProductId());
                     List<FsStoreProductAttrScrm> items = fsStoreProductAttrMapper.selectFsStoreProductAttrByProductId(product.getProductId());
 
 

+ 13 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsHuiFuPayInfo.java

@@ -0,0 +1,13 @@
+package com.fs.hisStore.vo;
+
+import lombok.Data;
+
+@Data
+public class FsHuiFuPayInfo {
+    private String timeStamp;
+    private String packageStr;
+    private String paySign;
+    private String appId;
+    private String signType;
+    private String nonceStr;
+}

+ 15 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsOrderMoneyDetailsVo.java

@@ -0,0 +1,15 @@
+package com.fs.hisStore.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class FsOrderMoneyDetailsVo {
+    //购物车id
+    private String createOrderKey;
+    //原价
+    private BigDecimal totalPrice;
+    //实收价格
+    private BigDecimal payPrice;
+}

+ 12 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreCartGroupStoreVO.java

@@ -0,0 +1,12 @@
+package com.fs.hisStore.vo;
+
+import com.fs.store.vo.FsStoreCartScrmVO;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class FsStoreCartGroupStoreVO {
+    private String storeName;
+    private List<FsStoreCartScrmVO> list;
+}

+ 16 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreCartQueryGroupStoreVO.java

@@ -0,0 +1,16 @@
+package com.fs.hisStore.vo;
+
+import com.fs.store.vo.FsStoreCartScrmQueryVO;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+public class FsStoreCartQueryGroupStoreVO {
+    private String storeName;
+    private List<FsStoreCartScrmQueryVO> list;
+    private BigDecimal totalMoney; //原价
+    private BigDecimal payMoney; //实收
+    private String createOrderKey;
+}

+ 1006 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderGroupStoreVO.java

@@ -0,0 +1,1006 @@
+package com.fs.hisStore.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.annotation.Excel;
+import com.fs.common.core.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+/**
+ *
+ * @author fs
+ * @date 2022-03-15
+ */
+public class FsStoreOrderGroupStoreVO extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 订单ID */
+    private List<Long> ids;
+
+    /** 订单号 */
+    private List<String> orderCodes;
+
+//    /** 额外订单号 */
+//    private String extendOrderId;
+//
+//    private String payOrderId;
+//
+//    private String bankOrderId;
+
+    /** 用户id */
+    private Long userId;
+
+    /** 用户姓名 */
+    @Excel(name = "收货人")
+    private String realName;
+
+    /** 用户电话 */
+    @Excel(name = "手机号")
+    private String userPhone;
+
+    /** 详细地址 */
+    @Excel(name = "详细地址")
+    private String userAddress;
+
+//    /** 购物车id */
+//    private String cartId;
+//
+//    /** 运费金额 */
+//    private BigDecimal freightPrice;
+
+    /** 订单商品总数 */
+    @Excel(name = "订单商品总数")
+    private Long totalNum;
+
+    /** 订单总价 */
+    @Excel(name = "订单总价")
+    private BigDecimal totalPrice;
+
+    /** 邮费 */
+    private BigDecimal totalPostage;
+
+    /** 实际支付金额 */
+    @Excel(name = "应付金额")
+    private BigDecimal payPrice;
+
+    /** 支付邮费 */
+    private BigDecimal payPostage;
+
+    @Excel(name = "物流代收金额")
+    private BigDecimal payDelivery;
+
+    @Excel(name = "支付金额")
+    private BigDecimal payMoney;
+
+    /** 抵扣金额 */
+    private BigDecimal deductionPrice;
+
+    /** 优惠券id */
+    private Long couponId;
+
+    /** 优惠券金额 */
+    private BigDecimal couponPrice;
+
+    /** 支付状态 */
+    @Excel(name = "支付状态 1已支付 0未支付 2支付中")
+    private Integer paid;
+
+    /** 支付时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date payTime;
+
+    /** 支付方式 */
+    @Excel(name = "支付方式 1线上 2物流代收")
+    private String payType;
+
+    private Integer status;
+
+    /** 0 未退款 1 申请中 2 已退款 */
+    private Integer refundStatus;
+
+    /** 退款图片 */
+    @Excel(name = "退款图片")
+    private String refundReasonWapImg;
+
+    /** 退款用户说明 */
+    @Excel(name = "退款用户说明")
+    private String refundReasonWapExplain;
+
+    /** 退款时间 */
+
+    private Date refundReasonTime;
+
+    /** 前台退款原因 */
+    private String refundReasonWap;
+
+    /** 不退款的理由 */
+    private String refundReason;
+
+    /** 退款金额 */
+    private BigDecimal refundPrice;
+
+    /** 快递公司编号 */
+    @Excel(name = "快递公司编号")
+    private String deliverySn;
+
+    /** 快递名称/送货人姓名 */
+    @Excel(name = "快递名称")
+    private String deliveryName;
+
+    /** 发货类型 */
+    private String deliveryType;
+
+    /** 快递单号/手机号 */
+    @Excel(name = "快递单号")
+    private String deliveryId;
+
+    /** 消费赚取积分 */
+    private BigDecimal gainIntegral;
+
+    /** 使用积分 */
+    @Excel(name = "使用积分")
+    private BigDecimal useIntegral;
+
+    /** 实际支付积分 */
+    @Excel(name = "实际支付积分")
+    private BigDecimal payIntegral;
+
+    /** 给用户退了多少积分 */
+    private BigDecimal backIntegral;
+
+    /** 备注 */
+    @Excel(name = "备注")
+    private String mark;
+
+
+    /** 是否删除 */
+    private Integer isDel;
+
+    /** 成本价 */
+    private BigDecimal cost;
+
+    /** 核销码 */
+    private String verifyCode;
+
+    /** 门店id */
+    private Long storeId;
+
+    /** 配送方式 1=快递 ,2=门店自提 */
+    private Integer shippingType;
+
+    /** 支付渠道(0微信公众号1微信小程序) */
+    private Integer isChannel;
+
+    /** 是否提醒 */
+    private Integer isRemind;
+
+    /** 是否系统删除 */
+    private Integer isSysDel;
+
+    private Integer isPrescribe;
+
+    private Long prescribeId;
+
+    private Long companyId;
+
+    private Long companyUserId;
+
+    private Integer isPackage;
+
+    private String packageJson;
+
+    private String itemJson;
+
+    private Integer orderType;
+
+    private Long packageId;
+
+    private Integer orderCreateType;
+
+    private String storeHouseCode;
+
+
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "完成时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date finishTime;
+
+    private Integer deliveryStatus;
+
+    private Integer deliveryPayStatus;
+
+    @Excel(name = "快递帐单日期")
+    private String deliveryTime;
+
+    @Excel(name = "快递结算日期")
+    private String deliveryPayTime;
+
+    private BigDecimal deliveryPayMoney;
+
+    private BigDecimal tuiMoney;
+
+    private Integer tuiMoneyStatus;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "回单导入时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date deliveryImportTime;
+
+    private Long tuiUserId;
+
+    private Integer tuiUserMoneyStatus;
+
+    private Long deptId;
+
+    private Integer isEditMoney;
+
+    private Long customerId;
+
+    private Integer isPayRemain;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "发货时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date deliverySendTime;
+
+    //凭证
+    private String certificates;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date uploadTime;
+
+    private Long scheduleId; //归属档期id
+
+    //组合订单标识
+    private String combinationOrderId;
+
+    public Long getScheduleId() {
+        return scheduleId;
+    }
+
+    public void setScheduleId(Long scheduleId) {
+        this.scheduleId = scheduleId;
+    }
+
+    public Date getUploadTime() {
+        return uploadTime;
+    }
+
+    public void setUploadTime(Date uploadTime) {
+        this.uploadTime = uploadTime;
+    }
+
+    public String getCertificates() {
+        return certificates;
+    }
+
+    public void setCertificates(String certificates) {
+        this.certificates = certificates;
+    }
+
+    public Date getDeliverySendTime() {
+        return deliverySendTime;
+    }
+
+    public void setDeliverySendTime(Date deliverySendTime) {
+        this.deliverySendTime = deliverySendTime;
+    }
+
+    public Integer getIsPayRemain() {
+        return isPayRemain;
+    }
+
+    public void setIsPayRemain(Integer isPayRemain) {
+        this.isPayRemain = isPayRemain;
+    }
+
+    public Long getCustomerId() {
+        return customerId;
+    }
+
+    public void setCustomerId(Long customerId) {
+        this.customerId = customerId;
+    }
+
+    public Integer getTuiUserMoneyStatus() {
+        return tuiUserMoneyStatus;
+    }
+
+    public void setTuiUserMoneyStatus(Integer tuiUserMoneyStatus) {
+        this.tuiUserMoneyStatus = tuiUserMoneyStatus;
+    }
+
+    public Integer getIsEditMoney() {
+        return isEditMoney;
+    }
+
+    public void setIsEditMoney(Integer isEditMoney) {
+        this.isEditMoney = isEditMoney;
+    }
+
+    public Long getDeptId() {
+        return deptId;
+    }
+
+    public void setDeptId(Long deptId) {
+        this.deptId = deptId;
+    }
+
+    public String getStoreHouseCode() {
+        return storeHouseCode;
+    }
+
+    public void setStoreHouseCode(String storeHouseCode) {
+        this.storeHouseCode = storeHouseCode;
+    }
+
+    public Integer getOrderCreateType() {
+        return orderCreateType;
+    }
+
+    public void setOrderCreateType(Integer orderCreateType) {
+        this.orderCreateType = orderCreateType;
+    }
+
+    public Long getTuiUserId() {
+        return tuiUserId;
+    }
+
+    public void setTuiUserId(Long tuiUserId) {
+        this.tuiUserId = tuiUserId;
+    }
+
+    public Date getDeliveryImportTime() {
+        return deliveryImportTime;
+    }
+
+    public void setDeliveryImportTime(Date deliveryImportTime) {
+        this.deliveryImportTime = deliveryImportTime;
+    }
+
+    public Integer getTuiMoneyStatus() {
+        return tuiMoneyStatus;
+    }
+
+    public void setTuiMoneyStatus(Integer tuiMoneyStatus) {
+        this.tuiMoneyStatus = tuiMoneyStatus;
+    }
+
+    public BigDecimal getTuiMoney() {
+        return tuiMoney;
+    }
+
+    public void setTuiMoney(BigDecimal tuiMoney) {
+        this.tuiMoney = tuiMoney;
+    }
+
+//    public String getPayOrderId() {
+//        return payOrderId;
+//    }
+//
+//    public void setPayOrderId(String payOrderId) {
+//        this.payOrderId = payOrderId;
+//    }
+//
+//    public String getBankOrderId() {
+//        return bankOrderId;
+//    }
+
+//    public void setBankOrderId(String bankOrderId) {
+//        this.bankOrderId = bankOrderId;
+//    }
+
+    public BigDecimal getDeliveryPayMoney() {
+        return deliveryPayMoney;
+    }
+
+    public void setDeliveryPayMoney(BigDecimal deliveryPayMoney) {
+        this.deliveryPayMoney = deliveryPayMoney;
+    }
+
+    public Integer getDeliveryStatus() {
+        return deliveryStatus;
+    }
+
+    public void setDeliveryStatus(Integer deliveryStatus) {
+        this.deliveryStatus = deliveryStatus;
+    }
+
+    public Integer getDeliveryPayStatus() {
+        return deliveryPayStatus;
+    }
+
+    public void setDeliveryPayStatus(Integer deliveryPayStatus) {
+        this.deliveryPayStatus = deliveryPayStatus;
+    }
+
+    public String getDeliveryTime() {
+        return deliveryTime;
+    }
+
+    public void setDeliveryTime(String deliveryTime) {
+        this.deliveryTime = deliveryTime;
+    }
+
+    public String getDeliveryPayTime() {
+        return deliveryPayTime;
+    }
+
+    public void setDeliveryPayTime(String deliveryPayTime) {
+        this.deliveryPayTime = deliveryPayTime;
+    }
+
+    public Date getFinishTime() {
+        return finishTime;
+    }
+
+    public void setFinishTime(Date finishTime) {
+        this.finishTime = finishTime;
+    }
+
+    public Long getPackageId() {
+        return packageId;
+    }
+
+    public void setPackageId(Long packageId) {
+        this.packageId = packageId;
+    }
+
+    public Integer getOrderType() {
+        return orderType;
+    }
+
+    public void setOrderType(Integer orderType) {
+        this.orderType = orderType;
+    }
+
+    public String getPackageJson() {
+        return packageJson;
+    }
+
+    public void setPackageJson(String packageJson) {
+        this.packageJson = packageJson;
+    }
+
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
+    }
+
+    public BigDecimal getPayMoney() {
+        return payMoney;
+    }
+
+    public void setPayMoney(BigDecimal payMoney) {
+        this.payMoney = payMoney;
+    }
+
+    public BigDecimal getPayDelivery() {
+        return payDelivery;
+    }
+
+    public void setPayDelivery(BigDecimal payDelivery) {
+        this.payDelivery = payDelivery;
+    }
+
+    public Integer getIsPackage() {
+        return isPackage;
+    }
+
+    public void setIsPackage(Integer isPackage) {
+        this.isPackage = isPackage;
+    }
+
+    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 Long getPrescribeId() {
+        return prescribeId;
+    }
+
+    public void setPrescribeId(Long prescribeId) {
+        this.prescribeId = prescribeId;
+    }
+
+    public Integer getIsPrescribe() {
+        return isPrescribe;
+    }
+
+    public void setIsPrescribe(Integer isPrescribe) {
+        this.isPrescribe = isPrescribe;
+    }
+
+    public void setIds(List<Long> ids)
+    {
+        this.ids = ids;
+    }
+
+    public List<Long> getIds()
+    {
+        return ids;
+    }
+    public void setOrderCodes(List<String> orderCodes)
+    {
+        this.orderCodes = orderCodes;
+    }
+
+    public List<String> getOrderCodes()
+    {
+        return orderCodes;
+    }
+//    public void setExtendOrderId(String extendOrderId)
+//    {
+//        this.extendOrderId = extendOrderId;
+//    }
+//
+//    public String getExtendOrderId()
+//    {
+//        return extendOrderId;
+//    }
+    public void setUserId(Long userId)
+    {
+        this.userId = userId;
+    }
+
+    public Long getUserId()
+    {
+        return userId;
+    }
+    public void setRealName(String realName)
+    {
+        this.realName = realName;
+    }
+
+    public String getRealName()
+    {
+        return realName;
+    }
+    public void setUserPhone(String userPhone)
+    {
+        this.userPhone = userPhone;
+    }
+
+    public String getUserPhone()
+    {
+        return userPhone;
+    }
+    public void setUserAddress(String userAddress)
+    {
+        this.userAddress = userAddress;
+    }
+
+    public String getUserAddress()
+    {
+        return userAddress;
+    }
+//    public void setCartId(String cartId)
+//    {
+//        this.cartId = cartId;
+//    }
+//
+//    public String getCartId()
+//    {
+//        return cartId;
+//    }
+//    public void setFreightPrice(BigDecimal freightPrice)
+//    {
+//        this.freightPrice = freightPrice;
+//    }
+//
+//    public BigDecimal getFreightPrice()
+//    {
+//        return freightPrice;
+//    }
+    public void setTotalNum(Long totalNum)
+    {
+        this.totalNum = totalNum;
+    }
+
+    public Long getTotalNum()
+    {
+        return totalNum;
+    }
+    public void setTotalPrice(BigDecimal totalPrice)
+    {
+        this.totalPrice = totalPrice;
+    }
+
+    public BigDecimal getTotalPrice()
+    {
+        return totalPrice;
+    }
+    public void setTotalPostage(BigDecimal totalPostage)
+    {
+        this.totalPostage = totalPostage;
+    }
+
+    public BigDecimal getTotalPostage()
+    {
+        return totalPostage;
+    }
+    public void setPayPrice(BigDecimal payPrice)
+    {
+        this.payPrice = payPrice;
+    }
+
+    public BigDecimal getPayPrice()
+    {
+        return payPrice;
+    }
+    public void setPayPostage(BigDecimal payPostage)
+    {
+        this.payPostage = payPostage;
+    }
+
+    public BigDecimal getPayPostage()
+    {
+        return payPostage;
+    }
+    public void setDeductionPrice(BigDecimal deductionPrice)
+    {
+        this.deductionPrice = deductionPrice;
+    }
+
+    public BigDecimal getDeductionPrice()
+    {
+        return deductionPrice;
+    }
+    public void setCouponId(Long couponId)
+    {
+        this.couponId = couponId;
+    }
+
+    public Long getCouponId()
+    {
+        return couponId;
+    }
+    public void setCouponPrice(BigDecimal couponPrice)
+    {
+        this.couponPrice = couponPrice;
+    }
+
+    public BigDecimal getCouponPrice()
+    {
+        return couponPrice;
+    }
+    public void setPaid(Integer paid)
+    {
+        this.paid = paid;
+    }
+
+    public Integer getPaid()
+    {
+        return paid;
+    }
+    public void setPayTime(Date payTime)
+    {
+        this.payTime = payTime;
+    }
+
+    public Date getPayTime()
+    {
+        return payTime;
+    }
+    public void setPayType(String payType)
+    {
+        this.payType = payType;
+    }
+
+    public String getPayType()
+    {
+        return payType;
+    }
+    public void setStatus(Integer status)
+    {
+        this.status = status;
+    }
+
+    public Integer getStatus()
+    {
+        return status;
+    }
+    public void setRefundStatus(Integer refundStatus)
+    {
+        this.refundStatus = refundStatus;
+    }
+
+    public Integer getRefundStatus()
+    {
+        return refundStatus;
+    }
+    public void setRefundReasonWapImg(String refundReasonWapImg)
+    {
+        this.refundReasonWapImg = refundReasonWapImg;
+    }
+
+    public String getRefundReasonWapImg()
+    {
+        return refundReasonWapImg;
+    }
+    public void setRefundReasonWapExplain(String refundReasonWapExplain)
+    {
+        this.refundReasonWapExplain = refundReasonWapExplain;
+    }
+
+    public String getRefundReasonWapExplain()
+    {
+        return refundReasonWapExplain;
+    }
+    public void setRefundReasonTime(Date refundReasonTime)
+    {
+        this.refundReasonTime = refundReasonTime;
+    }
+
+    public Date getRefundReasonTime()
+    {
+        return refundReasonTime;
+    }
+    public void setRefundReasonWap(String refundReasonWap)
+    {
+        this.refundReasonWap = refundReasonWap;
+    }
+
+    public String getRefundReasonWap()
+    {
+        return refundReasonWap;
+    }
+    public void setRefundReason(String refundReason)
+    {
+        this.refundReason = refundReason;
+    }
+
+    public String getRefundReason()
+    {
+        return refundReason;
+    }
+    public void setRefundPrice(BigDecimal refundPrice)
+    {
+        this.refundPrice = refundPrice;
+    }
+
+    public BigDecimal getRefundPrice()
+    {
+        return refundPrice;
+    }
+    public void setDeliverySn(String deliverySn)
+    {
+        this.deliverySn = deliverySn;
+    }
+
+    public String getDeliverySn()
+    {
+        return deliverySn;
+    }
+    public void setDeliveryName(String deliveryName)
+    {
+        this.deliveryName = deliveryName;
+    }
+
+    public String getDeliveryName()
+    {
+        return deliveryName;
+    }
+    public void setDeliveryType(String deliveryType)
+    {
+        this.deliveryType = deliveryType;
+    }
+
+    public String getDeliveryType()
+    {
+        return deliveryType;
+    }
+    public void setDeliveryId(String deliveryId)
+    {
+        this.deliveryId = deliveryId;
+    }
+
+    public String getDeliveryId()
+    {
+        return deliveryId;
+    }
+    public void setGainIntegral(BigDecimal gainIntegral)
+    {
+        this.gainIntegral = gainIntegral;
+    }
+
+    public BigDecimal getGainIntegral()
+    {
+        return gainIntegral;
+    }
+    public void setUseIntegral(BigDecimal useIntegral)
+    {
+        this.useIntegral = useIntegral;
+    }
+
+    public BigDecimal getUseIntegral()
+    {
+        return useIntegral;
+    }
+    public void setPayIntegral(BigDecimal payIntegral)
+    {
+        this.payIntegral = payIntegral;
+    }
+
+    public BigDecimal getPayIntegral()
+    {
+        return payIntegral;
+    }
+    public void setBackIntegral(BigDecimal backIntegral)
+    {
+        this.backIntegral = backIntegral;
+    }
+
+    public BigDecimal getBackIntegral()
+    {
+        return backIntegral;
+    }
+    public void setMark(String mark)
+    {
+        this.mark = mark;
+    }
+
+    public String getMark()
+    {
+        return mark;
+    }
+    public void setIsDel(Integer isDel)
+    {
+        this.isDel = isDel;
+    }
+
+    public Integer getIsDel()
+    {
+        return isDel;
+    }
+    public void setCost(BigDecimal cost)
+    {
+        this.cost = cost;
+    }
+
+    public BigDecimal getCost()
+    {
+        return cost;
+    }
+    public void setVerifyCode(String verifyCode)
+    {
+        this.verifyCode = verifyCode;
+    }
+
+    public String getVerifyCode()
+    {
+        return verifyCode;
+    }
+    public void setStoreId(Long storeId)
+    {
+        this.storeId = storeId;
+    }
+
+    public Long getStoreId()
+    {
+        return storeId;
+    }
+    public void setShippingType(Integer shippingType)
+    {
+        this.shippingType = shippingType;
+    }
+
+    public Integer getShippingType()
+    {
+        return shippingType;
+    }
+    public void setIsChannel(Integer isChannel)
+    {
+        this.isChannel = isChannel;
+    }
+
+    public Integer getIsChannel()
+    {
+        return isChannel;
+    }
+    public void setIsRemind(Integer isRemind)
+    {
+        this.isRemind = isRemind;
+    }
+
+    public Integer getIsRemind()
+    {
+        return isRemind;
+    }
+    public void setIsSysDel(Integer isSysDel)
+    {
+        this.isSysDel = isSysDel;
+    }
+
+    public Integer getIsSysDel()
+    {
+        return isSysDel;
+    }
+
+    public String getItemJson() {
+        return itemJson;
+    }
+
+    public void setItemJson(String itemJson) {
+        this.itemJson = itemJson;
+    }
+
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+                .append("ids", getIds())
+                .append("orderCodes", getOrderCodes())
+//                .append("extendOrderId", getExtendOrderId())
+                .append("userId", getUserId())
+                .append("realName", getRealName())
+                .append("userPhone", getUserPhone())
+                .append("userAddress", getUserAddress())
+//                .append("cartId", getCartId())
+//                .append("freightPrice", getFreightPrice())
+                .append("totalNum", getTotalNum())
+                .append("totalPrice", getTotalPrice())
+                .append("totalPostage", getTotalPostage())
+                .append("payPrice", getPayPrice())
+                .append("payPostage", getPayPostage())
+                .append("deductionPrice", getDeductionPrice())
+                .append("couponId", getCouponId())
+                .append("couponPrice", getCouponPrice())
+                .append("paid", getPaid())
+                .append("payTime", getPayTime())
+                .append("payType", getPayType())
+                .append("createTime", getCreateTime())
+                .append("updateTime", getUpdateTime())
+                .append("status", getStatus())
+                .append("refundStatus", getRefundStatus())
+                .append("refundReasonWapImg", getRefundReasonWapImg())
+                .append("refundReasonWapExplain", getRefundReasonWapExplain())
+                .append("refundReasonTime", getRefundReasonTime())
+                .append("refundReasonWap", getRefundReasonWap())
+                .append("refundReason", getRefundReason())
+                .append("refundPrice", getRefundPrice())
+                .append("deliverySn", getDeliverySn())
+                .append("deliveryName", getDeliveryName())
+                .append("deliveryType", getDeliveryType())
+                .append("deliveryId", getDeliveryId())
+                .append("gainIntegral", getGainIntegral())
+                .append("useIntegral", getUseIntegral())
+                .append("payIntegral", getPayIntegral())
+                .append("backIntegral", getBackIntegral())
+                .append("mark", getMark())
+                .append("isDel", getIsDel())
+                .append("remark", getRemark())
+                .append("cost", getCost())
+                .append("verifyCode", getVerifyCode())
+                .append("storeId", getStoreId())
+                .append("shippingType", getShippingType())
+                .append("isChannel", getIsChannel())
+                .append("isRemind", getIsRemind())
+                .append("isSysDel", getIsSysDel())
+                .append("combinationOrderId", getCombinationOrderId())
+                .toString();
+    }
+
+    public String getCombinationOrderId() {
+        return combinationOrderId;
+    }
+
+    public void setCombinationOrderId(String combinationOrderId) {
+        this.combinationOrderId = combinationOrderId;
+    }
+}

+ 6 - 0
fs-service/src/main/java/com/fs/store/vo/FsStoreCartScrmQueryVO.java

@@ -63,5 +63,11 @@ import java.math.BigDecimal;
 
 
     private BigDecimal brokerageThree;
     private BigDecimal brokerageThree;
 
 
+    private String erpCode;
+
+    private String erpSkuName;
+
+    private String storeId;
+    private String storeName;
 
 
 }
 }

+ 3 - 0
fs-service/src/main/java/com/fs/store/vo/FsStoreCartScrmVO.java

@@ -38,4 +38,7 @@ import java.math.BigDecimal;
     private Integer stock;
     private Integer stock;
 
 
     private Integer productType;
     private Integer productType;
+
+    //店铺ID
+    private Long storeId;
 }
 }

+ 9 - 1
fs-service/src/main/resources/mapper/hisStore/FsStoreOrderScrmMapper.xml

@@ -92,7 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
     </resultMap>
 
 
     <sql id="selectFsStoreOrderVo">
     <sql id="selectFsStoreOrderVo">
-        select id, order_code,service_fee, extend_order_id,pay_order_id,bank_order_id, user_id,order_visit, real_name, user_phone, user_address, cart_id, freight_price, total_num, total_price, total_postage, pay_price, pay_postage,pay_delivery,pay_money, deduction_price, coupon_id, coupon_price, paid, pay_time, pay_type, create_time, update_time, status, refund_status, refund_reason_wap_img, refund_reason_wap_explain, refund_reason_time, refund_reason_wap, refund_reason, refund_price, delivery_sn, delivery_name, delivery_type, delivery_id, gain_integral, use_integral, pay_integral, back_integral, mark, is_del, remark, cost, verify_code, store_id, shipping_type, is_channel, is_remind, is_sys_del,is_prescribe,prescribe_id ,company_id,company_user_id,is_package,package_json,item_json,order_type,package_id,finish_time,delivery_status,delivery_pay_status,delivery_time,delivery_pay_time,delivery_pay_money,tui_money,tui_money_status,delivery_import_time,tui_user_id,tui_user_money_status,order_create_type,store_house_code,dept_id,is_edit_money,customer_id,is_pay_remain,delivery_send_time,certificates,schedule_id from fs_store_order_scrm
+        select id, order_code,service_fee, extend_order_id,pay_order_id,bank_order_id, user_id,order_visit, real_name, user_phone, user_address, cart_id, freight_price, total_num, total_price, total_postage, pay_price, pay_postage,pay_delivery,pay_money, deduction_price, coupon_id, coupon_price, paid, pay_time, pay_type, create_time, update_time, status, refund_status, refund_reason_wap_img, refund_reason_wap_explain, refund_reason_time, refund_reason_wap, refund_reason, refund_price, delivery_sn, delivery_name, delivery_type, delivery_id, gain_integral, use_integral, pay_integral, back_integral, mark, is_del, remark, cost, verify_code, store_id, shipping_type, is_channel, is_remind, is_sys_del,is_prescribe,prescribe_id ,company_id,company_user_id,is_package,package_json,item_json,order_type,package_id,finish_time,delivery_status,delivery_pay_status,delivery_time,delivery_pay_time,delivery_pay_money,tui_money,tui_money_status,delivery_import_time,tui_user_id,tui_user_money_status,order_create_type,store_house_code,dept_id,is_edit_money,customer_id,is_pay_remain,delivery_send_time,certificates,schedule_id,combination_order_id from fs_store_order_scrm
     </sql>
     </sql>
 
 
     <select id="selectFsStoreOrderList" parameterType="FsStoreOrderScrm" resultMap="FsStoreOrderResult">
     <select id="selectFsStoreOrderList" parameterType="FsStoreOrderScrm" resultMap="FsStoreOrderResult">
@@ -248,6 +248,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="followTime != null">follow_time,</if>
             <if test="followTime != null">follow_time,</if>
             <if test="followDoctorId != null">follow_doctor_id,</if>
             <if test="followDoctorId != null">follow_doctor_id,</if>
             <if test="cycle != null">cycle,</if>
             <if test="cycle != null">cycle,</if>
+            <if test="combinationOrderId != null">combination_order_id,</if>
          </trim>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="orderCode != null and orderCode != ''">#{orderCode},</if>
             <if test="orderCode != null and orderCode != ''">#{orderCode},</if>
@@ -334,6 +335,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="followTime != null">#{followTime},</if>
             <if test="followTime != null">#{followTime},</if>
             <if test="followDoctorId != null">#{followDoctorId},</if>
             <if test="followDoctorId != null">#{followDoctorId},</if>
             <if test="cycle != null">#{cycle},</if>
             <if test="cycle != null">#{cycle},</if>
+            <if test="combinationOrderId != null">#{combinationOrderId},</if>
          </trim>
          </trim>
     </insert>
     </insert>
 
 
@@ -426,6 +428,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="followTime != null">follow_time = #{followTime},</if>
             <if test="followTime != null">follow_time = #{followTime},</if>
             <if test="followDoctorId != null">follow_doctor_id = #{followDoctorId},</if>
             <if test="followDoctorId != null">follow_doctor_id = #{followDoctorId},</if>
             <if test="cycle != null">cycle = #{cycle},</if>
             <if test="cycle != null">cycle = #{cycle},</if>
+            <if test="combinationOrderId != null">combination_order_id = #{combinationOrderId},</if>
         </trim>
         </trim>
         where id = #{id}
         where id = #{id}
     </update>
     </update>
@@ -971,4 +974,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{item}
             #{item}
     </foreach>
     </foreach>
     </select>
     </select>
+
+    <select id="getStoreOrderByCombinationId" resultType="com.fs.hisStore.domain.FsStoreOrderScrm">
+        <include refid="selectFsStoreOrderVo"/>
+        where combination_order_id like #{combinationId}
+    </select>
 </mapper>
 </mapper>

+ 3 - 0
fs-service/src/main/resources/mapper/hisStore/FsStoreProductAttrValueScrmMapper.xml

@@ -76,6 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="brokerageTwo != null">brokerage_two,</if>
             <if test="brokerageTwo != null">brokerage_two,</if>
             <if test="brokerageThree != null">brokerage_three,</if>
             <if test="brokerageThree != null">brokerage_three,</if>
             <if test="integral != null">integral,</if>
             <if test="integral != null">integral,</if>
+            <if test="storeId != null">store_id,</if>
          </trim>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="productId != null">#{productId},</if>
             <if test="productId != null">#{productId},</if>
@@ -95,6 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="brokerageTwo != null">#{brokerageTwo},</if>
             <if test="brokerageTwo != null">#{brokerageTwo},</if>
             <if test="brokerageThree != null">#{brokerageThree},</if>
             <if test="brokerageThree != null">#{brokerageThree},</if>
             <if test="integral != null">#{integral},</if>
             <if test="integral != null">#{integral},</if>
+            <if test="storeId != null">#{storeId},</if>
          </trim>
          </trim>
     </insert>
     </insert>
 
 
@@ -118,6 +120,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="brokerageTwo != null">brokerage_two = #{brokerageTwo},</if>
             <if test="brokerageTwo != null">brokerage_two = #{brokerageTwo},</if>
             <if test="brokerageThree != null">brokerage_three = #{brokerageThree},</if>
             <if test="brokerageThree != null">brokerage_three = #{brokerageThree},</if>
             <if test="integral != null">integral = #{integral},</if>
             <if test="integral != null">integral = #{integral},</if>
+            <if test="storeId != null">store_id = #{storeId},</if>
         </trim>
         </trim>
         where id = #{id}
         where id = #{id}
     </update>
     </update>

+ 22 - 0
fs-user-app/src/main/java/com/fs/app/controller/store/PayScrmController.java

@@ -114,4 +114,26 @@ public class PayScrmController {
 
 
 
 
 
 
+    /**
+     * 多店铺汇付回调
+     * **/
+    @ApiOperation("汇付第三方支付回调")
+    @PostMapping(value="/multiStore/hfPayNotify")
+    public String multiStoreHfPayNotify(@RequestParam String resp_desc, @RequestParam String resp_code, @RequestParam String sign, @RequestParam String resp_data) throws Exception {
+        //验证
+        HuiFuResult o = JSON.parseObject(resp_data, HuiFuResult.class);
+        logger.info("汇付支付回调:"+o);
+        if(o.getResp_code().equals("00000000")){
+            String[] order=o.getReq_seq_id().split("-");
+            switch (order[0]) {
+                case "store":
+                    return orderService.payConfirmMultiStore(1,null,order[1], o.getHf_seq_id(),o.getOut_trans_id(),o.getParty_order_id());
+                case "store_remain":
+                    return orderService.payRemainConfirmMultiStore( order[1], o.getHf_seq_id(),o.getOut_trans_id(),o.getParty_order_id());
+                case "payment":
+                    return storePaymentService.payConfirmMultiStore(order[1],o.getHf_seq_id(),o.getOut_trans_id(),o.getParty_order_id());
+            }
+        }
+        return "ok";
+    }
 }
 }

+ 9 - 5
fs-user-app/src/main/java/com/fs/app/controller/store/ProductScrmController.java

@@ -12,10 +12,7 @@ import com.fs.hisStore.config.MedicalMallConfig;
 import com.fs.hisStore.domain.*;
 import com.fs.hisStore.domain.*;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.service.*;
 import com.fs.hisStore.service.*;
-import com.fs.hisStore.vo.FsStoreCartVO;
-import com.fs.hisStore.vo.FsStoreProductAttrValueQueryVO;
-import com.fs.hisStore.vo.FsStoreProductListQueryVO;
-import com.fs.hisStore.vo.FsStoreProductQueryVO;
+import com.fs.hisStore.vo.*;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.service.ISysConfigService;
 import com.fs.system.service.ISysConfigService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
@@ -299,5 +296,12 @@ public class ProductScrmController extends AppBaseController {
     }
     }
 
 
 
 
-
+    @Login
+    @ApiOperation("获取购物车列表")
+    @GetMapping("/getCartsMultiStore")
+    public R getCartsMultiStore(HttpServletRequest request){
+//        List<FsStoreCartVO> carts= cartService.selectFsStoreCartListByUid(Long.parseLong(getUserId()));
+        List<FsStoreCartGroupStoreVO> carts= cartService.selectFsStoreCartListByUidMultiStore(Long.parseLong(getUserId()));
+        return R.ok().put("carts",carts);
+    }
 }
 }

+ 504 - 0
fs-user-app/src/main/java/com/fs/app/controller/store/StoreOrderScrmController.java

@@ -3,7 +3,9 @@ package com.fs.app.controller.store;
 import cn.binarywang.wx.miniapp.api.WxMaService;
 import cn.binarywang.wx.miniapp.api.WxMaService;
 import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
 import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.TypeReference;
 import com.alibaba.fastjson.TypeReference;
@@ -27,7 +29,9 @@ import com.fs.hisStore.enums.OrderInfoEnum;
 import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
 import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.service.*;
 import com.fs.hisStore.service.*;
+import com.fs.hisStore.vo.FsHuiFuPayInfo;
 import com.fs.hisStore.vo.FsMyStoreOrderListQueryVO;
 import com.fs.hisStore.vo.FsMyStoreOrderListQueryVO;
+import com.fs.hisStore.vo.FsStoreOrderGroupStoreVO;
 import com.fs.hisStore.vo.FsStoreOrderItemVO;
 import com.fs.hisStore.vo.FsStoreOrderItemVO;
 import com.fs.hospital580.entity.Hospital580PrescriptionScrmEntity;
 import com.fs.hospital580.entity.Hospital580PrescriptionScrmEntity;
 import com.fs.hospital580.service.Hospital580PrescriptionScrmService;
 import com.fs.hospital580.service.Hospital580PrescriptionScrmService;
@@ -52,6 +56,7 @@ import io.swagger.annotations.ApiOperation;
 import me.chanjar.weixin.common.error.WxErrorException;
 import me.chanjar.weixin.common.error.WxErrorException;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
@@ -269,6 +274,15 @@ public class StoreOrderScrmController extends AppBaseController {
     public R confirm(@Validated @RequestBody FsStoreConfirmOrderParam param, HttpServletRequest request){
     public R confirm(@Validated @RequestBody FsStoreConfirmOrderParam param, HttpServletRequest request){
         return orderService.confirmOrder(Long.parseLong(getUserId()),param);
         return orderService.confirmOrder(Long.parseLong(getUserId()),param);
     }
     }
+
+    @Login
+    @ApiOperation("确认订单")
+    @PostMapping("/confirmMultiStore")
+//    public R confirm(@Validated @RequestBody FsStoreConfirmOrderParam param, HttpServletRequest request){
+    public R confirmMultiStore(@Validated @RequestBody List<FsStoreConfirmOrderGroupStoreParam> paramList, HttpServletRequest request) {
+        return orderService.confirmOrderMultiStore(Long.parseLong(getUserId()), paramList);
+    }
+
     @Login
     @Login
     @ApiOperation("计算订单金额")
     @ApiOperation("计算订单金额")
     @PostMapping("/computed")
     @PostMapping("/computed")
@@ -277,6 +291,17 @@ public class StoreOrderScrmController extends AppBaseController {
         return R.ok().put("data",dto);
         return R.ok().put("data",dto);
     }
     }
 
 
+    @Login
+    @ApiOperation("计算订单金额")
+    @PostMapping("/computedMultiStore")
+//    public R computed(@Validated @RequestBody FsStoreOrderComputedParam param, HttpServletRequest request){
+    public R computedMultiStore(@Validated @RequestBody FsStoreOrderComputedGroupStoreParam param, HttpServletRequest request) {
+//        FsStoreOrderComputeDTO dto=orderService.computedOrder(Long.parseLong(getUserId()),param);
+//        return R.ok().put("data",dto);
+        List<FsStoreOrderComputeDTO> dtos = orderService.computedOrders(Long.parseLong(getUserId()), param);
+        return R.ok().put("data", dtos);
+    }
+
     @Login
     @Login
     @ApiOperation("创建订单")
     @ApiOperation("创建订单")
     @PostMapping("/create")
     @PostMapping("/create")
@@ -286,6 +311,40 @@ public class StoreOrderScrmController extends AppBaseController {
         return orderService.createOrder(Long.parseLong(getUserId()),param);
         return orderService.createOrder(Long.parseLong(getUserId()),param);
     }
     }
 
 
+
+    /**
+     * 多店铺创建拆分创建订单
+     * **/
+    @Login
+    @ApiOperation("创建订单")
+    @PostMapping("/createMultiStore")
+//    public R create(@Validated @RequestBody FsStoreOrderCreateParam param, HttpServletRequest request){
+    public R createMultiStore(@Validated @RequestBody FsStoreOrderCreateGroupStoreParam param, HttpServletRequest request) {
+//        return orderService.createOrder(Long.parseLong(getUserId()),param);
+        List<R> res = new ArrayList<>();
+        String combinationOrderId = IdUtil.randomUUID();
+        List<String> orderKeys = param.getOrderKeys();
+
+        List<String> createOrderKeys = null;
+        if (param.getCreateOrderKey()==null){
+            createOrderKeys = orderKeys;
+        } else {
+            createOrderKeys = Arrays.asList(param.getCreateOrderKey().split(","));
+        }
+        for (int i = 0; i < orderKeys.size(); i++) {
+            FsStoreOrderCreateParam fsStoreOrderCreateParam = new FsStoreOrderCreateParam();
+            BeanUtils.copyProperties(param, fsStoreOrderCreateParam);
+            //备注
+            fsStoreOrderCreateParam.setMark(param.getMark().get(i));
+            fsStoreOrderCreateParam.setOrderKey(orderKeys.get(i));
+            fsStoreOrderCreateParam.setCombinationOrderId(combinationOrderId);
+            fsStoreOrderCreateParam.setCreateOrderKey(createOrderKeys.get(i));
+            R order = orderService.createOrderMultiStore(Long.parseLong(getUserId()), fsStoreOrderCreateParam);
+            res.add(order);
+        }
+        return R.ok().put("data",res);
+    }
+
     @Login
     @Login
     @ApiOperation("支付")
     @ApiOperation("支付")
     @PostMapping("/pay")
     @PostMapping("/pay")
@@ -431,7 +490,178 @@ public class StoreOrderScrmController extends AppBaseController {
 
 
     }
     }
 
 
+    @Login
+    @ApiOperation("支付")
+    @PostMapping("/payByCombinationId")
+    @Transactional
+    public R payByCombinationId(HttpServletRequest request, @Validated @RequestBody FsStoreOrderPayCombinationIdParam param) {
+        //组合微信支付order
+        FsStoreOrderScrm fsStoreOrder = new FsStoreOrderScrm();
+        BigDecimal payPrice = BigDecimal.ZERO;
+        BigDecimal payMoneyTotal = BigDecimal.ZERO;
+
+        FsUserScrm fsUser = new FsUserScrm();
+
+        String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
+        List<FsStoreOrderScrm> orders = orderService.getStoreOrderByCombinationId(param.getCombinationOrderId());
+        //新增的支付详情id
+        ArrayList<Long> paymentIds = new ArrayList<>();
+        for (FsStoreOrderScrm order : orders) {
+            if (order == null) {
+                return R.error("订单不存在");
+            }
+            if (order.getStatus() != OrderInfoEnum.STATUS_0.getValue()) {
+                return R.error("订单状态不正确");
+            }
+            FsUserScrm user = userService.selectFsUserById(order.getUserId());
+
+            fsUser = user;
+
+            payPrice = NumberUtil.add(payPrice, order.getPayPrice());
+            if (user != null && StringUtils.isNotEmpty(user.getMaOpenId())) {
+                //已改价处理
+                if (order.getIsEditMoney() != null && order.getIsEditMoney() == 1) {
+                    //改过价不做处理
+                } else {
+                    String config = configService.selectConfigByKey("store.config");
+                    StoreConfig storeConfig = JSONUtil.toBean(config, StoreConfig.class);
+                    if (param.getPayType().equals(1)) {
+                        order.setPayType("1");
+                        order.setPayMoney(order.getPayPrice());
+                        order.setPayDelivery(BigDecimal.ZERO);
+                        payMoneyTotal = NumberUtil.add(payMoneyTotal, order.getPayPrice());
+                    } else if (param.getPayType().equals(2)) {
+                        order.setPayType("2");
+                        BigDecimal payMoney = order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
+                        payMoney = new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
+                        order.setPayDelivery(order.getPayPrice().subtract(payMoney));
+                        order.setPayMoney(payMoney);
+
+                        payMoneyTotal = NumberUtil.add(payMoneyTotal, payMoney);
+
+                    } else if (param.getPayType().equals(3)) {
+                        //货到付款
+                        order.setPayType("3");
+                        order.setPayDelivery(order.getPayPrice());
+                        order.setPayMoney(BigDecimal.ZERO);
+                    }
+                    orderService.updateFsStoreOrder(order);
+                }
+            } else {
+                return R.error("用户OPENID不存在");
+            }
 
 
+            if (order.getPayType().equals("1") || order.getPayType().equals("2")) {
+                String json = configService.selectConfigByKey(STORE_PAY_CONF);
+                FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+                String paySubCode = IdUtil.getSnowflake(0, 0).nextIdStr();
+                FsStorePaymentScrm payment = new FsStorePaymentScrm();
+                payment.setCompanyId(order.getCompanyId());
+                payment.setCompanyUserId(order.getCompanyUserId());
+                payment.setStatus(0);
+                payment.setPayCode(payCode);
+                payment.setPaySubCode(paySubCode);
+                payment.setPayMode(fsPayConfig.getType());
+                payment.setPayMoney(order.getPayMoney());
+                payment.setCreateTime(new Date());
+                payment.setPayTypeCode("weixin");
+                payment.setBusinessType(2);
+                payment.setRemark("商城订单支付");
+                payment.setOpenId(order.getRealName());
+                payment.setUserId(fsUser.getUserId());
+                //换成唯一标识
+//            storePayment.setBusinessOrderId(order.getId().toString());
+                payment.setBusinessOrderId(order.getCombinationOrderId());
+                payment.setOrderId(order.getId());
+                fsStorePaymentMapper.insertFsStorePayment(payment);
+                paymentIds.add(payment.getPaymentId());
+            }
+        }
+
+        fsStoreOrder.setPayType(orders.get(0).getPayType());
+        fsStoreOrder.setCompanyId(orders.get(0).getCompanyId());
+        fsStoreOrder.setCompanyUserId(orders.get(0).getCompanyUserId());
+        fsStoreOrder.setPayMoney(payMoneyTotal);
+        fsStoreOrder.setRealName(orders.get(0).getRealName());
+        fsStoreOrder.setCombinationOrderId(orders.get(0).getCombinationOrderId());
+        if (fsUser != null && StringUtils.isNotEmpty(fsUser.getMaOpenId())) {
+//            String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
+            if (fsStoreOrder.getPayType().equals("1") || fsStoreOrder.getPayType().equals("2")) {
+                FsStorePaymentScrm storePayment = new FsStorePaymentScrm();
+                storePayment.setCompanyId(fsStoreOrder.getCompanyId());
+                storePayment.setCompanyUserId(fsStoreOrder.getCompanyUserId());
+                storePayment.setStatus(0);
+                storePayment.setPayCode(payCode);
+                storePayment.setPayMoney(fsStoreOrder.getPayMoney());
+                storePayment.setCreateTime(new Date());
+                storePayment.setPayTypeCode("weixin");
+                storePayment.setBusinessType(2);
+                storePayment.setRemark("商城订单支付");
+                storePayment.setOpenId(fsStoreOrder.getRealName());
+                storePayment.setUserId(fsUser.getUserId());
+
+                //支付
+                HuiFuCreateOrder o = new HuiFuCreateOrder();
+                o.setTradeType("T_MINIAPP");
+                o.setOpenid(fsUser.getMaOpenId());
+                o.setReqSeqId("store-" + storePayment.getPayCode());
+                o.setTransAmt(storePayment.getPayMoney().toString());
+                o.setGoodsDesc("商城订单支付");
+                HuifuCreateOrderResult result = huiFuService.createOrder(o);
+                //创建订单
+                if (result.getBank_code() != null && result.getBank_code().equals("00000000")) {
+                    for (Long paymentId : paymentIds) {
+                        FsStorePaymentScrm mt = new FsStorePaymentScrm();
+                        mt.setPaymentId(paymentId);
+                        mt.setTradeNo(result.getHf_seq_id());
+                        fsStorePaymentMapper.updateFsStorePayment(mt);
+                    }
+
+                    String mes = result.getPay_info();
+                    JSONObject payInfo = JSONUtil.parseObj(mes);
+                    FsHuiFuPayInfo fsHuiFuPayInfo = new FsHuiFuPayInfo();
+                    if (payInfo.get("timeStamp") != null) {
+                        fsHuiFuPayInfo.setTimeStamp(payInfo.get("timeStamp").toString());
+                    }
+                    if (payInfo.get("package") != null) {
+                        fsHuiFuPayInfo.setPackageStr(payInfo.get("package").toString());
+                    }
+                    if (payInfo.get("paySign") != null) {
+                        fsHuiFuPayInfo.setPaySign(payInfo.get("paySign").toString());
+
+                    }
+                    if (payInfo.get("appId") != null) {
+                        fsHuiFuPayInfo.setAppId(payInfo.get("appId").toString());
+
+                    }
+                    if (payInfo.get("signType") != null) {
+                        fsHuiFuPayInfo.setSignType(payInfo.get("signType").toString());
+
+                    }
+                    if (payInfo.get("nonceStr") != null) {
+                        fsHuiFuPayInfo.setNonceStr(payInfo.get("nonceStr").toString());
+                    }
+
+
+//                    return R.ok().put("payType",param.getPayType()).put("result",result.getPay_info());
+                    return R.ok().put("payType", param.getPayType()).put("result", fsHuiFuPayInfo);
+                } else {
+                    return R.error(result.getResp_desc());
+                }
+            } else if (fsStoreOrder.getPayType().equals("3")) {
+                for (FsStoreOrderScrm order : orders) {
+                    //货到付款
+                    orderService.payConfirm(2, order.getId(), null, null, null, null);
+                    return R.ok().put("payType", param.getPayType());
+                }
+
+            }
+
+
+        }
+        return R.error("用户OPENID不存在");
+
+    }
 
 
 
 
 
 
@@ -927,4 +1157,278 @@ public class StoreOrderScrmController extends AppBaseController {
     }
     }
 
 
 
 
+    @Login
+    @ApiOperation("根据组合标识获取订单")
+    @GetMapping("/getStoreOrderByCombinationId")
+    public R getStoreOrderById(@RequestParam("combinationId") String combinationId, HttpServletRequest request) {
+        if (StringUtils.isBlank(combinationId)) {
+            return R.error("未选择订单");
+        }
+        List<FsStoreOrderScrm> orders = orderService.getStoreOrderByCombinationId(combinationId);
+        FsStoreOrderGroupStoreVO orderRes = new FsStoreOrderGroupStoreVO();
+        ArrayList<FsStoreProductPackageScrm> productPackages = new ArrayList<>();
+        List<Long> ids = new ArrayList<>();
+        List<String> orderCode = new ArrayList<>();
+        BigDecimal payPrice = BigDecimal.ZERO;
+        BigDecimal payMoney = BigDecimal.ZERO;
+        String payLimitTime = "";
+        String prescribeOrder = "";
+        for (int i = 0; i < orders.size(); i++) {
+            String json = configService.selectConfigByKey("store.config");
+            StoreConfig config = JSONUtil.toBean(json, StoreConfig.class);
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(orders.get(i).getCreateTime());
+            calendar.add(Calendar.MINUTE, config.getUnPayTime());
+            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            payLimitTime = format.format(calendar.getTime());
+            FsStoreProductPackageScrm productPackage = null;
+            if (orders.get(i).getIsPackage() != null && orders.get(i).getIsPackage() == 1) {
+                productPackage = productPackageService.selectFsStoreProductPackageById(orders.get(i).getPackageId());
+            }
+            productPackages.add(productPackage);
+            payMoney = NumberUtil.add(payMoney, orders.get(i).getPayMoney());
+            payPrice = NumberUtil.add(payPrice, orders.get(i).getPayPrice());
+            ids.add(orders.get(i).getId());
+            orderCode.add(orders.get(i).getOrderCode());
+            if (orders.get(i).getIsPrescribe() ==1){
+                if (prescribeOrder.length()<=1){
+                    prescribeOrder = prescribeOrder + orders.get(i).getId();
+                } else {
+                    prescribeOrder = prescribeOrder + "," + orders.get(i).getId();
+                }
+            }
+        }
+        orderRes.setIds(ids);
+        orderRes.setOrderCodes(orderCode);
+        orderRes.setPayType(orders.get(0).getPayType());
+        orderRes.setIsEditMoney(orders.get(0).getIsEditMoney());
+        orderRes.setOrderCreateType(orders.get(0).getOrderCreateType());
+        orderRes.setCreateTime(orders.get(0).getCreateTime());
+        orderRes.setPayPrice(payPrice);
+        orderRes.setPayMoney(payMoney);
+        orderRes.setCombinationOrderId(combinationId);
+
+
+        return R.ok().put("order", orderRes).put("productPackage", productPackages).put("payLimitTime", payLimitTime)
+                .put("prescribeOrder",prescribeOrder);
+    }
+
+    @Login
+    @ApiOperation("修改支付类型")
+    @PostMapping("/editPayTypeByCombinationId")
+    @Transactional
+    public R editPayTypeByCombinationId(HttpServletRequest request, @Validated @RequestBody FsStoreOrderPayCombinationIdParam param) {
+        //返回对象
+        FsStoreOrderGroupStoreVO orderRes = new FsStoreOrderGroupStoreVO();
+        List<Long> ids = new ArrayList<>();
+        List<String> orderCodes = new ArrayList<>();
+        String prescribeOrder = "";
+        BigDecimal payPrice = BigDecimal.ZERO;
+        BigDecimal payMoneyRes = BigDecimal.ZERO;
+        List<FsStoreOrderScrm> orders = orderService.getStoreOrderByCombinationId(param.getCombinationOrderId());
+        for (int i = 0; i < orders.size(); i++) {
+
+            if (orders.get(i) == null) {
+                return R.error("订单不存在");
+            }
+            if (orders.get(i).getStatus() != OrderInfoEnum.STATUS_0.getValue()) {
+                return R.error("订单状态不正确");
+            }
+            FsUserScrm user = userService.selectFsUserById(orders.get(i).getUserId());
+            if (user != null && StringUtils.isNotEmpty(user.getMaOpenId())) {
+                //已改价处理
+                if (orders.get(i).getIsEditMoney() != null && orders.get(i).getIsEditMoney() == 1) {
+                    //改过价不做处理
+                } else {
+                    String config = configService.selectConfigByKey("store.config");
+                    StoreConfig storeConfig = JSONUtil.toBean(config, StoreConfig.class);
+                    if (param.getPayType().equals(1)) {
+                        orders.get(i).setPayType("1");
+                        orders.get(i).setPayMoney(orders.get(i).getPayPrice());
+                        orders.get(i).setPayDelivery(BigDecimal.ZERO);
+                    } else if (param.getPayType().equals(2)) {
+
+                        orders.get(i).setPayType("2");
+                        BigDecimal payMoney = orders.get(i).getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
+                        payMoney = new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
+                        orders.get(i).setPayDelivery(orders.get(i).getPayPrice().subtract(payMoney));
+                        orders.get(i).setPayMoney(payMoney);
+                    } else if (param.getPayType().equals(3)) {
+                        //货到付款
+                        orders.get(i).setPayType("3");
+                        orders.get(i).setPayDelivery(orders.get(i).getPayPrice());
+                        orders.get(i).setPayMoney(BigDecimal.ZERO);
+                    }
+                    if (orders.get(i).getIsPrescribe() ==1){
+                        if (prescribeOrder.length()<=1){
+                            prescribeOrder = prescribeOrder + orders.get(i).getId();
+                        } else {
+                            prescribeOrder = prescribeOrder + "," + orders.get(i).getId();
+                        }
+                    }
+                    orderService.updateFsStoreOrder(orders.get(i));
+                    ids.add(orders.get(i).getId());
+                    orderCodes.add(orders.get(i).getOrderCode());
+                }
+                payMoneyRes = NumberUtil.add(orders.get(i).getPayMoney(), payMoneyRes);
+                payPrice = NumberUtil.add(payPrice, orders.get(i).getPayPrice());
+            } else {
+                return R.error(orders.get(i).getOrderCode() + "用户OPENID不存在");
+            }
+        }
+        orderRes.setIds(ids);
+        orderRes.setOrderCodes(orderCodes);
+        orderRes.setPayType(orders.get(0).getPayType());
+        orderRes.setIsEditMoney(orders.get(0).getIsEditMoney());
+        orderRes.setOrderCreateType(orders.get(0).getOrderCreateType());
+        orderRes.setCreateTime(orders.get(0).getCreateTime());
+        orderRes.setPayPrice(payPrice);
+        orderRes.setPayMoney(payMoneyRes);
+        orderRes.setCombinationOrderId(param.getCombinationOrderId());
+//        return R.ok().put("order", orderRes);
+        return R.ok().put("order", orderRes).put("prescribeOrder",prescribeOrder);
+    }
+
+    @Login
+    @ApiOperation("亲友支付")
+    @PostMapping("/otherPaymentByCombinationId")
+    @Transactional
+    public R otherPaymentByCombinationId(@Validated @RequestBody FsStoreOrderOtherPayCombinationIdParam param, HttpServletRequest request) {
+        final WxMaService wxService = WxMaConfiguration.getMaService(param.getAppId());
+        try {
+            //组合微信支付order
+            FsStoreOrderScrm fsStoreOrder = new FsStoreOrderScrm();
+            BigDecimal payPrice = BigDecimal.ZERO;
+            BigDecimal payMoneyTotal = BigDecimal.ZERO;
+
+            String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
+            //新增的支付详情id
+            ArrayList<Long> paymentIds = new ArrayList<>();
+            String ip = IpUtil.getRequestIp();
+            WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
+            FsUserScrm user = userService.selectFsUserByMaOpenId(session.getOpenid());
+            if (user == null) {
+                //创建
+                user = new FsUserScrm();
+                user.setUsername("");
+                user.setNickname("微信用户");
+                user.setStatus(1);
+                user.setMaOpenId(session.getOpenid());
+                user.setUnionId(session.getUnionid());
+                user.setIsWeixinAuth(0);
+                user.setLastIp(ip);
+                user.setCreateTime(new Date());
+                userService.insertFsUser(user);
+            }
+//            FsStoreOrder order = orderService.selectFsStoreOrderById(param.getOrderId());
+            List<FsStoreOrderScrm> orders = orderService.getStoreOrderByCombinationId(param.getCombinationOrderId());
+            for (FsStoreOrderScrm order : orders) {
+                if (order == null) {
+                    return R.error("订单不存在");
+                }
+                if (order.getStatus() != OrderInfoEnum.STATUS_0.getValue()) {
+                    return R.error("此订单不能支付");
+                }
+                if (order.getPayMoney().compareTo(new BigDecimal(0)) < 1) {
+                    return R.error("此订单没有可支付的金额");
+                }
+                payPrice = NumberUtil.add(payPrice, order.getPayPrice());
+                payMoneyTotal = NumberUtil.add(payMoneyTotal, order.getPayMoney());
+                String paySubCode = IdUtil.getSnowflake(0, 0).nextIdStr();
+                //小雨点支付
+                FsStorePaymentScrm storePayment = new FsStorePaymentScrm();
+                storePayment.setCompanyId(order.getCompanyId());
+                storePayment.setCompanyUserId(order.getCompanyUserId());
+                storePayment.setStatus(0);
+                storePayment.setPayCode(payCode);
+                storePayment.setPaySubCode(paySubCode);
+                storePayment.setPayMoney(order.getPayMoney());
+                storePayment.setCreateTime(new Date());
+                storePayment.setPayTypeCode("weixin");
+                storePayment.setBusinessType(2);
+                storePayment.setRemark("商城订单支付");
+                storePayment.setOpenId(session.getOpenid());
+                storePayment.setUserId(user.getUserId());
+                storePayment.setBusinessOrderId(order.getCombinationOrderId().toString());
+                storePayment.setOrderId(order.getId());
+                fsStorePaymentMapper.insertFsStorePayment(storePayment);
+                paymentIds.add(storePayment.getPaymentId());
+
+            }
+
+            //创建订单
+            fsStoreOrder.setPayType(orders.get(0).getPayType());
+            fsStoreOrder.setCompanyId(orders.get(0).getCompanyId());
+            fsStoreOrder.setCompanyUserId(orders.get(0).getCompanyUserId());
+            fsStoreOrder.setPayMoney(payMoneyTotal);
+//        fsStoreOrder.setPayMoney(BigDecimal.valueOf(0.01));
+            fsStoreOrder.setRealName(orders.get(0).getRealName());
+            fsStoreOrder.setCombinationOrderId(orders.get(0).getCombinationOrderId());
+
+            FsStorePaymentScrm payment = new FsStorePaymentScrm();
+            payment.setCompanyId(fsStoreOrder.getCompanyId());
+            payment.setCompanyUserId(fsStoreOrder.getCompanyUserId());
+            payment.setStatus(0);
+            payment.setPayCode(payCode);
+            payment.setPayMoney(fsStoreOrder.getPayMoney());
+            payment.setCreateTime(new Date());
+            payment.setPayTypeCode("weixin");
+            payment.setBusinessType(2);
+            payment.setRemark("商城订单支付");
+            payment.setOpenId(session.getOpenid());
+            payment.setUserId(user.getUserId());
+
+            HuiFuCreateOrder o = new HuiFuCreateOrder();
+            o.setTradeType("T_MINIAPP");
+            o.setOpenid(user.getMaOpenId());
+//            o.setReqSeqId("store-" + storePayment.getPayCode());
+            o.setReqSeqId("store-" + payment.getPayCode());
+            o.setTransAmt(payment.getPayMoney().toString());
+            o.setGoodsDesc("商城订单支付");
+            HuifuCreateOrderResult result = huiFuService.createOrder(o);
+            if (result.getBank_code() != null && result.getBank_code().equals("00000000")) {
+                for (int i = 0; i < paymentIds.size(); i++) {
+                    FsStorePaymentScrm mt = new FsStorePaymentScrm();
+                    mt.setPaymentId(Long.parseLong(paymentIds.get(i).toString()));
+                    mt.setTradeNo(result.getHf_seq_id());
+                    fsStorePaymentMapper.updateFsStorePayment(mt);
+                    redisCache.setCacheObject("isPaying:" + orders.get(i).getId(), orders.get(i).getId().toString(), 1, TimeUnit.MINUTES);
+                }
+
+                String mes = result.getPay_info();
+                JSONObject payInfo = JSONUtil.parseObj(mes);
+                FsHuiFuPayInfo fsHuiFuPayInfo = new FsHuiFuPayInfo();
+                if (payInfo.get("timeStamp") != null) {
+                    fsHuiFuPayInfo.setTimeStamp(payInfo.get("timeStamp").toString());
+                }
+                if (payInfo.get("package") != null) {
+                    fsHuiFuPayInfo.setPackageStr(payInfo.get("package").toString());
+                }
+                if (payInfo.get("paySign") != null) {
+                    fsHuiFuPayInfo.setPaySign(payInfo.get("paySign").toString());
+
+                }
+                if (payInfo.get("appId") != null) {
+                    fsHuiFuPayInfo.setAppId(payInfo.get("appId").toString());
+
+                }
+                if (payInfo.get("signType") != null) {
+                    fsHuiFuPayInfo.setSignType(payInfo.get("signType").toString());
+
+                }
+                if (payInfo.get("nonceStr") != null) {
+                    fsHuiFuPayInfo.setNonceStr(payInfo.get("nonceStr").toString());
+                }
+
+                return R.ok().put("result", fsHuiFuPayInfo);
+            } else {
+                return R.error(result.getResp_desc());
+            }
+
+
+        } catch (WxErrorException e) {
+            e.printStackTrace();
+            return R.error(e.getMessage());
+        }
+    }
 }
 }