diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponCodeController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponCodeController.java index 0a3c65c5..e668ed17 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponCodeController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponCodeController.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,7 +10,10 @@ import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; +import com.hai.common.utils.DateUtil; import com.hai.common.utils.ResponseMsgUtil; +import com.hai.model.GzSinopecModel; +import com.hai.model.OilCardOrderModel; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; import com.hai.service.HighCouponCodeService; @@ -22,7 +27,10 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.io.File; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -94,4 +102,102 @@ public class HighCouponCodeController { return ResponseMsgUtil.exception(e); } } + + @RequestMapping(value="/getGzSinopecAssignList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询贵州中石化分配列表") + public ResponseData getGzSinopecAssignList(@RequestParam(name = "couponName", required = false) String couponName, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "assignTimeS", required = false) Long assignTimeS, + @RequestParam(name = "assignTimeE", required = false) Long assignTimeE, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize) { + try { + Map map = new HashMap<>(); + map.put("couponName", couponName); + map.put("status", status); + map.put("assignTimeS", assignTimeS); + map.put("assignTimeE", assignTimeE); + + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>(highCouponCodeService.getGzSinopecAssignList(map))); + + } catch (Exception e) { + log.error("HighCouponController -> getGzSinopeAssigncList() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/importGzSinopecAssign",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "导出贵州中石化分配列表") + public ResponseData importGzSinopecAssign(@RequestParam(name = "couponName", required = false) String couponName, + @RequestParam(name = "assignTimeS", required = false) Long assignTimeS, + @RequestParam(name = "assignTimeE", required = false) Long assignTimeE, + @RequestParam(name = "status", required = false) Integer status) { + try { + Map map = new HashMap<>(); + map.put("couponName", couponName); + map.put("status", status); + map.put("assignTimeS", assignTimeS); + map.put("assignTimeE", assignTimeE); + + List list = highCouponCodeService.getGzSinopecAssignList(map); + + List headList = new ArrayList<>(); + headList.add("卡券名称"); + headList.add("卡券金额"); + headList.add("分发时间"); + headList.add("分发手机号"); + headList.add("状态"); + + List> dataList = new ArrayList<>(); + List data; + + for (GzSinopecModel gzSinopecModel: list) { + data = new ArrayList<>(); + data.add(gzSinopecModel.getCouponName()); + data.add(gzSinopecModel.getSalesPrice()); + data.add(DateUtil.format(gzSinopecModel.getSalesTime(), "yyyy-MM-dd HH:mm:ss")); + data.add(gzSinopecModel.getConvertUserPhone()); + if (gzSinopecModel.getStatus().equals(2)) { + data.add("待使用"); + } else if (gzSinopecModel.getStatus().equals(3)) { + data.add("已使用"); + } + 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("sheet1").doWrite(dataList); + + return ResponseMsgUtil.success(pathName); + + } catch (Exception e) { + log.error("HighCouponController -> importGzSinopecAssign() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + + /** + * 生成头部 + * @param headList + * @return + */ + private static List> generationHead(List headList) { + List> list = new ArrayList<>(); + List head; + for (String headStr : headList) { + head = new ArrayList<>(); + head.add(headStr); + list.add(head); + } + return list; + } } diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponCodeMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighCouponCodeMapperExt.java index 5456b1b4..4f46287d 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponCodeMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponCodeMapperExt.java @@ -1,10 +1,12 @@ package com.hai.dao; import com.hai.entity.HighCouponCode; +import com.hai.model.GzSinopecModel; import org.apache.ibatis.annotations.*; import org.apache.ibatis.type.JdbcType; import java.util.List; +import java.util.Map; /** * mapper扩展类 @@ -83,4 +85,22 @@ public interface HighCouponCodeMapperExt { }) HighCouponCode selectCouponCodeByUserDiscount(@Param("discountUserRelId") Long discountUserRelId); + @Select({""}) + List selectGzSinopecAssignList(@Param("param") Map param); + } diff --git a/hai-service/src/main/java/com/hai/model/GzSinopecModel.java b/hai-service/src/main/java/com/hai/model/GzSinopecModel.java new file mode 100644 index 00000000..bb315771 --- /dev/null +++ b/hai-service/src/main/java/com/hai/model/GzSinopecModel.java @@ -0,0 +1,62 @@ +package com.hai.model; + +import java.math.BigDecimal; +import java.util.Date; + +public class GzSinopecModel { + + // 卡券名称 + private String couponName; + + // 卡券价格 + private BigDecimal salesPrice; + + // 销售时间 + private Date salesTime; + + // 领取人 + private String convertUserPhone; + + // 状态 + private Integer status; + + public String getCouponName() { + return couponName; + } + + public void setCouponName(String couponName) { + this.couponName = couponName; + } + + public BigDecimal getSalesPrice() { + return salesPrice; + } + + public void setSalesPrice(BigDecimal salesPrice) { + this.salesPrice = salesPrice; + } + + public Date getSalesTime() { + return salesTime; + } + + public void setSalesTime(Date salesTime) { + this.salesTime = salesTime; + } + + public String getConvertUserPhone() { + return convertUserPhone; + } + + public void setConvertUserPhone(String convertUserPhone) { + this.convertUserPhone = convertUserPhone; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } +} diff --git a/hai-service/src/main/java/com/hai/service/HighCouponCodeService.java b/hai-service/src/main/java/com/hai/service/HighCouponCodeService.java index 4b7e4e4b..465840b6 100644 --- a/hai-service/src/main/java/com/hai/service/HighCouponCodeService.java +++ b/hai-service/src/main/java/com/hai/service/HighCouponCodeService.java @@ -2,6 +2,7 @@ package com.hai.service; import com.hai.entity.HighCoupon; import com.hai.entity.HighCouponCode; +import com.hai.model.GzSinopecModel; import com.hai.model.OrderSumModel; import com.hai.model.UserInfoModel; @@ -111,4 +112,11 @@ public interface HighCouponCodeService { **/ List getCouponCodeList(Map map); + /** + * 查询贵州中石化卡券 + * @param map + * @return + */ + List getGzSinopecAssignList(Map map) throws Exception; + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java index 986f173d..17727303 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java @@ -553,6 +553,7 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { convertCode.setConvertUserPhone(phone); convertCode.setRemark(remark); convertCode.setCouponCode(System.currentTimeMillis()+""); + convertCode.setSalesTime(new Date()); convertCode.setStatus(2); highCouponAgentCodeMapper.updateByPrimaryKey(convertCode); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java index abc2c985..8ebf0472 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java @@ -10,6 +10,7 @@ import com.hai.dao.HighChildOrderMapper; import com.hai.dao.HighCouponCodeMapper; import com.hai.dao.HighCouponCodeMapperExt; import com.hai.entity.*; +import com.hai.model.GzSinopecModel; import com.hai.model.UserInfoModel; import com.hai.service.*; import org.apache.commons.collections4.MapUtils; @@ -282,5 +283,17 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { return highCouponCodeMapper.selectByExample(example); } + @Override + public List getGzSinopecAssignList(Map map) throws Exception { + if (MapUtils.getLong(map, "assignTimeS") != null) { + map.put("assignTimeS", DateUtil.date2String(new Date(MapUtils.getLong(map, "assignTimeS")), "yyyy-MM-dd HH:mm:ss")); + } + + if (MapUtils.getLong(map, "assignTimeE") != null) { + map.put("assignTimeE", DateUtil.date2String(new Date(MapUtils.getLong(map, "assignTimeE")), "yyyy-MM-dd HH:mm:ss")); + } + return highCouponCodeMapper.selectGzSinopecAssignList(map); + } + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighTyAgentOilStationServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighTyAgentOilStationServiceImpl.java index b6bc745c..ca5d6875 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighTyAgentOilStationServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighTyAgentOilStationServiceImpl.java @@ -29,6 +29,9 @@ public class HighTyAgentOilStationServiceImpl implements HighTyAgentOilStationSe @Resource private HighTySalesmanService tySalesmanService; + @Resource + private HighTyAgentPriceService tyAgentPriceService; + @Resource private HighMerchantStoreService merchantStoreService; @@ -106,6 +109,12 @@ public class HighTyAgentOilStationServiceImpl implements HighTyAgentOilStationSe } detail.setStatus(0); editData(detail); + + List priceList = tyAgentPriceService.getPriceList(2, detail.getOilStationId()); + for (HighTyAgentPrice price : priceList) { + price.setStatus(0); + tyAgentPriceService.editTyAgentPrice(price); + } } } @@ -144,6 +153,12 @@ public class HighTyAgentOilStationServiceImpl implements HighTyAgentOilStationSe detail.setTySalesmanId(null); detail.setTySalesmanName(null); editData(detail); + + List priceList = tyAgentPriceService.getPriceList(2, detail.getOilStationId()); + for (HighTyAgentPrice price : priceList) { + price.setStatus(0); + tyAgentPriceService.editTyAgentPrice(price); + } } }