diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponOrderController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponOrderController.java index f51053363..56e6a0b9b 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponOrderController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponOrderController.java @@ -6,7 +6,6 @@ import com.iformall.common.ErrorCode; import com.iformall.common.ResultData; import com.iformall.controller.base.BaseController; import com.iformall.domain.po.WxAppinfo; -import com.iformall.domain.po.WxCouponOrder; import com.iformall.domain.vo.WxCouponOrderBVo; import com.iformall.enums.EnumAppType; import com.iformall.enums.EnumPayType; @@ -26,7 +25,6 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.text.SimpleDateFormat; import java.util.Map; @RestController @@ -74,47 +72,6 @@ public class WxCouponOrderController extends BaseController { return wxCouponOrderService.detailAdminVo(couponOrderId); } - @RequestMapping("/exportData") - @SystemControllerLog(description = "券包-导出") - public void exportData( - @RequestParam("endDate") String endDate, - @RequestParam("startDate") String startDate, - @RequestParam("merchantName") String merchantName, - @RequestParam("couponOrderStatus") String couponOrderStatus, - @RequestParam("id") String id, - HttpServletRequest request, HttpServletResponse response) { - logger.debug("[" + getIpAddr() + "] WxCouponOrderController::exportData"); - - WxCouponOrderBVo wxCouponOrder = new WxCouponOrderBVo(); - wxCouponOrder.setTenantId(getTenantId()); - wxCouponOrder.setMerchantName(merchantName); - try { - wxCouponOrder.setId(Long.valueOf(id)); - }catch (Exception e){ - wxCouponOrder.setId(null); - } - try { - wxCouponOrder.setCouponOrderStatus(Integer.valueOf(couponOrderStatus)); - }catch (Exception e){ - wxCouponOrder.setCouponOrderStatus(null); - } - - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - try { - wxCouponOrder.setStartTime( sdf.parse(startDate)); - } catch (Exception e) { - wxCouponOrder.setStartTime(null); - } - try { - wxCouponOrder.setEndTime( sdf.parse(endDate)); - } catch (Exception e) { - wxCouponOrder.setEndTime(null); - } - wxCouponOrder.setSortColumns(WxCouponOrder.Field.Id_DESC); - wxCouponOrderService.exportData(request, response, wxCouponOrder); - - } - @ApiOperation(value = "退券退款", notes = "{\"couponOrderId\":\"string\"}") @PostMapping("/refund") @SystemControllerLog(description = "券包-退券退款") @@ -158,4 +115,17 @@ public class WxCouponOrderController extends BaseController { return new ResultData(ErrorCode.REFUND_ORDER_ERROR.getCode(), "AppInfo获取失败"); } + @GetMapping("exportData") + @SystemControllerLog(description = "券订单数据-导出数据") + public void exportData(@ModelAttribute WxCouponOrderBVo wxCouponOrder, HttpServletRequest request, HttpServletResponse response) { + logger.debug("[" + getIpAddr() + "] WxCouponOrderController::exportData"); + if (wxCouponOrder == null) wxCouponOrder = new WxCouponOrderBVo(); + wxCouponOrder.setTenantId(getTenantId()); + if (wxCouponOrder.getMerchantName() != null && + wxCouponOrder.getMerchantName().isEmpty()) { + wxCouponOrder.setMerchantName(null); + } + wxCouponOrderService.exportData(wxCouponOrder, request, response); + } + } diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponOrderBVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponOrderBVo.java index ed400f188..9f74ada21 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponOrderBVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponOrderBVo.java @@ -9,6 +9,8 @@ import lombok.ToString; import javax.persistence.Id; import javax.persistence.Transient; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.Date; import java.util.List; @@ -20,7 +22,7 @@ public class WxCouponOrderBVo extends WxCouponOrder{ private static final long serialVersionUID = 6687954932922444531L; @Id - @Excel(name="券码",width = 20) + @Excel(name = "券码", width = 20, orderNum = "1") protected Long id; @Override @@ -40,31 +42,31 @@ public class WxCouponOrderBVo extends WxCouponOrder{ @io.swagger.annotations.ApiModelProperty(value = "该订单对应券的实际过期时间 ", name = "expiredTime") private Date expiredTime; - @Excel(name="券名称",width = 50) + @Excel(name = "券名称", width = 50, orderNum = "2") @io.swagger.annotations.ApiModelProperty(value="券名称",name="title") private String title; - @Excel(name="用户手机号",width = 20) + @Excel(name = "会员手机号", width = 20, orderNum = "13") @io.swagger.annotations.ApiModelProperty(value="c用户绑定的手机号",name="cUserPhone") private String cUserPhone; - @Excel(name="交易时间",width = 20,exportFormat="yyyy-MM-dd HH:mm:ss") + @Excel(name = "交易时间", width = 20, exportFormat = "yyyy-MM-dd HH:mm:ss", orderNum = "8") @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate") private Date createDate; @Transient - @Excel(name="面额",width = 20) + @Excel(name = "面额(元)", width = 20, orderNum = "6") private String priceStr; @Transient - @Excel(name="交易价格",width = 20) + @Excel(name = "交易价格(元)", width = 20, orderNum = "5") private String salePriceStr; - @Excel(name="订单状态",width = 20,replace = { "可以退款_0", "已经使用_1","已经过期_2","已经退款_3"}) + @Excel(name = "状态", width = 20, replace = {"可以退款_0", "已经使用_1", "已经过期_2", "已经退款_3"}, orderNum = "14") @io.swagger.annotations.ApiModelProperty(value = "状态:0,待使用 1,已核销 2,已过期 3,已作废 ", name = "couponOrderStatus") private Integer couponOrderStatus; - @Excel(name="核销/过期/退款时间",width = 20,exportFormat="yyyy-MM-dd HH:mm:ss") + @Excel(name = "核销/过期/退款时间", width = 20, exportFormat = "yyyy-MM-dd HH:mm:ss", orderNum = "9") @io.swagger.annotations.ApiModelProperty(value = "", name = "updateDate") private Date updateDate; @@ -81,6 +83,23 @@ public class WxCouponOrderBVo extends WxCouponOrder{ @io.swagger.annotations.ApiModelProperty(value="面额",name="price") private Integer price; + @Excel(name = "所属业态", width = 50, orderNum = "11", replace = {"餐饮_1", "娱乐_2", "服饰_3", "亲子_4", "超市_5", "其它_6", "美妆_7", "珠宝_8", "服务_9", "家居_10"}) + @io.swagger.annotations.ApiModelProperty(value = "业态", name = "business") + private Integer business; + + @io.swagger.annotations.ApiModelProperty(value = "补贴额", name = "subsidySum") + private Integer subsidySum; + + public String getSubsidySumStr() { + return new BigDecimal(subsidySum).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).toPlainString(); + } + + @Excel(name = "补贴额(元)", width = 50, orderNum = "7") + @io.swagger.annotations.ApiModelProperty(value = "补贴额", name = "subsidySum") + private String subsidySumStr; + + @io.swagger.annotations.ApiModelProperty(value = "补贴类型", name = "subsidyType") + private Integer subsidyType; @Excel(name="商户管理员(核销人)姓名",width = 50) @io.swagger.annotations.ApiModelProperty(value="b端用户姓名",name="bUserName") @@ -88,10 +107,14 @@ public class WxCouponOrderBVo extends WxCouponOrder{ @Excel(name="商户管理员手机",width = 20) @io.swagger.annotations.ApiModelProperty(value="b端用户手机号",name="bUserPhone") private String bUserPhone; - @Excel(name="使用券商户名",width = 50) + @Excel(name = "商户名", width = 50, orderNum = "3") @io.swagger.annotations.ApiModelProperty(value="使用券商户名",name="merchantName") private String merchantName; + @Excel(name = "商铺号", width = 50, orderNum = "4") + @Transient + private String shopNumber; + /**发券商户信息*/ @io.swagger.annotations.ApiModelProperty(value="商户列表",name="merchantVoList") private List merchantVoList; @@ -102,12 +125,30 @@ public class WxCouponOrderBVo extends WxCouponOrder{ @Transient private Date endDate; + @Transient + private Long merchantId; + + @Transient + private Date verifyStartDate; + + @Transient + private Date verifyEndDate; + @Transient private Long couponId; @Transient private Integer couponType; - @Override + @Transient + private Integer floor; + @Transient + private Integer building; + + @Excel(name = "楼层楼座", width = 50, orderNum = "12") + @Transient + private String buildingStr; + + @Override public Long getCouponId() { return couponId; } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java index 4ca99cc6b..339507e93 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java @@ -152,9 +152,6 @@ public interface WxCouponOrderService { ResultData detailAdminVo(Long couponOrderId); - void exportData(HttpServletRequest request, HttpServletResponse response, WxCouponOrderBVo wxCouponOrder); - - /** * 日期分组 消费总数 * @param tenantId @@ -190,4 +187,6 @@ public interface WxCouponOrderService { ResultData queryCardStatus(WxCouponOrder wxCouponOrder); + void exportData(WxCouponOrderBVo wxCouponOrder, HttpServletRequest request, HttpServletResponse response); + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java index 41d92d7c6..cca9c20d2 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java @@ -20,7 +20,6 @@ import com.iformall.exception.MallinkException; import com.iformall.mapper.*; import com.iformall.mq.MqBaseProducer; import com.iformall.service.*; -import com.iformall.utils.DateUtils; import com.iformall.utils.PayUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -272,12 +271,27 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { } @Override - public void exportData(HttpServletRequest request, HttpServletResponse response, WxCouponOrderBVo wxCouponOrder) { - WxMall wxMall = new WxMall(); - wxMall.setTenantId(wxCouponOrder.getTenantId()); - wxMall = wxMallMapper.findList(wxMall).get(0); - String filename = wxMall.getName() + DateUtils.getSystemTime("yyyyMMDDHHmmss"); + public void exportData(WxCouponOrderBVo wxCouponOrder, HttpServletRequest request, HttpServletResponse response) { + String filename = "券订单"; List list = wxCouponOrderMapper.findListOfAdmin(wxCouponOrder); + list.parallelStream().forEach(c -> { + if (!c.getMerchantId().equals(0L)) { + List merchantVoList = c.getMerchantVoList(); + if (!merchantVoList.isEmpty()) { + StringBuffer shopNumber = new StringBuffer(); + StringBuffer building = new StringBuffer(); + WxMerchantVo wxMerchantVo = merchantVoList.get(0); + List shopVoList = wxMerchantVo.getShopVoList(); + for (int j = 0, s_size = shopVoList.size(); j < s_size; j++) { + WxShopVo wxShopVo = shopVoList.get(j); + shopNumber.append(wxShopVo.getShopNumber()).append(";"); + building.append(wxShopVo.getBuildingName()).append(wxShopVo.getFloorName()).append(";"); + } + c.setShopNumber(shopNumber.toString()); + c.setBuildingStr(building.toString()); + } + } + }); excelService.exportExcel(list, null, filename, WxCouponOrderBVo.class, filename + ".xlsx", response, false); } diff --git a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml index 642bdfbda..91f1f748d 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml @@ -360,19 +360,24 @@ - + + + - + + + + - + co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, - c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund, + c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund,c.business,c.subsidy_type,c.subsidy_sum, (case when com.mc=1 then (select m.name from wx_merchant m, wx_coupon_merchant cm - where m.id = cm.merchant_id and cm.product_id=co.coupon_id and cm.status = 0) else '[多商户通用]' end) as merchant_name + where m.id = cm.merchant_id and cm.product_id=co.coupon_id and cm.status = 0) else '[多商户通用]' end) as merchant_name, + case when com.mc = 1 then (select m.id from wx_merchant m, + wx_coupon_merchant cm where m.id = cm.merchant_id and cm.product_id = co.coupon_id + and cm.status = 0) else 0 end) as merchant_id co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, - c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund, + c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund,c.business,c.subsidy_type,c.subsidy_sum, bu.name, bu.phone as bphone, cu.phone, m.name as merchant_name @@ -443,13 +451,37 @@ AND co.create_date < #{endDate,jdbcType=TIMESTAMP} + + AND co.update_date > #{verifyStartDate,jdbcType=TIMESTAMP} + + + + AND co.update_date < #{verifyEndDate,jdbcType=TIMESTAMP} + + and co.id = #{id} and c.id = #{couponId} - + + and c.business = #{business} + + + and co.coupon_id in( + select cm.product_id from wx_merchant_shop ms left join wx_merchant m on ms.merchant_id=m.id + left join wx_shop s on ms.shop_id=s.id + left join wx_coupon_merchant cm on ms.merchant_id=cm.merchant_id + where ms.is_del=0 and s.building=#{building} + + and ms.tenant_id=#{tenant_id} + + + and s.floor=#{floor} + + ) + order by ${sortColumns} order by id desc