Browse Source

Merge branch 'master' of http://git.dayaedu.com/yonge/cooleshow

liujunchi 3 năm trước cách đây
mục cha
commit
d57671abc3

+ 4 - 0
cooleshow-common/src/main/java/com/yonge/cooleshow/common/constant/SysConfigConstant.java

@@ -179,6 +179,10 @@ public interface SysConfigConstant {
      * 琴房课扣时公式
      */
     String PIANO_ROOM_TIME_FORMULA = "piano_room_time_formula";
+    /**
+     * 琴房课开课最小时长(分钟)
+     */
+    String PIANO_ROOM_MIN_TIME = "piano_room_min_time";
     /***
      * 提现开关 0 关闭 1开启
      * @author liweifan

+ 32 - 24
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/UserWithdrawalDao.java

@@ -11,35 +11,43 @@ import com.yonge.cooleshow.biz.dal.vo.UserWithdrawalVo;
 import com.yonge.cooleshow.biz.dal.dto.search.TeacherWithdrawalSearch;
 
 
-public interface UserWithdrawalDao extends BaseMapper<UserWithdrawal>{
-	/**
-	 * 查询详情
+public interface UserWithdrawalDao extends BaseMapper<UserWithdrawal> {
+    /**
+     * 查询详情
+     *
      * @author liweifan
      * @date 2022-03-30 13:53:51
      * @return: com.yonge.cooleshow.biz.dal.vo.TeacherWithdrawalVo
-	 */
-	UserWithdrawalVo detail(@Param("id") Long id);
+     */
+    UserWithdrawalVo detail(@Param("id") Long id);
 
-	/**
-	 * 分页查询
+    UserWithdrawalVo detailByTransNo(@Param("transNo") String transNo);
+
+    /**
+     * 分页查询
+     *
      * @author liweifan
      * @date 2022-03-30 13:53:51
      * @return: com.yonge.cooleshow.biz.dal.vo.TeacherWithdrawalVo
-	 */
-	List<UserWithdrawalVo> selectPage(@Param("page") IPage page, @Param("param") TeacherWithdrawalSearch teacherWithdrawal);
-	/***
-	 * 查询集合
-	 * @author liweifan
-	 * @param: teacherWithdrawal
-	 * @updateTime 2022/4/15 18:05
-	 * @return: java.util.List<com.yonge.cooleshow.biz.dal.vo.UserWithdrawalVo>
-	 */
-	List<UserWithdrawalVo> selectList(@Param("param") TeacherWithdrawalSearch teacherWithdrawal);
-
-	/**
-	 * 查询用户今天发起的提现次数
-	 * @param userId
-	 * @return
-	 */
-	Integer getNowDayWithdrawalCount(@Param("userId") Long userId);
+     */
+    List<UserWithdrawalVo> selectPage(@Param("page") IPage page, @Param("param") TeacherWithdrawalSearch teacherWithdrawal);
+
+    /***
+     * 查询集合
+     * @author liweifan
+     * @param: teacherWithdrawal
+     * @updateTime 2022/4/15 18:05
+     * @return: java.util.List<com.yonge.cooleshow.biz.dal.vo.UserWithdrawalVo>
+     */
+    List<UserWithdrawalVo> selectList(@Param("param") TeacherWithdrawalSearch teacherWithdrawal);
+
+    /**
+     * 查询用户今天发起的提现次数
+     *
+     * @param userId
+     * @return
+     */
+    Integer getNowDayWithdrawalCount(@Param("userId") Long userId);
+
+
 }

+ 12 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/UserWithdrawal.java

@@ -57,12 +57,15 @@ public class UserWithdrawal implements Serializable {
     @ApiModelProperty("第三方类型 ")
     @TableField(value = "open_type_")
     private String openType;
-    @ApiModelProperty("三方交易流水号 ")
+    @ApiModelProperty("交易流水号 ")
     @TableField(value = "trans_no_")
     private String transNo;
     @ApiModelProperty("交易状态 pending、交易处理中 succeeded、交易成功 failed、交易失败 ")
     @TableField(value = "trade_status_")
     private TradeStatusEnum tradeStatus;
+    @ApiModelProperty("三方交易流水号 ")
+    @TableField(value = "trade_no_")
+    private String tradeNo;
     @ApiModelProperty("三方接口返回金额 ")
     @TableField(value = "callbak_amount_")
     private BigDecimal callbakAmount;
@@ -250,4 +253,12 @@ public class UserWithdrawal implements Serializable {
     public void setAuthTime(Date authTime) {
         this.authTime = authTime;
     }
+
+    public String getTradeNo() {
+        return tradeNo;
+    }
+
+    public void setTradeNo(String tradeNo) {
+        this.tradeNo = tradeNo;
+    }
 }

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/sdk/WithdrawSdk.java

@@ -177,6 +177,7 @@ public class WithdrawSdk {
         map.put("cardAttribute", "C");
         map.put("payAccount", payAccount);
         String jsonStr = JSONObject.toJSONString(map);
+        logger.info("单笔请求请求参数:{}", JSONObject.toJSONString(jsonStr));
 
         //签名
         JSONObject mapParam = new JSONObject();
@@ -186,7 +187,6 @@ public class WithdrawSdk {
             mapParam.put("outMemberNo", memberNo);
             mapParam.put("signType", "RSA");
             mapParam.put("sign", encryptStr);
-            logger.info("单笔请求请求参数:{}", JSONObject.toJSONString(mapParam));
         } catch (Exception e) {
             logger.info("加密失败:{}", e);
         }

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/UserWithdrawalService.java

@@ -33,6 +33,8 @@ public interface UserWithdrawalService extends IService<UserWithdrawal> {
      */
     UserWithdrawalVo detail(Long id);
 
+    UserWithdrawalVo detailByTransNo(String transNo);
+
     /**
      * 分页查询
      *

+ 6 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java

@@ -1683,6 +1683,12 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         Integer singleClssTime = arrangeCourseVo.getSingleClssTime();//单课时长
         List<Long> studentIds = arrangeCourseVo.getStudentIds();//学员id集合
 
+        //单课最小时长
+//        Integer minTime = Integer.valueOf(sysConfigService.findConfigValue(SysConfigConstant.PIANO_ROOM_TIME_FORMULA));
+//        if (singleClssTime<minTime){
+//            throw new BizException("单课最小时长不得低于{}分钟", minTime);
+//        }
+
         String formula = sysConfigService.findConfigValue(SysConfigConstant.PIANO_ROOM_TIME_FORMULA);
         Integer n = (Integer) WrapperUtil.strToFormula(formula, "n", String.valueOf(studentIds.size() + 1));//人数计算 公式n*(n-1) n包含老师
         Integer consumTime = classNum * singleClssTime * n;//消耗时长 课程数*单课时长*人数

+ 34 - 18
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserWithdrawalServiceImpl.java

@@ -19,6 +19,7 @@ import com.yonge.cooleshow.biz.dal.vo.UserAccountVo;
 import com.yonge.cooleshow.biz.dal.vo.UserBankCardVo;
 import com.yonge.cooleshow.biz.dal.vo.res.WithdrawalInfoRes;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.cooleshow.common.service.IdGeneratorService;
 import com.yonge.toolset.base.exception.BizException;
 import com.yonge.toolset.base.string.StringPool;
 import com.yonge.toolset.base.util.StringUtil;
@@ -57,6 +58,8 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
     private SysMessageService sysMessageService;
     @Autowired
     private SysUserContractRecordDao userContractRecordDao;
+    @Autowired
+    private IdGeneratorService idGeneratorService;
 
     @Override
     public UserWithdrawalVo detail(Long id) {
@@ -65,6 +68,12 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
     }
 
     @Override
+    public UserWithdrawalVo detailByTransNo(String transNo) {
+        UserWithdrawalVo detail = baseMapper.detailByTransNo(transNo);
+        return detail;
+    }
+
+    @Override
     public IPage<UserWithdrawalVo> selectPage(IPage<UserWithdrawalVo> page, TeacherWithdrawalSearch query) {
         List<UserWithdrawalVo> withdrawalVoList = baseMapper.selectPage(page, query);
         withdrawalVoList.forEach(o -> o.setBankCard(ValueUtil.fuzzyBankCard(o.getBankCard())));
@@ -145,13 +154,17 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
         if (accountChange.getStatus()) {
             if (YesOrNoEnum.NO.getCode().toString().equals(withdrawalAuthSwitch)
                     || new BigDecimal(withdrawalAuthFee).compareTo(withdrawalReq.getAmountWithdrawal()) > 0) {
-                //不用审核的,需要请求三方
+                //不用审核的,直接请求三方
+                //交易流水号生成
+                Long transNo = idGeneratorService.generatorId("withdrawNo");
+
                 HttpResponseResult<Boolean> withdraw = withdrawSdk.withdraw(
-                        userWithdrawal.getId().toString(), bankCardVo.getName(), bankCardVo.getPhone(), user.getIdCardNo(),
+                        transNo.toString(), bankCardVo.getName(), bankCardVo.getPhone(), user.getIdCardNo(),
                         userWithdrawal.getActualAmount().multiply(new BigDecimal("100")).intValue(), bankCardVo.getBankCard(), null
                 );
                 if (withdraw.getStatus() && withdraw.getData()) {
                     userWithdrawal.setTradeStatus(TradeStatusEnum.pending);
+                    userWithdrawal.setTransNo(transNo.toString());
                     updateById(userWithdrawal);
                 } else {
                     log.error("结算调用三方接口失败:user is {}, param is {}, res is {}", user.getId(), JSONObject.toJSONString(withdrawalReq), withdraw);
@@ -184,14 +197,19 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
             Boolean flag = false;
             if (authOperaReq.getPass()) {
                 //请求三方接口
+
+                //交易流水号生成
+                Long transNo = idGeneratorService.generatorId("withdrawNo");
+
                 HttpResponseResult<Boolean> withdraw = withdrawSdk.withdraw(
-                        build.getId().toString(), build.getRealName(), build.getPhone(), withdrawalUser.getIdCardNo(),
+                        transNo.toString(), build.getRealName(), build.getPhone(), withdrawalUser.getIdCardNo(),
                         build.getActualAmount().multiply(new BigDecimal("100")).intValue(), build.getBankCard(), null
                 );
                 if (withdraw.getStatus() && withdraw.getData()) {
                     build.setTradeStatus(TradeStatusEnum.pending);
+                    build.setTransNo(transNo.toString());
                     flag = true;
-                }else{
+                } else {
                     build.setTradeStatus(TradeStatusEnum.failed);
                     build.setErrorMsg("请求三方接口返回失败");
                 }
@@ -225,13 +243,17 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
             return HttpResponseResult.failed("提现已经交易成功");
         }
 
+        //交易流水号生成
+        Long transNo = idGeneratorService.generatorId("withdrawNo");
+
         //不用审核的,需要请求三方
         HttpResponseResult<Boolean> withdraw = withdrawSdk.withdraw(
-                detail.getId().toString(), detail.getRealName(), detail.getPhone(), user.getIdCardNo(),
+                transNo.toString(), detail.getRealName(), detail.getPhone(), user.getIdCardNo(),
                 detail.getActualAmount().multiply(new BigDecimal("100")).intValue(), detail.getBankCard(), null
         );
         if (withdraw.getStatus() && withdraw.getData()) {
             detail.setTradeStatus(TradeStatusEnum.pending);
+            detail.setTransNo(transNo.toString());
             updateById(detail);
             return HttpResponseResult.succeed(true);
         } else {
@@ -246,11 +268,13 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
     public void callback(UserWithdrawalCallback callback, String jsonStr) {
         if (StringUtil.isEmpty(callback.getOuterOrderNo()) ||
                 StringUtil.isEmpty(callback.getStatus())) {
-            throw new BizException("参数异常,参数缺失,param is {}", jsonStr);
+            log.error("参数异常,参数缺失,param is {}", jsonStr);
+            return;
         }
-        UserWithdrawalVo detail = detail(Long.parseLong(callback.getOuterOrderNo().trim()));
+        UserWithdrawalVo detail = detailByTransNo(callback.getOuterOrderNo().trim());
         if (null == detail) {
-            throw new BizException("参数异常,未找到交易记录,param is {}", jsonStr);
+            log.error("参数异常,未找到交易记录,param is {}", jsonStr);
+            return;
         }
         if (!TradeStatusEnum.pending.equals(detail.getTradeStatus())) {
             return;
@@ -258,7 +282,7 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
         if ("1".equals(callback.getStatus())) {
             //交易成功
             detail.setTradeStatus(TradeStatusEnum.succeeded);
-            detail.setTransNo(callback.getOrderNo());
+            detail.setTradeNo(callback.getOrderNo());
             BigDecimal actualAmount = new BigDecimal(callback.getActualAmount());
             detail.setActualAmount(actualAmount.divide(new BigDecimal("100")));
             detail.setTransferTime(callback.getEndTime());
@@ -276,17 +300,9 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
         } else if ("2".equals(callback.getStatus())) {
             //交易失败
             detail.setTradeStatus(TradeStatusEnum.failed);
+            detail.setTradeNo(callback.getOrderNo());
             detail.setErrorCode(callback.getErrorCode());
             detail.setErrorMsg(callback.getErrorMsg());
-
-            //结算失败,账户解冻
-            /*UserAccountRecordDto accountRecordDto = new UserAccountRecordDto(
-                    detail.getUserId(), detail.getAmount(), InOrOutEnum.OUT, AccountBizTypeEnum.WITHDRAWAL,
-                    detail.getId(), "老师结算", null
-            );
-            accountRecordDto.setFrozenType(FrozenTypeEnum.FROZEN_BACK);
-            accountRecordDto.setSaveRecord(false);
-            userAccountService.accountChange(accountRecordDto);*/
         } else {
             return;
         }

+ 16 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/UserWithdrawalMapper.xml

@@ -16,6 +16,7 @@
         <result column="open_type_" property="openType" />
         <result column="trans_no_" property="transNo" />
         <result column="trade_status_" property="tradeStatus" />
+        <result column="trade_no_" property="tradeNo" />
         <result column="callbak_amount_" property="callbakAmount" />
         <result column="transfer_time_" property="transferTime" />
         <result column="error_code_" property="errorCode" />
@@ -39,6 +40,7 @@
         , t.open_type_ as openType
         , t.trans_no_ as transNo
         , t.trade_status_ as tradeStatus
+        , t.trade_no_ as tradeNo
         , t.callbak_amount_ as callbakAmount
         , t.transfer_time_ as transferTime
         , t.error_code_ as errorCode
@@ -62,6 +64,20 @@
         where t.id_ = #{id}
     </select>
 
+    <select id="detailByTransNo" resultType="com.yonge.cooleshow.biz.dal.vo.UserWithdrawalVo">
+        SELECT
+            <include refid="baseColumns"/>,
+            bc.name_ as realName,
+            bc.bank_name_ as bankName,
+            bc.bank_card_ as bankCard,
+            bc.phone_ as phone,
+            u.username_  as withdrawaUser
+        FROM user_withdrawal t
+        LEFT JOIN user_bank_card bc on t.bank_card_id_ = bc.id_ and t.user_id_ = bc.user_id_
+        left join sys_user u on t.user_id_ = u.id_
+        where t.trans_no_ = #{transNo}
+    </select>
+
     <sql id="selectSql">
         SELECT
             <include refid="baseColumns" />,