提交团油统计

dev-discount
袁野 3 years ago
parent 8b2f35f92c
commit 0fcf02d6f5
  1. 84
      hai-bweb/src/main/java/com/bweb/controller/HighOrderController.java
  2. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  3. 1
      hai-bweb/src/main/java/com/bweb/controller/HighTyAgentController.java
  4. 1
      hai-cweb/src/main/java/com/cweb/controller/CommonController.java
  5. 105
      hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java
  6. 84
      hai-service/src/main/java/com/hai/model/TyOrderCountModel.java
  7. 26
      hai-service/src/main/java/com/hai/model/TyOrderGorpModel.java
  8. 12
      hai-service/src/main/java/com/hai/service/HighOrderService.java
  9. 62
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java

@ -1,6 +1,7 @@
package com.bweb.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bweb.config.SysConst;
import com.bweb.model.ExportHighOrderModel;
@ -17,6 +18,8 @@ import com.hai.common.utils.ResponseMsgUtil;
import com.hai.common.utils.WxUtils;
import com.hai.config.HuiLianTongUnionCardConfig;
import com.hai.entity.HighOrder;
import com.hai.entity.HighTyAgent;
import com.hai.entity.HighTySalesman;
import com.hai.entity.OutRechargeOrder;
import com.hai.model.HighOrderModel;
import com.hai.model.OrderRefundModel;
@ -24,8 +27,11 @@ import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.HighCouponCodeService;
import com.hai.service.HighOrderService;
import com.hai.service.HighTyAgentService;
import com.hai.service.HighTySalesmanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -59,6 +65,12 @@ public class HighOrderController {
@Resource
private HighCouponCodeService highCouponCodeService;
@Resource
private HighTyAgentService highTyAgentService;
@Resource
private HighTySalesmanService highTySalesmanService;
@RequestMapping(value = "/getOrderById", method = RequestMethod.GET)
@ResponseBody
@ -771,7 +783,7 @@ public class HighOrderController {
}
}
@RequestMapping(value = "/HLTOrderByIndex", method = RequestMethod.GET)
@RequestMapping(value = "/1", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "工会卡预支付首页统计")
public ResponseData HLTOrderByIndex(
@ -820,5 +832,75 @@ public class HighOrderController {
}
}
@RequestMapping(value = "/TyOrderStatistics", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "团油订单统计")
public ResponseData TyOrderStatistics(@RequestBody JSONObject object) {
try {
Map<String, Object> map = new HashMap<>();
Map<String, Object> mapSam = new HashMap<>();
Map<String, Object> mapOrg = new HashMap<>();
StringBuilder salesmanIds = new StringBuilder();
if (object.getInteger("organizationId") != null) {
// 设置为空
salesmanIds.setLength(0);
// 查询代理商
mapOrg.put("orgId" , object.getInteger("organizationId"));
List<HighTyAgent> highTyAgentList = highTyAgentService.getAgentList(mapOrg);
for (HighTyAgent tyAgent : highTyAgentList) {
// 查询业务员
mapSam.put("tyAgentId" , tyAgent.getId());
List<HighTySalesman> salesmanList = highTySalesmanService.getSalesmanList(mapSam);
for (HighTySalesman salesman: salesmanList) {
salesmanIds.append(salesman.getId()).append(",");
}
}
}
if (object.getInteger("agentId") != null) {
// 设置为空
salesmanIds.setLength(0);
// 查询业务员
mapOrg.put("tyAgentId" , object.getInteger("agentId"));
List<HighTySalesman> salesmanList = highTySalesmanService.getSalesmanList(mapSam);
for (HighTySalesman salesman: salesmanList) {
salesmanIds.append(salesman.getId()).append(",");
}
}
if (object.getInteger("gasSalesmanId") != null) {
// 设置为空
salesmanIds.setLength(0);
salesmanIds.append(object.getInteger("gasSalesmanId"));
}
if (salesmanIds.length() == 0) {
map.put("gasSalesmanId" , null);
} else {
salesmanIds.deleteCharAt(salesmanIds.length() - 1);
map.put("gasSalesmanId" , salesmanIds.toString());
}
map.put("payType" , object.getInteger("payType"));
map.put("gasOilNo" , object.getString("gasOilNo"));
map.put("gasOilType" , object.getInteger("gasOilType"));
map.put("goodsId" , object.getLong("goodsId"));
map.put("createTimeS" , object.getLong("createTimeS"));
map.put("createTimeE" , object.getLong("createTimeE"));
return ResponseMsgUtil.success(highOrderService.TyOrderStatistics(map));
} catch (Exception e) {
log.error("HighOrderController --> getUserOrderList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

File diff suppressed because one or more lines are too long

@ -184,6 +184,7 @@ public class HighTyAgentController {
}
param.put("agentKey", agentKey);
param.put("agentName", agentName);
param.put("orgId", orgId);
param.put("agentUser", agentUser);
param.put("agentPhone", agentPhone);

@ -187,7 +187,6 @@ public class CommonController {
}
}
@RequestMapping(value="/getDictionaryByCodeTypeAndExt",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据 码值类型 查询数据字典")

@ -949,4 +949,109 @@ public interface HighOrderMapperExt {
"where id in (select b.order_id from high_child_order b where goods_type = 3 and mem_id = #{userId} and child_orde_status in (2,3)) " +
"and year(pay_time)=year(now()) and month(pay_time) = month(now()) and day(pay_time) = day(now())"})
int selectGasTheDayOrderNum(@Param("userId") Long userId);
@Select(value = {
"<script>",
"select sum(pay_real_price) as tradePrice,sum(deduction_price) as discountedPrice,sum(total_price) as orderPrice ",
"from ",
"(select pay_price, pay_real_price, deduction_price, ho.total_price as total_price from high_order ho join high_child_order hco on ho.id = hco.order_id ",
"where hco.goods_type = 3 and ho.order_status in (2, 3) ",
"<if test='map.payType != null'> and ho.pay_type = #{map.payType} </if> " ,
"<if test='map.gasOilNo != null'> and hco.gas_oil_no = #{map.gasOilNo} </if> " ,
"<if test='map.gasOilType != null'> and hco.gas_oil_type = #{map.gasOilType} </if> " ,
"<if test='map.goodsId != null'> and hco.goods_id = #{map.goodsId} </if> " ,
"<if test='map.createTimeS != null'> <![CDATA[ and ho.create_time >= #{map.createTimeS} ]]> </if> " +
"<if test='map.createTimeE != null'> <![CDATA[ and ho.create_time <= #{map.createTimeE} ]]> </if> " +
"<if test='map.gasSalesmanId != null'> and hco.gas_salesman_id in ( #{map.gasSalesmanId} ) </if> " ,
") as hh; " ,
"</script>"
})
@Results({
@Result(column="tradePrice", property="tradePrice", jdbcType=JdbcType.DECIMAL),
@Result(column="discountedPrice", property="discountedPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="orderPrice", property="orderPrice", jdbcType=JdbcType.DECIMAL),
})
TyOrderCountModel TyOrderCount(@Param("map") Map<String,Object> map);
@Select(value = {
"<script>",
"select count(total_price) ",
"from ",
"(select pay_price, pay_real_price, deduction_price, ho.total_price as total_price from high_order ho join high_child_order hco on ho.id = hco.order_id ",
"where hco.goods_type = 3 and ho.order_status in (2, 3) ",
"<if test='map.payType != null'> and ho.pay_type = #{map.payType} </if> " ,
"<if test='map.gasOilNo != null'> and hco.gas_oil_no = #{map.gasOilNo} </if> " ,
"<if test='map.gasOilType != null'> and hco.gas_oil_type = #{map.gasOilType} </if> " ,
"<if test='map.goodsId != null'> and hco.goods_id = #{map.goodsId} </if> " ,
"<if test='map.createTimeS != null'> <![CDATA[ and ho.create_time >= #{map.createTimeS} ]]> </if> " +
"<if test='map.createTimeE != null'> <![CDATA[ and ho.create_time <= #{map.createTimeE} ]]> </if> " +
"<if test='map.gasSalesmanId != null'> and hco.gas_salesman_id in ( #{map.gasSalesmanId} ) </if> " ,
") as hh; " ,
"</script>"
})
int TyOrderNum(@Param("map") Map<String,Object> map);
@Select(value = {
"<script>",
"select count(total_price) ",
"from ",
"(select pay_price, pay_real_price, deduction_price, ho.total_price as total_price from high_order ho join high_child_order hco on ho.id = hco.order_id ",
"where hco.goods_type = 3 and ho.order_status in (2, 3) ",
"<if test='map.payType != null'> and ho.pay_type = #{map.payType} </if> " ,
"<if test='map.gasOilNo != null'> and hco.gas_oil_no = #{map.gasOilNo} </if> " ,
"<if test='map.gasOilType != null'> and hco.gas_oil_type = #{map.gasOilType} </if> " ,
"<if test='map.goodsId != null'> and hco.goods_id = #{map.goodsId} </if> " ,
"<if test='map.totalPrice != null'> <![CDATA[ and ho.total_price < #{map.totalPrice} ]]> </if> " ,
"<if test='map.createTimeS != null'> <![CDATA[ and ho.create_time >= #{map.createTimeS} ]]> </if> " ,
"<if test='map.createTimeE != null'> <![CDATA[ and ho.create_time <= #{map.createTimeE} ]]> </if> " ,
"<if test='map.gasSalesmanId != null'> and hco.gas_salesman_id in ( #{map.gasSalesmanId} ) </if> " ,
") as hh; " ,
"</script>"
})
int TyOrderNumByPrice(@Param("map") Map<String,Object> map);
@Select(value = {
"<script>",
"select count(*) as value , " +
"case pay_type when 1 then '支付宝' when 2 then '微信' when 3 then '金币' when 4 then '工会卡' when 5 then '银联' end name " +
"from high_order ho join high_child_order hco on ho.id = hco.order_id ",
"where hco.goods_type = 3 and ho.order_status in (2, 3) ",
"<if test='map.payType != null'> and ho.pay_type = #{map.payType} </if> " ,
"<if test='map.gasOilNo != null'> and hco.gas_oil_no = #{map.gasOilNo} </if> " ,
"<if test='map.gasOilType != null'> and hco.gas_oil_type = #{map.gasOilType} </if> " ,
"<if test='map.goodsId != null'> and hco.goods_id = #{map.goodsId} </if> " ,
"<if test='map.gasSalesmanId != null'> and hco.gas_salesman_id in ( #{map.gasSalesmanId} ) </if> " ,
"<if test='map.createTimeS != null'> <![CDATA[ and ho.create_time >= #{map.createTimeS} ]]> </if> " ,
"<if test='map.createTimeE != null'> <![CDATA[ and ho.create_time <= #{map.createTimeE} ]]> </if> " ,
"group by pay_type " ,
"</script>"
})
@Results({
@Result(column="value", property="value", jdbcType=JdbcType.INTEGER),
@Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
})
List<TyOrderGorpModel> TyOrderNumGroupByPayType(@Param("map") Map<String,Object> map);
@Select(value = {
"<script>",
"select count(*) as value , hco.gas_oil_no as name from high_order ho join high_child_order hco on ho.id = hco.order_id ",
"where hco.goods_type = 3 and ho.order_status in (2, 3) ",
"<if test='map.payType != null'> and ho.pay_type = #{map.payType} </if> " ,
"<if test='map.gasOilNo != null'> and hco.gas_oil_no = #{map.gasOilNo} </if> " ,
"<if test='map.gasOilType != null'> and hco.gas_oil_type = #{map.gasOilType} </if> " ,
"<if test='map.goodsId != null'> and hco.goods_id = #{map.goodsId} </if> " ,
"<if test='map.gasSalesmanId != null'> and hco.gas_salesman_id in ( #{map.gasSalesmanId} ) </if> " ,
"<if test='map.createTimeS != null'> <![CDATA[ and ho.create_time >= #{map.createTimeS} ]]> </if> " ,
"<if test='map.createTimeE != null'> <![CDATA[ and ho.create_time <= #{map.createTimeE} ]]> </if> " ,
"group by hco.gas_oil_no " ,
"</script>"
})
@Results({
@Result(column="value", property="value", jdbcType=JdbcType.INTEGER),
@Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
})
List<TyOrderGorpModel> TyOrderNumGroupByGasOilNo(@Param("map") Map<String,Object> map);
}

@ -0,0 +1,84 @@
package com.hai.model;
import java.math.BigDecimal;
import java.util.List;
public class TyOrderCountModel {
// 订单定额
private BigDecimal orderPrice;
// 交易金额
private BigDecimal tradePrice;
// 优惠金额
private BigDecimal discountedPrice;
// 订单数量
private Integer orderNum;
// 金额分布列表
private List<TyOrderGorpModel> priceGorp;
// 支付方式分组
private List<TyOrderGorpModel> payTypeGorp;
// 油品方式分组
private List<TyOrderGorpModel> gasOilNoGorp;
public BigDecimal getOrderPrice() {
return orderPrice;
}
public void setOrderPrice(BigDecimal orderPrice) {
this.orderPrice = orderPrice;
}
public BigDecimal getTradePrice() {
return tradePrice;
}
public void setTradePrice(BigDecimal tradePrice) {
this.tradePrice = tradePrice;
}
public BigDecimal getDiscountedPrice() {
return discountedPrice;
}
public void setDiscountedPrice(BigDecimal discountedPrice) {
this.discountedPrice = discountedPrice;
}
public Integer getOrderNum() {
return orderNum;
}
public void setOrderNum(Integer orderNum) {
this.orderNum = orderNum;
}
public List<TyOrderGorpModel> getPriceGorp() {
return priceGorp;
}
public void setPriceGorp(List<TyOrderGorpModel> priceGorp) {
this.priceGorp = priceGorp;
}
public List<TyOrderGorpModel> getPayTypeGorp() {
return payTypeGorp;
}
public void setPayTypeGorp(List<TyOrderGorpModel> payTypeGorp) {
this.payTypeGorp = payTypeGorp;
}
public List<TyOrderGorpModel> getGasOilNoGorp() {
return gasOilNoGorp;
}
public void setGasOilNoGorp(List<TyOrderGorpModel> gasOilNoGorp) {
this.gasOilNoGorp = gasOilNoGorp;
}
}

@ -0,0 +1,26 @@
package com.hai.model;
public class TyOrderGorpModel {
// 数量
private Integer value;
// 类型
private String name;
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

@ -379,4 +379,16 @@ public interface HighOrderService {
*/
int getGasTheDayOrderNum(Long userId);
/**
* @Author Sum1Dream
* @name TyOrderStatistics.java
* @Description // 团游订单统计
* @Date 15:01 2022/3/31
* @Param [java.util.Map<java.lang.String,java.lang.Object>]
* @return com.hai.model.TyOrderCountModel
*/
TyOrderCountModel TyOrderStatistics(Map<String , Object> map) throws Exception;
}

@ -22,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.OffsetDateTime;
import java.util.*;
/**
@ -1242,6 +1243,65 @@ public class HighOrderServiceImpl implements HighOrderService {
@Override
public int getGasTheDayOrderNum(Long userId) {
return 0;
// return highOrderMapper.selectGasTheDayOrderNum(userId);
}
@Override
public TyOrderCountModel TyOrderStatistics(Map<String, Object> map) throws Exception {
if(MapUtils.getLong(map, "createTimeS") != null) {
map.put("createTimeS", DateUtil.date2String(new Date(MapUtils.getLong(map, "createTimeS")), "yyyy-MM-dd HH:mm:ss"));
}
if(MapUtils.getLong(map, "createTimeE") != null) {
map.put("createTimeE", DateUtil.date2String(new Date(MapUtils.getLong(map, "createTimeE")), "yyyy-MM-dd HH:mm:ss"));
}
TyOrderCountModel tyOrderCountModel = new TyOrderCountModel();
if (highOrderMapper.TyOrderCount(map) != null) {
tyOrderCountModel = highOrderMapper.TyOrderCount(map);
tyOrderCountModel.setOrderNum(highOrderMapper.TyOrderNum(map));
}
Integer[] priceArr = {100 , 200, 300, 400 , 20000};
List<TyOrderGorpModel> priceList = new ArrayList<>();
for(Integer s: priceArr) {
TyOrderGorpModel tyOrderGorpModel = new TyOrderGorpModel();
map.put("totalPrice" , s);
tyOrderGorpModel.setName(priceName(s));
tyOrderGorpModel.setValue(highOrderMapper.TyOrderNumByPrice(map));
priceList.add(tyOrderGorpModel);
}
priceList.get(1).setValue(priceList.get(1).getValue() - priceList.get(0).getValue());
priceList.get(2).setValue(priceList.get(2).getValue() - priceList.get(1).getValue() - priceList.get(0).getValue());
priceList.get(3).setValue(priceList.get(3).getValue() - priceList.get(2).getValue() - priceList.get(1).getValue() - priceList.get(0).getValue());
priceList.get(4).setValue(priceList.get(4).getValue() - priceList.get(3).getValue() - priceList.get(2).getValue() - priceList.get(1).getValue() - priceList.get(0).getValue());
tyOrderCountModel.setPriceGorp(priceList);
tyOrderCountModel.setPayTypeGorp(highOrderMapper.TyOrderNumGroupByPayType(map));
tyOrderCountModel.setGasOilNoGorp(highOrderMapper.TyOrderNumGroupByGasOilNo(map));
return tyOrderCountModel;
}
public String priceName(Integer num) {
switch (num) {
case 100 :
return "100元以下";
case 200 :
return "100-200元";
case 300 :
return "200-300元";
case 400 :
return "300-400元";
default :
return "400元以上";
}
}
}

Loading…
Cancel
Save