分销员

This commit is contained in:
曹磊 2024-08-07 16:39:05 +08:00
parent c7af021f86
commit e10c9d9ce3
19 changed files with 766 additions and 103 deletions

View File

@ -251,4 +251,10 @@ public class UserEntity implements Serializable {
@TableField(exist = false)
private String jjrName;
private Integer blIsFxy;
private Integer blFxyLevel;
private String blFxyCode;
}

View File

@ -620,6 +620,30 @@ public class Orders implements Serializable {
* 经纪人姓名
*/
private String jjrUserName;
/**
* 一级分销员分佣
*/
private BigDecimal fxyOneMoney;
/**
* 一级分销员ID
*/
private Long fxyOneUserId;
/**
* 一级分销员姓名
*/
private String fxyOneUserName;
/**
* 二级分销员分佣
*/
private BigDecimal fxyTwoMoney;
/**
* 二级分销员ID
*/
private Long fxyTwoUserId;
/**
* 二级分销员姓名
*/
private String fxyTwoUserName;
public Orders() {}
}

View File

@ -30,6 +30,8 @@ import com.sqx.modules.artificer.dao.ArtificerDao;
import com.sqx.modules.artificer.dao.OrdersDao;
import com.sqx.modules.artificer.entity.*;
import com.sqx.modules.artificer.service.*;
import com.sqx.modules.bl.commission.fxy.entity.FxyApply;
import com.sqx.modules.bl.commission.fxy.entity.FxyConfig;
import com.sqx.modules.bl.order.entity.UserPackage;
import com.sqx.modules.bl.order.entity.UserPackageOrder;
import com.sqx.modules.bl.order.service.UserPackageOrderService;
@ -4636,6 +4638,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
orders.setProjectBenefits(artificerPrice);
//取配置
UserEntity artificerUser = userService.selectUserById(artificer.getUserId());
UserEntity jjrUser = userService.queryByInvitationCode(artificerUser.getBlJjrCode());
BigDecimal jjrMoney = BigDecimal.ZERO;
@ -6668,4 +6671,25 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
return Result.success(map);
}
public static void main(String[] args) {
FxyConfig fc = new FxyConfig();
fc.setIsOpen(1);
fc.setType(2);
fc.setOneRate(new BigDecimal(2.5));
fc.setTwoRate(new BigDecimal(2));
fc.setArtificerRate(new BigDecimal(10));
fc.setAgentRate(new BigDecimal(10));
fc.setMostRate(new BigDecimal(15));
fc.setOneRecommendRate(new BigDecimal(5));
fc.setTwoRecommendRate(new BigDecimal(5));
fc.setFxmLimit(2);
fc.setFxmLimitDays(100);
// FxyApply fa = new FxyApply();
// fa.setUserId();
// fa.setStatus();
// fa.setApproveTime();
}
}

View File

@ -7,6 +7,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -30,35 +31,23 @@ public class FxyDataController {
return service.invitationPage(fxyData);
}
@GetMapping("/userPage")
@ApiOperation("用户列表(分页)")
public Result userPage(FxyData fxyData){
return service.userPage(fxyData);
}
@GetMapping("/findOrderPage")
@ApiOperation("分销员订单(分页)")
public Result findOrderPage(FxyData fxyData){
return service.findOrderPage(fxyData);
}
//
// @GetMapping("/artificerPage")
// @ApiOperation("技师(分页)")
// public Result artificerPage(FxyData fxyData){
// return service.artificerPage(jjrData);
// }
//
// @PostMapping("/cancelInvitation")
// @ApiOperation("取消邀请技师")
// public Result cancelInvitation(FxyData fxyData){
// service.cancelInvitation(jjrData);
// return Result.success();
// }
//
// @GetMapping("/jjrList")
// @ApiOperation("经纪人列表")
// public Result jjrList(FxyData fxyData){
// return service.findJjrPage(jjrData);
// }
//
// @PostMapping("/modifyJjr")
// @ApiOperation("技师修改经纪人")
// public Result modifyJjr(FxyData fxyData){
// service.modifyJjr(jjrData);
// return Result.success();
// }
@PostMapping("/invitationUser")
@ApiOperation("邀请用户")
public Result invitationUser(FxyData fxyData){
service.invitationUser(fxyData);
return Result.success();
}
}

View File

@ -2,20 +2,18 @@ package com.sqx.modules.bl.commission.fxy.controller.app;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.bl.commission.fxy.entity.FxyApply;
import com.sqx.modules.bl.commission.fxy.entity.FxyConfig;
import com.sqx.modules.bl.commission.fxy.entity.FxyData;
import com.sqx.modules.bl.commission.fxy.service.FxyApplyService;
import com.sqx.modules.bl.commission.fxy.service.FxyConfigService;
import com.sqx.modules.bl.commission.fxy.service.FxyDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/app/commission/fxy")
@ -25,10 +23,75 @@ public class AppFxyController {
@Autowired
private FxyApplyService service;
@Autowired
private FxyDataService dataService;
@Autowired
private FxyConfigService configService;
@PostMapping("/fxyConfig")
@ApiOperation("获取分销员配置")
public Result fxyConfig(){
return Result.success().put("data",configService.getOne(new QueryWrapper<FxyConfig>()));
}
@PostMapping("/apply")
@ApiOperation("申请分销员")
public Result apply(FxyApply fxyApply){
service.add(fxyApply);
return Result.success();
}
/**
* 可提现累计佣金已提现未入账今日成交订单累计成交订单今日邀请粉丝累计邀请粉丝
*/
@Login
@GetMapping("/myFxy")
@ApiOperation("我是分销员")
public Result myJjr(@RequestAttribute Long userId){
return dataService.myJjr(userId);
}
/**
* 我的收益-收益明细
*/
@Login
@GetMapping("/incomeDetail")
@ApiOperation("我的收益")
public Result incomeDetail(@RequestAttribute Long userId, Integer page, Integer limit){
return dataService.incomeDetail(userId,page,limit);
}
/**
* 提现记录-提现明细
*/
@Login
@GetMapping("/withdrawalDetail")
@ApiOperation("我的提现")
public Result withdrawalDetail(@RequestAttribute Long userId, Integer page, Integer limit){
return dataService.withdrawalDetail(userId,page,limit);
}
/**
* 我的邀请-明细
*/
@Login
@GetMapping("/invitationDetail")
@ApiOperation("我的邀请")
public Result invitationDetail(@RequestAttribute Long userId, Integer page, Integer limit){
FxyData fxyData = dataService.getByUserId(userId);
fxyData.setPage(page);
fxyData.setLimit(limit);
return dataService.invitationDetailPage(fxyData);
}
/**
* 邀请海报
*/
@GetMapping("/poster")
@ApiOperation("邀请海报")
public Result poster(){
FxyConfig entity = configService.getOne(new QueryWrapper<FxyConfig>());
return Result.success().put("data",entity);
}
}

View File

@ -10,6 +10,7 @@ import org.apache.ibatis.annotations.Param;
@Mapper
public interface FxyApplyDao extends BaseMapper<FxyApply> {
IPage<FxyApply> findPage(Page<FxyApply> page, @Param("params") FxyApply fxyApply);
FxyApply findByUserId(Long userId);
int add(FxyApply fxyApply);
int update(FxyApply fxyApply);
int approve(FxyApply fxyApply);

View File

@ -10,8 +10,14 @@ import org.apache.ibatis.annotations.Param;
@Mapper
public interface FxyDataDao extends BaseMapper<FxyData> {
IPage<FxyData> findPage(Page<FxyData> page, @Param("params") FxyData fxyData);
IPage<FxyData> invitationPage(Page<FxyData> page, @Param("params") FxyData fxyData);
IPage<FxyData> invitationFxyPage(Page<FxyData> page, @Param("params") FxyData fxyData);
IPage<FxyData> invitationUserPage(Page<FxyData> page, @Param("params") FxyData fxyData);
IPage<FxyData> oneFxyPage(Page<FxyData> page, @Param("params") FxyData fxyData);
IPage<FxyData> userPage(Page<FxyData> page, @Param("params") FxyData fxyData);
IPage<FxyData> findOrderPage(Page<FxyData> page, @Param("params") FxyData fxyData);
IPage<FxyData> invitationDetailPage(Page<FxyData> page, @Param("params") FxyData fxyData);
FxyData findFxy(FxyData fxyData);
void invitationUser(FxyData fxyData);
FxyData getByUserId(Long userId);
}

View File

@ -56,6 +56,16 @@ public class FxyData implements Serializable {
*/
@TableField(exist = false)
private String userName;
/**
*类型
*/
@TableField(exist = false)
private String type;
/**
*是否是分销员 1是 0否
*/
@TableField(exist = false)
private Integer blIsFxy;
/**
*分销员等级
*/

View File

@ -6,6 +6,7 @@ import com.sqx.modules.bl.commission.fxy.entity.FxyApply;
public interface FxyApplyService extends IService<FxyApply> {
Result findPage(FxyApply fxyApply);
FxyApply findByUserId(Long userId);
int add(FxyApply fxyApply);
int update(FxyApply fxyApply);
int approve(FxyApply fxyApply);

View File

@ -6,6 +6,14 @@ import com.sqx.modules.bl.commission.fxy.entity.FxyData;
public interface FxyDataService extends IService<FxyData> {
Result findPage(FxyData fxyData);
Result myJjr(Long userId);
Result invitationPage(FxyData fxyData);
Result userPage(FxyData fxyData);
Result findOrderPage(FxyData fxyData);
Result incomeDetail(Long userId,Integer page, Integer limit);
Result invitationDetailPage(FxyData fxyData);
Result withdrawalDetail(Long userId,Integer page, Integer limit);
void invitationUser(FxyData fxyData);
FxyData getByUserId(Long userId);
}

View File

@ -23,6 +23,11 @@ public class FxyApplyServiceImpl extends ServiceImpl<FxyApplyDao, FxyApply> impl
return Result.success().put("data",new PageUtils(baseMapper.findPage(pages,fxyApply)));
}
@Override
public FxyApply findByUserId(Long userId){
return baseMapper.findByUserId(userId);
}
@Override
public int add(FxyApply fxyApply){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

View File

@ -12,11 +12,7 @@ import com.sqx.modules.artificer.entity.Period;
import com.sqx.modules.bl.commission.fxy.dao.FxyDataDao;
import com.sqx.modules.bl.commission.fxy.entity.FxyData;
import com.sqx.modules.bl.commission.fxy.service.FxyDataService;
import com.sqx.modules.bl.commission.jjr.dao.JjrDataDao;
import com.sqx.modules.bl.commission.jjr.entity.JjrConfig;
import com.sqx.modules.bl.commission.jjr.entity.JjrData;
import com.sqx.modules.bl.commission.jjr.service.JjrConfigService;
import com.sqx.modules.bl.commission.jjr.service.JjrDataService;
import com.sqx.modules.utils.PeriodUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -30,18 +26,100 @@ import java.util.Map;
@Service
public class FxyDataServiceImpl extends ServiceImpl<FxyDataDao, FxyData> implements FxyDataService {
@Autowired
private UserMoneyDetailsService userMoneyDetailsService;
@Override
public Result findPage(FxyData fxyData){
Page<FxyData> pages=new Page<>(fxyData.getPage(),fxyData.getLimit());
return Result.success().put("data",new PageUtils(baseMapper.findPage(pages,fxyData)));
}
@Override
public Result myJjr(Long userId){
Map<String,Object> result=new HashMap<>();
//可提现
Date CurrentPeriod = new Date();//获取当前时间
//获取当前时间周期的上一个周期
Period periodDate= PeriodUtil.previousIssue(CurrentPeriod);
Period period = new Period();
period.setArtificerId(String.valueOf(userId));
period.setDetailsType(1);
period.setEndFundData(periodDate.getEndFundData());
period.setFundType(5);//分销员
List<UserMoneyDetails> filteredPersons = userMoneyDetailsService.selectIncome(period);
//进账
double incomeLong= filteredPersons.stream()
.filter(UserMoneyDetails -> UserMoneyDetails.getType() == 1)
.filter(UserMoneyDetails -> UserMoneyDetails.getState() == 2)
.mapToDouble(UserMoneyDetails -> UserMoneyDetails.getMoney().doubleValue())
.sum();
//出账
double outgoingLong= filteredPersons.stream()
.filter(UserMoneyDetails -> UserMoneyDetails.getType() == 2)
.filter(UserMoneyDetails -> UserMoneyDetails.getState() == 2)
.filter(UserMoneyDetails -> !UserMoneyDetails.getContent().contains("管理端减少"))
.mapToDouble(UserMoneyDetails -> UserMoneyDetails.getMoney().doubleValue())
.sum();
BigDecimal incomeMoney= BigDecimal.valueOf(incomeLong).setScale(2,BigDecimal.ROUND_HALF_UP);
BigDecimal outgoingMoney = BigDecimal.valueOf(outgoingLong).setScale(2,BigDecimal.ROUND_HALF_UP);
BigDecimal withdrawableAmount = incomeMoney.subtract(outgoingMoney).setScale(2,BigDecimal.ROUND_HALF_UP);
result.put("withdrawableAmount",withdrawableAmount);//可提现金额
//累计佣金
Period period2 = new Period();
period2.setArtificerId(String.valueOf(userId));
period2.setDetailsType(1);
period2.setFundType(5);//分销员
List<UserMoneyDetails> filteredPersons2 = userMoneyDetailsService.selectIncome(period2);
double income= filteredPersons2.stream()
.filter(UserMoneyDetails -> UserMoneyDetails.getType() == 1)
.filter(UserMoneyDetails -> UserMoneyDetails.getState() == 2)
.mapToDouble(UserMoneyDetails -> UserMoneyDetails.getMoney().doubleValue())
.sum();
result.put("income",income);//累计佣金
//已提现金额
double withdrawal= filteredPersons2.stream()
.filter(UserMoneyDetails -> UserMoneyDetails.getType() == 2)
.filter(UserMoneyDetails -> UserMoneyDetails.getState() == 2)
.filter(UserMoneyDetails -> UserMoneyDetails.getClassify() == 3)
.mapToDouble(UserMoneyDetails -> UserMoneyDetails.getMoney().doubleValue())
.sum();
result.put("withdrawal",withdrawal);//已提现金额
double notCredited = filteredPersons2.stream()
.filter(UserMoneyDetails -> UserMoneyDetails.getType() == 1)
.filter(UserMoneyDetails -> UserMoneyDetails.getState() == 1)
.mapToDouble(UserMoneyDetails -> UserMoneyDetails.getMoney().doubleValue())
.sum();
result.put("notCredited",notCredited);//未入账
FxyData fxyData = new FxyData();
fxyData.setUserId(userId);
fxyData = baseMapper.findFxy(fxyData);
result.put("curOrdersCount",fxyData.getCurOrdersCount());//今日成交订单
result.put("ordersCount",fxyData.getOrdersCount());//累计成交订单
result.put("curUserCount",fxyData.getCurUserCount());//今日新增粉丝
result.put("userCount",fxyData.getUserCount());//累计粉丝
return Result.success().put("data",result);
}
@Override
public Result invitationPage(FxyData fxyData){
Page<FxyData> pages=new Page<>(fxyData.getPage(),fxyData.getLimit());
IPage<FxyData> iPage = null;
if(fxyData.getFlag().equals("1")){
iPage = baseMapper.invitationPage(pages,fxyData);
iPage = baseMapper.invitationFxyPage(pages,fxyData);
}else{
iPage = baseMapper.invitationUserPage(pages,fxyData);
}
return Result.success().put("data",new PageUtils(iPage));
}
@Override
public Result userPage(FxyData fxyData){
Page<FxyData> pages=new Page<>(fxyData.getPage(),fxyData.getLimit());
IPage<FxyData> iPage = null;
if(fxyData.getFlag().equals("1")){
iPage = baseMapper.oneFxyPage(pages,fxyData);
}else{
iPage = baseMapper.userPage(pages,fxyData);
}
@ -54,4 +132,49 @@ public class FxyDataServiceImpl extends ServiceImpl<FxyDataDao, FxyData> impleme
return Result.success().put("data",new PageUtils(baseMapper.findOrderPage(pages,fxyData)));
}
@Override
public Result incomeDetail(Long userId,Integer page, Integer limit){
QueryWrapper<UserMoneyDetails> queryWrapper = new QueryWrapper();
queryWrapper.eq("user_id", userId);
queryWrapper.eq("bl_role", 5);//分销员
queryWrapper.eq("type", 1);
queryWrapper.eq("state", 2);
queryWrapper.eq("manipulate_type", 2);
queryWrapper.orderByDesc("create_time");
Page<UserMoneyDetails> pages = new Page<>(page, limit);
PageUtils pageUtils = new PageUtils(userMoneyDetailsService.page(pages,queryWrapper));
return Result.success().put("data", pageUtils);
}
@Override
public Result invitationDetailPage(FxyData fxyData){
Page<FxyData> pages=new Page<>(fxyData.getPage(),fxyData.getLimit());
return Result.success().put("data",new PageUtils(baseMapper.invitationDetailPage(pages,fxyData)));
}
@Override
public Result withdrawalDetail(Long userId,Integer page, Integer limit){
QueryWrapper<UserMoneyDetails> queryWrapper = new QueryWrapper();
queryWrapper.eq("user_id", userId);
queryWrapper.eq("classify", 3);
queryWrapper.eq("type", 2);
queryWrapper.eq("state", 2);
queryWrapper.eq("bl_role", 5);//分销员
queryWrapper.eq("manipulate_type", 2);
queryWrapper.orderByDesc("create_time");
Page<UserMoneyDetails> pages = new Page<>(page, limit);
PageUtils pageUtils = new PageUtils(userMoneyDetailsService.page(pages,queryWrapper));
return Result.success().put("data", pageUtils);
}
@Override
public void invitationUser(FxyData fxyData){
baseMapper.invitationUser(fxyData);
}
@Override
public FxyData getByUserId(Long userId){
return baseMapper.getByUserId(userId);
}
}

View File

@ -28,6 +28,8 @@ import com.sqx.modules.artificer.dao.OrdersDao;
import com.sqx.modules.artificer.dao.UserRechargeDao;
import com.sqx.modules.artificer.entity.*;
import com.sqx.modules.artificer.service.*;
import com.sqx.modules.bl.commission.fxy.entity.FxyApply;
import com.sqx.modules.bl.commission.fxy.service.FxyApplyService;
import com.sqx.modules.bl.massage.entity.MassagePackage;
import com.sqx.modules.bl.massage.service.MassagePackageService;
import com.sqx.modules.bl.order.dao.UserPackageOrderDao;
@ -149,6 +151,8 @@ public class AliPayController {
private UserSadDetailsService userSadDetailsService;
@Autowired
private BlSadJobService blSadJobService;
@Autowired
private FxyApplyService fxyApplyService;
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ -1262,6 +1266,35 @@ public class AliPayController {
massagePackage.setSales(sales);
massagePackageService.updateSales(massagePackage);
}
}else if (payDetails.getType() == 9) {
//缴纳门槛费
Double cashDeposit = payDetails.getMoney();
Long userId = payDetails.getUserId();
Integer level = Integer.valueOf(payDetails.getRemark());
Long id = Long.valueOf(payDetails.getOrderId());
FxyApply fxyApply = new FxyApply();
fxyApply.setId(id);
fxyApply.setStatus(1);
fxyApply.setOpinion("自动授权");
fxyApplyService.approve(fxyApply);
//交缴纳门槛费记录
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
userMoneyDetails.setUserId(userId);
userMoneyDetails.setTitle("缴纳分销商门槛费");
userMoneyDetails.setContent("已缴分销商门槛费:" + cashDeposit + "");
userMoneyDetails.setManipulateType(1);
userMoneyDetails.setMoney(BigDecimal.valueOf(cashDeposit));
userMoneyDetails.setType(2);
userMoneyDetails.setState(2);
userMoneyDetails.setClassify(1);
userMoneyDetails.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
userMoneyDetails.setBlRole(5);
userMoneyDetails.setBlFlag(2);
userMoneyDetailsService.save(userMoneyDetails);
UserEntity userEntity = userService.selectUserById(userId);
userEntity.setBlIsFxy(1);
userEntity.setBlFxyLevel(level);
userService.updateById(userEntity);
}
}
} else {
@ -2711,6 +2744,35 @@ public class AliPayController {
massagePackage.setSales(sales);
massagePackageService.updateSales(massagePackage);
}
}else if (payDetails.getType() == 9) {
//缴纳门槛费
Double cashDeposit = payDetails.getMoney();
Long userId = payDetails.getUserId();
Integer level = Integer.valueOf(payDetails.getRemark());
Long id = Long.valueOf(payDetails.getOrderId());
FxyApply fxyApply = new FxyApply();
fxyApply.setId(id);
fxyApply.setStatus(1);
fxyApply.setOpinion("自动授权");
fxyApplyService.approve(fxyApply);
//交缴纳门槛费记录
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
userMoneyDetails.setUserId(userId);
userMoneyDetails.setTitle("缴纳分销商门槛费");
userMoneyDetails.setContent("已缴分销商门槛费:" + cashDeposit + "");
userMoneyDetails.setManipulateType(1);
userMoneyDetails.setMoney(BigDecimal.valueOf(cashDeposit));
userMoneyDetails.setType(2);
userMoneyDetails.setState(2);
userMoneyDetails.setClassify(1);
userMoneyDetails.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
userMoneyDetails.setBlRole(5);
userMoneyDetails.setBlFlag(2);
userMoneyDetailsService.save(userMoneyDetails);
UserEntity userEntity = userService.selectUserById(userId);
userEntity.setBlIsFxy(1);
userEntity.setBlFxyLevel(level);
userService.updateById(userEntity);
}
}
}
@ -3005,6 +3067,44 @@ public class AliPayController {
return null;
}
@Login
@ApiOperation("支付分销员门槛费")
@RequestMapping(value = "/payFxyMoney", method = RequestMethod.POST)
@Transactional(rollbackFor = Exception.class)
public Result payFxyMoney(@RequestAttribute Long userId, Integer level, Double money, String name, String phone, String remarks, Integer classify) {
//通知页面地址
CommonInfo one = commonInfoService.findOne(19);
String returnUrl = one.getValue() + "/pages/my/index";
CommonInfo one3 = commonInfoService.findOne(12);
String title = one3.getValue();
String generalOrder = getGeneralOrder();
FxyApply fxyApply = fxyApplyService.findByUserId(userId);
if(fxyApply==null){
fxyApply = new FxyApply();
fxyApply.setUserId(userId);
fxyApply.setName(name);
fxyApply.setPhone(phone);
fxyApply.setRemarks(remarks);
fxyApplyService.add(fxyApply);
}
PayDetails payDetails = new PayDetails();
payDetails.setState(0);
payDetails.setCreateTime(sdf.format(new Date()));
payDetails.setOrderId(generalOrder);
payDetails.setUserId(userId);
payDetails.setMoney(money);
payDetails.setClassify(6);
payDetails.setOrderId(String.valueOf(fxyApply.getId()));
payDetails.setRemark(String.valueOf(level));
payDetails.setType(9);
payDetailsDao.insert(payDetails);
// if (type == 1) {
// return payApp(title, generalOrder, money);
// } else {
// return payH5(title, generalOrder, money, returnUrl);
// }
payOrderResult(generalOrder);
return Result.success();
}
}

View File

@ -63,6 +63,12 @@ public class ApiWeiXinPayController {
return wxService.payGroupOrders(ordersId,type,request);
}
@Login
@ApiOperation("微信app支付分销门槛费")
@PostMapping("/payFxyMoney")
public Result payFxyMoney(@RequestAttribute Long userId,Integer level, Double money, String name, String phone, String remarks,Integer type,HttpServletRequest request) throws Exception {
return wxService.payFxyMoney(userId,level,money,name,phone,remarks,type,request);
}
@Login
@ApiOperation("缴纳保证金")

View File

@ -30,6 +30,8 @@ public interface WxService {
String payBacks(String resXml, Integer type);
Result payFxyMoney(Long userId,Integer level, Double money, String name, String phone, String remarks,Integer type,HttpServletRequest request) throws Exception;
Result submitRealName(Long userId, Integer type,HttpServletRequest request) throws Exception;
Result payUserVip( Long userId, Long vipDetailsId,Integer type,HttpServletRequest request) throws Exception;

View File

@ -18,6 +18,8 @@ import com.sqx.modules.artificer.dao.RealNameDao;
import com.sqx.modules.artificer.dao.UserRechargeDao;
import com.sqx.modules.artificer.entity.*;
import com.sqx.modules.artificer.service.*;
import com.sqx.modules.bl.commission.fxy.entity.FxyApply;
import com.sqx.modules.bl.commission.fxy.service.FxyApplyService;
import com.sqx.modules.bl.massage.entity.MassagePackage;
import com.sqx.modules.bl.massage.service.MassagePackageService;
import com.sqx.modules.bl.order.dao.UserPackageOrderDao;
@ -141,6 +143,8 @@ public class WxServiceImpl implements WxService {
private UserSadDetailsService userSadDetailsService;
@Autowired
private BlSadJobService blSadJobService;
@Autowired
private FxyApplyService fxyApplyService;
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ -1033,6 +1037,34 @@ public class WxServiceImpl implements WxService {
return Result.success();
}
@Override
public Result payFxyMoney(Long userId, Integer level, Double money, String name, String phone, String remarks,Integer type,HttpServletRequest request) throws Exception{
FxyApply fxyApply = fxyApplyService.findByUserId(userId);
if(fxyApply==null){
fxyApply = new FxyApply();
fxyApply.setUserId(userId);
fxyApply.setName(name);
fxyApply.setPhone(phone);
fxyApply.setRemarks(remarks);
fxyApplyService.add(fxyApply);
}
String generalOrder = getGeneralOrder();
PayDetails payDetails = new PayDetails();
payDetails.setState(0);
payDetails.setCreateTime(sdf.format(new Date()));
payDetails.setOrderId(generalOrder);
payDetails.setUserId(userId);
payDetails.setMoney(money);
payDetails.setClassify(type);
payDetails.setOrderId(String.valueOf(fxyApply.getId()));
payDetails.setRemark(String.valueOf(level));
payDetails.setType(9);
payDetailsDao.insert(payDetails);
// return pays(money, type,userId, generalOrder,request);
payOrderResult(generalOrder);
return Result.success();
}
@Override
public Result submitRealName( Long userId,Integer type,HttpServletRequest request) throws Exception {
CommonInfo two = commonInfoService.findOne(241);
@ -1382,7 +1414,6 @@ public class WxServiceImpl implements WxService {
public void payOrderResult(String out_trade_no) {
try {
//验证签名是否有效有效则进一步处理
log.error("验证成功222");
if (out_trade_no != null) {
// 注意特殊情况订单已经退款但收到了支付结果成功的通知不应把商户的订单状态从退款改成支付成功
@ -2170,18 +2201,44 @@ public class WxServiceImpl implements WxService {
massagePackage.setSales(sales);
massagePackageService.updateSales(massagePackage);
}
}else if (payDetails.getType() == 9) {
//缴纳门槛费
Double cashDeposit = payDetails.getMoney();
Long userId = payDetails.getUserId();
Integer level = Integer.valueOf(payDetails.getRemark());
Long id = Long.valueOf(payDetails.getOrderId());
FxyApply fxyApply = new FxyApply();
fxyApply.setId(id);
fxyApply.setStatus(1);
fxyApply.setOpinion("自动授权");
fxyApplyService.approve(fxyApply);
//交缴纳门槛费记录
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
userMoneyDetails.setUserId(userId);
userMoneyDetails.setTitle("缴纳分销商门槛费");
userMoneyDetails.setContent("已缴分销商门槛费:" + cashDeposit + "");
userMoneyDetails.setManipulateType(1);
userMoneyDetails.setMoney(BigDecimal.valueOf(cashDeposit));
userMoneyDetails.setType(2);
userMoneyDetails.setState(2);
userMoneyDetails.setClassify(1);
userMoneyDetails.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
userMoneyDetails.setBlRole(5);
userMoneyDetails.setBlFlag(2);
userMoneyDetailsService.save(userMoneyDetails);
UserEntity userEntity = userService.selectUserById(userId);
userEntity.setBlIsFxy(1);
userEntity.setBlFxyLevel(level);
userService.updateById(userEntity);
}
}
System.err.println("微信手机支付回调成功订单号:" + out_trade_no + "");
} else {
System.err.println("微信手机支付回调成功订单号:" + out_trade_no + "");
}
} catch (Exception e) {
System.err.println("手机支付回调通知失败" + e);
}
}
@Override
@ -2938,6 +2995,35 @@ public class WxServiceImpl implements WxService {
massagePackage.setSales(sales);
massagePackageService.updateSales(massagePackage);
}
}else if (payDetails.getType() == 9) {
//缴纳门槛费
Double cashDeposit = payDetails.getMoney();
Long userId = payDetails.getUserId();
Integer level = Integer.valueOf(payDetails.getRemark());
Long id = Long.valueOf(payDetails.getOrderId());
FxyApply fxyApply = new FxyApply();
fxyApply.setId(id);
fxyApply.setStatus(1);
fxyApply.setOpinion("自动授权");
fxyApplyService.approve(fxyApply);
//交缴纳门槛费记录
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
userMoneyDetails.setUserId(userId);
userMoneyDetails.setTitle("缴纳分销商门槛费");
userMoneyDetails.setContent("已缴分销商门槛费:" + cashDeposit + "");
userMoneyDetails.setManipulateType(1);
userMoneyDetails.setMoney(BigDecimal.valueOf(cashDeposit));
userMoneyDetails.setType(2);
userMoneyDetails.setState(2);
userMoneyDetails.setClassify(1);
userMoneyDetails.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
userMoneyDetails.setBlRole(5);
userMoneyDetails.setBlFlag(2);
userMoneyDetailsService.save(userMoneyDetails);
UserEntity userEntity = userService.selectUserById(userId);
userEntity.setBlIsFxy(1);
userEntity.setBlFxyLevel(level);
userService.updateById(userEntity);
}
}
System.err.println("微信手机支付回调成功订单号:" + out_trade_no + "");

View File

@ -29,6 +29,13 @@
order by id desc
</select>
<select id="findByUserId" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyApply">
select a.id,a.user_id,a.name,a.phone,a.remarks,a.create_time,a.status,a.opinion
from bl_fxy_apply a
where user_id = #{userId}
limit 1
</select>
<insert id="add" useGeneratedKeys="true" keyProperty="id" parameterType="com.sqx.modules.bl.commission.fxy.entity.FxyApply">
insert into bl_fxy_apply(user_id,name,phone,remarks,create_time)
values(#{userId},#{name},#{phone},#{remarks},#{createTime})

View File

@ -93,7 +93,7 @@
order by x.id desc
</select>
<select id="invitationPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
<select id="invitationFxyPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
select a.id,a.user_id,b.avatar,b.user_name,a.name,a.phone,a.remarks,a.create_time
from bl_fxy_apply a
inner join tb_user b on a.user_id = b.user_id
@ -107,7 +107,7 @@
order by a.user_id desc
</select>
<select id="userPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
<select id="invitationUserPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
select b.user_id,b.avatar,b.user_name as name,b.phone
from tb_user b
where b.bl_fxy_code = #{params.invitationCode}
@ -121,6 +121,36 @@
order by b.user_id desc
</select>
<select id="oneFxyPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
select a.id,a.user_id,b.avatar,b.user_name,a.name,a.phone,a.remarks,a.create_time
from bl_fxy_apply a
inner join tb_user b on a.user_id = b.user_id
where ifnull(b.bl_fxy_code,'') != #{params.invitationCode}
and b.bl_fxy_level = 1
and b.user_id != #{params.userId}
<if test="params.name!=null and params.name!=''">
and a.name like concat('%',#{params.name},'%')
</if>
<if test="params.phone!=null and params.phone!=''">
and a.phone like concat('%',#{params.phone},'%')
</if>
order by a.user_id desc
</select>
<select id="userPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
select b.user_id,b.avatar,b.user_name as name,b.phone
from tb_user b
where ifnull(b.bl_fxy_code,'') != #{params.invitationCode}
and b.bl_is_fxy = 0
<if test="params.name!=null and params.name!=''">
and b.user_name like concat('%',#{params.name},'%')
</if>
<if test="params.phone!=null and params.phone!=''">
and b.phone like concat('%',#{params.phone},'%')
</if>
order by b.user_id desc
</select>
<select id="findOrderPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
select a.id,a.user_id,b.avatar,a.name,a.phone,c.trade_no,c.money,c.pay_time,b.bl_fxy_level
from bl_fxy_apply a
@ -143,4 +173,176 @@
order by b.user_id desc
</select>
<select id="invitationDetailPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
select b.user_id,b.avatar,b.user_name,b.phone,
(case when b.bl_is_fxy = 0 then '用户' else '分销员' end) as type
from tb_user b
where b.bl_fxy_code= #{params.invitationCode}
<if test="params.name!=null and params.name!=''">
and b.user_name like concat('%',#{params.name},'%')
</if>
<if test="params.phone!=null and params.phone!=''">
and b.phone like concat('%',#{params.phone},'%')
</if>
<if test="params.blIsFxy!=null">
and b.bl_is_fxy = #{params.blIsFxy}
</if>
order by b.user_id desc
</select>
<select id="findFxy" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
select
x.id,x.user_id,y.avatar,y.user_name,x.name,x.phone,x.remarks,x.create_time,x.status,x.opinion,y.invitation_code,x.approve_time,
ifnull(select count(*) from tb_user ac where ac.bl_fxy_code = y.invitation_code,0) as userCount,
ifnull(select count(*)
from tb_user ac
where ac.bl_fxy_code = y.invitation_code
and date_format(aa.create_time, '%Y-%m-%d') = date_format(now(),'%Y-%m-%d'),0
) as curUserCount,
ifnull(t1.ordersCount,0)+ifnull(t2.ordersCount,0) as ordersCount,
ifnull(t4.ordersCount,0)+ifnull(t5.ordersCount,0) as curOrdersCount,
ifnull(t3.money,0) as money
from bl_fxy_apply x
inner join tb_user y on x.user_id = y.user_id
left join (
select count(*) as ordersCount, aa.user_id, bb.bl_fxy_code
from (
select o1.orders_id,o1.user_id
from orders o1
left join orders o2 on o1.old_orders_id = o2.orders_id and o2.status != 4
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
where o1.old_orders_id is not null
and o1.status in (3,5)
union all
select o1.orders_id,o1.user_id
from orders o1
where o1.parent_id = 0
and o1.old_orders_id is null
and o1.orders_id not in (
select orders_id from orders
where old_orders_id is not null
and status != 4
)
and o1.orders_id not in (
select old_orders_id from orders
where old_orders_id is not null
and status != 4
)
and o1.status in (3,5)
) aa inner join tb_user bb on aa.user_id = bb.user_id
group by aa.user_id, bb.bl_fxy_code
) t1 on t1.bl_fxy_code = y.invitation_code
left join (
select count(*) as ordersCount,cc.bl_fxy_code
from (
select o1.orders_id,o1.user_id
from orders o1
left join orders o2 on o1.old_orders_id = o2.orders_id and o2.status != 4
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
where o1.old_orders_id is not null
and o1.status in (3,5)
union all
select o1.orders_id,o1.user_id
from orders o1
where o1.parent_id = 0
and o1.old_orders_id is null
and o1.orders_id not in (
select orders_id from orders
where old_orders_id is not null
and status != 4
)
and o1.orders_id not in (
select old_orders_id from orders
where old_orders_id is not null
and status != 4
)
and o1.status in (3,5)
) aa inner join tb_user bb on aa.user_id = bb.user_id
inner join tb_user cc on cc.invitation_code = bb.bl_fxy_code
group by cc.bl_fxy_code
) t2 on t2.bl_fxy_code = y.invitation_code
left join (
select count(*) as ordersCount, aa.user_id, bb.bl_fxy_code
from (
select o1.orders_id,o1.user_id
from orders o1
left join orders o2 on o1.old_orders_id = o2.orders_id and o2.status != 4
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
where o1.old_orders_id is not null
and o1.status in (3,5)
and date_format(o1.serve_time, '%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
union all
select o1.orders_id,o1.user_id
from orders o1
where o1.parent_id = 0
and o1.old_orders_id is null
and o1.orders_id not in (
select orders_id from orders
where old_orders_id is not null
and status != 4
)
and o1.orders_id not in (
select old_orders_id from orders
where old_orders_id is not null
and status != 4
)
and o1.status in (3,5)
and date_format(o1.serve_time, '%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
) aa inner join tb_user bb on aa.user_id = bb.user_id
group by aa.user_id, bb.bl_fxy_code
) t4 on t4.bl_fxy_code = y.invitation_code
left join (
select count(*) as ordersCount,cc.bl_fxy_code
from (
select o1.orders_id,o1.user_id
from orders o1
left join orders o2 on o1.old_orders_id = o2.orders_id and o2.status != 4
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
where o1.old_orders_id is not null
and o1.status in (3,5)
and date_format(o1.serve_time, '%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
union all
select o1.orders_id,o1.user_id
from orders o1
where o1.parent_id = 0
and o1.old_orders_id is null
and o1.orders_id not in (
select orders_id from orders
where old_orders_id is not null
and status != 4
)
and o1.orders_id not in (
select old_orders_id from orders
where old_orders_id is not null
and status != 4
)
and o1.status in (3,5)
and date_format(o1.serve_time, '%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
) aa inner join tb_user bb on aa.user_id = bb.user_id
inner join tb_user cc on cc.invitation_code = bb.bl_fxy_code
group by cc.bl_fxy_code
) t5 on t5.bl_fxy_code = y.invitation_code
left join (
select sum(money) money,user_id
from user_money_details
where state = 2
and type = 1
group by user_id
) t3 on t3.user_id = x.user_id
where x.status= 1
and x.user_id = #{userId}
</select>
<update id="invitationUser" parameterType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
update tb_user
set bl_fxy_code=#{invitationCode}
where user_id=#{userId}
</update>
<select id="getByUserId" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
select user_id,avatar,user_name,phone,create_time,status,invitation_code
from tb_user
where user_id = #{userId}
</select>
</mapper>