diff --git a/1 b/1 new file mode 100644 index 00000000..39603359 Binary files /dev/null and b/1 differ diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java index a244b2b1..e8bd2408 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java @@ -4,6 +4,7 @@ import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.bweb.config.SysConst; import com.bweb.excelListener.ImportCouponListener; import com.bweb.model.ImportCouponModel; import com.github.pagehelper.PageHelper; @@ -37,6 +38,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.io.File; import java.util.*; import java.util.stream.Collectors; @@ -453,6 +455,121 @@ public class HighCouponController { } } + @RequestMapping(value="/exportStock",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "导出卡卷库存") + public ResponseData exportStock(@RequestBody JSONObject body, HttpServletRequest request) { + try { + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + if (body == null || body.getLong("couponId") == null) { + log.error("HighCouponController -> exportStock() error!","请求参数校验失败"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + // 查找卡卷 + HighCoupon coupon = highCouponService.getCouponById(body.getLong("couponId")); + if (coupon == null) { + log.error("HighCouponController -> writeStock() error!","未找到卡卷信息"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, ""); + } + + Map param = new HashMap<>(); + param.put("couponId", body.getLong("couponId")); + param.put("status", body.getInteger("status")); + param.put("createTimeS", body.getLong("createTimeS")); + param.put("createTimeE", body.getLong("createTimeE")); + // 销售码 + List codeList = highCouponCodeService.getCouponCodeList(param); + + List headList = new ArrayList<>();; + headList.add("序号"); + headList.add("消费码key"); + headList.add("消费码"); + headList.add("状态"); + headList.add("使用门店"); + headList.add("领取时间"); + headList.add("消费时间"); + headList.add("销售截止时间"); + headList.add("使用截止时间"); + headList.add("创建时间"); + + List> dataList = new ArrayList<>(); + List data; + Integer i = 1; + + for (HighCouponCode couponCode : codeList) { + data = new ArrayList<>(); + data.add(i++); + data.add(couponCode.getCodeKey()); + data.add(couponCode.getSalesCode()); + if (couponCode.getStatus() == 1) { + data.add("待销售"); + } else if (couponCode.getStatus() == 2) { + data.add("待使用"); + } else if (couponCode.getStatus() == 3) { + data.add("已使用"); + } else if (couponCode.getStatus() == 4) { + data.add("已过期"); + } else if (couponCode.getStatus() == 99) { + data.add("预支付"); + } else { + data.add("未知"); + } + data.add(couponCode.getStoreName()); + data.add(couponCode.getReceiveTime()); + data.add(couponCode.getConsumeTime()); + data.add(couponCode.getSalesEndTime()); + data.add(couponCode.getUseEndTime()); + data.add(couponCode.getCreateTime()); + 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("HighCouponController -> importStock() error!",e); + return ResponseMsgUtil.exception(e); + } + } + +/* private List> generationHead(List headList) { + List> list = new ArrayList<>(); + List head0 = new ArrayList<>(); + head0.add("字符串" + System.currentTimeMillis()); + List head1 = new ArrayList<>(); + head1.add("数字" + System.currentTimeMillis()); + List head2 = new ArrayList<>(); + head2.add("日期" + System.currentTimeMillis()); + list.add(head0); + list.add(head1); + list.add(head2); + return list; + }*/ + + /** + * 生成头部 + * @param headList + * @return + */ + private 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; + } + @RequestMapping(value="/writeStock",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "填写卡卷库存(内部劵)") 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 f83b806d..abc2c985 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 @@ -266,6 +266,14 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { criteria.andSalesEndTimeGreaterThan(new Date(MapUtils.getLong(map, "salesEndTimeS"))); } + if (MapUtils.getLong(map, "createTimeS") != null) { + criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeS"))); + } + + if (MapUtils.getLong(map, "createTimeE") != null) { + criteria.andCreateTimeLessThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeE"))); + } + if (MapUtils.getBoolean(map, "isAssignAgent") != null) { criteria.andIsAssignAgentEqualTo(MapUtils.getBoolean(map, "isAssignAgent")); }