|
|
|
@ -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<String, Object> 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<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("couponName", couponName); |
|
|
|
|
map.put("status", status); |
|
|
|
|
map.put("assignTimeS", assignTimeS); |
|
|
|
|
map.put("assignTimeE", assignTimeE); |
|
|
|
|
|
|
|
|
|
List<GzSinopecModel> list = highCouponCodeService.getGzSinopecAssignList(map); |
|
|
|
|
|
|
|
|
|
List<String> headList = new ArrayList<>(); |
|
|
|
|
headList.add("卡券名称"); |
|
|
|
|
headList.add("卡券金额"); |
|
|
|
|
headList.add("分发时间"); |
|
|
|
|
headList.add("分发手机号"); |
|
|
|
|
headList.add("状态"); |
|
|
|
|
|
|
|
|
|
List<List<Object>> dataList = new ArrayList<>(); |
|
|
|
|
List<Object> 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<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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|