提交代码

dev-discount
胡锐 3 years ago
parent 041931c606
commit a2163d8b35
  1. 106
      hai-bweb/src/main/java/com/bweb/controller/HighCouponCodeController.java
  2. 20
      hai-service/src/main/java/com/hai/dao/HighCouponCodeMapperExt.java
  3. 62
      hai-service/src/main/java/com/hai/model/GzSinopecModel.java
  4. 8
      hai-service/src/main/java/com/hai/service/HighCouponCodeService.java
  5. 1
      hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java
  6. 13
      hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java
  7. 15
      hai-service/src/main/java/com/hai/service/impl/HighTyAgentOilStationServiceImpl.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<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;
}
}

@ -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({"<script>" +
" select " +
" a.coupon_name couponName," +
" a.sales_price salesPrice," +
" b.sales_time salesTime," +
" insert(b.convert_user_phone, 4, 4, '****') convertUserPhone," +
" b.`status` status" +
" from (select id,coupon_name,sales_price from high_coupon_agent_rel where coupon_id in (select id from high_coupon where coupon_source = 4)) a" +
" LEFT JOIN high_coupon_agent_code b on b.coupon_agent_id = a.id" +
" where 1 = 1" +
" <if test='param.couponName != null'> and a.coupon_name like concat('%',#{param.couponName},'%') </if> " +
" <if test='param.status == null'> and b.`status` in (2,3) </if> " +
" <if test='param.status != null'> and b.`status` = #{param.status} </if> " +
" <if test='param.assignTimeS != null'> <![CDATA[ and b.sales_time >= #{param.assignTimeS} ]]> </if> " +
" <if test='param.assignTimeE != null'> <![CDATA[ and b.sales_time <= #{param.assignTimeE} ]]> </if> " +
"</script>"})
List<GzSinopecModel> selectGzSinopecAssignList(@Param("param") Map<String, Object> param);
}

@ -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;
}
}

@ -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<HighCouponCode> getCouponCodeList(Map<String,Object> map);
/**
* 查询贵州中石化卡券
* @param map
* @return
*/
List<GzSinopecModel> getGzSinopecAssignList(Map<String,Object> map) throws Exception;
}

@ -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);

@ -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<GzSinopecModel> getGzSinopecAssignList(Map<String, Object> 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);
}
}

@ -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<HighTyAgentPrice> 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<HighTyAgentPrice> priceList = tyAgentPriceService.getPriceList(2, detail.getOilStationId());
for (HighTyAgentPrice price : priceList) {
price.setStatus(0);
tyAgentPriceService.editTyAgentPrice(price);
}
}
}

Loading…
Cancel
Save