Commit 4b4890f9 by guanchen

合伙人 代理商 收入结算

parent 14660b73
...@@ -67,6 +67,7 @@ public class Constants { ...@@ -67,6 +67,7 @@ public class Constants {
*/ */
public static final int REWARD_STATUS_UNSETTLE = 100; public static final int REWARD_STATUS_UNSETTLE = 100;
public static final int REWARD_STATUS_SETTLE = 120; public static final int REWARD_STATUS_SETTLE = 120;
public static final int REWARD_STATUS_FAILED = 99;
/** /**
* 最小奖励金额 小于此不写入 * 最小奖励金额 小于此不写入
*/ */
......
...@@ -6,6 +6,7 @@ import com.lanren.huhu.partner.model.AgentResponse; ...@@ -6,6 +6,7 @@ import com.lanren.huhu.partner.model.AgentResponse;
import com.lanren.huhu.partner.model.ParentAgent; import com.lanren.huhu.partner.model.ParentAgent;
import com.lanren.huhu.partner.result.Result; import com.lanren.huhu.partner.result.Result;
import com.lanren.huhu.partner.schedule.AgentDailyExpandTask; import com.lanren.huhu.partner.schedule.AgentDailyExpandTask;
import com.lanren.huhu.partner.schedule.AgentSettleTask;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -28,6 +29,8 @@ public class AgentController { ...@@ -28,6 +29,8 @@ public class AgentController {
AgentManager agentManager; AgentManager agentManager;
@Autowired @Autowired
AgentDailyExpandTask agentDailyExpandTask; AgentDailyExpandTask agentDailyExpandTask;
@Autowired
AgentSettleTask agentSettleTask;
@RequestMapping(value = "/level", method = RequestMethod.POST) @RequestMapping(value = "/level", method = RequestMethod.POST)
public Result<AgentResponse> getAgentLevel(@RequestBody @Valid Agent agent, @RequestHeader HttpHeaders headers) { public Result<AgentResponse> getAgentLevel(@RequestBody @Valid Agent agent, @RequestHeader HttpHeaders headers) {
...@@ -76,4 +79,15 @@ public class AgentController { ...@@ -76,4 +79,15 @@ public class AgentController {
} }
return agentManager.doFinanceSettle(agent.getAgentId()); return agentManager.doFinanceSettle(agent.getAgentId());
} }
/**
* 结算全部代理商
*/
@RequestMapping(value = "/finance", method = RequestMethod.GET)
public Result<String> doFinanceSettle(@RequestHeader HttpHeaders headers) {
agentSettleTask.runScheduledTask();
logger.info("============>" + Thread.currentThread().getName());
Result<String> result = new Result<String>();
result.setData("异步,正在执行刷新......");
return result;
}
} }
package com.lanren.huhu.partner.controller; import com.lanren.huhu.partner.manager.PartnerManager;import com.lanren.huhu.partner.model.Partner;import com.lanren.huhu.partner.model.PartnerResponse;import com.lanren.huhu.partner.result.Result;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.http.HttpHeaders;import org.springframework.web.bind.annotation.*; import javax.validation.Valid;import java.time.LocalDateTime; /** * @Author houseme * @Date 2019-06-26 11:00 * @Project partner * @Package com.lanren.huhu.partner.controller * @File: PartnerController */@RestController@RequestMapping("/v1/partner")public class PartnerController { private static Logger logger = LoggerFactory.getLogger(PartnerController.class); @Autowired private PartnerManager partnerManager; @RequestMapping(value = "/level", method = RequestMethod.POST) public Result<PartnerResponse> getPartnerLevel(@RequestBody @Valid Partner partner, @RequestHeader HttpHeaders headers) { if (logger.isInfoEnabled()) { logger.info("getPartnerLevel userId:{},header:{},time:{}", partner.getUserId(), headers.keySet().toArray(), LocalDateTime.now()); } return partnerManager.getPartnerLevel(partner.getUserId()); } /** * 测试使用 结算单个用户 */ @RequestMapping(value = "/finance", method = RequestMethod.POST) public Result<String> doFinanceSettle(@RequestBody @Valid Partner partner, @RequestHeader HttpHeaders headers) { if (logger.isInfoEnabled()) { logger.info("doFinanceSettle userId:{},header:{},time:{}", partner.getUserId(), headers.keySet().toArray(), LocalDateTime.now()); } return partnerManager.doFinanceSettle(partner.getUserId()); }} package com.lanren.huhu.partner.controller; import com.lanren.huhu.partner.manager.PartnerManager;import com.lanren.huhu.partner.model.Partner;import com.lanren.huhu.partner.model.PartnerResponse;import com.lanren.huhu.partner.result.Result;import com.lanren.huhu.partner.schedule.PartnerSettleTask;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.http.HttpHeaders;import org.springframework.web.bind.annotation.*; import javax.validation.Valid;import java.time.LocalDateTime; /** * @Author houseme * @Date 2019-06-26 11:00 * @Project partner * @Package com.lanren.huhu.partner.controller * @File: PartnerController */@RestController@RequestMapping("/v1/partner")public class PartnerController { private static Logger logger = LoggerFactory.getLogger(PartnerController.class); @Autowired private PartnerManager partnerManager; @Autowired private PartnerSettleTask partnerSettleTask; @RequestMapping(value = "/level", method = RequestMethod.POST) public Result<PartnerResponse> getPartnerLevel(@RequestBody @Valid Partner partner, @RequestHeader HttpHeaders headers) { if (logger.isInfoEnabled()) { logger.info("getPartnerLevel userId:{},header:{},time:{}", partner.getUserId(), headers.keySet().toArray(), LocalDateTime.now()); } return partnerManager.getPartnerLevel(partner.getUserId()); } /** * 测试使用 结算单个用户 */ @RequestMapping(value = "/finance", method = RequestMethod.POST) public Result<String> doFinanceSettle(@RequestBody @Valid Partner partner, @RequestHeader HttpHeaders headers) { if (logger.isInfoEnabled()) { logger.info("doFinanceSettle userId:{},header:{},time:{}", partner.getUserId(), headers.keySet().toArray(), LocalDateTime.now()); } return partnerManager.doFinanceSettle(partner.getUserId()); } /** * 结算全部用户 */ @RequestMapping(value = "/finance", method = RequestMethod.GET) public Result<String> doFinanceSettle(@RequestHeader HttpHeaders headers) { partnerSettleTask.runScheduledTask(); logger.info("============>" + Thread.currentThread().getName()); Result<String> result = new Result<String>(); result.setData("异步,正在执行刷新......"); return result; }}
\ No newline at end of file \ No newline at end of file
......
...@@ -2,10 +2,11 @@ package com.lanren.huhu.partner.dao; ...@@ -2,10 +2,11 @@ package com.lanren.huhu.partner.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lanren.huhu.partner.domain.AgentSalary; import com.lanren.huhu.partner.domain.AgentSalary;
import java.util.List;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper @Mapper
public interface AgentSalaryMapper extends BaseMapper<AgentSalary> { public interface AgentSalaryMapper extends BaseMapper<AgentSalary> {
int updateBatch(List<AgentSalary> list); int updateBatch(List<AgentSalary> list);
......
...@@ -2,10 +2,11 @@ package com.lanren.huhu.partner.dao; ...@@ -2,10 +2,11 @@ package com.lanren.huhu.partner.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lanren.huhu.partner.domain.OrdersActive; import com.lanren.huhu.partner.domain.OrdersActive;
import java.util.List;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper @Mapper
public interface OrdersActiveMapper extends BaseMapper<OrdersActive> { public interface OrdersActiveMapper extends BaseMapper<OrdersActive> {
int updateBatch(List<OrdersActive> list); int updateBatch(List<OrdersActive> list);
...@@ -15,4 +16,6 @@ public interface OrdersActiveMapper extends BaseMapper<OrdersActive> { ...@@ -15,4 +16,6 @@ public interface OrdersActiveMapper extends BaseMapper<OrdersActive> {
int insertOrUpdate(OrdersActive record); int insertOrUpdate(OrdersActive record);
int insertOrUpdateSelective(OrdersActive record); int insertOrUpdateSelective(OrdersActive record);
OrdersActive selectOneByOrderSn(String type, String orderSn);
} }
\ No newline at end of file
...@@ -4,10 +4,12 @@ import com.baomidou.mybatisplus.annotation.IdType; ...@@ -4,10 +4,12 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import lombok.Data; import java.util.Date;
@Data @Data
@TableName(value = "agent_salary") @TableName(value = "agent_salary")
...@@ -28,6 +30,18 @@ public class AgentSalary implements Serializable { ...@@ -28,6 +30,18 @@ public class AgentSalary implements Serializable {
private Integer agentId; private Integer agentId;
/** /**
* 年份时间值
*/
@TableField(value = "yeartime")
private Integer yeartime;
/**
* 月份值
*/
@TableField(value = "monthtime")
private Integer monthtime;
/**
* 月份 * 月份
*/ */
@TableField(value = "month") @TableField(value = "month")
...@@ -70,6 +84,30 @@ public class AgentSalary implements Serializable { ...@@ -70,6 +84,30 @@ public class AgentSalary implements Serializable {
private BigDecimal taxBalance; private BigDecimal taxBalance;
/** /**
* 分享赚奖励
*/
@TableField(value = "share_balance")
private BigDecimal shareBalance;
/**
* 自购省奖励
*/
@TableField(value = "zigousheng_balance")
private BigDecimal zigoushengBalance;
/**
* 推荐分成奖励
*/
@TableField(value = "pingtui_balance")
private BigDecimal pingtuiBalance;
/**
* 技术服务费
*/
@TableField(value = "tech_charge")
private BigDecimal techCharge;
/**
* 姓名或许公司名称 * 姓名或许公司名称
*/ */
@TableField(value = "bank_account") @TableField(value = "bank_account")
...@@ -109,7 +147,7 @@ public class AgentSalary implements Serializable { ...@@ -109,7 +147,7 @@ public class AgentSalary implements Serializable {
* 创建时间 * 创建时间
*/ */
@TableField(value = "create_time") @TableField(value = "create_time")
private LocalDateTime createTime; private Date createTime;
/** /**
* 提现时间 * 提现时间
...@@ -132,6 +170,10 @@ public class AgentSalary implements Serializable { ...@@ -132,6 +170,10 @@ public class AgentSalary implements Serializable {
public static final String COL_AGENT_ID = "agent_id"; public static final String COL_AGENT_ID = "agent_id";
public static final String COL_YEARTIME = "yeartime";
public static final String COL_MONTHTIME = "monthtime";
public static final String COL_MONTH = "month"; public static final String COL_MONTH = "month";
public static final String COL_BALANCE = "balance"; public static final String COL_BALANCE = "balance";
...@@ -146,6 +188,14 @@ public class AgentSalary implements Serializable { ...@@ -146,6 +188,14 @@ public class AgentSalary implements Serializable {
public static final String COL_TAX_BALANCE = "tax_balance"; public static final String COL_TAX_BALANCE = "tax_balance";
public static final String COL_SHARE_BALANCE = "share_balance";
public static final String COL_ZIGOUSHENG_BALANCE = "zigousheng_balance";
public static final String COL_PINGTUI_BALANCE = "pingtui_balance";
public static final String COL_TECH_CHARGE = "tech_charge";
public static final String COL_BANK_ACCOUNT = "bank_account"; public static final String COL_BANK_ACCOUNT = "bank_account";
public static final String COL_BANK_CARD_NUMBER = "bank_card_number"; public static final String COL_BANK_CARD_NUMBER = "bank_card_number";
......
...@@ -110,7 +110,7 @@ public class AgentManager { ...@@ -110,7 +110,7 @@ public class AgentManager {
public Result<String> doFinanceSettle(int agentId) { public Result<String> doFinanceSettle(int agentId) {
Result<String> result = new Result<String>(); Result<String> result = new Result<String>();
if (agentSettleTask.doOneAgentSettle(agentId)) { if (agentSettleTask.doOneAgentSettle(agentId)) {
result.setCode(200); result.setCode(0);
} else { } else {
result.setCode(500); result.setCode(500);
} }
......
package com.lanren.huhu.partner.manager; import com.lanren.huhu.partner.domain.PartnerAccount;import com.lanren.huhu.partner.model.PartnerResponse;import com.lanren.huhu.partner.result.Result;import com.lanren.huhu.partner.schedule.PartnerSettleTask;import com.lanren.huhu.partner.service.PartnerAccountService;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Component; import java.time.LocalDateTime; /** * @author houseme * @date 2019-06-26 10:56 * @Project partner * @Package com.lanren.huhu.partner.manager * @File: PartnerAccountManager */@Componentpublic class PartnerManager { private static Logger logger = LoggerFactory.getLogger(PartnerManager.class); @Autowired private PartnerAccountService partnerAccountService; @Autowired private PartnerSettleTask partnerSettleTask; /*** * 获取合伙人账户信息 * @param userId * @return */ public Result<PartnerAccount> findByUserId(Integer userId) { Result<PartnerAccount> result = new Result<>(); if (logger.isDebugEnabled()) { logger.info("PartnerAccountManager findByUserId userId:{},time:{}", userId, LocalDateTime.now()); } PartnerAccount partnerAccount = partnerAccountService.getOneByUserId(userId); result.setData(partnerAccount); return result; } /*** * 获取合伙人等级 10 普通, 20 高级, 30 超级 * @param userId * @return */ public Result<PartnerResponse> getPartnerLevel(Integer userId) { if (logger.isDebugEnabled()) { logger.info("PartnerAccountManager getPartnerLevel userId:{},time:{}", userId, LocalDateTime.now()); } Result<PartnerResponse> result = new Result<>(); PartnerAccount partnerAccount = partnerAccountService.getOneByUserId(userId); if (null != partnerAccount) { int partnerLevel; if (partnerAccount.getIsSuperPartner() == 1) { partnerLevel = 30; } else { partnerLevel = partnerAccount.getPartnerLevel(); } result.setData(new PartnerResponse(partnerLevel)); } else { result.setCode(601); } return result; } public Result<String> doFinanceSettle(int userId) { Result<String> result = new Result<>(); if (partnerSettleTask.doOneUserSettle(userId)) { result.setCode(200); } else { result.setCode(500); } return result; }} package com.lanren.huhu.partner.manager; import com.lanren.huhu.partner.domain.PartnerAccount;import com.lanren.huhu.partner.model.PartnerResponse;import com.lanren.huhu.partner.result.Result;import com.lanren.huhu.partner.schedule.PartnerSettleTask;import com.lanren.huhu.partner.service.PartnerAccountService;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Component; import java.time.LocalDateTime; /** * @author houseme * @date 2019-06-26 10:56 * @Project partner * @Package com.lanren.huhu.partner.manager * @File: PartnerAccountManager */@Componentpublic class PartnerManager { private static Logger logger = LoggerFactory.getLogger(PartnerManager.class); @Autowired private PartnerAccountService partnerAccountService; @Autowired private PartnerSettleTask partnerSettleTask; /*** * 获取合伙人账户信息 * @param userId * @return */ public Result<PartnerAccount> findByUserId(Integer userId) { Result<PartnerAccount> result = new Result<>(); if (logger.isDebugEnabled()) { logger.info("PartnerAccountManager findByUserId userId:{},time:{}", userId, LocalDateTime.now()); } PartnerAccount partnerAccount = partnerAccountService.getOneByUserId(userId); result.setData(partnerAccount); return result; } /*** * 获取合伙人等级 10 普通, 20 高级, 30 超级 * @param userId * @return */ public Result<PartnerResponse> getPartnerLevel(Integer userId) { if (logger.isDebugEnabled()) { logger.info("PartnerAccountManager getPartnerLevel userId:{},time:{}", userId, LocalDateTime.now()); } Result<PartnerResponse> result = new Result<>(); PartnerAccount partnerAccount = partnerAccountService.getOneByUserId(userId); if (null != partnerAccount) { int partnerLevel; if (partnerAccount.getIsSuperPartner() == 1) { partnerLevel = 30; } else { partnerLevel = partnerAccount.getPartnerLevel(); } result.setData(new PartnerResponse(partnerLevel)); } else { result.setCode(601); } return result; } public Result<String> doFinanceSettle(int userId) { Result<String> result = new Result<>(); if (partnerSettleTask.doOneUserSettle(userId)) { result.setCode(0); } else { result.setCode(500); } return result; }}
\ No newline at end of file \ No newline at end of file
......
...@@ -23,4 +23,5 @@ public interface AgentBankCardService extends IService<AgentBankCard>{ ...@@ -23,4 +23,5 @@ public interface AgentBankCardService extends IService<AgentBankCard>{
int insertOrUpdateSelective(AgentBankCard record); int insertOrUpdateSelective(AgentBankCard record);
AgentBankCard getOneByAgentId(int agentId);
} }
...@@ -4,15 +4,16 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -4,15 +4,16 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.lanren.huhu.partner.domain.AgentSalary; import com.lanren.huhu.partner.domain.AgentSalary;
import java.util.List; import java.util.List;
/**
/**
* @author chen
* @title: ${NAME} * @title: ${NAME}
* @projectName partner * @projectName partner
* @description: 代理商收入 * @description: 代理商收入
* @author chen
* @package ${PACKAGE_NAME} * @package ${PACKAGE_NAME}
* @date 2019-07-02 15:57 * @date 2019-07-02 15:57
*/ */
public interface AgentSalaryService extends IService<AgentSalary>{ public interface AgentSalaryService extends IService<AgentSalary> {
int updateBatch(List<AgentSalary> list); int updateBatch(List<AgentSalary> list);
...@@ -23,4 +24,6 @@ public interface AgentSalaryService extends IService<AgentSalary>{ ...@@ -23,4 +24,6 @@ public interface AgentSalaryService extends IService<AgentSalary>{
int insertOrUpdateSelective(AgentSalary record); int insertOrUpdateSelective(AgentSalary record);
int insert(AgentSalary agentSalary);
} }
package com.lanren.huhu.partner.service.impl; package com.lanren.huhu.partner.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lanren.huhu.partner.dao.AgentBankCardMapper; import com.lanren.huhu.partner.dao.AgentBankCardMapper;
import com.lanren.huhu.partner.domain.AgentBankCard; import com.lanren.huhu.partner.domain.AgentBankCard;
...@@ -34,4 +35,10 @@ public class AgentBankCardServiceImpl extends ServiceImpl<AgentBankCardMapper, A ...@@ -34,4 +35,10 @@ public class AgentBankCardServiceImpl extends ServiceImpl<AgentBankCardMapper, A
public int insertOrUpdateSelective(AgentBankCard record) { public int insertOrUpdateSelective(AgentBankCard record) {
return baseMapper.insertOrUpdateSelective(record); return baseMapper.insertOrUpdateSelective(record);
} }
@Override
public AgentBankCard getOneByAgentId(int agentId) {
QueryWrapper<AgentBankCard> wrapper = new QueryWrapper<AgentBankCard>();
wrapper.eq("agent_id", agentId).eq("is_default", 100);
return baseMapper.selectOne(wrapper);
}
} }
...@@ -4,34 +4,45 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -4,34 +4,45 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lanren.huhu.partner.dao.AgentSalaryMapper; import com.lanren.huhu.partner.dao.AgentSalaryMapper;
import com.lanren.huhu.partner.domain.AgentSalary; import com.lanren.huhu.partner.domain.AgentSalary;
import com.lanren.huhu.partner.service.AgentSalaryService; import com.lanren.huhu.partner.service.AgentSalaryService;
import org.apache.ibatis.annotations.Options;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
/** /**
* @author chen
* @title: ${NAME} * @title: ${NAME}
* @projectName partner * @projectName partner
* @description: 代理商收入 * @description: 代理商收入
* @author chen
* @package ${PACKAGE_NAME} * @package ${PACKAGE_NAME}
* @date 2019-07-02 15:57 * @date 2019-07-02 15:57
*/ */
@Service @Service
public class AgentSalaryServiceImpl extends ServiceImpl<AgentSalaryMapper, AgentSalary> implements AgentSalaryService{ public class AgentSalaryServiceImpl extends ServiceImpl<AgentSalaryMapper, AgentSalary> implements AgentSalaryService {
@Override @Override
public int updateBatch(List<AgentSalary> list) { public int updateBatch(List<AgentSalary> list) {
return baseMapper.updateBatch(list); return baseMapper.updateBatch(list);
} }
@Override @Override
public int batchInsert(List<AgentSalary> list) { public int batchInsert(List<AgentSalary> list) {
return baseMapper.batchInsert(list); return baseMapper.batchInsert(list);
} }
@Override @Override
public int insertOrUpdate(AgentSalary record) { public int insertOrUpdate(AgentSalary record) {
return baseMapper.insertOrUpdate(record); return baseMapper.insertOrUpdate(record);
} }
@Override @Override
public int insertOrUpdateSelective(AgentSalary record) { public int insertOrUpdateSelective(AgentSalary record) {
return baseMapper.insertOrUpdateSelective(record); return baseMapper.insertOrUpdateSelective(record);
} }
@Override
@Options(useGeneratedKeys = true, keyProperty = "agentSalary", keyColumn = "id")
public int insert(AgentSalary agentSalary) {
return baseMapper.insert(agentSalary);
}
} }
package com.lanren.huhu.partner.service.impl; package com.lanren.huhu.partner.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lanren.huhu.partner.dao.OrdersActiveMapper; import com.lanren.huhu.partner.dao.OrdersActiveMapper;
import com.lanren.huhu.partner.domain.OrdersActive; import com.lanren.huhu.partner.domain.OrdersActive;
...@@ -38,8 +37,6 @@ public class OrdersActiveServiceImpl extends ServiceImpl<OrdersActiveMapper, Ord ...@@ -38,8 +37,6 @@ public class OrdersActiveServiceImpl extends ServiceImpl<OrdersActiveMapper, Ord
@Override @Override
public OrdersActive getOneByOrderSn(String type, String orderSn) { public OrdersActive getOneByOrderSn(String type, String orderSn) {
QueryWrapper<OrdersActive> wrapper = new QueryWrapper<OrdersActive>(); return baseMapper.selectOneByOrderSn(type, orderSn);
wrapper.eq("type", type).eq("order_sn", orderSn);
return baseMapper.selectOne(wrapper);
} }
} }
...@@ -679,7 +679,7 @@ ...@@ -679,7 +679,7 @@
SELECT SELECT
agent_id, agent_id,
SUM(amount) balance, SUM(amount) balance,
SUM(case when agent_level=4 then amount * 0.06 else 0 end) techCharge, SUM(case when agent_level=4 and reward_type in (50,740,60,760,300,750) then amount * 0.06 else 0 end) techCharge,
SUM(case when reward_type in (40) then amount else 0 end) opencardBalance, SUM(case when reward_type in (40) then amount else 0 end) opencardBalance,
SUM(case when reward_type in (50,740) then amount else 0 end) rechargeBalance, SUM(case when reward_type in (50,740) then amount else 0 end) rechargeBalance,
SUM(case when reward_type in (30,710,720) then amount else 0 end) upgradeBalance, SUM(case when reward_type in (30,710,720) then amount else 0 end) upgradeBalance,
...@@ -715,7 +715,7 @@ ...@@ -715,7 +715,7 @@
SELECT SELECT
agent_id, agent_id,
SUM(amount) balance, SUM(amount) balance,
SUM(case when agent_level=4 then amount * 0.06 else 0 end) techCharge, SUM(case when agent_level=4 and reward_type in (50,740,60,760,300,750) then amount * 0.06 else 0 end) techCharge,
SUM(case when reward_type in (40) then amount else 0 end) opencardBalance, SUM(case when reward_type in (40) then amount else 0 end) opencardBalance,
SUM(case when reward_type in (50,740) then amount else 0 end) rechargeBalance, SUM(case when reward_type in (50,740) then amount else 0 end) rechargeBalance,
SUM(case when reward_type in (30,710,720) then amount else 0 end) upgradeBalance, SUM(case when reward_type in (30,710,720) then amount else 0 end) upgradeBalance,
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
<id column="id" property="id" /> <id column="id" property="id" />
<result column="user_id" property="userId" /> <result column="user_id" property="userId" />
<result column="agent_id" property="agentId" /> <result column="agent_id" property="agentId" />
<result column="yeartime" property="yeartime" />
<result column="monthtime" property="monthtime" />
<result column="month" property="month" /> <result column="month" property="month" />
<result column="balance" property="balance" /> <result column="balance" property="balance" />
<result column="opencard_balance" property="opencardBalance" /> <result column="opencard_balance" property="opencardBalance" />
...@@ -13,6 +15,10 @@ ...@@ -13,6 +15,10 @@
<result column="upgrade_balance" property="upgradeBalance" /> <result column="upgrade_balance" property="upgradeBalance" />
<result column="upgrade_super_balance" property="upgradeSuperBalance" /> <result column="upgrade_super_balance" property="upgradeSuperBalance" />
<result column="tax_balance" property="taxBalance" /> <result column="tax_balance" property="taxBalance" />
<result column="share_balance" property="shareBalance" />
<result column="zigousheng_balance" property="zigoushengBalance" />
<result column="pingtui_balance" property="pingtuiBalance" />
<result column="tech_charge" property="techCharge" />
<result column="bank_account" property="bankAccount" /> <result column="bank_account" property="bankAccount" />
<result column="bank_card_number" property="bankCardNumber" /> <result column="bank_card_number" property="bankCardNumber" />
<result column="bank_name" property="bankName" /> <result column="bank_name" property="bankName" />
...@@ -27,8 +33,9 @@ ...@@ -27,8 +33,9 @@
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
<!--@mbg.generated--> <!--@mbg.generated-->
id, user_id, agent_id, `month`, balance, opencard_balance, recharge_balance, upgrade_balance, id, user_id, agent_id, yeartime, monthtime, `month`, balance, opencard_balance, recharge_balance,
upgrade_super_balance, tax_balance, bank_account, bank_card_number, bank_name, branch_name, upgrade_balance, upgrade_super_balance, tax_balance, share_balance, zigousheng_balance,
pingtui_balance, tech_charge, bank_account, bank_card_number, bank_name, branch_name,
reference_id, `status`, create_time, modify_time, created_at, updated_at, deleted_at reference_id, `status`, create_time, modify_time, created_at, updated_at, deleted_at
</sql> </sql>
<update id="updateBatch" parameterType="java.util.List"> <update id="updateBatch" parameterType="java.util.List">
...@@ -45,6 +52,16 @@ ...@@ -45,6 +52,16 @@
when id = #{item.id} then #{item.agentId} when id = #{item.id} then #{item.agentId}
</foreach> </foreach>
</trim> </trim>
<trim prefix="yeartime = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id} then #{item.yeartime}
</foreach>
</trim>
<trim prefix="monthtime = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id} then #{item.monthtime}
</foreach>
</trim>
<trim prefix="`month` = case" suffix="end,"> <trim prefix="`month` = case" suffix="end,">
<foreach collection="list" index="index" item="item"> <foreach collection="list" index="index" item="item">
when id = #{item.id} then #{item.month} when id = #{item.id} then #{item.month}
...@@ -80,6 +97,26 @@ ...@@ -80,6 +97,26 @@
when id = #{item.id} then #{item.taxBalance} when id = #{item.id} then #{item.taxBalance}
</foreach> </foreach>
</trim> </trim>
<trim prefix="share_balance = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id} then #{item.shareBalance}
</foreach>
</trim>
<trim prefix="zigousheng_balance = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id} then #{item.zigoushengBalance}
</foreach>
</trim>
<trim prefix="pingtui_balance = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id} then #{item.pingtuiBalance}
</foreach>
</trim>
<trim prefix="tech_charge = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id} then #{item.techCharge}
</foreach>
</trim>
<trim prefix="bank_account = case" suffix="end,"> <trim prefix="bank_account = case" suffix="end,">
<foreach collection="list" index="index" item="item"> <foreach collection="list" index="index" item="item">
when id = #{item.id} then #{item.bankAccount} when id = #{item.id} then #{item.bankAccount}
...@@ -144,17 +181,19 @@ ...@@ -144,17 +181,19 @@
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true"> <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
<!--@mbg.generated--> <!--@mbg.generated-->
insert into agent_salary insert into agent_salary
(user_id, agent_id, `month`, balance, opencard_balance, recharge_balance, upgrade_balance, (user_id, agent_id, yeartime, monthtime, `month`, balance, opencard_balance, recharge_balance,
upgrade_super_balance, tax_balance, bank_account, bank_card_number, bank_name, upgrade_balance, upgrade_super_balance, tax_balance, share_balance, zigousheng_balance,
branch_name, reference_id, `status`, create_time, modify_time, created_at, updated_at, pingtui_balance, tech_charge, bank_account, bank_card_number, bank_name, branch_name,
deleted_at) reference_id, `status`, create_time, modify_time, created_at, updated_at, deleted_at
)
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.userId}, #{item.agentId}, #{item.month}, #{item.balance}, #{item.opencardBalance}, (#{item.userId}, #{item.agentId}, #{item.yeartime}, #{item.monthtime}, #{item.month},
#{item.rechargeBalance}, #{item.upgradeBalance}, #{item.upgradeSuperBalance}, #{item.taxBalance}, #{item.balance}, #{item.opencardBalance}, #{item.rechargeBalance}, #{item.upgradeBalance},
#{item.bankAccount}, #{item.bankCardNumber}, #{item.bankName}, #{item.branchName}, #{item.upgradeSuperBalance}, #{item.taxBalance}, #{item.shareBalance}, #{item.zigoushengBalance},
#{item.referenceId}, #{item.status}, #{item.createTime}, #{item.modifyTime}, #{item.createdAt}, #{item.pingtuiBalance}, #{item.techCharge}, #{item.bankAccount}, #{item.bankCardNumber},
#{item.updatedAt}, #{item.deletedAt}) #{item.bankName}, #{item.branchName}, #{item.referenceId}, #{item.status}, #{item.createTime},
#{item.modifyTime}, #{item.createdAt}, #{item.updatedAt}, #{item.deletedAt})
</foreach> </foreach>
</insert> </insert>
<insert id="insertOrUpdate" keyColumn="id" keyProperty="id" parameterType="com.lanren.huhu.partner.domain.AgentSalary" useGeneratedKeys="true"> <insert id="insertOrUpdate" keyColumn="id" keyProperty="id" parameterType="com.lanren.huhu.partner.domain.AgentSalary" useGeneratedKeys="true">
...@@ -166,6 +205,8 @@ ...@@ -166,6 +205,8 @@
</if> </if>
user_id, user_id,
agent_id, agent_id,
yeartime,
monthtime,
`month`, `month`,
balance, balance,
opencard_balance, opencard_balance,
...@@ -173,6 +214,10 @@ ...@@ -173,6 +214,10 @@
upgrade_balance, upgrade_balance,
upgrade_super_balance, upgrade_super_balance,
tax_balance, tax_balance,
share_balance,
zigousheng_balance,
pingtui_balance,
tech_charge,
bank_account, bank_account,
bank_card_number, bank_card_number,
bank_name, bank_name,
...@@ -192,6 +237,8 @@ ...@@ -192,6 +237,8 @@
</if> </if>
#{userId}, #{userId},
#{agentId}, #{agentId},
#{yeartime},
#{monthtime},
#{month}, #{month},
#{balance}, #{balance},
#{opencardBalance}, #{opencardBalance},
...@@ -199,6 +246,10 @@ ...@@ -199,6 +246,10 @@
#{upgradeBalance}, #{upgradeBalance},
#{upgradeSuperBalance}, #{upgradeSuperBalance},
#{taxBalance}, #{taxBalance},
#{shareBalance},
#{zigoushengBalance},
#{pingtuiBalance},
#{techCharge},
#{bankAccount}, #{bankAccount},
#{bankCardNumber}, #{bankCardNumber},
#{bankName}, #{bankName},
...@@ -218,6 +269,8 @@ ...@@ -218,6 +269,8 @@
</if> </if>
user_id = #{userId}, user_id = #{userId},
agent_id = #{agentId}, agent_id = #{agentId},
yeartime = #{yeartime},
monthtime = #{monthtime},
`month` = #{month}, `month` = #{month},
balance = #{balance}, balance = #{balance},
opencard_balance = #{opencardBalance}, opencard_balance = #{opencardBalance},
...@@ -225,6 +278,10 @@ ...@@ -225,6 +278,10 @@
upgrade_balance = #{upgradeBalance}, upgrade_balance = #{upgradeBalance},
upgrade_super_balance = #{upgradeSuperBalance}, upgrade_super_balance = #{upgradeSuperBalance},
tax_balance = #{taxBalance}, tax_balance = #{taxBalance},
share_balance = #{shareBalance},
zigousheng_balance = #{zigoushengBalance},
pingtui_balance = #{pingtuiBalance},
tech_charge = #{techCharge},
bank_account = #{bankAccount}, bank_account = #{bankAccount},
bank_card_number = #{bankCardNumber}, bank_card_number = #{bankCardNumber},
bank_name = #{bankName}, bank_name = #{bankName},
...@@ -251,6 +308,12 @@ ...@@ -251,6 +308,12 @@
<if test="agentId != null"> <if test="agentId != null">
agent_id, agent_id,
</if> </if>
<if test="yeartime != null">
yeartime,
</if>
<if test="monthtime != null">
monthtime,
</if>
<if test="month != null"> <if test="month != null">
`month`, `month`,
</if> </if>
...@@ -272,6 +335,18 @@ ...@@ -272,6 +335,18 @@
<if test="taxBalance != null"> <if test="taxBalance != null">
tax_balance, tax_balance,
</if> </if>
<if test="shareBalance != null">
share_balance,
</if>
<if test="zigoushengBalance != null">
zigousheng_balance,
</if>
<if test="pingtuiBalance != null">
pingtui_balance,
</if>
<if test="techCharge != null">
tech_charge,
</if>
<if test="bankAccount != null"> <if test="bankAccount != null">
bank_account, bank_account,
</if> </if>
...@@ -317,6 +392,12 @@ ...@@ -317,6 +392,12 @@
<if test="agentId != null"> <if test="agentId != null">
#{agentId}, #{agentId},
</if> </if>
<if test="yeartime != null">
#{yeartime},
</if>
<if test="monthtime != null">
#{monthtime},
</if>
<if test="month != null"> <if test="month != null">
#{month}, #{month},
</if> </if>
...@@ -338,6 +419,18 @@ ...@@ -338,6 +419,18 @@
<if test="taxBalance != null"> <if test="taxBalance != null">
#{taxBalance}, #{taxBalance},
</if> </if>
<if test="shareBalance != null">
#{shareBalance},
</if>
<if test="zigoushengBalance != null">
#{zigoushengBalance},
</if>
<if test="pingtuiBalance != null">
#{pingtuiBalance},
</if>
<if test="techCharge != null">
#{techCharge},
</if>
<if test="bankAccount != null"> <if test="bankAccount != null">
#{bankAccount}, #{bankAccount},
</if> </if>
...@@ -383,6 +476,12 @@ ...@@ -383,6 +476,12 @@
<if test="agentId != null"> <if test="agentId != null">
agent_id = #{agentId}, agent_id = #{agentId},
</if> </if>
<if test="yeartime != null">
yeartime = #{yeartime},
</if>
<if test="monthtime != null">
monthtime = #{monthtime},
</if>
<if test="month != null"> <if test="month != null">
`month` = #{month}, `month` = #{month},
</if> </if>
...@@ -404,6 +503,18 @@ ...@@ -404,6 +503,18 @@
<if test="taxBalance != null"> <if test="taxBalance != null">
tax_balance = #{taxBalance}, tax_balance = #{taxBalance},
</if> </if>
<if test="shareBalance != null">
share_balance = #{shareBalance},
</if>
<if test="zigoushengBalance != null">
zigousheng_balance = #{zigoushengBalance},
</if>
<if test="pingtuiBalance != null">
pingtui_balance = #{pingtuiBalance},
</if>
<if test="techCharge != null">
tech_charge = #{techCharge},
</if>
<if test="bankAccount != null"> <if test="bankAccount != null">
bank_account = #{bankAccount}, bank_account = #{bankAccount},
</if> </if>
......
...@@ -829,4 +829,9 @@ ...@@ -829,4 +829,9 @@
</if> </if>
</trim> </trim>
</insert> </insert>
<select id="selectOneByOrderSn" resultMap="BaseResultMap">
SELECT * FROM orders_active
WHERE type=#{type} AND order_sn=#{orderSn}
LIMIT 1
</select>
</mapper> </mapper>
\ No newline at end of file
上线SQL:
ALTER TABLE `huhu`.`partner_account_log` ALTER TABLE `huhu`.`partner_account_log`
ADD COLUMN `snapshot` varchar(512) NULL COMMENT '变更前的快照' AFTER `modify_time`; ADD COLUMN `snapshot` varchar(512) NULL COMMENT '变更前的快照' AFTER `modify_time`;
ALTER TABLE `huhu`.`agent_salary`
MODIFY COLUMN `balance` decimal(20, 6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '总金额' AFTER `month`,
MODIFY COLUMN `opencard_balance` decimal(20, 6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '开卡奖励金额' AFTER `balance`,
MODIFY COLUMN `recharge_balance` decimal(20, 6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '充值奖励金额' AFTER `opencard_balance`,
MODIFY COLUMN `upgrade_balance` decimal(20, 6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '购买VIP会员奖励金额' AFTER `recharge_balance`,
MODIFY COLUMN `upgrade_super_balance` decimal(20, 6) NOT NULL DEFAULT 0 COMMENT '购买超级VIP会员奖励金额' AFTER `upgrade_balance`,
ADD COLUMN `share_balance` decimal(20, 6) NOT NULL DEFAULT 0 COMMENT '分享赚奖励' AFTER `upgrade_super_balance`,
ADD COLUMN `zigousheng_balance` decimal(20, 6) NOT NULL DEFAULT 0 COMMENT '自购省奖励' AFTER `share_balance`,
ADD COLUMN `pingtui_balance` decimal(20, 6) NOT NULL DEFAULT 0 COMMENT '推荐分成奖励' AFTER `zigousheng_balance`,
ADD COLUMN `tech_charge` decimal(20, 6) NOT NULL COMMENT '技术服务费' AFTER `pingtui_balance`,
MODIFY COLUMN `tax_balance` decimal(20, 6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '缴税金额' AFTER `upgrade_super_balance`;
ALTER TABLE `huhu`.`agent_reward` ALTER TABLE `huhu`.`agent_reward`
MODIFY COLUMN `reward_type` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '奖励类型 40 开卡奖励 50 充值奖励 30 购买VIP会员 20 购买超级VIP会员 60 分享赚 300 自购省 得的购买年-VIP; 720 城市代理商所得的购买半年-VIP; 730 城市代理商所得的购买超级VIP收益; 740 城市代理商的红包收益; 750 城市代理商的自购省收益; 760 城市代理商的分享赚收益 ' AFTER `user_id`; MODIFY COLUMN `reward_type` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '奖励类型 40 开卡奖励 50 充值奖励 30 购买VIP会员 20 购买超级VIP会员 60 分享赚 300 自购省 得的购买年-VIP; 720 城市代理商所得的购买半年-VIP; 730 城市代理商所得的购买超级VIP收益; 740 城市代理商的红包收益; 750 城市代理商的自购省收益; 760 城市代理商的分享赚收益 ' AFTER `user_id`;
ALTER TABLE `huhu`.`agent_account_log` ALTER TABLE `huhu`.`agent_account_log`
ADD COLUMN `snapshot` varchar(255) NOT NULL DEFAULT '' COMMENT '变更前的快照' AFTER `modify_time`; ADD COLUMN `snapshot` varchar(255) NOT NULL DEFAULT '' COMMENT '变更前的快照' AFTER `modify_time`;
ALTER TABLE `huhu`.`partner_account_log`
MODIFY COLUMN `change_num` decimal(20, 6) NOT NULL DEFAULT 0 COMMENT '变化的金额 进账为正数 出账为负数' AFTER `type`,
MODIFY COLUMN `changed_amount` decimal(20, 6) NOT NULL DEFAULT 0 COMMENT '变化的之后的金额' AFTER `change_num`;
ALTER TABLE `huhu`.`agent_account_log`
MODIFY COLUMN `change_num` decimal(20, 6) NOT NULL DEFAULT 0 COMMENT '变化的金额 进账为正数 出账为负数' AFTER `type`,
MODIFY COLUMN `changed_amount` decimal(20, 6) NOT NULL DEFAULT 0 COMMENT '变化的之后的金额' AFTER `change_num`;
ALTER TABLE `huhu`.`agent_account`
MODIFY COLUMN `balance` decimal(20, 6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '账户总额' AFTER `account_type`,
MODIFY COLUMN `frozen_balance` decimal(20, 6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '冻结余额' AFTER `balance`,
MODIFY COLUMN `income_freeze` decimal(20, 6) UNSIGNED NULL DEFAULT 0 COMMENT '收入冻结' AFTER `frozen_balance`,
MODIFY COLUMN `pay_freeze` decimal(20, 6) UNSIGNED NULL DEFAULT 0 COMMENT '出款冻结' AFTER `income_freeze`,
MODIFY COLUMN `free_balance` decimal(20, 6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '可用余额' AFTER `pay_freeze`,
MODIFY COLUMN `income_balance` decimal(20, 6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '账户收入总额' AFTER `free_balance`,
MODIFY COLUMN `recharge_income` decimal(20, 6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '在线充值收入' AFTER `income_balance`,
MODIFY COLUMN `opencard_income` decimal(20, 6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '账户开卡收入' AFTER `recharge_income`,
MODIFY COLUMN `withdraw_balance` decimal(20, 6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '提现总额' AFTER `deleted_at`,
MODIFY COLUMN `consume_balance` decimal(20, 6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '消费总额' AFTER `withdraw_balance`;
UPDATE agent_reward a
JOIN user_agent b ON a.agent_id=b.agent_id
SET a.agent_level=b.agent_level
WHERE a.recharge_time BETWEEN '2019-06-01 00:00:00' and '2019-06-30 23:59:59'
AND a.agent_level=0;
测试
select * from agent_salary where agent_id=29 and yeartime=2019 and monthtime=6;
select * from agent_account_log where agent_id=29;
select * from agent_reward where agent_id=29 and recharge_time BETWEEN '2019-06-01 00:00:00' and '2019-06-30 23:59:59';
select * from agent_income_summary where agent_id=29 and yeartime=2019 and monthtime=6;
delete from agent_salary where agent_id=29 and yeartime=2019 and monthtime=6;
delete from agent_account_log where agent_id=29;
update agent_reward set reward_status=100,settle_state=case when settle_state=300 then 200 else settle_state end where agent_id=29 and recharge_time BETWEEN '2019-06-01 00:00:00' and '2019-06-30 23:59:59' ;
delete from agent_income_summary where agent_id=29 and yeartime=2019 and monthtime=6;
select * from partner_account_log where user_id=89 order by id desc;
select * from partner_reward where user_id=89 and recharge_time BETWEEN '2019-06-01 00:00:00' and '2019-06-30 23:59:59';
select * from partner_income_summary where user_id=89 and yeartime=2019 and monthtime=6;
delete from partner_account_log where user_id=89 and yeartime=2019 and monthtime=6;
update partner_reward set reward_status=100,settle_state=case when settle_state=300 then 200 else settle_state end where user_id=89 and recharge_time BETWEEN '2019-06-01 00:00:00' and '2019-06-30 23:59:59' ;
delete from partner_income_summary where user_id=89 and yeartime=2019 and monthtime=6;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment