技师首页-业绩、收益

This commit is contained in:
曹磊 2024-07-10 23:00:59 +08:00
parent c66ba90caa
commit 0fd37f61ca
6 changed files with 534 additions and 122 deletions

View File

@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -56,6 +57,8 @@ public interface OrdersDao extends BaseMapper<Orders> {
IPage<Orders> selectTodayOrder(Page<Orders> pages,@Param("artificerId") Long artificerId,@Param("type") Integer type,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("minutes") Integer minutes);
IPage<Orders> selectDividedIntoDetails(Page<Orders> pages,@Param("artificerId") Long artificerId,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("isSfwc") Integer isSfwc);
IPage<Orders> selectArtificerOrder(Page<Orders> pages, Long userId, Integer status);
int selectOrdersCountByUnderway(@Param("artificerId") Long artificerId);
@ -93,13 +96,15 @@ public interface OrdersDao extends BaseMapper<Orders> {
Double selectNewUserOrdersRate();
Integer selectOrdersArtificerIntegralAchievement(Long artificerId, String endDate, String startDate);
Integer selectOrdersArtificerIntegralEarnings(Long artificerId, String endDate, String startDate);
String selectOrdersArtificerIntegral(Long artificerId, String endDate, String startDate);
String selectOrdersArtificerIntegraladdNum(Long artificerId, String endDate, String startDate);
String selectOrdersCurrentPeriodRechargeSum(Long artificerId, String endDate, String startDate);
String selectOrdersCurrentPeriodRechargeSum(Long artificerId, String endDate, String startDate,@Param("isSfwc") Integer isSfwc);
String selectOrdersStoredValueIntegral(Long artificerId, String endDate, String startDate);
@ -123,7 +128,7 @@ public interface OrdersDao extends BaseMapper<Orders> {
IPage<Orders> getJiazhongList(Page<Orders> pages, Long userId, Integer isSfwc, String startTime, String endTime);
IPage<Orders> getChongzhiList(Page<Orders> pages, Long userId, Integer isSfwc, String startTime, String endTime);
IPage<Orders> getChongzhiList(Page<Orders> pages, Long artificerId, Integer isSfwc, String startTime, String endTime);
String selectOrdersZxscNum(Long artificerId, String startTime, String endTime);

View File

@ -88,6 +88,13 @@ public class Orders implements Serializable {
@TableField(exist = false)
private BigDecimal artificerMoneyTotal;
/**
* 总业绩
*/
@TableField(exist = false)
private BigDecimal priceTotal;
/**
* 服务费用
*/

View File

@ -67,23 +67,26 @@ public class AppArtificerIntegralServiceImpl implements AppArtificerIntegralServ
orders.setGrade(grade);
//当期业绩
Integer currentPerformance = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, endDate, startDate);
Integer currentPerformance = ordersDao.selectOrdersArtificerIntegralAchievement(artificerId, endDate, startDate);
orders.setCurrentPerformance(String.valueOf(currentPerformance));
//当期收益
String earnings = ordersDao.earnings(artificerId, endDate, startDate);
// String earnings = ordersDao.earnings(artificerId, endDate, startDate);
String earnings = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, endDate, startDate).toString();
orders.setEarnings(earnings);
//当日收益
String todayEndIncome = DateUtil.formatDateTime(DateUtil.endOfDay(new Date()));
String dailyEarnings = ordersDao.earnings(artificerId, todayEndIncome, String.valueOf(DateUtil.beginOfDay(new Date())));
// String dailyEarnings = ordersDao.earnings(artificerId, todayEndIncome, String.valueOf(DateUtil.beginOfDay(new Date())));
String dailyEarnings = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, todayEndIncome, String.valueOf(DateUtil.beginOfDay(new Date()))).toString();
orders.setDailyEarnings(dailyEarnings);
//当月收益
//当月结束日
String startFundDataformat = DateUtil.formatDateTime(DateUtil.beginOfMonth(new Date()));
String endFundDataformat = DateUtil.formatDateTime(DateUtil.endOfMonth(new Date()));
String currentMonthsIncome = ordersDao.earnings(artificerId, endFundDataformat, startFundDataformat);
// String currentMonthsIncome = ordersDao.earnings(artificerId, endFundDataformat, startFundDataformat);
String currentMonthsIncome = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, endFundDataformat, startFundDataformat).toString();
orders.setCurrentMonthsIncome(currentMonthsIncome);
//当期结束日
@ -128,7 +131,7 @@ public class AppArtificerIntegralServiceImpl implements AppArtificerIntegralServ
orders.setCurrentPeriodAddBellsSum(clockRate.toString());
//当前周期充值率(本周期内充值订单数/本单数)
String currentPeriodRechargeSum = ordersDao.selectOrdersCurrentPeriodRechargeSum(artificerId, endDate, startDate);
String currentPeriodRechargeSum = ordersDao.selectOrdersCurrentPeriodRechargeSum(artificerId, endDate, startDate,1);
BigDecimal c = new BigDecimal(currentPeriodRechargeSum);
divide1 = c.divide(currentPeriodOrdersSumBig, 2, RoundingMode.HALF_UP);
orders.setCurrentPeriodRechargeSum(divide1.toString());
@ -315,7 +318,7 @@ public class AppArtificerIntegralServiceImpl implements AppArtificerIntegralServ
if (currentPeriodOrdersSumBig.compareTo(new BigDecimal("0")) != 0) {
clockRate = currentPeriodAddBellsSumBig.divide(currentPeriodOrdersSumBig, 2, RoundingMode.HALF_UP);
//当前周期充值率(本周期内充值订单数/本单数)
String currentPeriodRechargeSum = ordersDao.selectOrdersCurrentPeriodRechargeSum(artificerId, date, cycleTime);
String currentPeriodRechargeSum = ordersDao.selectOrdersCurrentPeriodRechargeSum(artificerId, date, cycleTime,1);
BigDecimal c = new BigDecimal(currentPeriodRechargeSum);
divide1 = c.divide(currentPeriodOrdersSumBig, 2, RoundingMode.HALF_UP);
} else {
@ -424,7 +427,7 @@ public class AppArtificerIntegralServiceImpl implements AppArtificerIntegralServ
if (currentPeriodOrdersSumBig.compareTo(new BigDecimal("0")) != 0) {
clockRate = currentPeriodAddBellsSumBig.divide(currentPeriodOrdersSumBig, 2, RoundingMode.HALF_UP);
//当前周期充值率(本周期内充值订单数/本单数)
String currentPeriodRechargeSum = ordersDao.selectOrdersCurrentPeriodRechargeSum(artificerId, date, cycleTime);
String currentPeriodRechargeSum = ordersDao.selectOrdersCurrentPeriodRechargeSum(artificerId, date, cycleTime,1);
BigDecimal c = new BigDecimal(currentPeriodRechargeSum);
divide1 = c.divide(currentPeriodOrdersSumBig, 2, RoundingMode.HALF_UP);
} else {

View File

@ -550,7 +550,7 @@ public class ArtificerServiceImpl extends ServiceImpl<ArtificerDao, Artificer> i
clockRate = currentPeriodAddBellsSumBig.divide(currentPeriodOrdersSumBig, 2, RoundingMode.HALF_UP);//加钟率
//当前周期充值率(本周期内充值订单数/本单数)
String currentPeriodRechargeSum = ordersDao.selectOrdersCurrentPeriodRechargeSum(artificerId, endTime, startTime);
String currentPeriodRechargeSum = ordersDao.selectOrdersCurrentPeriodRechargeSum(artificerId, endTime, startTime,1);
BigDecimal c = new BigDecimal(currentPeriodRechargeSum);
divide1 = c.divide(currentPeriodOrdersSumBig, 2, RoundingMode.HALF_UP);//充值率
} else {
@ -689,11 +689,14 @@ public class ArtificerServiceImpl extends ServiceImpl<ArtificerDao, Artificer> i
String earnings = "0";
BigDecimal cy100 = new BigDecimal(100);
if(orderType == 1){//1当期
ordersIPage = ordersDao.getDangqiList(pages, userId,isSfwc,startTime,endTime);
earnings = ordersDao.earnings(userId, endTime, startTime);
// ordersIPage = ordersDao.getDangqiList(pages, userId,isSfwc,startTime,endTime);
ordersIPage = ordersDao.selectDividedIntoDetails(pages, userId,startTime,endTime,null);
int yeji = ordersDao.selectOrdersArtificerIntegralEarnings(userId, endTime, startTime);
earnings = yeji+"";
}else if(orderType == 2){//2加钟
//查询列表
ordersIPage = ordersDao.getJiazhongList(pages, userId,isSfwc,startTime,endTime);
// ordersIPage = ordersDao.getJiazhongList(pages, userId,isSfwc,startTime,endTime);
ordersIPage = ordersDao.selectDividedIntoDetails(pages, userId,startTime,endTime,isSfwc);
//当期加钟率本周期内加钟数/本单数
String jzl = ordersDao.selectOrdersArtificerIntegraladdNum(userId, endTime, startTime);
//加钟数
@ -704,17 +707,17 @@ public class ArtificerServiceImpl extends ServiceImpl<ArtificerDao, Artificer> i
System.out.println(currentPeriodOrdersSumBig+"=========="+num+"---"+clockRate);
}else if(orderType == 3){//3充值
ordersIPage = ordersDao.getChongzhiList(pages, userId,isSfwc,startTime,endTime);
//当前周期充值率(本周期内充值订单数/本单数)
String currentPeriodRechargeSum = ordersDao.selectOrdersCurrentPeriodRechargeSum(userId, endTime, startTime);
String currentPeriodRechargeSum = ordersDao.selectOrdersCurrentPeriodRechargeSum(userId, endTime, startTime,1);
BigDecimal c = new BigDecimal(currentPeriodRechargeSum);
BigDecimal divide1 = c.divide(currentPeriodOrdersSumBig, 2, RoundingMode.HALF_UP);
divide1 = divide1.multiply(cy100);
earnings = divide1.intValue()+"%";
System.out.println(currentPeriodOrdersSumBig+"=========="+c+"---"+divide1);
}else if(orderType == 4){//业绩
ordersIPage = ordersDao.getDangqiList(pages, userId,isSfwc,startTime,endTime);
int yeji = ordersDao.selectOrdersArtificerIntegralEarnings(userId, endTime, startTime);
// ordersIPage = ordersDao.getDangqiList(pages, userId,isSfwc,startTime,endTime);
ordersIPage = ordersDao.selectDividedIntoDetails(pages, userId,startTime,endTime,null);
int yeji = ordersDao.selectOrdersArtificerIntegralAchievement(userId, endTime, startTime);
earnings = yeji+"";
}

View File

@ -6667,20 +6667,24 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
}
@Override
public Result selectDividedIntoDetails(Integer page, Integer limit, Period period) {
IPage<Orders> page1 = new Page(page, limit);
QueryWrapper<Orders> queryWrapper = new QueryWrapper();
queryWrapper.eq("artificer_id", period.getArtificerId());
if(StringUtil.isNotEmpty(period.getStartFundData().toString())){
queryWrapper.between("end_times", period.getStartFundData(), period.getEndFundData());
}
//只查询已完成和待评价的订单
queryWrapper.in("status", Arrays.asList(5, 3));
//只查询根节点数据
queryWrapper.eq("parent_id", 0);
queryWrapper.orderByDesc("end_times");
IPage<Orders> page2 = baseMapper.selectPage(page1, queryWrapper);
//分成明细添加到返回对象中
return Result.success().put("data", page2);
Page<Orders> page1 = new Page(page, limit);
// QueryWrapper<Orders> queryWrapper = new QueryWrapper();
// queryWrapper.eq("artificer_id", period.getArtificerId());
// if(StringUtil.isNotEmpty(period.getStartFundData().toString())){
// queryWrapper.between("end_times", period.getStartFundData(), period.getEndFundData());
// }
// //只查询已完成和待评价的订单
// queryWrapper.in("status", Arrays.asList(5, 3));
// //只查询根节点数据
// queryWrapper.eq("parent_id", 0);
// queryWrapper.orderByDesc("end_times");
// IPage<Orders> page2 = baseMapper.selectPage(page1, queryWrapper);
// //分成明细添加到返回对象中
// return Result.success().put("data", page2);
String startFundData = DateUtils.format(period.getStartFundData());
String endFundData = DateUtils.format(period.getEndFundData());
return Result.success().put("data", baseMapper.selectDividedIntoDetails(page1,Long.valueOf(period.getArtificerId()),startFundData,endFundData,0));
}
@Override

View File

@ -762,6 +762,73 @@
order by serve_time desc
</select>
<select id="selectDividedIntoDetails" resultType="com.sqx.modules.artificer.entity.Orders">
select o.*,
(case when o.user_package_detail_id is null then m.title else bl.title end ) as title,
(case when o.user_package_detail_id is null then m.massage_img else bl.massage_img end ) as massageImg,
(case when o.status = 4
then o.artificer_money + ifnull(o.add_artificer_money,0)
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) + ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
end) as artificer_money_total
from orders o
left join orders o2 on o.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
left join orders_massage om on om.orders_id=o.orders_id
left join massage_type m on m.massage_type_id=om.massage_id
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
where o.artificer_id = #{artificerId}
and o.old_orders_id is not null
and o.status not in (4,11,15)
<if test="startTime!=null and startTime!=''">
and date_format(o.end_times,'%Y-%m-%d') >= #{startTime}
</if>
<if test="endTime!=null and endTime!=''">
and date_format(o.end_times,'%Y-%m-%d') &lt;= #{endTime}
</if>
<if test="isSfwc != null and isSfwc == 0">
and ifnull(o.add_num,0) = 0
</if>
<if test="isSfwc != null and isSfwc == 1">
and o.add_num > 0
</if>
and o.status in (3,5)
union all
select o.*,
(case when o.user_package_detail_id is null then m.title else bl.title end ) as title,
(case when o.user_package_detail_id is null then m.massage_img else bl.massage_img end ) as massageImg,
o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total
from orders o
left join orders_massage om on om.orders_id=o.orders_id
left join massage_type m on m.massage_type_id=om.massage_id
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
where o.artificer_id = #{artificerId}
and o.parent_id = 0
and o.orders_id not in (
select orders_id from orders
where old_orders_id is not null
and status != 4
)
and o.orders_id not in (
select old_orders_id from orders
where old_orders_id is not null
and status != 4
)
<if test="startTime!=null and startTime!=''">
and date_format(o.end_times,'%Y-%m-%d') >= #{startTime}
</if>
<if test="endTime!=null and endTime!=''">
and date_format(o.end_times,'%Y-%m-%d') &lt;= #{endTime}
</if>
<if test="isSfwc != null and isSfwc == 0">
and ifnull(o.add_num,0) = 0
</if>
<if test="isSfwc != null and isSfwc == 1">
and o.add_num > 0
</if>
and o.status in (3,5)
order by serve_time desc
</select>
<select id="selectArtificerOrder" resultType="com.sqx.modules.artificer.entity.Orders">
select o.*,a.artificer_name as artificerName,a.artificer_img as artificerImg,a.user_id as artificerUserId
from orders o
@ -1038,80 +1105,281 @@
FROM tb_user u
WHERE date_format(DATE_ADD(u.create_time, INTERVAL 7 DAY ), '%Y-%m-%d') >= date_format(now(),'%Y-%m-%d')) a
</select>
<!--当期业绩-->
<select id="selectOrdersArtificerIntegralEarnings" resultType="java.lang.Integer">
select
IFNULL( SUM(o.price ),0) AS currentPerformance
<!--当期业绩-->
<select id="selectOrdersArtificerIntegralAchievement" resultType="java.lang.Integer">
select IFNULL(SUM(price_total),0) AS currentAchievement
from (
select o.*,
(
(case when o.is_supplement in (1,3,4) then 0 else o.price end) + ifnull(o.add_price,0)
+ ifnull((case when o2.is_supplement in (1,3,4) then 0 else o2.price end),0) + ifnull(o2.add_price,0)
+ ifnull((case when o3.is_supplement in (1,3,4) then 0 else o3.price end),0) + ifnull(o3.add_price,0)
) as price_total
from orders o
left join artificer a on a.artificer_id=o.artificer_id
left join tb_user u on u.user_id=o.user_id
left join consortia c on c.consortia_id=o.consortia_id
where o.artificer_id=#{artificerId}
left join orders o2 on o.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
left join orders_massage om on om.orders_id=o.orders_id
left join massage_type m on m.massage_type_id=om.massage_id
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
where o.artificer_id = #{artificerId}
and o.old_orders_id is not null
and o.status not in (4,11,15)
<if test="startDate!=null and startDate !=''">
and o.end_times >= #{startDate}
and date_format(o.end_times,'%Y-%m-%d') >= #{startDate}
</if>
<if test="endDate!=null and endDate !=''">
and o.end_times &lt;= #{endDate}
and date_format(o.end_times,'%Y-%m-%d') &lt;= #{endDate}
</if>
<!-- and o.end_times BETWEEN #{startDate} and #{endDate}-->
and o.status in (3,5)
union all
select o.*,
o.price + ifnull(o.add_price,0) as price_total
from orders o
left join orders_massage om on om.orders_id=o.orders_id
where o.artificer_id = #{artificerId}
and o.parent_id = 0
and o.orders_id not in (
select orders_id from orders
where old_orders_id is not null
and status != 4
)
and o.orders_id not in (
select old_orders_id from orders
where old_orders_id is not null
and status != 4
)
<if test="startDate!=null and startDate !=''">
and date_format(o.end_times,'%Y-%m-%d') >= #{startDate}
</if>
<if test="endDate!=null and endDate !=''">
and date_format(o.end_times,'%Y-%m-%d') &lt;= #{endDate}
</if>
and o.status in (3,5)
) t
</select>
<!--当期收益-->
<select id="selectOrdersArtificerIntegralEarnings" resultType="java.lang.Integer">
select IFNULL(SUM(artificer_money_total),0) AS currentEarnings
from (
select (case when o.status = 4
then o.artificer_money + ifnull(o.add_artificer_money,0)
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) + ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
end) as artificer_money_total
from orders o
left join orders o2 on o.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 o.artificer_id = #{artificerId}
and o.old_orders_id is not null
and o.status not in (4,11,15)
<if test="startDate!=null and startDate !=''">
and date_format(o.end_times,'%Y-%m-%d') >= #{startDate}
</if>
<if test="endDate!=null and endDate !=''">
and date_format(o.end_times,'%Y-%m-%d') &lt;= #{endDate}
</if>
and o.status in (3,5)
union all
select o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total
from orders o
where o.artificer_id = #{artificerId}
and o.parent_id = 0
and o.orders_id not in (
select orders_id from orders
where old_orders_id is not null
and status != 4
)
and o.orders_id not in (
select old_orders_id from orders
where old_orders_id is not null
and status != 4
)
<if test="startDate!=null and startDate !=''">
and date_format(o.end_times,'%Y-%m-%d') >= #{startDate}
</if>
<if test="endDate!=null and endDate !=''">
and date_format(o.end_times,'%Y-%m-%d') &lt;= #{endDate}
</if>
and o.status in (3,5)
) t
</select>
<!-- 订单数-->
<select id="selectOrdersArtificerIntegral" resultType="java.lang.String">
select
IFNULL( count(o.orders_id ),'0') AS currentPeriodOrdersSum
select IFNULL( count(*),'0') AS currentPeriodOrdersSum
from (
select (case when o.status = 4
then o.artificer_money + ifnull(o.add_artificer_money,0)
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) + ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
end) as artificer_money_total
from orders o
left join artificer a on a.artificer_id=o.artificer_id
left join tb_user u on u.user_id=o.user_id
left join consortia c on c.consortia_id=o.consortia_id
where o.artificer_id=#{artificerId}
<!-- and o.end_times BETWEEN #{startDate} and #{endDate}-->
left join orders o2 on o.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 o.artificer_id = #{artificerId}
and o.old_orders_id is not null
and o.status not in (4,11,15)
<if test="startDate!=null and startDate !=''">
and o.end_times >= #{startDate}
and date_format(o.end_times,'%Y-%m-%d') >= #{startDate}
</if>
<if test="endDate!=null and endDate !=''">
and o.end_times &lt;= #{endDate}
and date_format(o.end_times,'%Y-%m-%d') &lt;= #{endDate}
</if>
and o.status in (3,5)
union all
select o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total
from orders o
where o.artificer_id = #{artificerId}
and o.parent_id = 0
and o.orders_id not in (
select orders_id from orders
where old_orders_id is not null
and status != 4
)
and o.orders_id not in (
select old_orders_id from orders
where old_orders_id is not null
and status != 4
)
<if test="startDate!=null and startDate !=''">
and date_format(o.end_times,'%Y-%m-%d') >= #{startDate}
</if>
<if test="endDate!=null and endDate !=''">
and date_format(o.end_times,'%Y-%m-%d') &lt;= #{endDate}
</if>
and o.status in (3,5)
) t
</select>
<!-- 加钟率-->
<select id="selectOrdersArtificerIntegraladdNum" resultType="java.lang.String">
select
IFNULL( count(o.add_num ),'0') AS currentPeriodAddBellsSum
select IFNULL(count(*),0) AS currentPeriodAddBellsSum
from (
select o.*
from orders o
left join artificer a on a.artificer_id=o.artificer_id
left join tb_user u on u.user_id=o.user_id
left join consortia c on c.consortia_id=o.consortia_id
where o.artificer_id=#{artificerId}
left join orders o2 on o.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 o.artificer_id = #{artificerId}
and o.old_orders_id is not null
and o.status not in (4,11,15)
and o.add_num > 0
<if test="startDate!=null and startDate !=''">
and o.end_times >= #{startDate}
and date_format(o.end_times,'%Y-%m-%d') >= #{startDate}
</if>
<if test="endDate!=null and endDate !=''">
and o.end_times &lt;= #{endDate}
and date_format(o.end_times,'%Y-%m-%d') &lt;= #{endDate}
</if>
<!-- and o.end_times BETWEEN #{startDate} and #{endDate} -->
and o.status in (3,5)
union all
select o.*
from orders o
where o.artificer_id = #{artificerId}
and o.parent_id = 0
and o.orders_id not in (
select orders_id from orders
where old_orders_id is not null
and status != 4
)
and o.orders_id not in (
select old_orders_id from orders
where old_orders_id is not null
and status != 4
)
and o.add_num > 0
<if test="startDate!=null and startDate !=''">
and date_format(o.end_times,'%Y-%m-%d') >= #{startDate}
</if>
<if test="endDate!=null and endDate !=''">
and date_format(o.end_times,'%Y-%m-%d') &lt;= #{endDate}
</if>
and o.status in (3,5)
) t
</select>
<!-- 充值率-->
<select id="selectOrdersCurrentPeriodRechargeSum" resultType="java.lang.String">
select
IFNULL( count(user_recharge ),'0') AS currentPeriodRechargeSum
select IFNULL( count(*),'0') AS currentPeriodRechargeSum
from (
select o.*,
(case when o.user_package_detail_id is null then m.title else bl.title end ) as title,
(case when o.user_package_detail_id is null then m.massage_img else bl.massage_img end ) as massageImg,
(case when o.status = 4
then o.artificer_money + ifnull(o.add_artificer_money,0)
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) +
ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
end) as artificer_money_total
from orders o
left join artificer a on a.artificer_id=o.artificer_id
left join tb_user u on u.user_id=o.user_id
left join consortia c on c.consortia_id=o.consortia_id
left join user_recharge uu on uu.orders_id = o.orders_id
where o.artificer_id=#{artificerId}
left join orders o2 on o.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
left join orders_massage om on om.orders_id=o.orders_id
left join massage_type m on m.massage_type_id=om.massage_id
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
where o.artificer_id = #{artificerId}
and o.old_orders_id is not null
and o.status not in (4,11,15)
<if test="startDate!=null and startDate !=''">
and o.end_times >= #{startDate}
and date_format(o.end_times,'%Y-%m-%d') >= #{startDate}
</if>
<if test="endDate!=null and endDate !=''">
and o.end_times &lt;= #{endDate}
and date_format(o.end_times,'%Y-%m-%d') &lt;= #{endDate}
</if>
<!-- and o.end_times BETWEEN #{startDate} and #{endDate} -->
<if test="isSfwc != null and isSfwc == 0">
and o.orders_id not in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and
type = '2' and orders_id is not null)
and (
case when o2.orders_id is not null then
o2.orders_id not in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and
type = '2' and orders_id is not null)
else 1=1 end)
and (
case when o3.orders_id is not null then
o3.orders_id not in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and
type = '2' and orders_id is not null)
else 1=1 end)
</if>
<if test="isSfwc != null and isSfwc == 1">
and (o.orders_id in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and
type = '2' and orders_id is not null)
or o2.orders_id in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and
type = '2' and orders_id is not null)
or o3.orders_id in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and
type = '2' and orders_id is not null)
)
</if>
and o.status in (3,5)
union all
select o.*,
(case when o.user_package_detail_id is null then m.title else bl.title end ) as title,
(case when o.user_package_detail_id is null then m.massage_img else bl.massage_img end ) as massageImg,
o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total
from orders o
left join orders_massage om on om.orders_id=o.orders_id
left join massage_type m on m.massage_type_id=om.massage_id
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
where o.artificer_id = #{artificerId}
and o.parent_id = 0
and uu.type = 2
and o.orders_id not in (
select orders_id from orders
where old_orders_id is not null
and status != 4
)
and o.orders_id not in (
select old_orders_id from orders
where old_orders_id is not null
and status != 4
)
<if test="startDate!=null and startDate !=''">
and date_format(o.end_times,'%Y-%m-%d') >= #{startDate}
</if>
<if test="endDate!=null and endDate !=''">
and date_format(o.end_times,'%Y-%m-%d') &lt;= #{endDate}
</if>
<if test="isSfwc != null and isSfwc == 0">
and o.orders_id not in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and
type = '2' and orders_id is not null)
</if>
<if test="isSfwc != null and isSfwc == 1">
and o.orders_id in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and
type = '2' and orders_id is not null)
</if>
and o.status in (3,5)
) t
</select>
<!-- 储值积分数-->
<select id="selectOrdersStoredValueIntegral" resultType="java.lang.String">
@ -1176,7 +1444,6 @@
and o.status in (3,5,15)
</select>
<select id="getDangqiList" resultType="com.sqx.modules.artificer.entity.Orders">
select a.*,b.massage_img from orders a
left join massage_type b on a.massage_type_id = b.massage_type_id
@ -1201,47 +1468,170 @@
</select>
<select id="getChongzhiList" resultType="com.sqx.modules.artificer.entity.Orders">
select
o.*,uu.user_recharge as userRecharge,b.massage_img
<!-- select-->
<!-- o.*,uu.user_recharge as userRecharge,b.massage_img-->
<!-- from orders o-->
<!-- left join artificer a on a.artificer_id=o.artificer_id-->
<!-- left join user_recharge uu on uu.orders_id = o.orders_id-->
<!-- left join massage_type b on o.massage_type_id = b.massage_type_id-->
<!-- where o.artificer_id=#{userId} and o.parent_id = 0-->
<!-- and o.status in (3,5,15)-->
<!-- and o.end_times BETWEEN #{startTime} and #{endTime}-->
<!-- <if test="isSfwc != null and isSfwc == 0">-->
<!-- and uu.type is null-->
<!-- </if>-->
<!-- <if test="isSfwc != null and isSfwc == 1">-->
<!-- and uu.type = 2-->
<!-- </if>-->
select o.*,
(case when o.user_package_detail_id is null then m.title else bl.title end ) as title,
(case when o.user_package_detail_id is null then m.massage_img else bl.massage_img end ) as massageImg,
(case when o.status = 4
then o.artificer_money + ifnull(o.add_artificer_money,0)
else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) + ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0)
end) as artificer_money_total
from orders o
left join artificer a on a.artificer_id=o.artificer_id
left join user_recharge uu on uu.orders_id = o.orders_id
left join massage_type b on o.massage_type_id = b.massage_type_id
where o.artificer_id=#{userId} and o.parent_id = 0
and o.status in (3,5,15)
and o.end_times BETWEEN #{startTime} and #{endTime}
left join orders o2 on o.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
left join orders_massage om on om.orders_id=o.orders_id
left join massage_type m on m.massage_type_id=om.massage_id
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
where o.artificer_id = #{artificerId}
and o.old_orders_id is not null
and o.status not in (4,11,15)
<if test="startTime!=null and startTime!=''">
and date_format(o.end_times,'%Y-%m-%d') >= #{startTime}
</if>
<if test="endTime!=null and endTime!=''">
and date_format(o.end_times,'%Y-%m-%d') &lt;= #{endTime}
</if>
<if test="isSfwc != null and isSfwc == 0">
and uu.type is null
and o.orders_id not in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and type = '2' and orders_id is not null)
and (
case when o2.orders_id is not null then
o2.orders_id not in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and type = '2' and orders_id is not null)
else 1=1 end)
and (
case when o3.orders_id is not null then
o3.orders_id not in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and type = '2' and orders_id is not null)
else 1=1 end)
</if>
<if test="isSfwc != null and isSfwc == 1">
and uu.type = 2
and (o.orders_id in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and type = '2' and orders_id is not null)
or o2.orders_id in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and type = '2' and orders_id is not null)
or o3.orders_id in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and type = '2' and orders_id is not null)
)
</if>
and o.status in (3,5)
union all
select o.*,
(case when o.user_package_detail_id is null then m.title else bl.title end ) as title,
(case when o.user_package_detail_id is null then m.massage_img else bl.massage_img end ) as massageImg,
o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total
from orders o
left join orders_massage om on om.orders_id=o.orders_id
left join massage_type m on m.massage_type_id=om.massage_id
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
where o.artificer_id = #{artificerId}
and o.parent_id = 0
and o.orders_id not in (
select orders_id from orders
where old_orders_id is not null
and status != 4
)
and o.orders_id not in (
select old_orders_id from orders
where old_orders_id is not null
and status != 4
)
<if test="startTime!=null and startTime!=''">
and date_format(o.end_times,'%Y-%m-%d') >= #{startTime}
</if>
<if test="endTime!=null and endTime!=''">
and date_format(o.end_times,'%Y-%m-%d') &lt;= #{endTime}
</if>
<if test="isSfwc != null and isSfwc == 0">
and o.orders_id not in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and type = '2' and orders_id is not null)
</if>
<if test="isSfwc != null and isSfwc == 1">
and o.orders_id in (select distinct orders_id from user_recharge where artificer_id = #{artificerId} and type = '2' and orders_id is not null)
</if>
and o.status in (3,5)
order by serve_time desc
</select>
<!-- 获取业绩积分-->
<select id="getYjjfList" resultType="com.sqx.modules.artificer.entity.Orders">
select a.*,a.price as jifen,a.end_times as jftime,b.massage_img from orders a
left join massage_type b on a.massage_type_id = b.massage_type_id
where a.status in (3,5,15)
and a.artificer_id = ${userId}
and a.end_times BETWEEN #{startTime} and #{endTime}
select t.*,price_total AS jifen
from (
select o.*,
(
(case when o.is_supplement in (1,3,4) then 0 else o.price end) + ifnull(o.add_price,0)
+ ifnull((case when o2.is_supplement in (1,3,4) then 0 else o2.price end),0) + ifnull(o2.add_price,0)
+ ifnull((case when o3.is_supplement in (1,3,4) then 0 else o3.price end),0) + ifnull(o3.add_price,0)
) as price_total
from orders o
left join orders o2 on o.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
left join orders_massage om on om.orders_id=o.orders_id
left join massage_type m on m.massage_type_id=om.massage_id
LEFT JOIN bl_user_package_detail bl ON bl.id = om.massage_id
where o.artificer_id = ${userId}
and o.old_orders_id is not null
and o.status not in (4,11,15)
<if test="startTime!=null and startTime !=''">
and date_format(o.end_times,'%Y-%m-%d') >= #{startTime}
</if>
<if test="endTime!=null and endTime !=''">
and date_format(o.end_times,'%Y-%m-%d') &lt;= #{endTime}
</if>
and o.status in (3,5)
union all
select o.*,
o.price + ifnull(o.add_price,0) as price_total
from orders o
left join orders_massage om on om.orders_id=o.orders_id
where o.artificer_id = ${userId}
and o.parent_id = 0
and o.orders_id not in (
select orders_id from orders
where old_orders_id is not null
and status != 4
)
and o.orders_id not in (
select old_orders_id from orders
where old_orders_id is not null
and status != 4
)
<if test="startTime!=null and startTime !=''">
and date_format(o.end_times,'%Y-%m-%d') >= #{startTime}
</if>
<if test="endTime!=null and endTime !=''">
and date_format(o.end_times,'%Y-%m-%d') &lt;= #{endTime}
</if>
and o.status in (3,5)
) t
</select>
<!-- 获取储值积分(为他充值的)-->
<select id="getCzjfList" resultType="com.sqx.modules.artificer.entity.Orders">
select id,user_recharge as jifen,create_time as jftime from user_recharge
where type = 2 and orders_id is null
where type = 2
and orders_id is null
and artificer_id = ${userId}
and create_time BETWEEN #{startTime} and #{endTime}
</select>
<!-- 获取订单充值积分-->
<select id="getDdczList" resultType="com.sqx.modules.artificer.entity.Orders">
select id,user_recharge as jifen,a.create_time as jftime,b.* from user_recharge a , orders b
where a.orders_id = b.orders_id and type = 2
and a.artificer_id =${userId}
and a.create_time BETWEEN #{startTime} and #{endTime}
select id,user_recharge as jifen,create_time as jftime
from user_recharge
where type = 2
and orders_id is not null
and artificer_id =${userId}
and create_time BETWEEN #{startTime} and #{endTime}
</select>
<!-- 获取在线时长积分-->
<select id="getZxscList" resultType="com.sqx.modules.artificer.entity.Orders">
select id,sum(user_recharge) as jifen,DATE_FORMAT(create_time,'%Y-%m-%d') as jftime from user_recharge
select id,sum(user_recharge) as jifen,DATE_FORMAT(create_time,'%Y-%m-%d') as jftime
from user_recharge
where type = 1
and artificer_id =${userId}
and create_time BETWEEN #{startTime} and #{endTime}