提交代码

pre
胡锐 2 weeks ago
parent 8c7765dfbd
commit b4f9c98cb7
  1. 122
      bweb/src/main/java/com/bweb/controller/BsUserSpreadController.java
  2. 26
      service/src/main/java/com/hfkj/dao/BsGasOrderSpreadMapperExt.java
  3. 22
      service/src/main/java/com/hfkj/dao/BsUserSpreadAccountMapperExt.java
  4. 21
      service/src/main/java/com/hfkj/dao/BsUserSpreadRelMapperExt.java
  5. 8
      service/src/main/java/com/hfkj/service/gas/BsGasOrderSpreadService.java
  6. 16
      service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderSpreadServiceImpl.java

@ -8,15 +8,12 @@ import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsUserSpreadOilChannel;
import com.hfkj.entity.BsUserSpreadPower;
import com.hfkj.entity.BsUserSpreadRel;
import com.hfkj.entity.*;
import com.hfkj.model.ResponseData;
import com.hfkj.model.UserSessionObject;
import com.hfkj.service.spread.BsUserSpreadAccountService;
import com.hfkj.service.spread.BsUserSpreadOilChannelService;
import com.hfkj.service.spread.BsUserSpreadPowerService;
import com.hfkj.service.spread.BsUserSpreadRelService;
import com.hfkj.service.gas.BsGasOrderService;
import com.hfkj.service.gas.BsGasOrderSpreadService;
import com.hfkj.service.spread.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
@ -42,8 +39,14 @@ public class BsUserSpreadController {
@Resource
private BsUserSpreadOilChannelService userSpreadOilChannelService;
@Resource
private BsUserSpreadAccountRecordService userSpreadAccountRecordService;
@Resource
private BsUserSpreadAccountService userSpreadAccountService;
@Resource
private BsGasOrderSpreadService gasOrderSpreadService;
@Resource
private BsGasOrderService gasOrderService;
@Resource
private BsUserSpreadRelService userSpreadRelService;
@RequestMapping(value = "/editOilChannel", method = RequestMethod.POST)
@ -89,6 +92,20 @@ public class BsUserSpreadController {
}
}
@RequestMapping(value = "/getOilChannelList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询油站渠道列表")
public ResponseData getOilChannelList(@RequestParam(value = "channel", required = false) Integer channel) {
try {
Map<String,Object> param = new HashMap<>();
param.put("channel", channel);
return ResponseMsgUtil.success(userSpreadOilChannelService.getList(param));
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getUserSpreadList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询推广用户列表")
@ -139,14 +156,95 @@ public class BsUserSpreadController {
}
}
@RequestMapping(value = "/getOilChannelList", method = RequestMethod.GET)
@RequestMapping(value = "/countAccount", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询油站渠道列表")
public ResponseData getOilChannelList(@RequestParam(value = "channel", required = false) Integer channel) {
@ApiOperation(value = "统计金额")
public ResponseData countAccount(@RequestParam(value = "userId", required = true) Long userId,
@RequestParam(name = "orderStatus", required = false) Integer orderStatus,
@RequestParam(name = "payTimeS", required = false) Long payTimeS,
@RequestParam(name = "payTimeE", required = false) Long payTimeE) {
try {
Map<String,Object> param = new HashMap<>();
param.put("channel", channel);
return ResponseMsgUtil.success(userSpreadOilChannelService.getList(param));
param.put("userId", userId);
param.put("orderStatus", orderStatus);
param.put("payTimeS", payTimeS);
param.put("payTimeE", payTimeE);
return ResponseMsgUtil.success(gasOrderSpreadService.countSettleOrderPrice(param));
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/queryOilOrderSpread",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询加油推广订单")
public ResponseData queryOilOrderSpread(@RequestParam(value = "userId", required = true) Long userId,
@RequestParam(name = "orderNo", required = false) String orderNo,
@RequestParam(name = "orderStatus", required = false) Integer orderStatus,
@RequestParam(name = "payTimeS", required = false) Long payTimeS,
@RequestParam(name = "payTimeE", required = false) Long payTimeE,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize) {
try {
Map<String,Object> param = new HashMap<>();
param.put("userId", userId);
param.put("orderNo", orderNo);
param.put("status", orderStatus);
param.put("payTimeS", payTimeS);
param.put("payTimeE", payTimeE);
PageHelper.startPage(pageNum,pageSize);
return ResponseMsgUtil.success(new PageInfo<>(gasOrderService.getOilOrderSpread(param)));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getAccount", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询余额账户")
public ResponseData getAccount(@RequestParam(value = "userId", required = true) Long userId) {
try {
// 查询账户
BsUserSpreadAccount userSpreadAccount = userSpreadAccountService.getDetailByUser(userId);
if (userSpreadAccount == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
HashMap<String,Object> map = new HashMap<>();
// 账户余额
map.put("amount", userSpreadAccount.getAmount());
map.put("cashOutAmount", userSpreadAccount.getCashOutAmount());
map.put("notCashOutAmount", gasOrderSpreadService.getNotCashOutAmount(userSpreadAccount.getUserId()));
return ResponseMsgUtil.success(map);
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getRecordList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询记录列表")
public ResponseData getRecordList(@RequestParam(value = "userId", required = true) Long userId,
@RequestParam(value = "type", required = false) Integer type,
@RequestParam(value = "sourceType", required = false) Integer sourceType,
@RequestParam(value = "createTimeS", required = false) Long createTimeS,
@RequestParam(value = "createTimeE", required = false) Long createTimeE,
@RequestParam(value = "pageNum", required = true) Integer pageNum,
@RequestParam(value = "pageSize", required = true) Integer pageSize) {
try {
Map<String,Object> param = new HashMap<>();
param.put("userId", userId);
param.put("type", type);
param.put("sourceType", sourceType);
param.put("createTimeS", createTimeS);
param.put("createTimeE", createTimeE);
PageHelper.startPage(pageNum,pageSize);
return ResponseMsgUtil.success(new PageInfo<>(userSpreadAccountRecordService.getList(param)));
} catch (Exception e) {
return ResponseMsgUtil.exception(e);

@ -34,6 +34,32 @@ public interface BsGasOrderSpreadMapperExt {
" ) a")
HashMap<String,Object> querySettleOrderList(@Param("param") Map<String,Object> param);
@Select("<script>" +
" select " +
" case when sum(totalAmount) is not null then sum(totalAmount) else 0 end" +
" from (" +
" select sum(b.gains_rebate_amount) totalAmount" +
" from bs_gas_order a LEFT JOIN bs_gas_order_spread b on a.order_no = b.order_no" +
" WHERE b.gains_rebate_user_id = #{param.userId} and a.`status` in (${param.status})" +
" <if test='param.payTimeS != null'> <![CDATA[ and a.pay_time >= #{param.payTimeS} ]]> </if>" +
" <if test='param.payTimeE != null'> <![CDATA[ and a.pay_time <= #{param.payTimeE} ]]> </if>" +
" union all" +
" select sum(b.gains_rebate_one_amount) totalAmount" +
" from bs_gas_order a LEFT JOIN bs_gas_order_spread b on a.order_no = b.order_no" +
" WHERE b.gains_rebate_one_user_id = #{param.userId} and a.`status` in (${param.status}) " +
" <if test='param.payTimeS != null'> <![CDATA[ and a.pay_time >= #{param.payTimeS} ]]> </if>" +
" <if test='param.payTimeE != null'> <![CDATA[ and a.pay_time <= #{param.payTimeE} ]]> </if>" +
" union all" +
" select sum(b.gains_rebate_two_amount) totalAmount" +
" from bs_gas_order a LEFT JOIN bs_gas_order_spread b on a.order_no = b.order_no" +
" WHERE b.gains_rebate_two_user_id = #{param.userId} and a.`status` in (${param.status}) " +
" <if test='param.payTimeS != null'> <![CDATA[ and a.pay_time >= #{param.payTimeS} ]]> </if>" +
" <if test='param.payTimeE != null'> <![CDATA[ and a.pay_time <= #{param.payTimeE} ]]> </if>" +
" ) a" +
"</script>")
BigDecimal countSettleOrderPrice(@Param("param") Map<String,Object> param);
@Select(" select " +
" case when sum(totalAmount) is not null then sum(totalAmount) else 0 end" +
" from (" +

@ -1,7 +1,27 @@
package com.hfkj.dao;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.math.BigDecimal;
import java.util.Map;
/**
* mapper扩展类
*/
public interface BsUserSpreadAccountMapperExt {
}
@Select("<script>" +
" select " +
" case when sum(transaction_amount) is not null then sum(transaction_amount) else 0 end amount" +
" from bs_user_spread_account_record " +
" where status = 1 " +
" and user_id = #{param.userId} " +
" <if test='param.type != null'> and type = #{param.type} </if>" +
" <if test='param.sourceType != null'> and source_type = #{param.sourceType} </if>" +
" <if test='param.createTimeS != null'><![CDATA[ and create_time >= #{param.createTimeS} ]]> </if>" +
" <if test='param.createTimeE != null'><![CDATA[ and create_time <= #{param.createTimeE} ]]> </if>" +
"</script>")
BigDecimal countSpreadAmount(@Param("param") Map<String,Object> param);
}

@ -3,6 +3,7 @@ package com.hfkj.dao;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -28,19 +29,23 @@ public interface BsUserSpreadRelMapperExt {
List<HashMap<String,Object>> getTeamList(@Param("param") Map<String,Object> param);
@Select("<script>" +
" select " +
" b.id userId," +
" b.user_name userName," +
" b.phone," +
" c.id userId," +
" c.user_name userName," +
" c.phone," +
" b.amount," +
" b.cash_out_amount cashOutAmount," +
" a.create_time createTime," +
" a.status," +
" count(c.id) spreadCount" +
" count(d.id) spreadCount" +
" from bs_user_spread_power a" +
" LEFT JOIN bs_user b on b.id = a.user_id" +
" LEFT JOIN bs_user_spread_rel c on c.parent_user_id = b.id" +
" LEFT JOIN bs_user_spread_account b on b.user_id = a.user_id" +
" LEFT JOIN bs_user c on c.id = a.user_id" +
" LEFT JOIN bs_user_spread_rel d on d.parent_user_id = b.id" +
" where 1 = 1" +
" <if test='param.phone != null'> and b.phone like concat('%',#{param.phone},'%') </if>" +
" GROUP BY b.id" +
" <if test='param.phone != null'> and c.phone like concat('%',#{param.phone},'%') </if>" +
" GROUP BY c.id" +
" ORDER BY a.create_time desc" +
"</script>")
List<HashMap<String,Object>> getUserSpreadList(@Param("param") Map<String,Object> param);
}

@ -4,6 +4,7 @@ import com.hfkj.entity.BsGasOrder;
import com.hfkj.entity.BsGasOrderSpread;
import java.math.BigDecimal;
import java.util.Map;
/**
* @className: BsGasOrderSpreadService
@ -36,6 +37,13 @@ public interface BsGasOrderSpreadService {
*/
void settleOrder(Long userId) throws Exception;
/**
* 统计结算订单金额
* @param param
* @throws Exception
*/
BigDecimal countSettleOrderPrice(Map<String,Object> param);
/**
* 查询未结算金额
* @param userId

@ -9,6 +9,7 @@ import com.hfkj.service.spread.BsUserSpreadOilChannelService;
import com.hfkj.service.spread.BsUserSpreadRelService;
import com.hfkj.sysenum.spread.UserSpreadAccountRecordSourceTypeEnum;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -105,6 +106,21 @@ public class BsGasOrderSpreadServiceImpl implements BsGasOrderSpreadService {
}
}
@Override
public BigDecimal countSettleOrderPrice(Map<String, Object> param) {
if (StringUtils.isBlank(MapUtils.getString(param, "status"))) {
// 设置查询默认状态数据
param.put("status", "2,4");
}
if (MapUtils.getLong(param, "payTimeS") != null) {
param.put("payTimeS", DateUtil.date2String(new Date(MapUtils.getLong(param, "payTimeS")),DateUtil.Y_M_D_HMS));
}
if (MapUtils.getLong(param, "payTimeE") != null) {
param.put("payTimeE", DateUtil.date2String(new Date(MapUtils.getLong(param, "payTimeE")),DateUtil.Y_M_D_HMS));
}
return gasOrderSpreadMapper.countSettleOrderPrice(param);
}
@Override
public BigDecimal getNotCashOutAmount(Long userId) {
return gasOrderSpreadMapper.queryNotCashOutAmount(userId);

Loading…
Cancel
Save