|
@@ -88,8 +88,6 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
|
|
|
private @Autowired ICommissionSettingService iCommissionSettingService;
|
|
|
|
|
|
- private @Autowired IUserBillService iUserBillService;
|
|
|
-
|
|
|
private @Autowired ITyBillService iTyBillService;
|
|
|
|
|
|
private @Autowired ISchoolVideoOperateService schoolVideoOperateService;
|
|
@@ -168,8 +166,7 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
|
|
|
if (caseEntity.getRedEnvelopeId() != null) {
|
|
|
// 是否使用红包修改状态
|
|
|
- userCouponMapper.updateOrderIdAndStatusByCouponIdAndUserId(caseEntity.getRedEnvelopeId(), 2,
|
|
|
- caseEntity.getId());
|
|
|
+ userCouponMapper.updateOrderIdAndStatusByCouponIdAndUserId(caseEntity.getRedEnvelopeId(), 2, caseEntity.getId());
|
|
|
}
|
|
|
|
|
|
log.info("--- 微信问诊记录平台流水开始 ---");
|
|
@@ -193,15 +190,16 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
UserBillEntity billUpEntity = new UserBillEntity();
|
|
|
billUpEntity.setCreateTime(date);
|
|
|
billUpEntity.setUserId(userId);
|
|
|
+ billUpEntity.setTargetUserId(caseEntity.getChargerId());
|
|
|
billUpEntity.setAmount(new BigDecimal(totalAmount).divide(new BigDecimal("100")));
|
|
|
billUpEntity.setType(1);
|
|
|
billUpEntity.setBusinessType(4);
|
|
|
billUpEntity.setDescr("微信支付问诊服务费");
|
|
|
billUpEntity.setFlowNum(tradeNo);
|
|
|
// 查询最近一次的余额
|
|
|
- BigDecimal latestBalance = iUserBillService.getLatestBalance(userId);
|
|
|
+ BigDecimal latestBalance = userBillService.getLatestBalance(userId);
|
|
|
billUpEntity.setBalance(latestBalance);
|
|
|
- iUserBillService.save(billUpEntity);
|
|
|
+ userBillService.save(billUpEntity);
|
|
|
log.info("记录流水完成");
|
|
|
|
|
|
log.info("交易成功,处理业务代码完成");
|
|
@@ -222,6 +220,8 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
entity.setAmount(amount);
|
|
|
entity.setCreateTime(date);
|
|
|
entity.setUserId(user.getUserId());
|
|
|
+ //充值,收款人为平台
|
|
|
+ entity.setTargetUserId(1L);
|
|
|
entity.setFlowNum(tradeNo);
|
|
|
entity.setType(2);// '交易类型 1:支出、2:收入
|
|
|
entity.setBusinessType(3); // '业务类型:如:2 打赏,3 充值,1 充值会员',
|
|
@@ -318,8 +318,7 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
|
|
|
if (caseEntity.getRedEnvelopeId() != null) {
|
|
|
// 是否使用红包修改状态
|
|
|
- userCouponMapper.updateOrderIdAndStatusByCouponIdAndUserId(caseEntity.getRedEnvelopeId(), 2,
|
|
|
- caseEntity.getId());
|
|
|
+ userCouponMapper.updateOrderIdAndStatusByCouponIdAndUserId(caseEntity.getRedEnvelopeId(), 2, caseEntity.getId());
|
|
|
}
|
|
|
|
|
|
log.info("--- 微信出诊记录平台流水开始 ---");
|
|
@@ -343,15 +342,16 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
UserBillEntity billUpEntity = new UserBillEntity();
|
|
|
billUpEntity.setCreateTime(date);
|
|
|
billUpEntity.setUserId(userId);
|
|
|
+ billUpEntity.setTargetUserId(caseEntity.getChargerId());
|
|
|
billUpEntity.setAmount(new BigDecimal(totalAmount).divide(new BigDecimal("100")));
|
|
|
billUpEntity.setType(1);
|
|
|
billUpEntity.setBusinessType(4);
|
|
|
billUpEntity.setDescr("微信支付出诊服务费");
|
|
|
billUpEntity.setFlowNum(tradeNo);
|
|
|
// 查询最近一次的余额
|
|
|
- BigDecimal latestBalance = iUserBillService.getLatestBalance(userId);
|
|
|
+ BigDecimal latestBalance = userBillService.getLatestBalance(userId);
|
|
|
billUpEntity.setBalance(latestBalance);
|
|
|
- iUserBillService.save(billUpEntity);
|
|
|
+ userBillService.save(billUpEntity);
|
|
|
|
|
|
PushUserInfo pushUserInfo =
|
|
|
iUserAccountService.getPushUserInfoByUserId(caseEntity.getChargerId().toString());
|
|
@@ -392,16 +392,17 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
UserBillEntity userBillEntity = new UserBillEntity();
|
|
|
userBillEntity.setAmount(amount);
|
|
|
userBillEntity.setUserId(questionBankEntity.getExpert());
|
|
|
+ userBillEntity.setTargetUserId(userId);
|
|
|
userBillEntity.setType(2);
|
|
|
userBillEntity.setDescr("用户题库打赏");
|
|
|
userBillEntity.setBusinessType(2);
|
|
|
userBillEntity.setFlowNum(tradeNo);
|
|
|
// 查询最近一次的余额
|
|
|
- BigDecimal latestBalance = iUserBillService.getLatestBalance(questionBankEntity.getExpert());
|
|
|
+ BigDecimal latestBalance = userBillService.getLatestBalance(questionBankEntity.getExpert());
|
|
|
if (null != latestBalance) {
|
|
|
userBillEntity.setBalance(latestBalance.add(amount));
|
|
|
}
|
|
|
- iUserBillService.save(userBillEntity);
|
|
|
+ userBillService.save(userBillEntity);
|
|
|
// 修改余额
|
|
|
userInfoMapper.rechargePayBalance(questionBankEntity.getExpert(), amount);
|
|
|
|
|
@@ -409,11 +410,12 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
UserBillEntity billEntity = new UserBillEntity();
|
|
|
billEntity.setAmount(reward);
|
|
|
billEntity.setUserId(userId);
|
|
|
+ billEntity.setTargetUserId(questionBankEntity.getExpert());
|
|
|
billEntity.setType(1);
|
|
|
billEntity.setBusinessType(2);
|
|
|
billEntity.setFlowNum(tradeNo);
|
|
|
// 查询最近一次的余额
|
|
|
- BigDecimal ba = iUserBillService.getLatestBalance(userId);
|
|
|
+ BigDecimal ba = userBillService.getLatestBalance(userId);
|
|
|
if (payType == 1) {
|
|
|
billEntity.setDescr("微信题库打赏");
|
|
|
billEntity.setBalance(ba);
|
|
@@ -424,7 +426,7 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
userInfoMapper.updateUserBalance(userId, reward);
|
|
|
}
|
|
|
|
|
|
- iUserBillService.save(billEntity);
|
|
|
+ userBillService.save(billEntity);
|
|
|
|
|
|
if (payType == 1) {
|
|
|
log.info("--- 微信题库打赏记录平台流水开始 ---");
|
|
@@ -476,16 +478,17 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
UserBillEntity userBillEntity = new UserBillEntity();
|
|
|
userBillEntity.setAmount(amount);
|
|
|
userBillEntity.setUserId(videoEntity.getUserId());
|
|
|
+ userBillEntity.setTargetUserId(userId);
|
|
|
userBillEntity.setType(2);
|
|
|
userBillEntity.setDescr("用户视频打赏");
|
|
|
userBillEntity.setBusinessType(2);
|
|
|
userBillEntity.setFlowNum(tradeNo);
|
|
|
// 查询最近一次的余额
|
|
|
- BigDecimal latestBalance = iUserBillService.getLatestBalance(videoEntity.getUserId());
|
|
|
+ BigDecimal latestBalance = userBillService.getLatestBalance(videoEntity.getUserId());
|
|
|
if (null != latestBalance) {
|
|
|
userBillEntity.setBalance(latestBalance.add(amount));
|
|
|
}
|
|
|
- iUserBillService.save(userBillEntity);
|
|
|
+ userBillService.save(userBillEntity);
|
|
|
// 修改余额
|
|
|
userInfoMapper.rechargePayBalance(videoEntity.getUserId(), amount);
|
|
|
|
|
@@ -493,11 +496,12 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
UserBillEntity billEntity = new UserBillEntity();
|
|
|
billEntity.setAmount(reward);
|
|
|
billEntity.setUserId(userId);
|
|
|
+ billEntity.setTargetUserId(videoEntity.getUserId());
|
|
|
billEntity.setType(1);
|
|
|
billEntity.setBusinessType(2);
|
|
|
billEntity.setFlowNum(tradeNo);
|
|
|
// 查询最近一次的余额
|
|
|
- BigDecimal ba = iUserBillService.getLatestBalance(userId);
|
|
|
+ BigDecimal ba = userBillService.getLatestBalance(userId);
|
|
|
if (payType == 1) {
|
|
|
billEntity.setDescr("微信视频打赏");
|
|
|
billEntity.setBalance(ba);
|
|
@@ -507,7 +511,7 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
// 减少余额
|
|
|
userInfoMapper.updateUserBalance(userId, reward);
|
|
|
}
|
|
|
- iUserBillService.save(billEntity);
|
|
|
+ userBillService.save(billEntity);
|
|
|
|
|
|
if (payType == 1) {
|
|
|
log.info("--- 微信视频记录平台流水开始 ---");
|
|
@@ -583,7 +587,7 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
// 如果是第一次成为会员,或者不是后台直接升级成会员的(是vip但是没有邀请码)
|
|
|
// user_rebate 中修改此人的会费信息,并且给他的上级返利
|
|
|
// 判断是否是第一次充值成为会员
|
|
|
- UserBillEntity userBill = iUserBillService.getByUserIdAndBusinessType(userId, 1);
|
|
|
+ UserBillEntity userBill = userBillService.getByUserIdAndBusinessType(userId, 1);
|
|
|
if (null == userBill && userInfoEntity.getRequestCode() == null) {
|
|
|
// 第一次成为会员
|
|
|
// 如果他有上级,上级的user_bill中加入流水信息,余额增加
|
|
@@ -609,17 +613,18 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
}
|
|
|
}
|
|
|
// ----------------- 充值的人自己也要加上流水信息,余额不变
|
|
|
- BigDecimal latestUserBalance = iUserBillService.getLatestBalance(userId);
|
|
|
+ BigDecimal latestUserBalance = userBillService.getLatestBalance(userId);
|
|
|
UserBillEntity uBillEntity = new UserBillEntity();
|
|
|
uBillEntity.setCreateTime(LocalDateTime.now());
|
|
|
uBillEntity.setUserId(userId);
|
|
|
+ uBillEntity.setTargetUserId(1L);
|
|
|
uBillEntity.setAmount(fee);
|
|
|
uBillEntity.setType(1);
|
|
|
uBillEntity.setDescr("充值vip会员");
|
|
|
uBillEntity.setBusinessType(1);
|
|
|
uBillEntity.setBalance(latestUserBalance);
|
|
|
uBillEntity.setFlowNum(tradeNo);
|
|
|
- iUserBillService.save(uBillEntity);
|
|
|
+ userBillService.save(uBillEntity);
|
|
|
|
|
|
log.info("--- 充值vip会员记录平台流水开始 ---");
|
|
|
// 记录平台流水
|
|
@@ -679,15 +684,17 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
UserBillEntity billUpEntity = new UserBillEntity();
|
|
|
billUpEntity.setCreateTime(LocalDateTime.now());
|
|
|
billUpEntity.setUserId(upUser.getUserId());
|
|
|
+ //下级用户id
|
|
|
+ billUpEntity.setTargetUserId(upUser.getLowerUserId());
|
|
|
billUpEntity.setAmount(fee.multiply(rebate1));
|
|
|
billUpEntity.setType(2);
|
|
|
billUpEntity.setBusinessType(11);
|
|
|
billUpEntity.setDescr("一级下线返利");
|
|
|
billUpEntity.setFlowNum(tradeNo);
|
|
|
// 查询最近一次的余额
|
|
|
- BigDecimal latestBalance = iUserBillService.getLatestBalance(upUser.getUserId());
|
|
|
+ BigDecimal latestBalance = userBillService.getLatestBalance(upUser.getUserId());
|
|
|
billUpEntity.setBalance(latestBalance.add(fee.multiply(rebate1)));
|
|
|
- iUserBillService.save(billUpEntity);
|
|
|
+ userBillService.save(billUpEntity);
|
|
|
// 上一级的 user_info 余额增加
|
|
|
UserInfoEntity uiEntity = new UserInfoEntity();
|
|
|
uiEntity.setUserId(userInfo.getUserId());
|
|
@@ -701,7 +708,6 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
ubEntity.setUserId(upUser.getUserId());
|
|
|
iUserRebateService.updateByTwoId(ubEntity);
|
|
|
return fee.multiply(rebate1);
|
|
|
- // todo 给上级发送消息
|
|
|
}
|
|
|
|
|
|
return new BigDecimal("0");
|
|
@@ -739,15 +745,17 @@ public class WxpayServiceImpl implements WxpayService {
|
|
|
UserBillEntity billUpEntity = new UserBillEntity();
|
|
|
billUpEntity.setCreateTime(LocalDateTime.now());
|
|
|
billUpEntity.setUserId(upUpUser.getUserId());
|
|
|
+ //下级用户
|
|
|
+ billUpEntity.setTargetUserId(upUpUser.getLowerUserId());
|
|
|
billUpEntity.setAmount(fee.multiply(rebate2));
|
|
|
billUpEntity.setType(2);
|
|
|
billUpEntity.setBusinessType(11);
|
|
|
billUpEntity.setDescr("二级下线返利");
|
|
|
billUpEntity.setFlowNum(tradeNo);
|
|
|
// 查询最近一次的余额
|
|
|
- BigDecimal latestBalance = iUserBillService.getLatestBalance(upUpUser.getUserId());
|
|
|
+ BigDecimal latestBalance = userBillService.getLatestBalance(upUpUser.getUserId());
|
|
|
billUpEntity.setBalance(latestBalance.add(fee.multiply(rebate2)));
|
|
|
- iUserBillService.save(billUpEntity);
|
|
|
+ userBillService.save(billUpEntity);
|
|
|
// 上上级的 user_info 余额增加
|
|
|
UserInfoEntity uiEntity = new UserInfoEntity();
|
|
|
uiEntity.setUserId(upUserInfo.getUserId());
|