D1D0数据同步,提现审核相关

This commit is contained in:
liuyingfang 2023-07-06 17:01:21 +08:00
parent f0174ef087
commit a473fd6457
10 changed files with 271 additions and 37 deletions

View File

@ -7,6 +7,7 @@ import cn.pluss.platform.cash.CashService;
import cn.pluss.platform.entity.Cash;
import cn.pluss.platform.entity.UserApp;
import cn.pluss.platform.entity.WxBankCode;
import cn.pluss.platform.userApp.UserAppService;
import cn.pluss.platform.util.*;
import cn.pluss.platform.wxBankCode.WxBankCodeService;
import io.swagger.annotations.Api;
@ -18,6 +19,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
@ -33,6 +35,8 @@ public class CashController {
private final CashService cashService;
private final WxBankCodeService wxBankCodeService;
@Resource
private UserAppService userAppService;
@GetMapping({ "", "/v3" })
@ApiOperation(tags = { "页面-提现记录" }, value = "获取分页提现记录", notes = "返回分页过后的数据", httpMethod = "GET")
@ -91,4 +95,34 @@ public class CashController {
return ResultGenerator.genSuccessResult();
}
/**
* 下级相关
* @param
* @return
*/
@GetMapping("/subordinate")
public Result<Object> subordinate(@RequestParam("status") String status, @RequestParam("size") Integer size,
@RequestParam("page") Integer page){
UserApp tokenUa = userAppService.queryUserAppByToken();
List<Cash> subordinate = cashService.subordinate(tokenUa.getUserId().toString(),status, size, page);
return ResultGenerator.genSuccessResult(subordinate);
}
/**
* 提现审核
*/
@GetMapping ("/examine")
public Result<Object> examine(@RequestParam("id") Integer id,@RequestParam("status") String status,
@RequestParam("remark") String remark){
UserApp tokenUa = userAppService.queryUserAppByToken();
try {
Boolean aBoolean = cashService.modifyOutFlow(id, String.valueOf(tokenUa.getUserId()), status, remark);
if (aBoolean){
return ResultGenerator.genSuccessResult();
}
}catch (Exception e){
e.printStackTrace();
}
return ResultGenerator.genFailResult("");
}
}

View File

@ -21,6 +21,7 @@ import cn.pluss.platform.merchantIncome.MerchantIncomeService;
import cn.pluss.platform.merchantMenber.MerchantMenberService;
import cn.pluss.platform.merchantMenberRecharge.MerchantMenberRechargeService;
import cn.pluss.platform.merchantOrder.MerchantOrderService;
import cn.pluss.platform.merchantProfit.MerchantProfitService;
import cn.pluss.platform.notice.NoticeService;
import cn.pluss.platform.pay.PayService;
import cn.pluss.platform.pos.BasePosReq;
@ -54,8 +55,10 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
@ -534,17 +537,41 @@ public class MerchantOrderController {
}
@Resource
private MerchantProfitService profitService;
@PostMapping("/orderTest")
public Result<Object> orderTest(@RequestBody MerchantOrder merchantOrder){
UserApp tokenUa = userAppService.queryUserAppByToken();
merchantOrder.setOrderNumber("TEST"+StringUtil.getBillno());
merchantOrder.setOrderType("2");
merchantOrder.setMerchantCode(tokenUa.getMerchantCode());
merchantOrder.setMerchantName("尖愁");
merchantOrder.setPayTypeCode("wechatPay");
merchantOrder.setPayTypeName("微信");
merchantOrder.setStoreId("0ZZC7Q");
merchantOrder.setStoreName("尖愁");
merchantOrder.setTransDt(new Date());
merchantOrder.setCreateDt(new Date());
merchantOrder.setStatus("1");
merchantOrder.setEnterFee(merchantOrder.getConsumeFee());
merchantOrder.setAisleSwitch("0");
merchantOrder.setRate(new BigDecimal("38.00"));
merchantOrder.setSettlementType(1);
merchantOrder.setChannelRate(new BigDecimal("21.00"));
merchantOrder.setChannelFee(new BigDecimal("0.00"));
merchantOrder.setMercFee(new BigDecimal("0.00"));
boolean save = merchantOrderService.save(merchantOrder);
profitService.createOrderProfitV2(merchantOrder,"1");
if (save){
return ResultGenerator.genSuccessResult();
}else {
return ResultGenerator.genFailResult("失败");
}
}
/**
* 主扫会员支付

View File

@ -71,5 +71,8 @@ public interface CashMapper extends BaseMapper<Cash> {
* @return 提现总金额
*/
BigDecimal selectCashAmtTotal(@Param("userId") String userId, @Param("statusArr") int... statusArr);
List<Cash> subordinate(@Param("userId") Long userId, @Param("size") Integer size, @Param("page")Integer page,
@Param("status") String status);
}

View File

@ -217,4 +217,32 @@
</foreach>
</if>
</select>
<select id="subordinate" parameterType="java.lang.Long" resultType="cn.pluss.platform.entity.Cash">
SELECT
IF( v.accountNo='', '', CONCAT(LEFT(v.accountNo, 3), '****', RIGHT(v.accountNo,4))) AS accountNo,
v.*
FROM
(
SELECT
@ids AS _ids,
( SELECT @ids := GROUP_CONCAT( user_id ) FROM tb_pluss_user_promotion WHERE FIND_IN_SET( parent_user_id, @ids ) ) AS cids,
@l := @l + 1 AS LEVEL
FROM
tb_pluss_user_promotion,
( SELECT @ids := #{userId}, @l := 0 ) b
WHERE
@ids IS NOT NULL
) ID,
tb_pluss_user_promotion p
LEFT JOIN tb_pluss_cash v ON p.user_id = v.userId
WHERE
FIND_IN_SET( p.user_id, ID._ids )
AND v.userId != #{userId}
AND v.id IS NOT NULL
<if test="status != null and status !=''">
AND v.status = #{status}
</if>
limit #{page},#{size}
</select>
</mapper>

View File

@ -70,11 +70,11 @@ public class Cash {
private String updator;
private Integer type;
/**
* 备注
*/
@TableField(exist = false)
private String remark;
// /**
// * 备注
// */
// @TableField(exist = false)
// private String remark;
@TableField(exist = false)
private String phone;
@ -159,5 +159,8 @@ public class Cash {
@TableField("cashStatus")
private String cashStatus;
@TableField("remark")
private String remark;
}

View File

@ -125,5 +125,8 @@ public interface CashService extends IService<Cash> {
default BigDecimal getSumCheckingCashAmtTotal(@Param("userId") String userId) {
return ((CashMapper) getBaseMapper()).selectCashAmtTotal(userId, Cash.STATUS_CHECKING);
}
List<Cash> subordinate(String userId,String status,Integer size, Integer page);
Boolean modifyOutFlow(Integer id,String userId,String status, String remark) throws Exception;
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.DesensitizedUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import cn.pluss.platform.ali.AlipayService;
import cn.pluss.platform.cash.CashService;
@ -34,6 +35,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -46,6 +48,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service("cashService")
@ -89,6 +92,8 @@ public class CashServiceImpl extends ServiceImpl<CashMapper, Cash> implements Ca
@Resource
private MerchantProfitMapper mpMapper;
@Resource
private CashMapper cashMapper;
private void checkStatus(Integer userId) {
RiskBlacklist condition = new RiskBlacklist();
@ -371,7 +376,7 @@ public class CashServiceImpl extends ServiceImpl<CashMapper, Cash> implements Ca
cashStatus.setUserId(promotion.getUserId().toString());
cashStatus.setUserType(promotion.getTypeCode());
cashStatus.setStatus("0");
cashStatus.setLoginName(promotion.getLoginName());
cashStatus.setLoginName(promotion.getLoginName() == null?"null":promotion.getLoginName());
list.add(cashStatus);
promotion.setCashStatusVOList(list);
return list;
@ -612,5 +617,124 @@ public class CashServiceImpl extends ServiceImpl<CashMapper, Cash> implements Ca
public Map<String, Object> getCashCountData(Map<String, Object> params) {
return baseMapper.getCashCountData(params);
}
@Override
public List<Cash> subordinate(String userId,String status, Integer size, Integer page) {
page = page-1;
return cashMapper.subordinate(Long.valueOf(userId),size,page, status);
}
@Override
public Boolean modifyOutFlow(Integer id, String userId, String status, String remark) throws Exception {
Boolean flag=false;
if(ObjectUtil.isEmpty(id)||ObjectUtil.isEmpty(userId)||ObjectUtil.isEmpty(status)){
log.error("参数错误");
MsgException.checkNull(null,"参数错误");
}
Cash cash = getById(id);
if(ObjectUtil.isEmpty(cash)){
log.error("对应的提现信息不存在:{}",id);
MsgException.checkNull(null,"对应的提现信息不存在");
}
if(cash.getStatus()==1 || cash.getStatus()==2){
log.error("订单已处理完成: id :{}, status:{}",id,cash.getStatus());
MsgException.checkNull(null,"订单已处理完成");
}
UserPromotion promotion= userPromotionMapper.selectByUserId(userId);
if(ObjectUtil.isEmpty(promotion)){
log.error("审核员信息不存在");
MsgException.checkNull(null,"审核员信息不存在");
}
Map<String,CashStatusVO> map=new HashMap<>();
List<CashStatusVO> cashStatusList= JSONUtil.toList(new JSONArray(cash.getCashStatus()),CashStatusVO.class);
if(ObjectUtil.isEmpty(cashStatusList)||cashStatusList.size()<=0){
log.error("审核信息为空");
MsgException.checkNull(null,"审核信息为空");
}
for (CashStatusVO cashStatus : cashStatusList) {
map.put(cashStatus.getUserType(),cashStatus);
}
CashStatusVO cashStatus=null;
CashStatusVO upStatus=null;
switch (promotion.getTypeCode()){
case "AG":
cashStatus=map.get("AG");
upStatus=map.get("SO");
break;
case "SO":
cashStatus=map.get("AG");
upStatus=map.get("FO");
break;
case "FO":
cashStatus=map.get("SO");
upStatus=map.get("MG");
break;
case "MG":
cashStatus=map.get("FO");
upStatus=map.get("MG");
break;
}
// if(!userId.equals(cashStatus.getUserId().toString())){
// log.error("操作权限不足");
// return new RespBody("000025");
// }
if("0".equals(cashStatus.getStatus())){
log.error("请等待下级审核完成");
MsgException.checkNull(null,"请等待下级审核完成");
}
if("2".equals(cashStatus.getStatus())){
log.error("提现已被拒绝");
MsgException.checkNull(null,"提现已被拒绝");
}
if(!upStatus.getStatus().equals("0")){
log.error("已被上级审核");
MsgException.checkNull(null,"已被上级审核");
}
switch (status){
case "1":
cashStatusList.stream().filter(it->{
if(it.getUserId().toString().equals(userId))
it.setStatus("1");
return true;
}).collect(Collectors.toList());
if(promotion.getTypeCode().equals("MG")){
cash.setStatus(1);
}
cash.setCashStatus(JSONUtil.toJsonStr(cashStatusList));
break;
case "2":
cashStatusList.stream().filter(it->{
if(it.getUserId().toString().equals(userId))
it.setStatus("2");
return true;
}).collect(Collectors.toList());
cash.setStatus(2);
cash.setRemark(remark);
cash.setCashStatus(JSONUtil.toJsonStr(cashStatusList));
break;
default:
log.error("错误的操作类型");
MsgException.checkNull(null,"错误的操作类型");
}
updateById(cash);
flag=true;
return flag;
}
}

View File

@ -103,7 +103,12 @@ public class BankCardServiceImpl extends ServiceImpl<BankCardMapper, BankCard> i
d0Data.put("type", Account.CHANNEL_TYPE_D0);
d0Data.put("data", BankCard.desensitized(d0.getBankCard()));
if (MerchantChannelStatus.AUDIT_STATUS_DATA_EDIT.equals(mcs.getStatus())) {
BankCard edit = d0.getBak().toJavaObject(BankCard.class);
BankCard edit = null;
if (d0.getBak() != null) {
edit = d0.getBak().toJavaObject(BankCard.class);
}else {
edit = null;
}
d0Data.put("editData", BankCard.desensitized(edit));
}

View File

@ -409,22 +409,24 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
// }
// 如果不存在D0的结算信息则直接将D1的结算信息带过来
// LambdaQueryWrapper<Account> qWrapperAccountD1 = Wrappers.lambdaQuery();
// qWrapperAccountD1.eq(Account::getUserId, accountDTO.getUserId()).eq(Account::getChannelType, Account.CHANNEL_TYPE_D0);
// int count = baseMapper.selectCount(qWrapperAccountD1);
// if (count == 0) {
// account.setChannelType(Account.CHANNEL_TYPE_D0);
// save(account);
// }
// //TODO
// // 如果不存在D1的结算信息则直接将D0的结算信息带过来
// LambdaQueryWrapper<Account> qWrapperAccountD0 = Wrappers.lambdaQuery();
// qWrapperAccountD0.eq(Account::getUserId, accountDTO.getUserId()).eq(Account::getChannelType, Account.CHANNEL_TYPE_D1);
// int countD0 = baseMapper.selectCount(qWrapperAccountD0);
// if (countD0 == 0) {
// account.setChannelType(Account.CHANNEL_TYPE_D1);
// save(account);
// }
LambdaQueryWrapper<Account> qWrapperAccountD1New = Wrappers.lambdaQuery();
qWrapperAccountD1New.eq(Account::getUserId, accountDTO.getUserId()).eq(Account::getChannelType, Account.CHANNEL_TYPE_D0);
int countNew = baseMapper.selectCount(qWrapperAccountD1New);
if (countNew == 0) {
account.setChannelType(Account.CHANNEL_TYPE_D0);
account.setValid(0);
save(account);
}
//TODO
// 如果不存在D1的结算信息则直接将D0的结算信息带过来
LambdaQueryWrapper<Account> qWrapperAccountD0 = Wrappers.lambdaQuery();
qWrapperAccountD0.eq(Account::getUserId, accountDTO.getUserId()).eq(Account::getChannelType, Account.CHANNEL_TYPE_D1);
int countD0 = baseMapper.selectCount(qWrapperAccountD0);
if (countD0 == 0) {
account.setChannelType(Account.CHANNEL_TYPE_D1);
account.setValid(0);
save(account);
}
}
@Override

View File

@ -113,10 +113,7 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
}
MsgException.checkNull(userApp, "用户信息为空,分润创建失败");
log.info("【分润V2.0】当前交易用户ID:{},交易单号:{},交易用户角色:{},用户等级:{}", userApp.getUserId(), order.getOrderNumber(), userApp.getRoleCode(), userApp.getLevelCode());
if (StringUtil.isEmpty(userApp.getRoleCode()) || StringUtil.isEmpty(userApp.getLevelCode())) {
log.info("【分润V2.0】订单号为:{}当前交易角色为空 创建分润结束", order.getOrderNumber());
return;
}
order.setUserId(userApp.getUserId().intValue());
calcUserProfitV2(userApp, order, type);
}
@ -182,10 +179,18 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
}
UserApp nowUserApp = userAppMapper.selectByUserId(userId);
if(ObjectUtil.isEmpty(nowUserApp)){
log.error("订单号:{},分润结束,获取分润数为:{}",order.getOrderNumber(),profits.size());
return;
}
QueryWrapper<UserApp> queryWrapper=new QueryWrapper<>();
queryWrapper.eq("parentId",userPromotion.getParentUserId());
queryWrapper.eq("userId",userPromotion.getParentUserId());
UserApp pUserApp=userAppMapper.selectOne(queryWrapper);
if(ObjectUtil.isEmpty(pUserApp)){
log.error("订单号:{},分润结束,获取分润数为:{}",order.getOrderNumber(),profits.size());
return;
}
BigDecimal profitAmt = profitRate.divide(BigDecimal.valueOf(10000)).multiply(BigDecimal.valueOf(order.getConsumeFee())).setScale(4, BigDecimal.ROUND_DOWN);
MerchantProfit profit = new MerchantProfit(nowUserApp, pUserApp, order, profitAmt, profitRate, "1", "1");