添加定时器
This commit is contained in:
parent
1b874a4ac8
commit
a22f18c54d
|
|
@ -69,6 +69,65 @@ public class UserController {
|
|||
return userservice.getIndexData(Integer.valueOf(userId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取近七日收单额
|
||||
* @param loginName
|
||||
* @param token
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("getDayOrder")
|
||||
public RespBody getDayOrder(@RequestHeader("loginName") String loginName,@RequestHeader("token") String token,@RequestHeader("userId") String userId
|
||||
, @RequestParam("reqUserId") String reqUserId
|
||||
){
|
||||
return userservice.getDayOrder(reqUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取近一年的收单额
|
||||
* @param loginName
|
||||
* @param token
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
|
||||
@GetMapping("getMonthOrder")
|
||||
public RespBody getMonthOrder(@RequestHeader("loginName") String loginName,@RequestHeader("token") String token,@RequestHeader("userId") String userId,
|
||||
@RequestParam("year") String year, @RequestParam("reqUserId") String reqUserId
|
||||
){
|
||||
return userservice.getMonthOrder(reqUserId,year);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取近七日收益
|
||||
* @param loginName
|
||||
* @param token
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("getDayProfit")
|
||||
public RespBody getDayProfit(@RequestHeader("loginName") String loginName,@RequestHeader("token") String token,@RequestHeader("userId") String userId, @RequestParam("reqUserId") String reqUserId){
|
||||
return userservice.getDayProfit(reqUserId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取近一年的收益数据
|
||||
* @param loginName
|
||||
* @param token
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("getMonthProfit")
|
||||
public RespBody getMonthProfit(@RequestHeader("loginName") String loginName,@RequestHeader("token") String token,@RequestHeader("userId") String userId,
|
||||
@RequestParam("year") String year, @RequestParam("reqUserId") String reqUserId
|
||||
){
|
||||
return userservice.getMonth(reqUserId,year);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出
|
||||
* @param loginName
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ public class AgencyService {
|
|||
Integer count= userPromotionMapper.selectCountByUserId(id);
|
||||
if(count<=0){
|
||||
it.put("sumfansShareMoney",0);
|
||||
it.put("yestedayConsumeFee",0);
|
||||
it.put("yestedayShareMoney",0);
|
||||
it.put("sumConsumeFee",0);
|
||||
it.put("sumAccount",0);
|
||||
|
|
@ -188,11 +189,13 @@ public class AgencyService {
|
|||
Map<String,Object> map= userPromotionMapper.selectByUserId(id);
|
||||
if(ObjectUtil.isEmpty(map)){
|
||||
it.put("sumfansShareMoney",0);
|
||||
it.put("yestedayConsumeFee",0);
|
||||
it.put("yestedayShareMoney",0);
|
||||
it.put("sumConsumeFee",0);
|
||||
it.put("sumAccount",0);
|
||||
}else{
|
||||
it.put("sumfansShareMoney",map.get("sumfansShareMoney"));
|
||||
it.put("yestedayConsumeFee",map.get("yestedayConsumeFee"));
|
||||
it.put("yestedayShareMoney",map.get("yestedayShareMoney"));
|
||||
it.put("sumConsumeFee",map.get("sumConsumeFee"));
|
||||
it.put("sumAccount",count);
|
||||
|
|
|
|||
|
|
@ -138,6 +138,49 @@ public class Userservice {
|
|||
return new RespBody("000000",map);
|
||||
}
|
||||
|
||||
|
||||
public RespBody getDayOrder(String userId){
|
||||
if(ObjectUtil.isEmpty(userId)){
|
||||
log.error("参数错误");
|
||||
return new RespBody("000019");
|
||||
}
|
||||
return new RespBody("000000",userInfoMapper.selectOrderByDay(userId));
|
||||
}
|
||||
|
||||
public RespBody getDayProfit(String userId){
|
||||
if(ObjectUtil.isEmpty(userId)){
|
||||
log.error("参数错误");
|
||||
return new RespBody("000019");
|
||||
}
|
||||
|
||||
return new RespBody("000000",userInfoMapper.selectProfitByDay(userId));
|
||||
}
|
||||
|
||||
|
||||
public RespBody getMonth(String userId,String year){
|
||||
if(ObjectUtil.isEmpty(userId)){
|
||||
log.error("参数错误");
|
||||
return new RespBody("000019");
|
||||
}
|
||||
|
||||
if(ObjectUtil.isEmpty(year)){
|
||||
year=StringUtil.getYear();
|
||||
}
|
||||
return new RespBody("000000",userInfoMapper.selectProfitByMonth(userId,year));
|
||||
}
|
||||
|
||||
|
||||
public RespBody getMonthOrder(String userId,String year){
|
||||
if(ObjectUtil.isEmpty(userId)){
|
||||
log.error("参数错误");
|
||||
return new RespBody("000019");
|
||||
}
|
||||
if(ObjectUtil.isEmpty(year)){
|
||||
year=StringUtil.getYear();
|
||||
}
|
||||
return new RespBody("000000",userInfoMapper.selectOrderByMonth(userId,year));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
TbPlussUserPromotionMapper userPromotionMapper;
|
||||
public RespBody getOutFlow(String userId,String userName,String merchantCode,String status,Integer pageNum,Integer pageSize){
|
||||
|
|
@ -153,6 +196,9 @@ public class Userservice {
|
|||
cn.hutool.json.JSONObject object=array.getJSONObject(i);
|
||||
map.put(object.getStr("userType"),object.getStr("status"));
|
||||
}
|
||||
|
||||
switch (it.get("typeCode").toString()){
|
||||
case "MC":
|
||||
if("SO".equals(userPromotion.getTypeCode())){
|
||||
if("1".equals(map.get("AG"))&&"0".equals(map.get("SO"))){
|
||||
flag=true;
|
||||
|
|
@ -164,12 +210,93 @@ public class Userservice {
|
|||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if("MG".equals(userPromotion.getTypeCode())) {
|
||||
if ("1".equals(map.get("FO")) && "0".equals(map.get("MG"))) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case "SB":
|
||||
if("SO".equals(userPromotion.getTypeCode())){
|
||||
if("1".equals(map.get("AG"))&&"0".equals(map.get("SO"))){
|
||||
flag=true;
|
||||
}
|
||||
}
|
||||
|
||||
if("FO".equals(userPromotion.getTypeCode())) {
|
||||
if ("1".equals(map.get("SO")) && "0".equals(map.get("FO"))) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if("MG".equals(userPromotion.getTypeCode())) {
|
||||
if ("1".equals(map.get("FO")) && "0".equals(map.get("MG"))) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "FB":
|
||||
if("SO".equals(userPromotion.getTypeCode())){
|
||||
if("1".equals(map.get("AG"))&&"0".equals(map.get("SO"))){
|
||||
flag=true;
|
||||
}
|
||||
}
|
||||
|
||||
if("FO".equals(userPromotion.getTypeCode())) {
|
||||
if ("1".equals(map.get("SO")) && "0".equals(map.get("FO"))) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if("MG".equals(userPromotion.getTypeCode())) {
|
||||
if ("1".equals(map.get("FO")) && "0".equals(map.get("MG"))) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "AG":
|
||||
if("SO".equals(userPromotion.getTypeCode())){
|
||||
if("0".equals(map.get("SO"))){
|
||||
flag=true;
|
||||
}
|
||||
}
|
||||
|
||||
if("FO".equals(userPromotion.getTypeCode())) {
|
||||
if ("1".equals(map.get("SO")) && "0".equals(map.get("FO"))) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if("MG".equals(userPromotion.getTypeCode())) {
|
||||
if ("1".equals(map.get("FO")) && "0".equals(map.get("MG"))) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "SO":
|
||||
if("FO".equals(userPromotion.getTypeCode())) {
|
||||
if ("0".equals(map.get("FO"))) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if("MG".equals(userPromotion.getTypeCode())) {
|
||||
if ("1".equals(map.get("FO")) && "0".equals(map.get("MG"))) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "FO":
|
||||
if("MG".equals(userPromotion.getTypeCode())) {
|
||||
if ( "0".equals(map.get("MG"))) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}else {
|
||||
flag=true;
|
||||
}
|
||||
|
|
@ -244,7 +371,12 @@ public class Userservice {
|
|||
upStatus=map.get("MG");
|
||||
break;
|
||||
case "MG":
|
||||
if(!map.containsKey("FO")){
|
||||
cashStatus=new CashStatus();
|
||||
cashStatus.setStatus("1");
|
||||
}else {
|
||||
cashStatus=map.get("FO");
|
||||
}
|
||||
upStatus=map.get("MG");
|
||||
break;
|
||||
}
|
||||
|
|
@ -329,6 +461,19 @@ public class Userservice {
|
|||
return new RespBody("000007");
|
||||
}
|
||||
|
||||
TbPlussUserPromotion promotion= userPromotionMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||
if(ObjectUtil.isEmpty(promotion)){
|
||||
log.error("用户不存在");
|
||||
return new RespBody("000007");
|
||||
}
|
||||
|
||||
if(promotion.getTypeCode().equals("MG")){
|
||||
log.error("平台不允许提现");
|
||||
return new RespBody("000033");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(amount.compareTo(BigDecimal.TEN)<0){
|
||||
log.error("小于最小提现金额");
|
||||
return new RespBody("000032");
|
||||
|
|
@ -352,11 +497,7 @@ public class Userservice {
|
|||
return new RespBody("000029");
|
||||
}
|
||||
|
||||
TbPlussUserPromotion promotion= userPromotionMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||
if(ObjectUtil.isEmpty(promotion)){
|
||||
log.error("用户不存在");
|
||||
return new RespBody("000007");
|
||||
}
|
||||
|
||||
// TbPlussCashAccount account= tbPlussCashAccountMapper.selectByUserId(userId);
|
||||
// if(ObjectUtil.isEmpty(account)){
|
||||
// log.error("提现账户信息不完整");
|
||||
|
|
@ -376,7 +517,7 @@ public class Userservice {
|
|||
cash.setCreatedt(new Date());
|
||||
cash.setCashnumber(StringUtil.getBillno());
|
||||
cash.setType(1);
|
||||
cash.setStatus(1);
|
||||
cash.setStatus(0);
|
||||
cash.setBaseservicecharge(BigDecimal.valueOf(3));
|
||||
cash.setRatiocharge(cash.getCashamt().multiply(BigDecimal.valueOf(0.08)));
|
||||
cash.setCashstatus(JSONUtil.toJsonStr(getCashMap(promotion.getParentUserId(),new LinkedList<>())));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
package com.chaozhanggui.admin.system.task;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.chaozhanggui.dao.system.dao.TbPlussMerchantOrderMapper;
|
||||
import com.chaozhanggui.dao.system.dao.TbPlussUserPromotionMapper;
|
||||
import com.chaozhanggui.dao.system.entity.TbPlussUserPromotion;
|
||||
import com.chaozhanggui.dao.system.model.TaskOrderSum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CustomerTask {
|
||||
|
||||
|
||||
@Autowired
|
||||
private TbPlussMerchantOrderMapper tbPlussMerchantOrderMapper;
|
||||
|
||||
@Autowired
|
||||
private TbPlussUserPromotionMapper tbPlussUserPromotionMapper;
|
||||
|
||||
@Scheduled(initialDelay = 6000,fixedDelay = 1800000)
|
||||
public void customerTask(){
|
||||
List<TaskOrderSum> list= tbPlussMerchantOrderMapper.selectByUserId();
|
||||
if(ObjectUtil.isEmpty(list)||list.size()<=0){
|
||||
log.warn("没有待升级的创客信息");
|
||||
return;
|
||||
}
|
||||
for (TaskOrderSum taskOrderSum : list) {
|
||||
deal(taskOrderSum);
|
||||
}
|
||||
}
|
||||
|
||||
private void deal(TaskOrderSum orderSum){
|
||||
|
||||
|
||||
TbPlussUserPromotion userPromotion= tbPlussUserPromotionMapper.selectByPrimaryKey(Integer.valueOf(orderSum.getUserId()));
|
||||
if(ObjectUtil.isEmpty(userPromotion)){
|
||||
log.warn("小微商户不存在或者状态异常");
|
||||
return;
|
||||
}
|
||||
|
||||
if(orderSum.getConsumeFee().compareTo(new BigDecimal(20000))>=0&&orderSum.getConsumeFee().compareTo(new BigDecimal(50000))<0){
|
||||
userPromotion.setIsExtend("1");
|
||||
}
|
||||
|
||||
if(orderSum.getConsumeFee().compareTo(new BigDecimal(50000))>=0){
|
||||
userPromotion.setIsExtend("2");
|
||||
}
|
||||
|
||||
userPromotion.setUpdateTime(new Date());
|
||||
|
||||
tbPlussUserPromotionMapper.updateByPrimaryKey(userPromotion);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,8 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
|
@ -406,4 +408,15 @@ public class StringUtil extends StringUtils {
|
|||
return match.matches();
|
||||
}
|
||||
|
||||
|
||||
public static String getYear(){
|
||||
Date date = new Date();
|
||||
ZoneId timeZone = ZoneId.systemDefault();
|
||||
LocalDate getLocalDate = date.toInstant().atZone(timeZone).toLocalDate();
|
||||
return getLocalDate.getYear()+"";
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
System.out.println(getYear());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
spring:
|
||||
datasource:
|
||||
# url: jdbc:mysql://rm-bp1uo9iq250st2e691o.mysql.rds.aliyuncs.com:3306/chaozhanggui?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=CTT&useSSL=false
|
||||
url: jdbc:mysql://rm-bp1uo9iq250st2e69.mysql.rds.aliyuncs.com:3306/chaozhanggui?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=CTT&useSSL=false
|
||||
url: jdbc:mysql://rm-bp1uo9iq250st2e691o.mysql.rds.aliyuncs.com:3306/chaozhanggui?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=CTT&useSSL=false
|
||||
# url: jdbc:mysql://rm-bp1uo9iq250st2e69.mysql.rds.aliyuncs.com:3306/chaozhanggui?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=CTT&useSSL=false
|
||||
username: root
|
||||
password: prodCZGmysqlroot@123
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ server:
|
|||
# 指定日志级别 把springboot的所有日志修改成为debug
|
||||
logging:
|
||||
level:
|
||||
root: info
|
||||
root: debug
|
||||
mybatis:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
|
|
|
|||
|
|
@ -48,13 +48,12 @@ public class ExceptionUtil {
|
|||
map.put("000030","提现账户信息不完整");
|
||||
map.put("000031","商户信息不存在");
|
||||
map.put("000032","小于最小提现金额");
|
||||
map.put("000033","平台不允许提现");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
map.put("000034","此用户已在黑名单中");
|
||||
map.put("000035","此用户不在黑名单中");
|
||||
map.put("000036","多购物车结算禁止使用优惠券");
|
||||
map.put("000037","商品规格错误");
|
||||
|
|
|
|||
|
|
@ -2,9 +2,12 @@ package com.chaozhanggui.dao.system.dao;
|
|||
|
||||
import com.chaozhanggui.dao.system.entity.TbPlussMerchantOrder;
|
||||
|
||||
import com.chaozhanggui.dao.system.model.TaskOrderSum;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Mapper
|
||||
public interface TbPlussMerchantOrderMapper {
|
||||
|
|
@ -21,4 +24,8 @@ public interface TbPlussMerchantOrderMapper {
|
|||
int updateByPrimaryKeyWithBLOBs(TbPlussMerchantOrder record);
|
||||
|
||||
int updateByPrimaryKey(TbPlussMerchantOrder record);
|
||||
|
||||
List<TaskOrderSum> selectByUserId();
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.chaozhanggui.dao.system.dao;
|
|||
import com.chaozhanggui.dao.system.entity.TbPlussUserInfo;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -29,4 +30,12 @@ public interface TbPlussUserInfoMapper {
|
|||
|
||||
List<Map<String,Object>> selectOutFlow(String userId,String userName,String merchantCode,String status);
|
||||
|
||||
List<Map<String,Object>> selectOrderByDay(String userId);
|
||||
|
||||
List<Map<String,Object>> selectProfitByDay(String userId);
|
||||
|
||||
List<Map<String,Object>> selectProfitByMonth(@Param("userId") String userId, @Param("year") String year);
|
||||
|
||||
List<Map<String,Object>> selectOrderByMonth(@Param("userId") String userId, @Param("year") String year);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.chaozhanggui.dao.system.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class TaskOrderSum implements Serializable {
|
||||
|
||||
private String userId;
|
||||
|
||||
private BigDecimal consumeFee;
|
||||
}
|
||||
|
|
@ -706,4 +706,22 @@
|
|||
thirdSendNo = #{thirdsendno,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
|
||||
<select id="selectByUserId" resultType="com.chaozhanggui.dao.system.model.TaskOrderSum">
|
||||
|
||||
SELECT
|
||||
d.user_id AS userId,
|
||||
IFNULL( sum( b.consumeFee ), 0 ) AS consumeFee
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
tb_pluss_user_promotion p
|
||||
WHERE
|
||||
p.parent_user_id IN ( SELECT user_id FROM tb_pluss_user_promotion WHERE (is_extend = 4 or is_extend=1))) d
|
||||
LEFT JOIN view_base_order b ON d.user_id = b.userId
|
||||
GROUP BY
|
||||
d.user_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -415,7 +415,7 @@
|
|||
) d
|
||||
LEFT JOIN view_base_order o ON d.user_id = o.userId
|
||||
WHERE
|
||||
date_format( `o`.`createDt`, '%Y-%m-%d' ) = date_format(( curdate() - INTERVAL 1 DAY ), '%Y-%m-%d' )) m ON t.id = m.id
|
||||
date_format( `o`.`createDt`, '%Y-%m-%d' ) = date_format(( curdate() - INTERVAL 0 DAY ), '%Y-%m-%d' )) m ON t.id = m.id
|
||||
JOIN ( SELECT * FROM view_merchant_profit_sum WHERE userId = #{userId} ) p
|
||||
</select>
|
||||
|
||||
|
|
@ -464,4 +464,204 @@
|
|||
order by v.id desc
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectProfitByDay" resultType="java.util.Map">
|
||||
|
||||
SELECT
|
||||
d.a AS times,
|
||||
IFNULL( k.price, 0 ) AS price
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date_sub( curdate( ), INTERVAL 7 DAY ) AS a UNION
|
||||
SELECT
|
||||
date_sub( curdate( ), INTERVAL 6 DAY ) AS a UNION
|
||||
SELECT
|
||||
date_sub( curdate( ), INTERVAL 5 DAY ) AS a UNION
|
||||
SELECT
|
||||
date_sub( curdate( ), INTERVAL 4 DAY ) AS a UNION
|
||||
SELECT
|
||||
date_sub( curdate( ), INTERVAL 3 DAY ) AS a UNION
|
||||
SELECT
|
||||
date_sub( curdate( ), INTERVAL 2 DAY ) AS a UNION
|
||||
SELECT
|
||||
date_sub( curdate( ), INTERVAL 1 DAY ) AS a
|
||||
FROM
|
||||
DUAL
|
||||
) d
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
o.recordDate,
|
||||
sum( o.price ) AS price
|
||||
FROM
|
||||
tb_pluss_merchant_profit o
|
||||
WHERE
|
||||
o.userId IN (
|
||||
SELECT
|
||||
p.user_id
|
||||
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
|
||||
WHERE
|
||||
FIND_IN_SET( p.user_id, ID._ids )
|
||||
ORDER BY
|
||||
user_id
|
||||
)
|
||||
GROUP BY
|
||||
o.recordDate
|
||||
) k ON d.a = k.recordDate
|
||||
</select>
|
||||
|
||||
<select id="selectProfitByMonth" resultType="java.util.Map">
|
||||
SELECT
|
||||
f.mymonth,
|
||||
IFNULL( d.price, 0 ) AS price
|
||||
FROM
|
||||
( SELECT CONCAT( #{year}, '-', `code` ) AS mymonth FROM tb_pluss_month ) f
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
DATE_FORMAT( o.recordDate, '%Y-%m' ) AS recordDate,
|
||||
sum( o.price ) AS price
|
||||
FROM
|
||||
tb_pluss_merchant_profit o
|
||||
WHERE
|
||||
o.userId IN (
|
||||
SELECT
|
||||
p.user_id
|
||||
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
|
||||
WHERE
|
||||
FIND_IN_SET( p.user_id, ID._ids )
|
||||
ORDER BY
|
||||
user_id
|
||||
)
|
||||
AND YEAR ( o.recordDate )= #{year}
|
||||
GROUP BY
|
||||
DATE_FORMAT( o.recordDate, '%Y-%m' )) d ON f.mymonth = d.recordDate
|
||||
ORDER BY
|
||||
f.mymonth ASC
|
||||
</select>
|
||||
|
||||
<select id="selectOrderByMonth" resultType="java.util.Map">
|
||||
|
||||
|
||||
SELECT
|
||||
f.mymonth,
|
||||
IFNULL(d.consumeFee,0) as consumeFee
|
||||
FROM
|
||||
( SELECT CONCAT( #{year}, '-', `code` ) AS mymonth FROM tb_pluss_month ) f
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
DATE_FORMAT( o.createDate, '%Y-%m' ) AS createDate,
|
||||
sum( o.consumeFee ) AS consumeFee
|
||||
FROM
|
||||
view_base_order o
|
||||
WHERE
|
||||
o.userId IN (
|
||||
SELECT
|
||||
p.user_id
|
||||
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
|
||||
WHERE
|
||||
FIND_IN_SET( p.user_id, ID._ids )
|
||||
ORDER BY
|
||||
user_id
|
||||
)
|
||||
AND YEAR ( o.createDate )= #{year}
|
||||
GROUP BY
|
||||
DATE_FORMAT( o.createDate, '%Y-%m' )) d ON f.mymonth = d.createDate
|
||||
order by f.mymonth asc
|
||||
</select>
|
||||
|
||||
<select id="selectOrderByDay" resultType="java.util.Map">
|
||||
SELECT
|
||||
d.a AS times,
|
||||
IFNULL( k.consumeFee, 0 ) AS consumeFee
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
date_sub( curdate( ), INTERVAL 7 DAY ) AS a UNION
|
||||
SELECT
|
||||
date_sub( curdate( ), INTERVAL 6 DAY ) AS a UNION
|
||||
SELECT
|
||||
date_sub( curdate( ), INTERVAL 5 DAY ) AS a UNION
|
||||
SELECT
|
||||
date_sub( curdate( ), INTERVAL 4 DAY ) AS a UNION
|
||||
SELECT
|
||||
date_sub( curdate( ), INTERVAL 3 DAY ) AS a UNION
|
||||
SELECT
|
||||
date_sub( curdate( ), INTERVAL 2 DAY ) AS a UNION
|
||||
SELECT
|
||||
date_sub( curdate( ), INTERVAL 1 DAY ) AS a
|
||||
FROM
|
||||
DUAL
|
||||
) d
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
o.createDate,
|
||||
sum( o.consumeFee ) AS consumeFee
|
||||
FROM
|
||||
tb_pluss_merchant_order o
|
||||
LEFT JOIN tb_pluss_merchant_base_info b ON o.merchantCode = b.merchantCode
|
||||
WHERE
|
||||
o.`status` = 1
|
||||
AND b.userId IN (
|
||||
SELECT
|
||||
p.user_id
|
||||
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
|
||||
WHERE
|
||||
FIND_IN_SET( p.user_id, ID._ids )
|
||||
ORDER BY
|
||||
user_id
|
||||
)
|
||||
GROUP BY
|
||||
o.createDate
|
||||
) k ON d.a = k.createDate
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -303,7 +303,7 @@
|
|||
|
||||
<select id="selectCountByUserId" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
IFNULL(count(p.user_id),count(p.user_id)) as sumAccount
|
||||
IFNULL(count(p.user_id),0) as sumAccount
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
|
|
@ -318,9 +318,10 @@
|
|||
) ID,
|
||||
tb_pluss_user_promotion p
|
||||
WHERE
|
||||
p.type_code='MC' and
|
||||
FIND_IN_SET( p.user_id, ID._ids )
|
||||
ORDER BY
|
||||
user_id
|
||||
p.user_id
|
||||
</select>
|
||||
|
||||
<select id="selectOrderByUserIdOrAgecyCode" resultType="java.util.Map">
|
||||
|
|
|
|||
Loading…
Reference in New Issue