临时提交

This commit is contained in:
墨大叔 2024-09-26 16:19:56 +08:00
parent ef87631b5c
commit 877715ae43
12 changed files with 151 additions and 33 deletions

View File

@ -26,13 +26,10 @@ public enum BonusArrivalType {
private final String msg;
public static BonusArrivalType parseByUserType(String type) {
if (UserType.MCH.equalsType(type)) {
return MCH;
}
if (UserType.AGENT.equalsType(type)) {
return AGENT;
}
return null;
return MCH;
}
public static BonusArrivalType parseByDept(SysDept dept) {

View File

@ -61,8 +61,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item}
</foreach>
</if>
${query.params.dataScope}
${@com.ruoyi.common.utils.DataScopeUtil@dataScopeDept("sd", query.needScope)}
</sql>
<select id="selectBonusList" parameterType="BonusQuery" resultMap="BonusResult">
@ -288,13 +286,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</otherwise>
</choose>
</foreach>
<foreach open="pay_time = CASE id" collection="list" item="item" close="END,">
<foreach open="pre_pay_time = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.payTime != null">
WHEN #{item.id} THEN #{item.payTime}
<when test="item.prePayTime != null">
WHEN #{item.id} THEN #{item.prePayTime}
</when>
<otherwise>
WHEN #{item.id} THEN `pay_time`
WHEN #{item.id} THEN pre_pay_time
</otherwise>
</choose>
</foreach>

View File

@ -137,7 +137,10 @@ public class BonusConverterImpl implements BonusConverter {
ServiceUtil.assertion(point.compareTo(BigDecimal.valueOf(100)) > 0, "商户剩余分成不允许大于100");
// 剩余的给商户
String ancestors = Stream.of(device.getAgentId(), device.getUserId()).map(Object::toString).collect(Collectors.joining(","));
String ancestors = Stream.of(device.getAgentId(), device.getUserId())
.filter(Objects::nonNull)
.map(Object::toString)
.collect(Collectors.joining(","));
result.add(this.toPo(mch, point, ancestors));
return result;

View File

@ -201,28 +201,23 @@ public class BonusServiceImpl implements BonusService
.map(BonusVO::getArrivalId)
.collect(Collectors.toList())
);
// TODO 拼接用户实际到账延迟
// 获取全局配置默认延迟到账时间
int defaultDelay = sysConfigService.getInt(ConfigKey.ARRIVAL_DELAY);
// 拼接用户实际到账延迟
userAssembler.assembleRealArrivalDelay(userList);
LocalDateTime now = LocalDateTime.now();
LocalDateTime defaultPrePayTime = now.plusHours(defaultDelay);
// 循环遍历构造分成金额
for (BonusVO bonus : bonusList) {
BigDecimal amount = money.multiply(bonus.getPoint()).divide(decimal100, 2, RoundingMode.HALF_UP);
bonus.setAmount(amount);
bonus.setStatus(BonusStatus.WAIT_DIVIDE.getStatus());
// TODO 预计分成时间
// 预计分成时间
if (BonusArrivalType.userList().contains(bonus.getArrivalType())) {
SmUserVo user = userList.stream().filter(item -> item.getUserId().equals(bonus.getArrivalId())).findFirst().orElse(null);
this.getArrivalDelay(user);
// bonus.setPrePayTime();
if (user == null) {
continue;
}
bonus.setPrePayTime(now.plusHours(user.getRealArrivalDelay()));
} else {
bonus.setPrePayTime(now);
}

View File

@ -38,6 +38,9 @@ public class DeviceBO extends Device {
bo.setSuitIds(getSuitIds());
bo.setLimitRechargeTime(getLimitRechargeTime());
bo.setLimitRechargeReason(getLimitRechargeReason());
bo.setServiceMode(getServiceMode());
bo.setAgentServiceRate(getAgentServiceRate());
bo.setAgentId(getAgentId());
return bo;
}
@ -63,6 +66,9 @@ public class DeviceBO extends Device {
bo.setSuitIds(getSuitIds());
bo.setLimitRechargeTime(getLimitRechargeTime());
bo.setLimitRechargeReason(getLimitRechargeReason());
bo.setServiceMode(getServiceMode());
bo.setAgentServiceRate(getAgentServiceRate());
bo.setAgentId(getAgentId());
return bo;
}

View File

@ -153,6 +153,7 @@ public class TransactionBillConverterImpl implements TransactionBillConverter {
bo.setMch(userService.selectSmUserByUserId(bill.getMchId()));
bo.setDevice(deviceService.selectSmDeviceByDeviceId(bill.getDeviceId()));
bo.setChannel(channelService.selectSmChannelByChannelId(channelId));
bo.setPlatform(deptService.selectDeptById(Constants.ROOT_DEPT));
return bo;
}

View File

@ -135,15 +135,6 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
@Autowired
private RecordTimeConverter recordTimeConverter;
@Autowired
private RefundService refundService;
@Autowired
private RefundConverter refundConverter;
@Autowired
private ReceiveBillService receiveBillService;
@Autowired
private PayBillService payBillService;
@ -913,7 +904,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
int updateCount = this.updateByQuery(data, query);
ServiceUtil.assertion(updateCount != 1, "订单状态已发生变化,请刷新后重试");
// 处理分成
// 处理分成将金额分好
bonusService.partBonus(bill.getBonusList(), bill.getMoney());
return updateCount;

View File

@ -43,4 +43,7 @@ public class SmUserVo extends SmUser {
@ApiModelProperty("实名或用户名")
private String realOrUserName;
@ApiModelProperty("实际到账延迟")
private Integer realArrivalDelay;
}

View File

@ -54,6 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
su.limit_withdraw_time,
su.agent_service_rate,
su.arrival_delay,
su.type,
if(su.is_real, su.real_name, su.user_name) as real_or_user_name,
(select sum(stb.money) from sm_transaction_bill stb where stb.user_id = su.user_id and stb.type = '1' and stb.status = '2') as recharge_amount,
(select sum(stb.arrival_amount) from sm_transaction_bill stb where stb.user_id = su.user_id and stb.type = '2' and stb.status = '14') as with_drawl_amount,
@ -66,6 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="nickName != null and nickName != ''"> and su.nick_name like concat('%', #{nickName}, '%')</if>
<if test="phonenumber != null and phonenumber != ''"> and su.phonenumber like concat('%', #{phonenumber}, '%')</if>
<if test="sex != null and sex != ''"> and su.sex = #{sex}</if>
<if test="type != null and type != ''"> and su.type = #{type}</if>
<if test="status != null and status != ''"> and su.status = #{status}</if>
<if test="isMch != null"> and su.is_mch = #{isMch}</if>
<if test="deleteDate != null"> and date(su.delete_time) = #{deleteDate}</if>
@ -181,6 +183,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="limitWithdrawTime != null">limit_withdraw_time,</if>
<if test="arrivalDelay != null">arrival_delay,</if>
<if test="agentServiceRate != null">agent_service_rate,</if>
<if test="type != null">`type`,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userName != null and userName != ''">#{userName},</if>
@ -223,6 +226,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="limitWithdrawTime != null">#{limitWithdrawTime},</if>
<if test="arrivalDelay != null">arrival_delay,</if>
<if test="agentServiceRate != null">#{agentServiceRate},</if>
<if test="type != null">#{type},</if>
</trim>
</insert>
@ -281,6 +285,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="limitWithdrawTime != null">limit_withdraw_time = #{limitWithdrawTime},</if>
<if test="arrivalDelay != null">arrival_delay = #{arrivalDelay},</if>
<if test="agentServiceRate != null">agent_service_rate = #{agentServiceRate},</if>
<if test="type != null">`type` = #{type},</if>
</trim>
where user_id = #{userId}
</update>

View File

@ -19,4 +19,9 @@ public interface UserAssembler {
* 拼接用户设备数量
*/
void assembleDeviceCount(List<SmUserVo> list);
/**
* 拼接用户实际到账延迟
*/
void assembleRealArrivalDelay(List<SmUserVo> userList);
}

View File

@ -9,9 +9,12 @@ import com.ruoyi.ss.device.service.DeviceService;
import com.ruoyi.ss.store.service.StoreService;
import com.ruoyi.ss.user.domain.SmUserVo;
import com.ruoyi.ss.user.service.UserAssembler;
import com.ruoyi.system.domain.enums.config.ConfigKey;
import com.ruoyi.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -29,6 +32,9 @@ public class UserAssemblerImpl implements UserAssembler {
@Autowired
private DeviceService deviceService;
@Autowired
private ISysConfigService sysConfigService;
/**
* 拼接用户店铺数量
*
@ -70,4 +76,27 @@ public class UserAssemblerImpl implements UserAssembler {
user.setDeviceCount(count == null ? 0 : count);
}
}
@Override
public void assembleRealArrivalDelay(List<SmUserVo> list) {
if (CollectionUtils.isEmptyElement(list)) {
return;
}
// 获取全局配置默认延迟到账时间
int defaultDelay = sysConfigService.getInt(ConfigKey.ARRIVAL_DELAY);
for (SmUserVo user : list) {
if (user == null) {
continue;
}
// TODO 优先获取用户的延迟到账时间
if (user.getArrivalDelay() != null) {
user.setRealArrivalDelay(user.getArrivalDelay());
} else {
user.setRealArrivalDelay(defaultDelay);
}
}
}
}

View File

@ -0,0 +1,85 @@
package com.ruoyi.web.controller.ss;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ss.bonus.domain.BonusQuery;
import com.ruoyi.ss.bonus.domain.BonusVO;
import com.ruoyi.ss.bonus.service.BonusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 分成明细Controller
*
* @author ruoyi
* @date 2024-08-20
*/
@RestController
@RequestMapping("/ss/bonus")
public class BonusController extends BaseController
{
@Autowired
private BonusService bonusService;
/**
* 查询分成明细列表
*/
@DataScope(deptAlias = "sd")
@PreAuthorize("@ss.hasPermi('ss:bonus:list')")
@GetMapping("/list")
public TableDataInfo list(BonusQuery query)
{
startPage();
startOrderBy();
List<BonusVO> list = bonusService.selectBonusList(query);
return getDataTable(list);
}
/**
* 查询根据订单查询所有分成明细列表
*/
@DataScope(deptAlias = "sd")
@PreAuthorize("@ss.hasPermi('ss:bonus:list')")
@GetMapping("/byBill")
public AjaxResult listByBill(@RequestParam Long billId) {
BonusQuery query = new BonusQuery();
query.setBillId(billId);
// query.setNeedScope(true);
List<BonusVO> list = bonusService.selectBonusList(query);
return success(list);
}
/**
* 导出分成明细列表
*/
@DataScope(deptAlias = "sd")
@PreAuthorize("@ss.hasPermi('ss:bonus:export')")
@Log(title = "分成明细", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BonusQuery query)
{
List<BonusVO> list = bonusService.selectBonusList(query);
ExcelUtil<BonusVO> util = new ExcelUtil<BonusVO>(BonusVO.class);
util.exportExcel(response, list, "分成明细数据");
}
/**
* 获取分成明细详细信息
*/
@PreAuthorize("@ss.hasPermi('ss:bonus:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(bonusService.selectBonusById(id));
}
}