Browse Source

说明书校验,亲友代付功能,商品统计功能

yjwang 6 ngày trước cách đây
mục cha
commit
30c606d3ea

+ 4 - 0
fs-service/src/main/java/com/fs/his/mapper/FsUserMapper.java

@@ -14,6 +14,7 @@ import com.fs.his.param.FsUserParam;
 import com.fs.his.vo.FsUserVO;
 import com.fs.his.vo.FsUserExportListVO;
 import com.fs.his.vo.OptionsVO;
+import com.fs.hisStore.domain.FsUserScrm;
 import com.fs.hisStore.vo.FsCompanyUserListQueryVO;
 import com.fs.qw.dto.FsUserTransferParamDTO;
 import com.fs.qw.param.QwFsUserParam;
@@ -424,4 +425,7 @@ public interface FsUserMapper
      * 统计用户看课数据(课程观看次数、课程完播次数)
      * */
     ExternalWatchStatsVO countExternalWatchStats(UserStatisticsCommonParam param);
+
+    @Select("select * from fs_user where ma_open_id=#{openid}")
+    FsUser selectFsUserByMaOpenId(String openid);
 }

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

@@ -221,4 +221,6 @@ public interface IFsUserService
     void handleFsUserWx(FsUser user, LoginMaWxParam param, WxMaJscode2SessionResult session);
 
     R removeUser(Long id);
+
+    FsUser selectFsUserByMaOpenId(String openid);
 }

+ 1 - 1
fs-service/src/main/java/com/fs/his/service/impl/FsStoreProductServiceImpl.java

@@ -316,7 +316,7 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService {
         headerMap.put("minWidth", 140);
         headerMapList.add(ObjectUtil.clone(headerMap));
 
-        headerMap.put("title", "商品编号");
+        headerMap.put("title", "商品条码");
         headerMap.put("slot", "barCode");
         headerMap.put("align", align);
         headerMap.put("minWidth", 140);

+ 5 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsUserServiceImpl.java

@@ -1303,6 +1303,11 @@ public class FsUserServiceImpl implements IFsUserService {
         }
     }
 
+    @Override
+    public FsUser selectFsUserByMaOpenId(String openid) {
+        return fsUserMapper.selectFsUserByMaOpenId(openid);
+    }
+
     @Override
     public R removeUser(Long id) {
         fsUserMapper.removeUser(id);

+ 5 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreProductScrm.java

@@ -327,4 +327,9 @@ public class FsStoreProductScrm extends BaseEntity
      * **/
     private String complaint;
 
+    /**
+     * 说明书
+     * **/
+    private String instructionManual;
+
 }

+ 18 - 3
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreProductScrmMapper.java

@@ -8,6 +8,7 @@ import com.fs.his.vo.FsStoreProductListSVO;
 import com.fs.his.vo.OptionsVO;
 import com.fs.hisStore.config.MedicalMallConfig;
 import com.fs.hisStore.domain.FsStoreProductRuleScrm;
+import com.fs.hisStore.param.FsStoreCartCountParam;
 import com.fs.statis.dto.ModifyMoreDTO;
 import com.fs.hisStore.domain.FsStoreProductScrm;
 import com.fs.hisStore.param.FsStoreProductQueryParam;
@@ -346,10 +347,17 @@ public interface FsStoreProductScrmMapper
     @Select("select * from fs_store_product_scrm where  is_del=0 and is_show=1 order by sort desc limit #{count}")
     List<FsStoreProductListQueryVO> selectFsStoreProductByCateIdQuery(Long cateId);
     @Select({"<script> " +
-            "select p.* from fs_store_product_scrm p  " +
+//            "select p.* from fs_store_product_scrm p  " +
+            "SELECT\n" +
+            "\tCOUNT(*) OVER ( PARTITION BY p.product_name ) AS storeCount,\n" +
+            "\tp1.storeIds,\n" +
+            "\tp.* \n" +
+            "FROM\n" +
+            "\tfs_store_product_scrm p\n" +
+            "\tLEFT JOIN ( SELECT GROUP_CONCAT( DISTINCT fsp1.store_id SEPARATOR ',' ) AS storeIds, fsp1.product_name FROM fs_store_product_scrm fsp1 GROUP BY fsp1.product_name ) p1 ON p1.product_name = p.product_name\n" +
             //新增审核状态及所属店铺审核状态
             "<if test = 'maps.isStores != null and maps.isStores == 1   '>"+
-            "inner join fs_store_scrm fs on fs.store_id = p.store_id and fs.is_audit = 1 " +
+            "inner join fs_store_scrm fs on fs.store_id = p.store_id and fs.status = 1 " +
             "</if>" +
             "where p.is_del=0 and p.is_show=1  and p.is_audit = '1' and fs.status = '1'" +
             "<if test = 'maps.productName != null and  maps.productName !=\"\"    '> " +
@@ -401,7 +409,7 @@ public interface FsStoreProductScrmMapper
             "select p.* from fs_store_product_scrm p  " +
             //新增审核状态及所属店铺审核状态
             "<if test='config.isAudit == \"1\" '>" +
-            " inner join fs_store_scrm fs on fs.store_id = p.store_id and fs.is_audit = 1 " +
+            " inner join fs_store_scrm fs on fs.store_id = p.store_id and fs.status = 1 " +
             "</if>" +
             " where p.is_del=0 and p.is_show=1  " +
             "<if test='config.isAudit == \"1\" '>" +
@@ -582,4 +590,11 @@ public interface FsStoreProductScrmMapper
             "</script>"})
     int updateFsStoreProductIsShowBatch(@Param("productIds") Long[] productIds);
 
+    /**
+     * 校验处方药说明书查看权限
+     * @param param 请求参数
+     * @return int
+     * **/
+    int instructionsViewable(@Param("param") FsStoreCartCountParam param);
+
 }

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

@@ -267,4 +267,9 @@ public class FsStoreProductAddEditParam implements Serializable
         // 指定企业
     private String companyIds;
 
+    /**
+     * 说明书
+     * **/
+    private String instructionManual;
+
 }

+ 8 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreProductScrmService.java

@@ -11,6 +11,7 @@ import com.fs.his.param.FsStoreProductListSParam;
 import com.fs.his.vo.FsStoreProductExcelVO;
 import com.fs.his.vo.FsStoreProductListSVO;
 import com.fs.his.vo.OptionsVO;
+import com.fs.hisStore.param.FsStoreCartCountParam;
 import com.fs.hisStore.vo.*;
 import com.fs.statis.dto.ModifyMoreDTO;
 import com.fs.hisStore.domain.FsStoreProductScrm;
@@ -146,4 +147,11 @@ public interface IFsStoreProductScrmService
     void updateFsStoreProductIsShowBatch(Long[] productIds);
 
     List<FsStoreProductScrm> getStoreProductInProductIds(List<Long> storeProductIds);
+
+    /**
+     * 校验处方药说明书查看权限
+     * @param param 请求参数
+     * @return R
+     * **/
+    R instructionsViewable(FsStoreCartCountParam param);
 }

+ 21 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductScrmServiceImpl.java

@@ -31,6 +31,7 @@ import com.fs.his.vo.OptionsVO;
 import com.fs.hisStore.config.MedicalMallConfig;
 import com.fs.hisStore.domain.*;
 import com.fs.hisStore.mapper.*;
+import com.fs.hisStore.param.FsStoreCartCountParam;
 import com.fs.hisStore.utils.StoreAuditLogUtil;
 import com.fs.statis.dto.ModifyMoreDTO;
 import com.fs.hisStore.dto.ProductArrtDTO;
@@ -393,6 +394,14 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
         Long storeId = param.getStoreId();
         product.setStoreId(storeId);
         product.setIsDrug(param.getIsDrug().toString());
+        product.setInstructionManual(param.getInstructionManual());
+
+        //获取商品编码
+        if(!param.getValues().isEmpty()){
+            if(param.getValues().get(0).getBarCode() != null){
+                product.setBarCode(param.getValues().get(0).getBarCode());
+            }
+        }
         //校验店铺资质信息
         //获取店铺
         FsStoreScrm store = fsStoreScrmService.selectFsStoreByStoreId(product.getStoreId());
@@ -1250,6 +1259,18 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
         return fsStoreProductMapper.getStoreProductInProductIds(productIds);
     }
 
+    @Override
+    public R instructionsViewable(FsStoreCartCountParam param) {
+        //判断商品是否存在
+        FsStoreProductScrm productScrm = fsStoreProductMapper.selectFsStoreProductById(param.getProductId());
+        if(productScrm == null || productScrm.getProductType() == null){
+            return R.error("商品数据不存在,或类型异常!");
+        }else if(productScrm.getProductType() != 2){
+           return R.ok().put("data",true);
+        }
+        return R.ok().put("data",fsStoreProductMapper.instructionsViewable(param) > 0);
+    }
+
     @Override
     public List<Map<String, String>> getStoreProductColumns() {
         List<Map<String, String> > list = fsStoreProductMapper.getStoreProductColumns();

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

@@ -139,4 +139,8 @@ public class FsStoreProductQueryVO implements Serializable
 
     private String storeId;
 
+    /**
+     * 说明书
+     * **/
+    private String instructionManual;
 }

+ 8 - 5
fs-service/src/main/resources/application-config-dev-yjb.yml

@@ -76,11 +76,14 @@ watch:
   password3: v9xsKuqn_$d2y
 
 fs :
-  commonApi: http://172.16.0.16:8010
-  h5CommonApi: http://119.29.195.254:8010
-nuonuo:
-  key: 10924508
-  secret: A2EB20764D304D16
+  commonApi: http://127.0.0.1:7771
+  h5CommonApi: http://127.0.0.1
+  jwt:
+    # 加密秘钥
+    secret: f4e2e52034348f86b67cde581c0f9eb5
+    # token有效时长,7天,单位秒
+    expire: 31536000
+    header: AppToken
 
 # 存储捅配置
 # 存储捅配置

+ 61 - 20
fs-service/src/main/resources/mapper/hisStore/FsStoreProductScrmMapper.xml

@@ -68,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="precautions" column="precautions"/>
         <result property="isAudit" column="is_audit"/>
         <result property="storeId" column="store_id"/>
+        <result property="instructionManual" column="instruction_manual"/>
     </resultMap>
 
     <sql id="selectFsStoreProductVo">
@@ -78,7 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                integral, product_type, prescribe_code, prescribe_spec, prescribe_factory, prescribe_name,
                is_display,tui_cate_id,company_ids,is_drug,drug_image,drug_reg_cert_no,common_name,dosage_form,
                unit_price,batch_number,mah,mah_address,manufacturer,manufacturer_address,indications,dosage,
-               adverse_reactions,contraindications,precautions,is_audit,store_id
+               adverse_reactions,contraindications,precautions,is_audit,store_id,instruction_manual
                from fs_store_product_scrm
     </sql>
 
@@ -255,6 +256,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="precautions != null and precautions != ''">precautions ,</if>
             <if test="isAudit != null and isAudit != ''">is_audit ,</if>
             <if test="storeId != null and storeId != ''">store_id ,</if>
+            <if test="instructionManual != null and instructionManual != ''">instruction_manual ,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="image != null and image != ''">#{image},</if>
@@ -319,6 +321,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="precautions != null and precautions != ''">#{precautions} ,</if>
             <if test="isAudit != null and isAudit != ''">#{isAudit} ,</if>
             <if test="storeId != null and storeId != ''">#{storeId} ,</if>
+            <if test="instructionManual != null and instructionManual != ''">#{instructionManual} ,</if>
          </trim>
     </insert>
 
@@ -387,7 +390,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="precautions != null and precautions != ''">precautions = #{precautions} ,</if>
             <if test="isAudit != null and isAudit != ''">is_audit = #{isAudit} ,</if>
             <if test="storeId != null and storeId != ''">store_id = #{storeId} ,</if>
-
+            <if test="instructionManual != null and instructionManual != ''">instruction_manual = #{instructionManual} ,</if>
         </trim>
         where product_id = #{productId}
     </update>
@@ -431,24 +434,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <select id="selectFsStoreProductTuiListQuery" resultType="com.fs.hisStore.vo.FsStoreProductListQueryVO">
-        SELECT COUNT(*) OVER (PARTITION BY fsp.product_name) AS storeCount,p1.storeIds,fsp.*
-        FROM fs_store_product_scrm fsp
-        left join (select GROUP_CONCAT(distinct fsp1.store_id SEPARATOR ',' ) AS storeIds,fsp1.product_name
-        from  fs_store_product_scrm fsp1 group by fsp1.product_name) p1 on p1.product_name = fsp.product_name
-        <if test='config.isStores == "1" '>
-            inner join fs_store_scrm fs on fs.store_id = fsp.store_id
-        </if>
-        <if test='config.isAudit == "1" '>
-        and fs.is_audit = '1'
-        </if>
-        where fsp.is_del=0 and fsp.is_show=1 and fsp.is_good=1
-        <if test='config.isAudit == "1" '>
-        and fsp.is_audit = '1'
-        </if>
-        <if test='config.isStores == "1" '>
-            AND fs.status = '1'
-        </if>
-        and fsp.is_best=1 and fsp.is_display=1 order by fsp.sort desc,fsp.product_id desc
+            SELECT
+            t_all.storeCountAll AS storeCount,
+            t_all.storeIdsAll AS storeIds,
+            fsp.*
+            FROM fs_store_product_scrm fsp
+            LEFT JOIN (
+            SELECT
+            product_name,
+            COUNT(DISTINCT store_id) AS storeCountAll,
+            GROUP_CONCAT(DISTINCT store_id SEPARATOR ',') AS storeIdsAll
+            FROM fs_store_product_scrm
+            WHERE is_del=0 AND is_show=1
+            <if test='config.isStores == "1" '>
+                AND store_id IN (SELECT store_id FROM fs_store_scrm WHERE status = '1')
+            </if>
+            <if test='config.isAudit == "1" '>
+                AND is_audit = '1'
+            </if>
+            GROUP BY product_name
+            ) t_all ON t_all.product_name = fsp.product_name
+
+            <if test='config.isStores == "1" '>
+                INNER JOIN fs_store_scrm fs ON fs.store_id = fsp.store_id
+            </if>
+
+            WHERE
+            fsp.is_del = 0
+            AND fsp.is_show = 1
+            AND fsp.is_good = 1
+            AND fsp.is_best = 1
+            AND fsp.is_display = 1
+            <if test='config.isAudit == "1" '>
+                AND fsp.is_audit = '1'
+            </if>
+            <if test='config.isStores == "1" '>
+                AND fs.status = '1'
+            </if>
+            GROUP BY fsp.product_name
+            ORDER BY fsp.sort DESC, fsp.product_id DESC
     </select>
     <select id="bulkCopyFsStoreProductByIds" resultMap="FsStoreProductResult">
         <include refid="selectFsStoreProductVo"/>
@@ -546,4 +570,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         #{item}
     </foreach>
     </select>
+
+    <select id="instructionsViewable" resultType="int">
+        SELECT
+            count(*)
+        FROM
+            fs_store_product_scrm p
+                INNER JOIN fs_store_order_item_scrm ois ON p.product_id = ois.product_id
+                INNER JOIN fs_store_order_scrm o ON ois.order_id = o.id
+                INNER JOIN fs_store_hospital580_prescription_scrm ps ON o.id = ps.store_order_id
+        WHERE
+            o.`status` IN (0,1,2,3)
+           AND p.product_id = #{param.productId}
+           AND ps.audit_status = 2
+	       AND ps.user_id = #{param.userId}
+           AND ps.pid IS NOT NULL
+        GROUP BY p.product_id
+    </select>
 </mapper>

+ 19 - 0
fs-user-app/src/main/java/com/fs/app/controller/store/ProductScrmController.java

@@ -304,4 +304,23 @@ public class ProductScrmController extends AppBaseController {
         List<FsStoreCartGroupStoreVO> carts= cartService.selectFsStoreCartListByUidMultiStore(Long.parseLong(getUserId()));
         return R.ok().put("carts",carts);
     }
+
+    /**
+     * 校验处方药说明书查看权限
+     * @param param 请求参数
+     * @return R
+     * **/
+    @ApiOperation("校验说明书查看权限")
+    @PostMapping("/getCartsMultiStore")
+    public R instructionsViewable(@RequestBody FsStoreCartCountParam param){
+       Long userId = Long.parseLong(getUserId());
+        if(userId == null){
+            return  R.error("操作失败,用户信息不存在!");
+        }
+        if(param.getProductId() == null){
+            return R.error("操作失败,商品信息不能为空!");
+        }
+        param.setUserId(userId);
+        return productService.instructionsViewable(param);
+    }
 }

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

@@ -1366,148 +1366,148 @@ public class StoreOrderScrmController extends AppBaseController {
         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());
-//        }
-//    }
+    @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());
+            FsUser user = userService.selectFsUserByMaOpenId(session.getOpenid());
+            if (user == null) {
+                //创建
+                user = new FsUser();
+                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());
+        }
+    }
 
     /**
      * 检查订单列表中是否存在含处方药但未开方的订单

+ 1 - 1
fs-user-app/src/main/resources/application.yml

@@ -13,4 +13,4 @@ spring:
 #    active: druid-sxjz
 #    active: druid-qdtst
 #    active: druid-yzt
-    active: dev-jnlzjk
+    active: dev-yjb