提交代码

dev-discount
胡锐 3 years ago
parent 1cecea1e90
commit f682237f51
  1. 157
      hai-bweb/src/main/java/com/bweb/controller/HighGasController.java
  2. 144
      hai-cweb/src/main/java/com/cweb/controller/HighGasController.java
  3. 4
      hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java
  4. 11
      hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java
  5. 47
      hai-service/src/main/java/com/hai/enum_type/OrderStatusEnum.java
  6. 8
      hai-service/src/main/java/com/hai/service/HighGasOilPriceService.java
  7. 10
      hai-service/src/main/java/com/hai/service/HighOrderService.java
  8. 5
      hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceServiceImpl.java
  9. 13
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java

@ -1,6 +1,8 @@
package com.bweb.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONObject;
import com.bweb.config.SysConst;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
@ -8,27 +10,20 @@ import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.CoordCommonUtil;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.PageUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.HuiLianTongUnionCardConfig;
import com.hai.config.TuanYouConfig;
import com.hai.config.WxOrderConfig;
import com.hai.entity.HighChildOrder;
import com.hai.entity.HighGasOilPrice;
import com.hai.entity.HighMerchantStore;
import com.hai.entity.HighOrder;
import com.hai.enum_type.GasOilPriceStatusEnum;
import com.hai.enum_type.MerStoreAmountSourceTypeEnum;
import com.hai.enum_type.MerStoreAmountTypeEnum;
import com.hai.enum_type.OrderPayTypeEnum;
import com.hai.model.HighMerchantStoreModel;
import com.hai.model.OrderRefundModel;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.entity.*;
import com.hai.enum_type.*;
import com.hai.model.*;
import com.hai.msg.entity.MsgTopic;
import com.hai.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -38,6 +33,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.File;
import java.util.*;
import java.util.stream.Collectors;
@ -82,15 +78,39 @@ public class HighGasController {
Map<String, Object> param = new HashMap<>();;
param.put("gasName", userInfoModel.getMerchantStore().getStoreName());
Map<String, Object> today = new HashMap<>();
Map<String, Object> history = new HashMap<>();
// 历史加油总金额
Map<String, Object> historyTotal = highOrderService.getGasHistoryOrderCount(userInfoModel.getMerchantStore().getId(), "2,3,4,6,7");
history.put("totalPrice", historyTotal.get("price"));
history.put("totalCount", historyTotal.get("count"));
// 历史加油金额
Map<String, Object> historyIncomet = highOrderService.getGasHistoryOrderCount(userInfoModel.getMerchantStore().getId(), "2,3,6,7");
history.put("incomePrice", historyIncomet.get("price"));
history.put("incomeCount", historyIncomet.get("count"));
// 历史退款
Map<String, Object> historyRefund = highOrderService.getGasHistoryOrderCount(userInfoModel.getMerchantStore().getId(), "4");
history.put("refundPrice", historyRefund.get("price"));
history.put("refundCount", historyRefund.get("count"));
param.put("history", history);
Map<String, Object> incometObject = highOrderService.getGasTheDayOrderCount(userInfoModel.getMerchantStore().getId(), "2,3,6,7");
today.put("incomePrice", incometObject.get("price"));
today.put("incomeCount", incometObject.get("count"));
Map<String, Object> refundObject = highOrderService.getGasTheDayOrderCount(userInfoModel.getMerchantStore().getId(), "4");
today.put("refundPrice", refundObject.get("price"));
today.put("refundCount", refundObject.get("count"));
Map<String, Object> today = new HashMap<>();
// 今日加油总金额
Map<String, Object> todayTotal = highOrderService.getGasTheDayOrderCount(userInfoModel.getMerchantStore().getId(), "2,3,4,6,7");
today.put("totalPrice", todayTotal.get("price"));
today.put("totalCount", todayTotal.get("count"));
// 今日加油金额
Map<String, Object> todayIncomet = highOrderService.getGasTheDayOrderCount(userInfoModel.getMerchantStore().getId(), "2,3,6,7");
today.put("incomePrice", todayIncomet.get("price"));
today.put("incomeCount", todayIncomet.get("count"));
// 今日退款
Map<String, Object> todayRefund = highOrderService.getGasTheDayOrderCount(userInfoModel.getMerchantStore().getId(), "4");
today.put("refundPrice", todayRefund.get("price"));
today.put("refundCount", todayRefund.get("count"));
param.put("today", today);
return ResponseMsgUtil.success(param);
@ -106,6 +126,8 @@ public class HighGasController {
@ApiOperation(value = "查询油站订单列表")
public ResponseData getGasOrderList(@RequestParam(name = "orderNo", required = false) String orderNo,
@RequestParam(name = "status", required = false) Integer status,
@RequestParam(name = "createTimeS", required = false) Long createTimeS,
@RequestParam(name = "createTimeE", required = false) Long createTimeE,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize) {
try {
@ -117,6 +139,8 @@ public class HighGasController {
Map<String, Object> param = new HashMap<>();;
param.put("storeId", userInfoModel.getMerchantStore().getId());
param.put("orderNo", orderNo);
param.put("createTimeS", createTimeS);
param.put("createTimeE", createTimeE);
if (status == null) {
param.put("status", "2,3,4,6,7");
@ -133,6 +157,85 @@ public class HighGasController {
}
}
@RequestMapping(value="/exportGasOrder",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "导出油站订单")
public ResponseData exportGasOrder(@RequestParam(name = "orderNo", required = false) String orderNo,
@RequestParam(name = "status", required = false) Integer status,
@RequestParam(name = "createTimeS", required = false) Long createTimeS,
@RequestParam(name = "createTimeE", required = false) Long createTimeE) {
try {
UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class);
if (userInfoModel == null || userInfoModel.getMerchantStore() == null) {
log.error("HighGasController -> disabledOil() error!","");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, "");
}
Map<String, Object> param = new HashMap<>();;
param.put("storeId", userInfoModel.getMerchantStore().getId());
param.put("orderNo", orderNo);
param.put("createTimeS", createTimeS);
param.put("createTimeE", createTimeE);
if (status == null) {
param.put("status", "2,3,4,6,7");
} else {
param.put("status", status);
}
List<String> headList = new ArrayList<>();
headList.add("订单号");
headList.add("油站名称");
headList.add("油品类型");
headList.add("油品油号");
headList.add("油枪号");
headList.add("油枪价");
headList.add("优惠价");
headList.add("加油升数");
headList.add("加油金额");
headList.add("支付金额");
headList.add("优惠金额");
headList.add("创建时间");
headList.add("状态");
List<List<Object>> dataList = new ArrayList<>();
List<Object> data;
List<GasOrderModel> orderList = highOrderService.getGasOrderList(param);
for (GasOrderModel orderModel: orderList) {
data = new ArrayList<>();
data.add(orderModel.getOrderNo());
data.add(orderModel.getGasName());
data.add(orderModel.getGasOilType().equals(1) ? "汽油": "柴油");
data.add(orderModel.getGasOilNo() + "#");
data.add(orderModel.getGasGunNo() + "号");
data.add(orderModel.getGasPriceGun());
data.add(orderModel.getGasPricePreferences());
data.add(orderModel.getGasOilLiters());
data.add(orderModel.getTotalPrice());
data.add(orderModel.getPayRealPrice());
data.add(orderModel.getDeductionPrice());
data.add(DateUtil.date2String(orderModel.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
data.add(DateUtil.date2String(orderModel.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
data.add(OrderStatusEnum.getNameByType(orderModel.getStatus()));
dataList.add(data);
}
String fileUrl = SysConst.getSysConfig().getFileUrl() + "/temporary/";
String pathName = System.currentTimeMillis()+".xlsx";
File file = new File(fileUrl);
if (!file.exists()) {
file.mkdirs();
}
EasyExcel.write(fileUrl+pathName).head(generationHead(headList)).sheet("油卡").doWrite(dataList);
return ResponseMsgUtil.success(pathName);
} catch (Exception e) {
log.error("HighGasController -> getGasOrderList() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getGasOrderDetail",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询油站订单详情")
@ -385,6 +488,22 @@ public class HighGasController {
}
}
/**
* 生成头部
* @param headList
* @return
*/
private static List<List<String>> generationHead(List<String> headList) {
List<List<String>> list = new ArrayList<>();
List<String> head;
for (String headStr : headList) {
head = new ArrayList<>();
head.add(headStr);
list.add(head);
}
return list;
}
/* @RequestMapping(value="/refuelingOrderPush",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "推送订单")

@ -142,6 +142,7 @@ public class HighGasController {
}
}
}
return ResponseMsgUtil.success(mapPageInfo);
}
return ResponseMsgUtil.success(new PageInfo<>());
@ -342,6 +343,149 @@ public class HighGasController {
}
}
@RequestMapping(value="/recentGasStation",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询最近的油站")
public ResponseData recentGasStation(@RequestParam(name = "longitude", required = true) String longitude,
@RequestParam(name = "latitude", required = true) String latitude,
@RequestParam(name = "isTyAgent", required = false) Boolean isTyAgent) {
try {
Map<String, Object> station = gasOilPriceService.recentGasStation(longitude, latitude);
if (station == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "附近没有加油站哦");
}
// 商户门店
HighMerchantStoreModel store = merchantStoreService.getMerchantStoreByKey(MapUtils.getString(station, "storeKey"));
if (store == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到加油站");
}
if (!store.getType().equals(1)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到加油站");
}
if (store.getSourceType() == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知来源的加油站");
}
// 来源类型 1:平台自建 2:团油
if (store.getSourceType().equals(1)) {
Map<String, Object> param = new HashMap<>();
param.put("provinceName", null);
param.put("provinceCode", null);
param.put("cityCode", null);
param.put("cityName", null);
param.put("countyCode", null);
param.put("countyName", null);
param.put("gasId", store.getStoreKey());
param.put("gasName", store.getStoreName());
param.put("gasAddress", store.getAddress());
param.put("gasLogoBig", CommonSysConst.getSysConfig().getHsgDomainName()+"/filesystem/"+store.getStoreLogo());
param.put("gasLogoSmall", CommonSysConst.getSysConfig().getHsgDomainName()+"/filesystem/"+store.getStoreLogo());
param.put("gasAddressLatitude", store.getLatitude());
param.put("gasAddressLongitude", store.getLongitude());
// 距离
double distance = CoordCommonUtil.getDistance(Double.valueOf(param.get("gasAddressLatitude").toString()), Double.valueOf(param.get("gasAddressLongitude").toString()), Double.valueOf(latitude), Double.valueOf(longitude));
param.put("distance", Math.round(distance/100d)/10d);
// 查询油枪
List<Map<String, Object>> gasGunMapList = new ArrayList<>();
Map<String, Object> gasGunMap;
List<HighGasOilGunNo> oilGunNoList = gasOilGunNoService.getGunNoListByStoreId(store.getId());
for (HighGasOilGunNo oilGunNo : oilGunNoList) {
gasGunMap = new HashMap<>();
gasGunMap.put("gunNo", oilGunNo.getGunNo());
gasGunMap.put("oilNo", oilGunNo.getOilNo());
gasGunMap.put("oilNoName", oilGunNo.getOilNoName());
gasGunMapList.add(gasGunMap);
}
param.put("gasGunList", gasGunMapList);
// 查询油品
List<Map<String, Object>> oilPriceMapList = new ArrayList<>();
Map<String, Object> oilPriceMap;
List<HighGasOilPrice> oilPriceList = gasOilPriceService.getGasOilPriceByStore(store.getId());
for (HighGasOilPrice oilPrice : oilPriceList) {
oilPriceMap = new HashMap<>();
oilPriceMap.put("oilType", oilPrice.getOilType());
oilPriceMap.put("oilTypeName", oilPrice.getOilTypeName());
oilPriceMap.put("oilNo", oilPrice.getOilNo());
oilPriceMap.put("oilNoName", oilPrice.getOilNoName());
oilPriceMap.put("priceVip", oilPrice.getPriceVip());
oilPriceMap.put("priceGun", oilPrice.getPriceGun());
oilPriceMap.put("priceOfficial", oilPrice.getPriceOfficial());
oilPriceMapList.add(oilPriceMap);
}
param.put("oilPriceList", oilPriceMapList);
return ResponseMsgUtil.success(param);
} else if (store.getSourceType().equals(2)) {
JSONObject jsonObject = TuanYouConfig.queryGasInfoByGasId(MapUtils.getString(station, "storeKey"));
if (jsonObject != null && jsonObject.getString("code").equals("200")) {
JSONObject result = jsonObject.getJSONObject("result");
// 原始油品价格
JSONArray originalOilPriceList = result.getJSONArray("oilPriceList");
// 新油品价格
JSONArray newOilPriceList = new JSONArray();
// 处理油品价格
for (Object oilPriceObject : originalOilPriceList) {
JSONObject price = JSON.parseObject(JSONObject.toJSONString(oilPriceObject), JSONObject.class);
// 查询油站油品状态
HighGasOilPrice oilNo = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), price.getInteger("oilNo"));
if (oilNo != null && !oilNo.getStatus().equals(GasOilPriceStatusEnum.status1.getStatus())) {
continue;
}
// 查询是否配置了【油站的】优惠比例
HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, store.getId(), price.getString("oilNo"));
if (tyAgentPrice != null) {
// 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = tyAgentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));
// 油品国标价 * 最终优惠比例
price.put("priceVip", price.getBigDecimal("priceGun").multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP));
} else {
// 查询是否配置了【油品】优惠比例
HighGasDiscountOilPrice gasDiscountOilPrice = gasDiscountOilPriceService.getDetailByOilNo(price.getString("oilNo"));
if (gasDiscountOilPrice != null) {
// 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));
// 油品国标价 * 最终优惠比例
price.put("priceVip", price.getBigDecimal("priceGun").multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP));
}
}
// 查询是否配置了【代理商油站】优惠比例
if (isTyAgent != null && isTyAgent == true) {
HighTyAgentPrice agentPrice = tyAgentPriceService.getDetail(2, store.getId(), price.getString("oilNo"));
if (agentPrice != null) {
// 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = agentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));
// 油品国标价 * 最终优惠比例
price.put("priceVip", price.getBigDecimal("priceGun").multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP));
}
}
newOilPriceList.add(price);
}
result.put("oilPriceList", newOilPriceList);
double distance = CoordCommonUtil.getDistance(Double.valueOf(result.get("gasAddressLatitude").toString()), Double.valueOf(result.get("gasAddressLongitude").toString()), Double.valueOf(latitude), Double.valueOf(longitude));
result.put("distance", Math.round(distance/100d)/10d);
return ResponseMsgUtil.success(jsonObject.get("result"));
}
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message"));
}
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到加油站");
} catch (Exception e) {
log.error("HighGasController -> getGasDetailByStoreKey() error!",e);
return ResponseMsgUtil.exception(e);
}
}
/* @RequestMapping(value="/getGasPriceDetail",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据门店key和油号 查询油价")

@ -32,4 +32,8 @@ public interface HighGasOilPriceMapperExt {
" </script>" )
List<Map<String,Object>> selectStoreListByOilNo(@Param("storeName") String storeName, @Param("regionId") Long regionId, @Param("oilNoName") String oilNoName);
@Select({"SELECT store_key storeKey,ROUND((st_distance_sphere(point(longitude, latitude) , point(${longitude},${latitude}))/1000),2) as distance\n" +
"FROM high_merchant_store where type = 1 and `status` = 1 ORDER BY distance asc LIMIT 1"})
Map<String,Object> recentGasStation(@Param("longitude") String longitude,@Param("latitude") String latitude);
}

@ -1077,10 +1077,17 @@ public interface HighOrderMapperExt {
" case when SUM(b.total_price) is null then 0 else SUM(b.total_price) end price," +
" count(1) count" +
" from high_child_order a,high_order b " +
" where a.order_id = b.id and goods_type = 3 and goods_id = #{storeId} and b.order_status in (${storeId}) " +
" where a.order_id = b.id and goods_type = 3 and goods_id = #{storeId} and b.order_status in (${status}) " +
" and to_days(pay_time) = to_days(now())"})
Map<String, Object> selectGasTheDayOrderCount(@Param("storeId") Long storeId, @Param("status") String status);
@Select({" select" +
" case when SUM(b.total_price) is null then 0 else SUM(b.total_price) end price," +
" count(1) count" +
" from high_child_order a,high_order b " +
" where a.order_id = b.id and goods_type = 3 and goods_id = #{storeId} and b.order_status in (${status}) "})
Map<String, Object> selectGasHistoryOrderCount(@Param("storeId") Long storeId, @Param("status") String status);
@Select({
"<script> " +
" select " +
@ -1114,6 +1121,8 @@ public interface HighOrderMapperExt {
" and goods_type = 3 " +
"<if test='param.storeId != null'> and goods_id = #{param.storeId} </if>" +
"<if test='param.status != null'> and b.order_status in (${param.status})</if>" +
"<if test='param.createTimeS != null'> <![CDATA[ and b.create_time >= #{param.createTimeS} ]]> </if>",
"<if test='param.createTimeE != null'> <![CDATA[ and b.create_time <= #{param.createTimeE} ]]> </if>",
"<if test='param.orderNo != null'> and b.order_no LIKE concat('%', #{param.orderNo}, '%')</if>" +
" ORDER BY create_time desc" +
"</script>"

@ -0,0 +1,47 @@
package com.hai.enum_type;
import java.util.Objects;
/**
* 订单状态
* @author hurui
*/
public enum OrderStatusEnum {
type1(1 , "待支付"),
type2(2 , "已支付"),
type3(3 , "已完成"),
type4(4 , "已退款"),
type5(5 , "已取消"),
type6(6 , "退款中"),
type7(7 , "拒绝退款"),
;
private Integer type;
private String name;
OrderStatusEnum(int type , String name) {
this.type = type;
this.name = name;
}
public static String getNameByType(Integer type) {
for (OrderStatusEnum ele : values()) {
if(Objects.equals(type,ele.getType())) return ele.getName();
}
return null;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

@ -43,6 +43,14 @@ public interface HighGasOilPriceService {
*/
List<Map<String,Object>> getStoreListByOilNo(String storeName,Long regionId, String oilNoName);
/**
* 查询最近的油站
* @param longitude
* @param latitude
* @return
*/
Map<String,Object> recentGasStation(String longitude,String latitude);
}

@ -406,12 +406,20 @@ public interface HighOrderService {
*/
Map<String, Object> getGasTheDayOrderCount(Long storeId, String status);
/**
* 查询加油站历史统计
* @param storeId
* @param status
* @return
*/
Map<String, Object> getGasHistoryOrderCount(Long storeId, String status);
/**
* 查询加油站订单列表
* @param param
* @return
*/
List<GasOrderModel> getGasOrderList(Map<String, Object> param);
List<GasOrderModel> getGasOrderList(Map<String, Object> param) throws Exception;
/**
* 查询加油站订单列表

@ -55,5 +55,10 @@ public class HighGasOilPriceServiceImpl implements HighGasOilPriceService {
return highGasOilPriceMapper.selectStoreListByOilNo(storeName,regionId,oilNoName);
}
@Override
public Map<String, Object> recentGasStation(String longitude, String latitude) {
return highGasOilPriceMapper.recentGasStation(longitude, latitude);
}
}

@ -1706,7 +1706,18 @@ public class HighOrderServiceImpl implements HighOrderService {
}
@Override
public List<GasOrderModel> getGasOrderList(Map<String, Object> param) {
public Map<String, Object> getGasHistoryOrderCount(Long storeId, String status) {
return highOrderMapperExt.selectGasHistoryOrderCount(storeId,status);
}
@Override
public List<GasOrderModel> getGasOrderList(Map<String, Object> param) throws Exception {
if (MapUtils.getLong(param, "createTimeS") != null) {
param.put("createTimeS", DateUtil.date2String(new Date(MapUtils.getLong(param, "createTimeS")), "yyyy-MM-dd HH:mm:ss"));
}
if (MapUtils.getLong(param, "createTimeE") != null) {
param.put("createTimeE", DateUtil.date2String(new Date(MapUtils.getLong(param, "createTimeE")), "yyyy-MM-dd HH:mm:ss"));
}
return highOrderMapperExt.selectGasStoreOrderList(param);
}

Loading…
Cancel
Save