Prechádzať zdrojové kódy

Merge branch 'master' of http://1.14.104.71:10880/root/ylrz_his_scrm_java

15376779826 2 týždňov pred
rodič
commit
24ca23029c
23 zmenil súbory, kde vykonal 1014 pridanie a 335 odobranie
  1. 13 6
      README.md
  2. 3 3
      fs-company/src/main/java/com/fs/company/controller/live/LiveController.java
  3. 4 0
      fs-service/src/main/java/com/fs/company/service/ICompanyService.java
  4. 49 0
      fs-service/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java
  5. 5 0
      fs-service/src/main/java/com/fs/course/config/CourseConfig.java
  6. 11 7
      fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java
  7. 9 0
      fs-service/src/main/java/com/fs/hisStore/mapper/FsUserScrmMapper.java
  8. 7 0
      fs-service/src/main/java/com/fs/hisStore/service/IFsUserScrmService.java
  9. 42 0
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserScrmServiceImpl.java
  10. 2 1
      fs-service/src/main/java/com/fs/live/domain/LiveOrderPayment.java
  11. 1 0
      fs-service/src/main/java/com/fs/live/param/LiveOrderPayParam.java
  12. 2 0
      fs-service/src/main/java/com/fs/live/service/ILiveOrderService.java
  13. 565 293
      fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java
  14. 1 0
      fs-service/src/main/java/com/fs/live/vo/LiveDataListVo.java
  15. 1 0
      fs-service/src/main/java/com/fs/live/vo/LiveDataStatisticsVo.java
  16. 1 1
      fs-service/src/main/resources/application-config-druid-hst.yml
  17. 1 1
      fs-service/src/main/resources/application-config-druid-qdtst.yml
  18. 1 1
      fs-service/src/main/resources/mapper/company/CompanyUserMapper.xml
  19. 3 0
      fs-service/src/main/resources/mapper/live/LiveOrderPaymentMapper.xml
  20. 1 0
      fs-service/src/main/resources/mapper/sop/QwSopMapper.xml
  21. 11 0
      fs-user-app/src/main/java/com/fs/app/controller/HuifuPayController.java
  22. 270 22
      fs-user-app/src/main/java/com/fs/app/controller/live/LiveOrderController.java
  23. 11 0
      fs-user-app/src/main/java/com/fs/app/controller/store/PayScrmController.java

+ 13 - 6
README.md

@@ -5,14 +5,21 @@
 
 #### 软件模块说明
 
-| 模块名称         | 模块描述         | 对应前端项目                  |
-|--------------|--------------|-------------------------|
-| fs-admin     | 总后台服务        | ylrz_his_scrm_adminUI   |
-| fs-company   | 销售端          | ylrz_his_scrm_companyUI |
-| fs-user-app  | 微信小程序端       | 对应某个微信小程序(前端蒲瑶清楚)       |
-| fs-framework | 主要依赖包,核心包    | /                       |
+| 模块名称         | 模块描述          | 对应前端项目                  |
+|--------------|---------------|-------------------------|
+| fs-admin     | 总后台服务         | ylrz_his_scrm_adminUI   |
+| fs-company   | 销售端           | ylrz_his_scrm_companyUI |
+| fs-store     | 店铺端           | ylrz_his_scrm_storeUI |
+| fs-doctor    | 医生端           | ylrz_his_scrm_doctorUI |
+| fs-user-app  | 微信小程序端        | 对应某个微信小程序(前端蒲瑶清楚)       |
+| fs-framework | 主要依赖包,核心包     | /                       |
 | fs-service   | 所有的链接配置文件都在里面 | /                       |
 
+#### 分支说明
+| 分支名称       | 描述    | 对应前端项目与分支                                                                |
+|------------|-------|--------------------------------------------------------------------------|
+| ScrmStores | 医建宝项目 | ylrz_his_scrm_adminUI(yjb_ScrmStores)、ylrz_his_scrm_companyUI(ScrmStore) |
+
 
 #### 安装教程
 

+ 3 - 3
fs-company/src/main/java/com/fs/company/controller/live/LiveController.java

@@ -314,9 +314,9 @@ public class LiveController extends BaseController
         String url="https://api.weixin.qq.com/cgi-bin/stable_token";
         HashMap<String, String> map = new HashMap<>();
         map.put("grant_type","client_credential");
-        // 芳华惠选
-        map.put("appid","wx503cf8ab31f83dd4");
-        map.put("secret","1ba1972363889dcb4a37ecb685744435");
+        // 百域承品
+        map.put("appid","wx44beed5640bcb1ba");
+        map.put("secret","1bfcfa420f741801575a74d94752d014");
         String accessToken = HttpUtils.endApi(url, null, map);
         // 创建Gson对象
         Gson gson = new Gson();

+ 4 - 0
fs-service/src/main/java/com/fs/company/service/ICompanyService.java

@@ -193,4 +193,8 @@ public interface ICompanyService
     List<CompanyVO> liveShowList(CompanyParam param);
 
     void batchUpdateLiveShow(CompanyLiveShowParam param);
+
+    void addCompanyTuiLiveMoney(LiveOrder order);
+
+    void subLiveCompanyMoney(LiveOrder order);
 }

+ 49 - 0
fs-service/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java

@@ -35,6 +35,7 @@ import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.domain.FsStorePaymentScrm;
 import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
 import com.fs.live.domain.LiveOrder;
+import com.fs.live.mapper.LiveOrderMapper;
 import com.fs.live.service.ILiveService;
 import com.fs.store.config.CompanyMenuConfig;
 import com.fs.system.domain.SysConfig;
@@ -52,6 +53,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import com.fs.company.service.ICompanyService;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.support.TransactionTemplate;
 
@@ -119,6 +121,8 @@ public class CompanyServiceImpl implements ICompanyService
 
     @Autowired
     private ILiveService liveService;
+    @Autowired
+    private LiveOrderMapper liveOrderMapper;
 
 
     @Override
@@ -132,6 +136,51 @@ public class CompanyServiceImpl implements ICompanyService
         liveService.asyncToCache();
     }
 
+    @Override
+    @Transactional
+    public void addCompanyTuiLiveMoney(LiveOrder order) {
+        if(order.getCompanyId()!=null&&order.getCompanyId()>0){
+            Company company=companyMapper.selectCompanyByIdForUpdate(order.getCompanyId());
+            if(company!=null){
+                String json =configService.selectConfigByKey("store.config");
+                com.fs.store.config.StoreConfig config= JSONUtil.toBean(json, com.fs.store.config.StoreConfig.class);
+                //支付金额-(订单金额*rate%)
+                Double rate=config.getTuiMoneyRate()/100d;
+                BigDecimal tuiMoney=order.getPayPrice().subtract(order.getTotalPrice().multiply(new BigDecimal(rate)));
+                logger.info("写入公司推广佣金:"+tuiMoney);
+                company.setTuiMoney(company.getTuiMoney().add(tuiMoney));
+                companyMapper.updateCompany(company);
+                LiveOrder storeOrderMap=new LiveOrder();
+                storeOrderMap.setOrderId(order.getOrderId());
+                storeOrderMap.setTuiMoney(tuiMoney);
+                liveOrderMapper.updateLiveOrder(storeOrderMap);
+            }
+        }
+    }
+
+    @Override
+    @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
+    public void subLiveCompanyMoney(LiveOrder order) {
+        if(order.getCompanyId()>0){
+            Company company=companyMapper.selectCompanyByIdForUpdate(order.getCompanyId());
+            if(company!=null){
+                company.setMoney(company.getMoney().subtract(order.getTuiMoney()));
+                company.setTuiMoney(company.getTuiMoney().subtract(order.getTuiMoney()));
+                companyMapper.updateCompany(company);
+                //写入日志
+                CompanyMoneyLogs log=new CompanyMoneyLogs();
+                log.setCompanyId(order.getCompanyId());
+                log.setRemark("订单佣金退款");
+                log.setMoney(order.getTuiMoney().multiply(new BigDecimal(-1)));
+                log.setLogsType(5);
+                log.setBalance(company.getMoney());
+                log.setCreateTime(new Date());
+                log.setBusinessId(order.getOrderId().toString());
+                moneyLogsMapper.insertCompanyMoneyLogs(log);
+            }
+        }
+    }
+
     @Override
     public List<OptionsVO> selectAllCompanyList(Long deptId) {
         return companyMapper.selectAllCompanyList(deptId);

+ 5 - 0
fs-service/src/main/java/com/fs/course/config/CourseConfig.java

@@ -42,6 +42,8 @@ public class CourseConfig implements Serializable {
     private Integer delayEnd;
     private Integer isNegative;//是否为负数 0、不允许,1、允许
 
+    private Integer isOpen;
+
     /**
      * 侧边栏是否仅展示当天课程
      */
@@ -92,6 +94,9 @@ public class CourseConfig implements Serializable {
      */
     private String isRedPackageBalanceDeduction;
 
+    // 控制休息提示是否打开 默认打开 0-关闭 1-打开
+    private Integer isOpenRestReminder;
+
 
     @Data
     public static class DisabledTimeVo{

+ 11 - 7
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -2401,15 +2401,19 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
         } else {
             duration = Objects.isNull(watchLog) ? 0 : watchLog.getDuration();
         }
-//
-        if (courseVideoDetails != null && courseVideoDetails.getDuration() != null){
-            // 查询视频是否设置了红包,没有就不提示
-            Integer fsUserCourseVideoRedPackage = fsUserCourseVideoRedPackageMapper.selectRedPacketByCompanyCount(param.getVideoId(), null, param.getPeriodId());
-            if(fsUserCourseVideoRedPackage>0){
-                tipsTime = courseVideoDetails.getDuration() / 3;
-                tipsTime2 = (courseVideoDetails.getDuration() * 2) / 3;
+
+        // 2025-11-16 鹤颜堂 xgb 添加配置控制休息提示是否打开要暂停 默认打开 0-关闭 1-打开
+        if(config.getIsOpenRestReminder()==null || config.getIsOpenRestReminder()==1 ){
+            if (courseVideoDetails != null && courseVideoDetails.getDuration() != null){
+                // 查询视频是否设置了红包,没有就不提示
+                Integer fsUserCourseVideoRedPackage = fsUserCourseVideoRedPackageMapper.selectRedPacketByCompanyCount(param.getVideoId(), null, param.getPeriodId());
+                if(fsUserCourseVideoRedPackage>0){
+                    tipsTime = courseVideoDetails.getDuration() / 3;
+                    tipsTime2 = (courseVideoDetails.getDuration() * 2) / 3;
+                }
             }
         }
+
         vo.setTipsTime(tipsTime);
         vo.setTipsTime2(tipsTime2);
         //判断是否完课

+ 9 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsUserScrmMapper.java

@@ -21,6 +21,7 @@ import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
@@ -319,4 +320,12 @@ public interface FsUserScrmMapper
     Map<String, Long> countCourseDetailsNew(UserStatisticsCommonParam param);
     @Select("select * from fs_user where mp_open_id=#{openId}")
     FsUserScrm selectFsUserByOpenId(String openId);
+
+    /**
+     * 更新用户下单次数和累计成交总额
+     * @param userId 用户ID
+     * @param amount 成交金额
+     */
+    @Update("update fs_user set order_count = order_count + 1, total_amount = IFNULL(total_amount, 0) + #{amount} where user_id = #{userId}")
+    void updateUserOrderCountAndAmount(@Param("userId") Long userId, @Param("amount") BigDecimal amount);
 }

+ 7 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsUserScrmService.java

@@ -5,7 +5,10 @@ import com.fs.common.core.domain.ResponseResult;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.course.param.newfs.FsUserCourseBeMemberParam;
 import com.fs.course.vo.newfs.FsCourseAnalysisVO;
+import com.fs.his.domain.FsStoreProductAttrValue;
 import com.fs.his.vo.OptionsVO;
+import com.fs.hisStore.domain.FsStoreProductAttrValueScrm;
+import com.fs.live.domain.LiveOrder;
 import com.fs.qw.param.QwFsUserParam;
 import com.fs.qw.vo.QwFsUserVO;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
@@ -272,4 +275,8 @@ public interface IFsUserScrmService
     List<FSUserVO> selectFsUserVOListByProject(FsUserScrm fsUser);
 
     FsUserScrm selectFsUserByOpenId(String openid);
+
+    void addTuiLiveMoney(LiveOrder order, List<FsStoreProductAttrValueScrm> productAttrValues);
+
+    void subLiveTuiMoney(LiveOrder liveOrder);
 }

+ 42 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserScrmServiceImpl.java

@@ -30,7 +30,9 @@ import com.fs.course.param.newfs.UserCourseVideoPageParam;
 import com.fs.course.vo.newfs.FsCourseAnalysisCountVO;
 import com.fs.course.vo.newfs.FsCourseAnalysisVO;
 import com.fs.course.vo.newfs.FsUserCourseVideoPageListVO;
+import com.fs.his.domain.FsUserBill;
 import com.fs.his.vo.OptionsVO;
+import com.fs.live.domain.LiveOrder;
 import com.fs.qw.param.QwFsUserParam;
 import com.fs.qw.vo.QwFsUserVO;
 import com.fs.hisStore.domain.*;
@@ -1073,6 +1075,46 @@ public class FsUserScrmServiceImpl implements IFsUserScrmService
         return fsUserMapper.selectFsUserByOpenId(openid);
     }
 
+    @Override
+    @Transactional
+    public void addTuiLiveMoney(LiveOrder order, List<FsStoreProductAttrValueScrm> productAttrValues) {
+        BigDecimal brokerage=BigDecimal.ZERO;
+        //返佣金
+        FsUserScrm user= fsUserMapper.selectFsUserById(order.getCompanyUserId());
+        for (FsStoreProductAttrValueScrm productAttrValue : productAttrValues) {
+            brokerage=brokerage.add(productAttrValue.getBrokerage().multiply(new BigDecimal(order.getTotalNum())));
+        }
+        if(brokerage.compareTo(BigDecimal.ZERO)==1){
+            FsUserScrm tuiUserMap=new FsUserScrm();
+            tuiUserMap.setUserId(user.getUserId());
+            tuiUserMap.setBrokeragePrice(user.getBrokeragePrice().add(brokerage));
+            fsUserMapper.updateFsUser(tuiUserMap);
+            billService.addBill(tuiUserMap.getUserId(), CATEGORY_3.getValue(),1,BillDetailEnum.TYPE_5.getDesc(),brokerage,tuiUserMap.getBrokeragePrice(),"订单返佣金",order.getOrderId().toString(),order.getCompanyUserId());
+        }
+    }
+
+    @Override
+    @Transactional
+    public void subLiveTuiMoney(LiveOrder liveOrder) {
+        FsUserBillScrm map=new FsUserBillScrm();
+        map.setCategory(CATEGORY_3.getValue());
+        map.setBusinessId(liveOrder.getOrderId().toString());
+        map.setBillType(1);
+        List<FsUserBillScrm> list=billService.selectFsUserBillList(map);
+        if(list!=null&&list.size()>0){
+            for(FsUserBillScrm bill:list){
+                FsUserScrm tuiUser= fsUserMapper.selectFsUserByIdForUpdate(bill.getUserId());
+                if(tuiUser!=null){
+                    FsUserScrm tuiUserMap=new FsUserScrm();
+                    tuiUserMap.setUserId(tuiUser.getUserId());
+                    tuiUserMap.setBrokeragePrice(tuiUser.getBrokeragePrice().subtract(bill.getNumber()));
+                    fsUserMapper.updateFsUser(tuiUserMap);
+                    billService.addBill(tuiUserMap.getUserId(), CATEGORY_3.getValue(),0,BillDetailEnum.TYPE_6.getDesc(),bill.getNumber(),tuiUserMap.getBrokeragePrice(),"订单退佣金",liveOrder.getOrderId().toString(),bill.getTuiUserId());
+                }
+            }
+        }
+    }
+
     /**
      * 查询会员选项列表
      * @param params    参数

+ 2 - 1
fs-service/src/main/java/com/fs/live/domain/LiveOrderPayment.java

@@ -116,5 +116,6 @@ public class LiveOrderPayment extends BaseEntity{
     @Excel(name = "是否分账")
     private Integer isShare;
 
-
+    //小程序appId(用于多汇付支付/退款)
+    private String appId;
 }

+ 1 - 0
fs-service/src/main/java/com/fs/live/param/LiveOrderPayParam.java

@@ -21,4 +21,5 @@ public class LiveOrderPayParam implements Serializable
      * 小程序多商城
      * **/
     private String appId;
+    private Integer payPirce;
 }

+ 2 - 0
fs-service/src/main/java/com/fs/live/service/ILiveOrderService.java

@@ -234,4 +234,6 @@ public interface ILiveOrderService {
 
 
     List<LiveOrderVoZm> selectLiveOrderListZm(LiveOrder liveOrder);
+
+    R handleLiveOrderPay(LiveOrderPayParam param);
 }

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 565 - 293
fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java


+ 1 - 0
fs-service/src/main/java/com/fs/live/vo/LiveDataListVo.java

@@ -74,3 +74,4 @@ public class LiveDataListVo {
 
 
 
+

+ 1 - 0
fs-service/src/main/java/com/fs/live/vo/LiveDataStatisticsVo.java

@@ -55,3 +55,4 @@ public class LiveDataStatisticsVo {
 
 
 
+

+ 1 - 1
fs-service/src/main/resources/application-config-druid-hst.yml

@@ -64,7 +64,7 @@ fs :
   h5CommonApi: http://172.16.0.26:7771
   jwt:
     # 加密秘钥
-    secret: f4e2e52034348f86b67cde581c632eb5
+    secret: f4e2e52034348f86b67cde581c0f9eb5
     # token有效时长,7天,单位秒
     expire: 31536000
     header: AppToken

+ 1 - 1
fs-service/src/main/resources/application-config-druid-qdtst.yml

@@ -64,7 +64,7 @@ fs :
   h5CommonApi: http://10.206.0.16:8010
   jwt:
     # 加密秘钥
-    secret: f4q2d52034348t86b67ste581c0f9eb5
+    secret: f4q2d52034348t86b678s1581c0f9eb5
     # token有效时长,7天,单位秒
     expire: 31536000
     header: AppToken

+ 1 - 1
fs-service/src/main/resources/mapper/company/CompanyUserMapper.xml

@@ -464,7 +464,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         from company_user cu
         <where>
             <if test="params.nickName != null and params.nickName != ''">
-                and cu.nick_name like concat(#{params.nickName}, '%')
+                and cu.nick_name like concat( '%',#{params.nickName}, '%')
             </if>
             <if test="params.companyId != null">
                 and cu.company_id = #{params.companyId}

+ 3 - 0
fs-service/src/main/resources/mapper/live/LiveOrderPaymentMapper.xml

@@ -146,6 +146,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="shareCode != null">share_code,</if>
             <if test="shareMoney != null">share_money,</if>
             <if test="isShare != null">is_share,</if>
+            <if test="appId != null">app_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="payCode != null">#{payCode},</if>
@@ -173,6 +174,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="shareCode != null">#{shareCode},</if>
             <if test="shareMoney != null">#{shareMoney},</if>
             <if test="isShare != null">#{isShare},</if>
+            <if test="appId != null">#{appId},</if>
          </trim>
     </insert>
 
@@ -204,6 +206,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="shareCode != null">share_code = #{shareCode},</if>
             <if test="shareMoney != null">share_money = #{shareMoney},</if>
             <if test="isShare != null">is_share = #{isShare},</if>
+            <if test="appId != null">app_id = #{appId},</if>
         </trim>
         where payment_id = #{paymentId}
     </update>

+ 1 - 0
fs-service/src/main/resources/mapper/sop/QwSopMapper.xml

@@ -580,6 +580,7 @@
     <select id="selectAllQwSopInfo" parameterType="QwSop" resultMap="QwSopResult">
         <include refid="selectQwSopVo"/>
         <where>
+            status != 6
             <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
             <if test="status != null "> and status = #{status}</if>
             <if test="type != null "> and type = #{type}</if>

+ 11 - 0
fs-user-app/src/main/java/com/fs/app/controller/HuifuPayController.java

@@ -11,6 +11,7 @@ import com.fs.huifuPay.domain.HuiFuOnlinePay;
 import com.fs.huifuPay.domain.HuiFuOnlineRefund;
 import com.fs.huifuPay.domain.HuiFuResult;
 import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
+import com.fs.live.service.ILiveOrderService;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -36,6 +37,8 @@ public class HuifuPayController {
     private IFsCourseProductOrderService courseProductOrderService;
     @Autowired
     private IFsStorePaymentService storePaymentService;
+    @Autowired
+    private ILiveOrderService liveOrderService;
 
     org.slf4j.Logger logger= LoggerFactory.getLogger(getClass());
     @Autowired
@@ -112,6 +115,14 @@ public class HuifuPayController {
                         logger.error("-------分账明细回调错误{}", e.getMessage());
                     }
                     break;
+                case "live":
+                    liveOrderService.payConfirm(1,null,orderId[1], huiFuResult.getHf_seq_id(),huiFuResult.getOut_trans_id(),huiFuResult.getParty_order_id());
+//                    try {
+//                        HuiFuUtils.updateDivItem(orderId[1]);
+//                    } catch (Exception e) {
+//                        logger.error("-------分账明细回调错误{}", e.getMessage());
+//                    }
+                    break;
             }
         }
 

+ 270 - 22
fs-user-app/src/main/java/com/fs/app/controller/live/LiveOrderController.java

@@ -67,6 +67,10 @@ import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.common.error.WxErrorException;
+import org.redisson.api.RLock;
+import org.redisson.api.RedissonClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.transaction.annotation.Transactional;
@@ -79,6 +83,8 @@ import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 
+import static com.fs.hisStore.constants.UserAppsLockConstant.LOCK_KEY_PAY;
+
 /**
  * 订单Controller
  *
@@ -90,6 +96,9 @@ import java.util.concurrent.TimeUnit;
 @RequestMapping("/app/live/liveOrder")
 public class LiveOrderController extends AppBaseController
 {
+    Logger logger= LoggerFactory.getLogger(getClass());
+    @Autowired
+    private RedissonClient redissonClient;
     @Autowired
     private ILiveOrderService orderService;
 
@@ -118,26 +127,6 @@ public class LiveOrderController extends AppBaseController
     @Autowired
     private HuiFuService huiFuService;
 
-    @Autowired
-    @Qualifier("erpOrderServiceImpl")
-    private IErpOrderService gyOrderService;
-
-    @Autowired
-    @Qualifier("wdtErpOrderServiceImpl")
-    private IErpOrderService wdtOrderService;
-
-    @Autowired
-    @Qualifier("k9OrderScrmServiceImpl")
-    private IErpOrderService k9OrderService;
-
-    @Autowired
-    private ConfigUtil configUtil;
-
-
-    @Autowired
-    private IFsExpressService expressService;
-    @Autowired
-    private JwtUtils jwtUtils;
 
     /**
      * 查询订单列表
@@ -316,6 +305,151 @@ public class LiveOrderController extends AppBaseController
         return orderService.createLiveOrder(param);
     }
 
+//    @Login
+//    @ApiOperation("支付")
+//    @PostMapping("/pay")
+//    @Transactional
+//    //@Synchronized
+//    public R pay(HttpServletRequest request, @Validated @RequestBody LiveOrderPayParam param)
+//    {
+//        LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
+//        if(order==null){
+//            return R.error("订单不存在");
+//        }
+//        if(order.getStatus()!= OrderInfoEnum.STATUS_0.getValue()){
+//            return R.error("订单状态不正确");
+//        }
+//        String orderId=redisCache.getCacheObject("isPaying:"+order.getOrderId());
+//        if(StringUtils.isNotEmpty(orderId)&&orderId.equals(order.getOrderId().toString())){
+//            return R.error("正在支付中...");
+//        }
+//
+//        FsUserScrm user=userService.selectFsUserById(Long.valueOf(order.getUserId()));
+//        if(user!=null&& StringUtils.isNotEmpty(user.getMaOpenId())){
+//            //已改价处理
+//            if(order.getIsEditMoney()!=null&&order.getIsEditMoney()==1){
+//                //改过价不做处理
+//
+//            }
+//            else{
+//                String config=configService.selectConfigByKey("his.store");
+//                StoreConfig storeConfig= JSONUtil.toBean(config,StoreConfig.class);
+//                if(param.getPayType().equals(1)){
+//                    order.setPayType("1");
+//                    order.setPayMoney(order.getPayPrice());
+//                    order.setPayDelivery(BigDecimal.ZERO);
+//                }
+//                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);
+//                }
+//                else if(param.getPayType().equals(3)){
+//                    //货到付款
+//                    order.setPayType("3");
+//                    BigDecimal amount=redisCache.getCacheObject("orderAmount:"+order.getOrderId());
+//                    BigDecimal payMoney = BigDecimal.ZERO;
+//                    if (amount != null){
+//                        payMoney=amount;
+//                    }
+//                    order.setPayMoney(payMoney);
+//                    order.setPayDelivery(order.getPayPrice().subtract(payMoney) );
+////                    order.setPayMoney(BigDecimal.ZERO);
+//                }
+//                orderService.updateLiveOrder(order);
+//            }
+//            String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
+////            order.setOrderCode(orderCode);
+////            if(order.getPayType().equals("1")||order.getPayType().equals("2")){
+//            if((order.getPayType().equals("1")||order.getPayType().equals("2")||order.getPayType().equals("3")) && order.getPayMoney().compareTo(new BigDecimal(0))>0){
+//                String json = configService.selectConfigByKey("his.pay");
+//                FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+//                LiveOrderPayment storePayment=new LiveOrderPayment();
+//                storePayment.setCompanyId(order.getCompanyId());
+//                storePayment.setCompanyUserId(order.getCompanyUserId());
+//                storePayment.setPayMode(fsPayConfig.getType());
+//                storePayment.setStatus(0);
+//                storePayment.setPayCode(payCode);
+//                storePayment.setPayMoney(order.getPayMoney());
+//                storePayment.setCreateTime(new Date());
+//                storePayment.setPayTypeCode("weixin");
+//                storePayment.setBusinessType(2);
+//                storePayment.setRemark("直播订单支付");
+//                storePayment.setOpenId(user.getRealName());
+//                storePayment.setUserId(user.getUserId());
+//                storePayment.setBusinessId(String.valueOf(order.getOrderId()));
+//                liveOrderPaymentMapper.insertLiveOrderPayment(storePayment);
+//
+//                if (fsPayConfig.getType().equals("hf")){
+//                    HuiFuCreateOrder o = new HuiFuCreateOrder();
+//                    o.setTradeType("T_MINIAPP");
+//                    o.setOpenid(user.getMaOpenId());
+//                    o.setReqSeqId("live-"+storePayment.getPayCode());
+//                    o.setTransAmt(storePayment.getPayMoney().toString());
+//                    o.setGoodsDesc("直播订单支付");
+//                    if (param != null && StringUtils.isNotBlank(param.getAppId())) {
+//                        o.setAppId(param.getAppId());
+//                    }
+//                    HuifuCreateOrderResult result = huiFuService.createOrder(o);
+//                    if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
+//                        LiveOrderPayment mt=new LiveOrderPayment();
+//                        mt.setPaymentId(storePayment.getPaymentId());
+//                        mt.setTradeNo(result.getHf_seq_id());
+//                        liveOrderPaymentMapper.updateLiveOrderPayment(mt);
+//                        redisCache.setCacheObject("isPaying:"+order.getOrderId(),order.getOrderId().toString(),1, TimeUnit.MINUTES);
+//                        Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
+//                        String s = (String) resultMap.get("package");
+//                        resultMap.put("packageValue",s);
+//                        return R.ok().put("payType",param.getPayType()).put("result",resultMap);
+//                    }
+//                    else{
+//                        return R.error(result.getResp_desc());
+//                    }
+//                }else  if (fsPayConfig.getType().equals("wx")){
+//                    WxPayConfig payConfig = new WxPayConfig();
+//                    payConfig.setAppId(fsPayConfig.getAppId());
+//                    payConfig.setMchId(fsPayConfig.getWxMchId());
+//                    payConfig.setMchKey(fsPayConfig.getWxMchKey());
+//                    payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+//                    payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+//                    payConfig.setKeyPath(fsPayConfig.getKeyPath());
+//                    payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
+//                    wxPayService.setConfig(payConfig);
+//                    WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
+//                    orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
+//                    orderRequest.setBody("直播订单支付");
+//                    orderRequest.setOutTradeNo("live-" + storePayment.getPayCode());
+//                    orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
+//                    //orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(money));//测试
+//                    orderRequest.setTradeType("JSAPI");
+//                    orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
+//                    //调用统一下单接口,获取"预支付交易会话标识"
+//                    try {
+//                        WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
+//                        return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0).put("payType",param.getPayType());
+//                    } catch (WxPayException e) {
+//                        e.printStackTrace();
+//                        throw new CustomException("支付失败" + e.getMessage());
+//                    }
+//                }
+//            }
+////            else if(order.getPayType().equals("3")){
+//            else if(order.getPayType().equals("3") && order.getPayMoney().compareTo(new BigDecimal(0))<=0){
+//                //货到付款
+//                orderService.payConfirm(2,order.getOrderId(),null,null,null,null);
+//                return R.ok().put("payType",param.getPayType());
+//            }
+//            return R.error();
+//        }
+//        else{
+//            return R.error("用户OPENID不存在");
+//        }
+//
+//    }
+
+    /*
     @Login
     @ApiOperation("支付")
     @PostMapping("/pay")
@@ -323,6 +457,37 @@ public class LiveOrderController extends AppBaseController
     //@Synchronized
     public R pay(HttpServletRequest request, @Validated @RequestBody LiveOrderPayParam param)
     {
+        Long orderId = param.getOrderId();
+        logger.info("开始处理支付请求, 订单号: {}, 支付类型: {}", orderId, param.getPayType());
+
+        RLock lock = redissonClient.getLock(String.format(LOCK_KEY_PAY,orderId));
+        R result = null;
+
+        try {
+            boolean locked = lock.tryLock(100, 30000, TimeUnit.MILLISECONDS);
+
+            if (!locked) {
+                logger.warn("订单正在处理中,获取锁失败, 订单号: {}", orderId);
+                return R.error("订单正在处理中,请勿重复提交");
+            }
+
+            result = orderService.pay(param);
+
+        } catch (InterruptedException e) {
+            logger.error("获取支付锁的过程被中断, 订单号: {}", orderId, e);
+            Thread.currentThread().interrupt();
+            return R.error("支付处理被中断,请稍后重试");
+        } catch (Throwable e) {
+            logger.error("支付过程中发生异常, 订单号: {}", orderId, e);
+            throw e;
+        } finally {
+            if (lock.isHeldByCurrentThread()) {
+                lock.unlock();
+                logger.debug("支付锁已释放, 订单号: {}", orderId);
+            }
+        }
+
+        return result;
         LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
         if(order==null){
             return R.error("订单不存在");
@@ -459,7 +624,92 @@ public class LiveOrderController extends AppBaseController
         }
 
     }
+        /**
+     * 获取订单详细信息
+     */
+    @Login
+    @GetMapping(value = "/info/{orderId}")
+    public AjaxResult getInfo(@PathVariable("orderId") String orderId)
+    {
+        log.info("获取订单详细信息 参数: {}",orderId);
 
+        return AjaxResult.success(orderService.selectLiveOrderByOrderId(orderId));
+    }
+
+    @Login
+    @ApiOperation("支付")
+    @PostMapping("/pay")
+    @Transactional
+    public R pay(HttpServletRequest request, @Validated @RequestBody LiveOrderPayParam param)
+    {
+        Long orderId = param.getOrderId();
+        logger.info("开始处理支付请求, 订单号: {}, 支付类型: {}", orderId, param.getPayType());
+
+        RLock lock = redissonClient.getLock(String.format(LOCK_KEY_PAY,orderId));
+        R result = null;
+
+        try {
+            boolean locked = lock.tryLock(100, 30000, TimeUnit.MILLISECONDS);
+
+            if (!locked) {
+                logger.warn("订单正在处理中,获取锁失败, 订单号: {}", orderId);
+                return R.error("订单正在处理中,请勿重复提交");
+            }
+
+            result = orderService.handleLiveOrderPay(param);
+
+        } catch (InterruptedException e) {
+            logger.error("获取支付锁的过程被中断, 订单号: {}", orderId, e);
+            Thread.currentThread().interrupt();
+            return R.error("支付处理被中断,请稍后重试");
+        } catch (Throwable e) {
+            logger.error("支付过程中发生异常, 订单号: {}", orderId, e);
+            throw e;
+        } finally {
+            if (lock.isHeldByCurrentThread()) {
+                lock.unlock();
+                logger.debug("支付锁已释放, 订单号: {}", orderId);
+            }
+        }
+
+        return result;
+    }
+
+    @Login
+    @ApiOperation("取消支付")
+    @PostMapping("/cancelPay")
+    public R cancelPay(@Validated @RequestBody LiveOrderPayParam param) {
+        Long orderId = param.getOrderId();
+        logger.info("用户取消支付 订单号: {}, 支付类型: {}", orderId, param.getPayType());
+        RLock lock = redissonClient.getLock(String.format(LOCK_KEY_PAY,orderId));
+        try {
+            boolean locked = lock.tryLock(100, 30000, TimeUnit.MILLISECONDS);
+            if (!locked) {
+                logger.warn("订单正在处理中,获取锁失败, 订单号: {}", orderId);
+                return R.error("订单正在处理中,请稍后再试");
+            }
+            handleCancelLiveOrderPay(param);
+            return R.ok();
+        } catch (InterruptedException e) {
+            logger.error("获取取消支付锁的过程被中断, 订单号: {}", orderId, e);
+            Thread.currentThread().interrupt();
+            return R.error("取消支付处理被中断,请稍后重试");
+        } catch (Throwable e) {
+            logger.error("取消支付过程中发生异常, 订单号: {}", orderId, e);
+            throw e;
+        } finally {
+            if (lock.isHeldByCurrentThread()) {
+                lock.unlock();
+                logger.debug("取消支付锁已释放, 订单号: {}", orderId);
+            }
+        }
+    }
+
+
+
+    private void handleCancelLiveOrderPay(LiveOrderPayParam param) {
+        redisCache.deleteObject("isPaying:"+param.getOrderId());
+    }
 
 
 
@@ -519,8 +769,6 @@ public class LiveOrderController extends AppBaseController
                 else if(param.getPayType().equals(3)){
                     //货到付款
                     order.setPayType("3");
-//                    order.setPayDelivery(order.getPayPrice() );
-//                    order.setPayMoney(BigDecimal.ZERO);
                     BigDecimal amount=redisCache.getCacheObject("orderAmount:"+order.getOrderId());
                     BigDecimal payMoney = BigDecimal.ZERO;
                     if (amount != null){

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

@@ -11,6 +11,7 @@ import com.fs.erp.service.IErpOrderService;
 import com.fs.hisStore.service.*;
 import com.fs.huifuPay.domain.HuiFuResult;
 import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
+import com.fs.live.service.ILiveOrderService;
 import com.fs.ybPay.domain.OrderCallback;
 import com.fs.ybPay.domain.OrderResult;
 import com.fs.pay.pay.dto.OrderQueryDTO;
@@ -58,6 +59,8 @@ public class PayScrmController {
     private IFsStorePaymentScrmService storePaymentService;
     @Autowired
     private IFsExpressScrmService expressService;
+    @Autowired
+    private ILiveOrderService liveOrderService;
 
     @Autowired
     private ICompanyService companyService;
@@ -98,6 +101,14 @@ public class PayScrmController {
                         logger.error("-------分账明细回调错误{}", e.getMessage());
                     }
                     return storePaymentService.payConfirm(order[1],o.getHf_seq_id(),o.getOut_trans_id(),o.getParty_order_id());
+                case "live":
+                    liveOrderService.payConfirm(1,null,order[1], o.getHf_seq_id(),o.getOut_trans_id(),o.getParty_order_id());
+//                    try {
+//                        HuiFuUtils.updateDivItem(orderId[1]);
+//                    } catch (Exception e) {
+//                        logger.error("-------分账明细回调错误{}", e.getMessage());
+//                    }
+                    break;
             }
 
         }

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov