From aa09d64f1d38df87963d02c140f2f893d24bb99c Mon Sep 17 00:00:00 2001 From: hupeng Date: Mon, 10 Dec 2018 21:24:08 +0800 Subject: [PATCH] =?UTF-8?q?[A=E7=AB=AF][=E9=9C=80=E6=B1=82]:=E5=A4=9A?= =?UTF-8?q?=E5=95=86=E6=88=B7=E9=80=9A=E7=94=A8=E5=88=B8coupon/couponcar?= =?UTF-8?q?=E5=8E=BB=E6=8E=89merchantId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iformall/controller/WxCarController.java | 76 +---- .../controller/WxCouponController.java | 62 +--- .../controller/WxCouponOrderController.java | 1 - .../controller/WxCouponOrderController.java | 2 - .../controller/WxCouponController.java | 6 +- .../com/iformall/domain/dto/WxCounponDto.java | 26 -- .../iformall/domain/dto/WxCouponCarDto.java | 20 -- .../java/com/iformall/domain/po/WxCoupon.java | 9 - .../com/iformall/domain/po/WxCouponCar.java | 10 - .../iformall/domain/po/WxCouponMerchant.java | 4 +- .../com/iformall/domain/vo/WxCouponCarVo.java | 319 +----------------- .../iformall/mapper/WxCouponCarMapper.java | 5 +- .../mapper/WxCouponChannelMapper.java | 3 +- .../com/iformall/mapper/WxCouponMapper.java | 2 + .../mapper/WxCouponMerchantMapper.java | 3 + .../iformall/service/WxCouponCarService.java | 8 +- .../service/WxCouponChannelService.java | 2 +- .../service/WxCouponOrderService.java | 6 - .../com/iformall/service/WxCouponService.java | 9 +- .../service/impl/WxCouponCarServiceImpl.java | 4 +- .../impl/WxCouponChannelServiceImpl.java | 36 +- .../impl/WxCouponOrderServiceImpl.java | 31 +- .../service/impl/WxCouponServiceImpl.java | 99 +++--- .../service/impl/WxMerchantServiceImpl.java | 31 +- .../service/impl/WxOrderServiceImpl.java | 26 +- .../impl/WxRefundOrderServiceImpl.java | 2 +- .../resources/mapper/WxCouponCarMapper.xml | 24 +- .../mapper/WxCouponChannelMapper.xml | 7 +- .../main/resources/mapper/WxCouponMapper.xml | 41 +++ 29 files changed, 211 insertions(+), 663 deletions(-) delete mode 100644 mallinkService/src/main/java/com/iformall/domain/dto/WxCounponDto.java delete mode 100644 mallinkService/src/main/java/com/iformall/domain/dto/WxCouponCarDto.java diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxCarController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxCarController.java index 91f37e774..1b57220e5 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/WxCarController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxCarController.java @@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.iformall.common.ErrorCode; import com.iformall.common.ResultData; -import com.iformall.domain.dto.WxCouponCarDto; import com.iformall.domain.po.*; import com.iformall.domain.vo.WxCouponCarVo; import com.iformall.enums.EnumCarVendor; @@ -182,8 +181,6 @@ public class WxCarController extends BaseController { public ResultData save(@RequestBody WxCouponCarVo coupon) { logger.debug("[" + getIpAddr() + "] WxCarController::save"); logger.info(coupon.toString()); - //Assert.notNull(wxCoupon.getName(), "角色名不能为空"); - //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); // Save to wx_counpon Date curDate = new Date(); MallUserInfo user = getUser(); @@ -207,56 +204,13 @@ public class WxCarController extends BaseController { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "已达到停车厂商优免券数量限制"); } // check End - - - WxCoupon wxCoupon = new WxCoupon(); - wxCoupon.setTenantId(user.getTenantId()); - wxCoupon.setMerchantId(coupon.getMerchantId()); - if (StringUtils.isNotEmpty(coupon.getSalePriceStr())) { - wxCoupon.setSalePrice((int) (Double.parseDouble(coupon.getSalePriceStr()) * 100)); - } - if (StringUtils.isNotEmpty(coupon.getUsePriceStr())) { - wxCoupon.setUsePrice((int) (Double.parseDouble(coupon.getUsePriceStr()) * 100)); - } - if (StringUtils.isNotEmpty(coupon.getPriceStr())) { - // 不管时间是小时还是金额,都乘100 - String priceStr = coupon.getPriceStr(); - priceStr = priceStr.replace("元", ""); - priceStr = priceStr.replace("小时", ""); - wxCoupon.setPrice((int) (Double.parseDouble(priceStr) * 100)); - } - - wxCoupon.setBusiness(coupon.getBusiness()); - - if(coupon.getId() != null && coupon.getId().longValue() > 0) { - wxCoupon.setId(coupon.getId()); - } - wxCoupon.setType(coupon.getType()); - wxCoupon.setCoverImg(coupon.getCoverImg()); - wxCoupon.setTitle(coupon.getTitle()); - wxCoupon.setSubTitle(coupon.getSubTitle()); - wxCoupon.setUseLimitQuantity(coupon.getUseLimitQuantity()); - wxCoupon.setSendType(coupon.getSendType()); - wxCoupon.setValidType(coupon.getValidType()); - wxCoupon.setValidStartDate(coupon.getValidStartDate()); - wxCoupon.setValidEndDate(coupon.getValidEndDate()); - wxCoupon.setValidDays(coupon.getValidDays()); - wxCoupon.setDetail(coupon.getDetail()); - wxCoupon.setUnit(coupon.getUnit()); - wxCoupon.setRemainInventory(coupon.getRemainInventory()); - wxCoupon.setInventory(coupon.getInventory()); - wxCoupon.setRemark(coupon.getRemark()); - wxCoupon.setStatus(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()); - wxCoupon.setCreateDate(curDate); - wxCoupon.setUpdateDate(curDate); - wxCoupon.setChannels(""); - Long id = wxCouponService.saveOrUpdate(wxCoupon); + coupon.setTenantId(user.getTenantId()); + wxCouponService.saveOrUpdate(coupon); // Save to wx_coupon_car WxCouponCar couponCar = new WxCouponCar(); - couponCar.setId(id); + couponCar.setId(coupon.getId()); couponCar.setTenantId(user.getTenantId()); - couponCar.setMerchantId(coupon.getMerchantId()); WxPark park = getCurrentPark(user); couponCar.setParkId(park.getId()); @@ -271,8 +225,7 @@ public class WxCarController extends BaseController { wxCouponCarService.update(couponCar); } - - return new ResultData(id); + return new ResultData(coupon.getId()); } @@ -312,26 +265,9 @@ public class WxCarController extends BaseController { @ApiOperation("停车券detail") @GetMapping("/detail") - public ResultData getCouponCarDetail(@ModelAttribute WxCoupon coupon) { + public ResultData getCouponCarDetail(@RequestParam Long id) { logger.debug("[" + getIpAddr() + "] WxCarController::getCouponCarDetail"); - MallUserInfo user = getUser(); - coupon.setTenantId(user.getTenantId()); - try { - WxCouponCarVo couponCarVo = wxCouponCarService.getByCoupon(coupon); - if (couponCarVo != null) { - WxCouponCarDto dto = new WxCouponCarDto(); - org.springframework.beans.BeanUtils.copyProperties(couponCarVo, dto); - WxMerchant merchant = wxMerchantService.getById(couponCarVo.getMerchantId()); - dto.setWxMerchant(merchant); - return new ResultData(dto); - } else { - return new ResultData(ErrorCode.COUPON_IS_EMPTY); - } - } catch (Exception e) { - logger.error(e.getMessage()); - return new ResultData(ErrorCode.DB_FAIL.getCode(), e.getMessage()); - } - + return new ResultData(wxCouponCarService.findDetailVo(id)); } @ApiOperation(value = "停车场状态") diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxCouponController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxCouponController.java index d4a882c82..d48bf5b83 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/WxCouponController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxCouponController.java @@ -2,9 +2,9 @@ package com.iformall.controller; import com.alibaba.fastjson.JSON; import com.github.pagehelper.PageInfo; +import com.iformall.common.ErrorCode; import com.iformall.common.Result; import com.iformall.common.ResultData; -import com.iformall.domain.dto.WxCounponDto; import com.iformall.domain.po.WxCoupon; import com.iformall.domain.po.WxCouponChannel; import com.iformall.domain.po.WxMerchant; @@ -38,8 +38,6 @@ public class WxCouponController extends BaseController { @Autowired private WxCouponService wxCouponService; - @Autowired - private WxMerchantService wxMerchantService; @Autowired private WxCouponChannelService wxCouponChannelService; @@ -103,30 +101,7 @@ public class WxCouponController extends BaseController { @PostMapping("add") public ResultData add(@RequestBody WxCoupon wxCoupon) { logger.debug("[" + getIpAddr() + "] WxCouponController::add"); - //Assert.notNull(wxCoupon.getName(), "角色名不能为空"); - //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); - if (StringUtils.isNotEmpty(wxCoupon.getSalePriceStr())) { - wxCoupon.setSalePrice((int) (Double.parseDouble(wxCoupon.getSalePriceStr()) * 100)); - } - if (StringUtils.isNotEmpty(wxCoupon.getUsePriceStr())) { - wxCoupon.setUsePrice((int) (Double.parseDouble(wxCoupon.getUsePriceStr()) * 100)); - } - if (StringUtils.isNotEmpty(wxCoupon.getPriceStr())) { - wxCoupon.setPrice((int) (Double.parseDouble(wxCoupon.getPriceStr()) * 100)); - } - - wxCoupon.setTenantId(getUser().getTenantId()); - wxCoupon.setChannels(""); - if (wxCoupon.getValidType() != null) { - if (wxCoupon.getValidType().equals(EnumCouponValidType.DAYS_AFTER_RECEIVING)) { - wxCoupon.setValidStartDate(null); - wxCoupon.setValidEndDate(null); - } else if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME)) { - wxCoupon.setValidDays(null); - } - } - Long id = wxCouponService.saveOrUpdate(wxCoupon); - return new ResultData(id); + return wxCouponService.saveOrUpdate(wxCoupon); } @ApiOperation("根据id更新接口") @@ -136,25 +111,7 @@ public class WxCouponController extends BaseController { if (wxCoupon.getId() == null) { return new ResultData(ResultData.ERROR, "缺少id"); } - if (StringUtils.isNotEmpty(wxCoupon.getSalePriceStr())) { - wxCoupon.setSalePrice((int) (Double.parseDouble(wxCoupon.getSalePriceStr()) * 100)); - } - if (StringUtils.isNotEmpty(wxCoupon.getUsePriceStr())) { - wxCoupon.setUsePrice((int) (Double.parseDouble(wxCoupon.getUsePriceStr()) * 100)); - } - if (StringUtils.isNotEmpty(wxCoupon.getPriceStr())) { - wxCoupon.setPrice((int) (Double.parseDouble(wxCoupon.getPriceStr()) * 100)); - } - - if (wxCoupon.getValidType() != null) { - if (wxCoupon.getValidType().equals(EnumCouponValidType.DAYS_AFTER_RECEIVING)) { - wxCoupon.setValidStartDate(null); - wxCoupon.setValidEndDate(null); - } else if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME)) { - wxCoupon.setValidDays(null); - } - } - return wxCouponService.updateCoupon(wxCoupon); + return wxCouponService.saveOrUpdate(wxCoupon); } @ApiOperation("根据id删除接口") @@ -169,16 +126,9 @@ public class WxCouponController extends BaseController { @ApiOperation("根据id查询接口") @GetMapping("/findById") @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) - public ResultData findById(Long id) { - logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); - WxCoupon c = wxCouponService.getById(id); - WxMerchant merchant = wxMerchantService.getById(c.getMerchantId()); - if(merchant.getStatus().equals(EnumMerchantStatus.NOT_VALID.getCode())) - return new ResultData(Result.ERROR, "此券的商户已禁用"); - WxCounponDto dto = new WxCounponDto(); - org.springframework.beans.BeanUtils.copyProperties(c, dto); - dto.setWxMerchant(merchant); - return new ResultData(Result.SUCCESS, "查询成功", dto); + public ResultData findById(@RequestParam Long id) { + logger.debug("[" + getIpAddr() + "] WxCouponController::findById");; + return new ResultData(wxCouponService.getVoById(id)); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxCouponOrderController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxCouponOrderController.java index 01bc4d9f9..48a11d9b6 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/WxCouponOrderController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxCouponOrderController.java @@ -26,7 +26,6 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.text.SimpleDateFormat; -import java.util.Date; import java.util.Map; @RestController diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderController.java index 38d7f3a2b..b7bd64e0a 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderController.java @@ -46,8 +46,6 @@ public class WxCouponOrderController extends BaseController { return new ResultData(); } - - @ApiOperation("交易流水分页列表接口") @GetMapping("listUnverified") @ApiImplicitParams({ diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java index f51dc32ad..71f9eea20 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java @@ -43,10 +43,8 @@ public class WxCouponController extends BaseController { logger.error("id转换失败" + couponChannelId); return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId转换失败" + couponChannelId); } - WxCouponChannel wxCouponChannel = new WxCouponChannel(); - wxCouponChannel.setId(couponChannelIdL); - wxCouponChannel.setTenantId(getTenantId()); - WxCouponCVo wxCouponCVo = wxCouponChannelService.findDetailVo(wxCouponChannel); + + WxCouponCVo wxCouponCVo = wxCouponChannelService.findDetailVo(couponChannelIdL); if (wxCouponCVo == null) return new ResultData(ErrorCode.COUPON_IS_EMPTY); diff --git a/mallinkService/src/main/java/com/iformall/domain/dto/WxCounponDto.java b/mallinkService/src/main/java/com/iformall/domain/dto/WxCounponDto.java deleted file mode 100644 index 8e3a45d66..000000000 --- a/mallinkService/src/main/java/com/iformall/domain/dto/WxCounponDto.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.iformall.domain.dto; - -import javax.persistence.Transient; - -import com.iformall.domain.po.WxCoupon; -import com.iformall.domain.po.WxMerchant; - -public class WxCounponDto extends WxCoupon{ - - /** - * - */ - private static final long serialVersionUID = -5721410270215370223L; - @Transient - private WxMerchant wxMerchant; - - public WxMerchant getWxMerchant() { - return wxMerchant; - } - - public void setWxMerchant(WxMerchant wxMerchant) { - this.wxMerchant = wxMerchant; - } - - -} diff --git a/mallinkService/src/main/java/com/iformall/domain/dto/WxCouponCarDto.java b/mallinkService/src/main/java/com/iformall/domain/dto/WxCouponCarDto.java deleted file mode 100644 index a44b1af7c..000000000 --- a/mallinkService/src/main/java/com/iformall/domain/dto/WxCouponCarDto.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.iformall.domain.dto; - -import com.iformall.domain.po.WxMerchant; -import com.iformall.domain.vo.WxCouponCarVo; - -import javax.persistence.Transient; - -public class WxCouponCarDto extends WxCouponCarVo { - private static final long serialVersionUID = -5721410270215370223L; - @Transient - private WxMerchant wxMerchant; - - public WxMerchant getWxMerchant() { - return wxMerchant; - } - - public void setWxMerchant(WxMerchant wxMerchant) { - this.wxMerchant = wxMerchant; - } -} diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java index 5004fd20b..a7decb01f 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java @@ -69,9 +69,6 @@ public class WxCoupon implements Serializable { /*租户ID**/ @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") private String tenantId; - /*商户id**/ - @io.swagger.annotations.ApiModelProperty(value="商户id",name="merchantId") - private Long merchantId; /*券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券)**/ @io.swagger.annotations.ApiModelProperty(value="券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券)",name="type") private Integer type; @@ -144,12 +141,6 @@ public class WxCoupon implements Serializable { public void setTenantId(String _tenantId) { tenantId = _tenantId; } - public Long getMerchantId() { - return merchantId; - } - public void setMerchantId(Long _merchantId) { - merchantId = _merchantId; - } public Integer getType() { return type; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponCar.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponCar.java index a86456f0c..400d0c5ba 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponCar.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponCar.java @@ -46,9 +46,6 @@ public class WxCouponCar implements Serializable { /*停车场ID**/ @io.swagger.annotations.ApiModelProperty(value="停车场ID",name="parkId") private Long parkId; - /*商户ID**/ - @io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId") - private Long merchantId; /*车场服务商类型(1: ETCP,2:停简单)**/ @io.swagger.annotations.ApiModelProperty(value="车场服务商类型(1: ETCP,2:停简单)",name="vendorType") private Integer vendorType; @@ -73,12 +70,6 @@ public class WxCouponCar implements Serializable { public void setParkId(Long _parkId) { parkId = _parkId; } - public Long getMerchantId() { - return merchantId; - } - public void setMerchantId(Long _merchantId) { - merchantId = _merchantId; - } public Integer getVendorType() { return vendorType; } @@ -111,7 +102,6 @@ public class WxCouponCar implements Serializable { Id_ASC("`id` ASC"),Id_DESC("`id` DESC") ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") ,ParkId_ASC("`parkId` ASC"),ParkId_DESC("`parkId` DESC") - ,MerchantId_ASC("`merchantId` ASC"),MerchantId_DESC("`merchantId` DESC") ,VendorType_ASC("`vendorType` ASC"),VendorType_DESC("`vendorType` DESC") ,VendorParams_ASC("`vendorParams` ASC"),VendorParams_DESC("`vendorParams` DESC") ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponMerchant.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponMerchant.java index 350580655..8a18a2c07 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponMerchant.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponMerchant.java @@ -63,11 +63,11 @@ public class WxCouponMerchant implements Serializable { - public Long getCouponId() { + public Long getProductId() { return productId; } - public void setCouponId(Long productId) { + public void setProductId(Long productId) { this.productId = productId; } diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponCarVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponCarVo.java index 89d2b03be..8f06cd6fb 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponCarVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponCarVo.java @@ -1,5 +1,7 @@ package com.iformall.domain.vo; +import com.iformall.domain.po.WxCoupon; + import javax.persistence.Id; import javax.persistence.Transient; import java.io.Serializable; @@ -7,339 +9,26 @@ import java.text.DecimalFormat; import java.util.Date; import java.util.List; -public class WxCouponCarVo implements Serializable { +public class WxCouponCarVo extends WxCoupon implements Serializable { private static final long serialVersionUID = 1L; - @Id - protected Long id; - - @Transient - protected List ids; - @Transient - protected String sortColumns; - - @Transient - protected String channels; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getSortColumns() { - return sortColumns; - } - - public List getIds() { - return ids; - } - - public void setIds(List ids) { - this.ids = ids; - } - - - @Transient - private String salePriceStr; - - @Transient - private String usePriceStr; - - @Transient - private String priceStr; - - /*租户ID**/ - @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") - private String tenantId; - /*商户id**/ - @io.swagger.annotations.ApiModelProperty(value="商户id",name="merchantId") - private Long merchantId; - /*券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券)**/ - @io.swagger.annotations.ApiModelProperty(value="券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券)",name="type") - private Integer type; - /*封面图**/ - @io.swagger.annotations.ApiModelProperty(value="封面图",name="coverImg") - private String coverImg; - /*券名称**/ - @io.swagger.annotations.ApiModelProperty(value="券名称",name="title") - private String title; - /*副标题**/ - @io.swagger.annotations.ApiModelProperty(value="副标题",name="subTitle") - private String subTitle; - /*售价(适用于类型2,3,4,5)**/ - @io.swagger.annotations.ApiModelProperty(value="售价(适用于类型2,3,4,5)",name="salePrice") - private Integer salePrice; - /*使用条件金额(适用于类型1,2,3,4)**/ - @io.swagger.annotations.ApiModelProperty(value="使用条件金额(适用于类型1,2,3,4)",name="usePrice") - private Integer usePrice; - /*限领张数**/ - @io.swagger.annotations.ApiModelProperty(value="限领张数",name="useLimitQuantity") - private Integer useLimitQuantity; - /*投放频道位置(1.banner图,2.限时抢购)**/ - @io.swagger.annotations.ApiModelProperty(value="投放频道位置(1.banner图,2.限时抢购)",name="targetAd") - private Integer targetAd; - /*1.主动领取2.定向投放**/ - @io.swagger.annotations.ApiModelProperty(value="1.主动领取2.定向投放",name="sendType") - private Integer sendType; - /*有效时间类型1.时间范围(valid_start_date,valid_end_date). 2领取后几日有效(valid_days)**/ - @io.swagger.annotations.ApiModelProperty(value="有效时间类型1.时间范围(valid_start_date,valid_end_date). 2领取后几日有效(valid_days)",name="validType") - private Integer validType; - /*有效日期-开始**/ - @io.swagger.annotations.ApiModelProperty(value="有效日期-开始",name="validStartDate") - private Date validStartDate; - /*有效日期-结束**/ - @io.swagger.annotations.ApiModelProperty(value="有效日期-结束",name="validEndDate") - private Date validEndDate; - /*自领取之日几日有效,(停车券当天有效)**/ - @io.swagger.annotations.ApiModelProperty(value="自领取之日几日有效,(停车券当天有效)",name="validDays") - private Integer validDays; - /*须知**/ - @io.swagger.annotations.ApiModelProperty(value="须知",name="detail") - private String detail; - /*面额**/ - @io.swagger.annotations.ApiModelProperty(value="面额",name="price") - private Integer price; - /*单位**/ - @io.swagger.annotations.ApiModelProperty(value="单位(0:rmb分 1:小时)",name="unit") - private Integer unit; - /*剩余库存**/ - @io.swagger.annotations.ApiModelProperty(value="剩余库存",name="remainInventory") - private Integer remainInventory; - /*总库存**/ - @io.swagger.annotations.ApiModelProperty(value="总库存",name="inventory") - private Integer inventory; - /*购买须知**/ - @io.swagger.annotations.ApiModelProperty(value="购买须知",name="remark") - private String remark; - /*状态(-1:全部,0:草稿/待生效,1:已生效,2:已失效,3:已作废)**/ - @io.swagger.annotations.ApiModelProperty(value="状态(-1:全部,0:可投放,1:已生效,2:已失效,3:已作废)",name="status") - private Integer status; - /*创建时间**/ - @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") - private Date createDate; - /*更新时间**/ - @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") - private Date updateDate; - /*业态**/ - @io.swagger.annotations.ApiModelProperty(value="业态",name="business") - private Integer business; /*车场厂商类型**/ @io.swagger.annotations.ApiModelProperty(value="车场厂商类型1:ETCP,2:TJD",name="vendorType") private String vendorType; /*车场厂商相关信息**/ @io.swagger.annotations.ApiModelProperty(value="车场厂商相关信息",name="vendorParams") private String vendorParams; - public String getTenantId() { - return tenantId; - } - public void setTenantId(String _tenantId) { - tenantId = _tenantId; - } - public Long getMerchantId() { - return merchantId; - } - public void setMerchantId(Long _merchantId) { - merchantId = _merchantId; - } - public Integer getType() { - return type; - } - public void setType(Integer _type) { - type = _type; - } - public String getCoverImg() { - return coverImg; - } - public void setCoverImg(String _coverImg) { - coverImg = _coverImg; - } - public String getTitle() { - return title; - } - public void setTitle(String _title) { - title = _title; - } - public String getSubTitle() { - return subTitle; - } - public void setSubTitle(String _subTitle) { - subTitle = _subTitle; - } - public Integer getSalePrice() { - return salePrice; - } - public void setSalePrice(Integer _salePrice) { - salePrice = _salePrice; - } - public Integer getUsePrice() { - return usePrice; - } - public void setUsePrice(Integer _usePrice) { - usePrice = _usePrice; - } - public Integer getUseLimitQuantity() { - return useLimitQuantity; - } - public void setUseLimitQuantity(Integer _useLimitQuantity) { - useLimitQuantity = _useLimitQuantity; - } - public Integer getTargetAd() { - return targetAd; - } - public void setTargetAd(Integer _targetAd) { - targetAd = _targetAd; - } - public Integer getSendType() { - return sendType; - } - public void setSendType(Integer _sendType) { - sendType = _sendType; - } - public Integer getValidType() { - return validType; - } - public void setValidType(Integer _validType) { - validType = _validType; - } - public Date getValidStartDate() { - return validStartDate; - } - public void setValidStartDate(Date _validStartDate) { - validStartDate = _validStartDate; - } - public Date getValidEndDate() { - return validEndDate; - } - public void setValidEndDate(Date _validEndDate) { - validEndDate = _validEndDate; - } - public Integer getValidDays() { - return validDays; - } - public void setValidDays(Integer _validDays) { - validDays = _validDays; - } - public String getDetail() { - return detail; - } - public void setDetail(String _detail) { - detail = _detail; - } - public Integer getPrice() { - return price; - } - public void setPrice(Integer _price) { - price = _price; - } - public Integer getUnit() { - return unit; - } - public void setUnit(Integer _unit) { - unit = _unit; - } - public Integer getRemainInventory() { - return remainInventory; - } - public void setRemainInventory(Integer _remainInventory) { - remainInventory = _remainInventory; - } - public Integer getInventory() { - return inventory; - } - public void setInventory(Integer _inventory) { - inventory = _inventory; - } - public String getRemark() { - return remark; - } - public void setRemark(String _remark) { - remark = _remark; - } - public Integer getStatus() { - return status; - } - public void setStatus(Integer _status) { - status = _status; - } - public Date getCreateDate() { - return createDate; - } - public void setCreateDate(Date _createDate) { - createDate = _createDate; - } - public Date getUpdateDate() { - return updateDate; - } - public void setUpdateDate(Date _updateDate) { - updateDate = _updateDate; - } - public Integer getBusiness() { - return business; - } - public void setBusiness(Integer _business) { - business = _business; - } public String getVendorType() { return vendorType; } - public void setVendorType(String vendorType) { this.vendorType = vendorType; } - - public String getVendorParams() { - return vendorParams; - } - + public String getVendorParams() { return vendorParams; } public void setVendorParams(String vendorParams) { this.vendorParams = vendorParams; } - public String getSalePriceStr() { - if(salePrice!=null) { - DecimalFormat df=new DecimalFormat("0.00"); - salePriceStr = df.format((float)salePrice/100); - } - return salePriceStr; - } - public void setSalePriceStr(String salePriceStr) { - this.salePriceStr = salePriceStr; - } - - public String getUsePriceStr() { - if(usePrice!=null) { - DecimalFormat df=new DecimalFormat("0.00"); - usePriceStr = df.format((float)usePrice/100); - } - return usePriceStr; - } - - public void setUsePriceStr(String usePriceStr) { - this.usePriceStr = usePriceStr; - } - - public String getPriceStr() { - if(price!=null) { - DecimalFormat df=new DecimalFormat("0.00"); - priceStr = df.format((float)price/100); - } - return priceStr; - } - - public void setPriceStr(String priceStr) { - this.priceStr = priceStr; - } - - public String getChannels() { - return channels; - } - - public void setChannels(String channels) { - this.channels = channels; - } } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponCarMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponCarMapper.java index f67c0fbf1..929f0c3ce 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponCarMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponCarMapper.java @@ -2,7 +2,7 @@ package com.iformall.mapper; import java.util.*; import com.iformall.common.CommonMapper; -import com.iformall.domain.po.WxCoupon; +import org.apache.ibatis.annotations.Param; import com.iformall.domain.vo.WxCouponCarVo; import com.iformall.domain.po.WxCouponCar; @@ -15,6 +15,5 @@ public interface WxCouponCarMapper extends CommonMapper { Integer findTemplateAvailCount(Long templateId); - WxCouponCarVo selectCouponCarDetail(WxCoupon coupon); - + WxCouponCarVo findVoDetail(@Param("id")Long id); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java index 80495bde2..26d47c922 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java @@ -5,6 +5,7 @@ import com.iformall.common.CommonMapper; import com.iformall.domain.vo.WxCouponCVo; import com.iformall.domain.vo.WxCouponChannelVo; import com.iformall.domain.po.WxCouponChannel; +import org.apache.ibatis.annotations.Param; public interface WxCouponChannelMapper extends CommonMapper { @@ -14,7 +15,7 @@ public interface WxCouponChannelMapper extends CommonMapper findVoList(WxCouponChannel wxCouponChannel); - WxCouponCVo findVoDetail(WxCouponChannel wxCouponChannel); + WxCouponCVo findVoDetail(@Param("id")Long id); void updateStatusByCouponId(WxCouponChannel wxCouponChannel); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java index c0e226976..02dc208ac 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java @@ -11,6 +11,8 @@ public interface WxCouponMapper extends CommonMapper { List findList(WxCoupon wxCoupon); + WxCouponCVo findVoDetail(@Param("id")Long id); + void reduceInventory(@Param("id")Long id,@Param("number")Integer number); void offExpiriedCouponByValidDate(); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMerchantMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMerchantMapper.java index c32e33db4..a9f7485ea 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMerchantMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMerchantMapper.java @@ -3,11 +3,14 @@ package com.iformall.mapper; import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxCouponMerchant; +import com.iformall.domain.vo.WxMerchantVo; import java.util.List; +import java.util.Map; public interface WxCouponMerchantMapper extends CommonMapper { List findList(WxCouponMerchant wxCouponMerchant); + List findMerchantVoList(Map paramMap); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponCarService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponCarService.java index 984aa33ac..f64c11a09 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponCarService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponCarService.java @@ -63,11 +63,9 @@ public interface WxCouponCarService { /** * 根据coupon获得实体 * - * @param coupon + * @param id * @return */ - WxCouponCarVo getByCoupon(WxCoupon coupon); - - - + WxCouponCarVo findDetailVo(Long id); + } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java index 4b28ff43d..cd556696a 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java @@ -31,7 +31,7 @@ public interface WxCouponChannelService { */ PageInfo listPageCVo(WxCouponChannel record, Integer pageIndex, Integer pageSize); - WxCouponCVo findDetailVo(WxCouponChannel record); + WxCouponCVo findDetailVo(Long id); /** * 根据实体查询Vo分页列表 diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java index f088719a6..9eca58a29 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java @@ -44,12 +44,6 @@ public interface WxCouponOrderService { */ void saveOrUpdate(WxCouponOrder record); - /** - * 返回id - * @param record - * @return - */ - Long insertOne(WxCouponOrder record); /** * 根据Id删除实体 diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponService.java index dc475f580..c7ef52ed8 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponService.java @@ -34,13 +34,15 @@ public interface WxCouponService { * @return */ WxCoupon getById(Long id); - - /** + + + WxCouponCVo getVoById(Long id); + /** * 保存或更新实体 * * @param record */ - Long saveOrUpdate(WxCoupon record); + ResultData saveOrUpdate(WxCoupon record); /** * 根据Id删除实体 @@ -49,7 +51,6 @@ public interface WxCouponService { */ void deleteById(Long id); - ResultData updateCoupon(WxCoupon wxCoupon); void reduceInventory(Long id,Integer number); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponCarServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponCarServiceImpl.java index 08184a71c..36e0bf7a7 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponCarServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponCarServiceImpl.java @@ -57,8 +57,8 @@ public class WxCouponCarServiceImpl implements WxCouponCarService { } @Override - public WxCouponCarVo getByCoupon(WxCoupon coupon) { - return wxCouponCarMapper.selectCouponCarDetail(coupon); + public WxCouponCarVo findDetailVo(Long id) { + return wxCouponCarMapper.findVoDetail(id); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java index 3c04c2156..58f3dd377 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -10,15 +10,15 @@ import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.domain.po.WxCoupon; import com.iformall.domain.po.WxCouponChannel; +import com.iformall.domain.po.WxCouponMerchant; import com.iformall.domain.po.WxMerchant; import com.iformall.domain.vo.WxCouponCVo; import com.iformall.domain.vo.WxCouponChannelAddVo; import com.iformall.domain.vo.WxCouponChannelVo; -import com.iformall.enums.EnumCouponChannelStatus; -import com.iformall.enums.EnumCouponChannelType; -import com.iformall.enums.EnumCouponStatus; -import com.iformall.enums.EnumMerchantStatus; +import com.iformall.domain.vo.WxMerchantVo; +import com.iformall.enums.*; import com.iformall.mapper.WxCouponChannelMapper; +import com.iformall.mapper.WxCouponMerchantMapper; import com.iformall.mapper.WxMerchantMapper; import com.iformall.service.WxCouponChannelService; import com.iformall.service.WxCouponService; @@ -38,7 +38,8 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { WxCouponService wxCouponService; @Autowired WxMerchantMapper wxMerchantMapper; - + @Autowired + WxCouponMerchantMapper wxCouponMerchantMapper; /** * B端业务端 * @param record @@ -104,6 +105,15 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { wxCouponChannelMapper.updateStatusByCouponId(wxCouponChannel); } + private boolean isCouponMerchantValid(Long couponId) { + Map paramMap = new HashMap<>(); + paramMap.put("productId",couponId); + List merchantVoList = wxCouponMerchantMapper.findMerchantVoList(paramMap); + if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID)))){ + return true; + } + return false; + } public WxCouponChannelAddVo addCouponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime){ @@ -137,23 +147,13 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { return vo; } - WxMerchant wxMerchant = new WxMerchant(); - wxMerchant.setId(wxCoupon.getMerchantId()); - List merchants = wxMerchantMapper.findList(wxMerchant); - if(merchants.size() <= 0) { + if(!isCouponMerchantValid(wxCoupon.getId())) { logger.debug(wxCoupon.getId()+couponid+ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage()); vo.toCouponChannnelVo(wxCoupon,channelId); vo.setErrorMsg(ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage()); return vo; } - if(merchants.get(0).getStatus().equals(EnumMerchantStatus.NOT_VALID.getCode())) { - logger.debug(wxCoupon.getId()+couponid+ErrorCode.MERCHANT_INFO_NOT_VALID.getMessage()); - vo.toCouponChannnelVo(wxCoupon,channelId); - vo.setErrorMsg(ErrorCode.MERCHANT_INFO_NOT_VALID.getMessage()); - return vo; - } - if(channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_LIST.getCode())){ //列表默认投放结束时间为有效时间之后 beginTime = new Date(); endTime = wxCoupon.getValidEndDate(); @@ -197,8 +197,8 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { } @Override - public WxCouponCVo findDetailVo(WxCouponChannel record) { - return wxCouponChannelMapper.findVoDetail(record); + public WxCouponCVo findDetailVo(Long id) { + return wxCouponChannelMapper.findVoDetail(id); } @Override 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 67265f744..99c1ed539 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java @@ -108,14 +108,6 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { } } - @Override - public Long insertOne(WxCouponOrder record) { - final IdWorker idWorker = IdWorker.get(); - record.setId(idWorker.nextId()); - wxCouponOrderMapper.insertSelective(record); - return record.getId(); - } - @Override public void deleteById(Long id) { wxCouponOrderMapper.deleteByPrimaryKey(id); @@ -192,16 +184,6 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { return new ResultData(PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findListOfCUser(record))); } - @Override - public ResultData carlistCUserVoAsPage(WxCouponOrderCarCVo record, Integer pageIndex, Integer pageSize) { - return new ResultData(PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findCarListOfCUser(record))); - } - - @Override - public List carlistCUserVo(WxCouponOrderCarCVo record) { - return wxCouponOrderMapper.findCarListOfCUser(record); - } - @Override public ResultData detailCUserVo(Long cUserId, String couponOrderId) { WxCUser wxCuser = wxCUserMapper.selectByPrimaryKey(cUserId); @@ -221,6 +203,17 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { return new ResultData(wxCouponOrderCVo); } + + @Override + public ResultData carlistCUserVoAsPage(WxCouponOrderCarCVo record, Integer pageIndex, Integer pageSize) { + return new ResultData(PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findCarListOfCUser(record))); + } + + @Override + public List carlistCUserVo(WxCouponOrderCarCVo record) { + return wxCouponOrderMapper.findCarListOfCUser(record); + } + @Override public ResultData detailBUserVo(Long bUserId, String couponOrderId) { WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectByPrimaryKey(bUserId); @@ -333,7 +326,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); }else { WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); - wxCouponMerchant.setCouponId(wxCoupon.getId()); + wxCouponMerchant.setProductId(wxCoupon.getId()); wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); List couponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); if (!couponMerchantList.stream().anyMatch(cm->cm.getMerchantId().equals(wxMerchantBUser.getMerchantId()))){ diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java index 6881a0a92..847da1e53 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -1,18 +1,14 @@ package com.iformall.service.impl; -import java.time.LocalDate; import java.util.*; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; -import com.google.gson.JsonObject; +import com.iformall.common.ErrorCode; import com.iformall.common.ResultData; import com.iformall.domain.po.WxCoupon; -import com.iformall.domain.po.WxCouponChannel; import com.iformall.domain.po.WxCouponMerchant; -import com.iformall.domain.po.WxMerchant; import com.iformall.domain.vo.WxCouponCVo; import com.iformall.enums.*; import com.iformall.mapper.WxCouponMapper; @@ -66,14 +62,38 @@ public class WxCouponServiceImpl implements WxCouponService { return wxCouponMapper.selectByPrimaryKey(id); } + @Override + public WxCouponCVo getVoById(Long id) { + return wxCouponMapper.findVoDetail(id); + } + @Override @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) - public Long saveOrUpdate(WxCoupon record) { + public ResultData saveOrUpdate(WxCoupon record) { + + if (StringUtils.isNotEmpty(record.getSalePriceStr())) { + record.setSalePrice((int) (Double.parseDouble(record.getSalePriceStr()) * 100)); + } + if (StringUtils.isNotEmpty(record.getUsePriceStr())) { + record.setUsePrice((int) (Double.parseDouble(record.getUsePriceStr()) * 100)); + } + if (StringUtils.isNotEmpty(record.getPriceStr())) { + record.setPrice((int) (Double.parseDouble(record.getPriceStr()) * 100)); + } + + if (record.getValidType() != null) { + if (record.getValidType().equals(EnumCouponValidType.DAYS_AFTER_RECEIVING)) { + record.setValidStartDate(null); + record.setValidEndDate(null); + } else if (record.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME)) { + record.setValidDays(null); + } + } + final IdWorker idWorker = IdWorker.get(); - if (record.getId() == null) { - if (record.getType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) - && !record.getMerchantParams().isEmpty()) + if (record.getId() == null) { + if (!record.getMerchantParams().isEmpty()) { List merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); List couponMerchantList = new ArrayList<>(); @@ -83,7 +103,7 @@ public class WxCouponServiceImpl implements WxCouponService { cm.setId(idWorker.nextId()); cm.setMerchantId(merchantParam.getLong("id")); cm.setParameter(merchantParam.getString("param")); - cm.setCouponId(record.getId()); + cm.setProductId(record.getId()); cm.setCreateDate(new Date()); cm.setUpdateDate(new Date()); cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); @@ -95,35 +115,28 @@ public class WxCouponServiceImpl implements WxCouponService { } else { record.setBusiness(businessList.get(0)); } - wxCouponMerchantMapper.insertList(couponMerchantList); - - }else { - WxMerchant wxMerchant = wxMerchantMapper.selectByPrimaryKey(record.getMerchantId()); - if (wxMerchant != null){ - record.setBusiness(wxMerchant.getBusinessId()); - } + } else{ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); } + record.setId(idWorker.nextId()); record.setCreateDate(new Date()); record.setUpdateDate(new Date()); wxCouponMapper.insertSelective(record); } else { - - if (record.getType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) - && !record.getMerchantParams().isEmpty()) - { + if (!record.getMerchantParams().isEmpty()) { List merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); WxCouponMerchant cmParam = new WxCouponMerchant(); - cmParam.setCouponId(record.getId()); + cmParam.setProductId(record.getId()); List oldList = wxCouponMerchantMapper.findList(cmParam); List businessList= new ArrayList<>(); merchantParamList.stream().forEach(merchantParam -> { WxCouponMerchant cm = new WxCouponMerchant(); cm.setMerchantId(merchantParam.getLong("id")); - cm.setCouponId(record.getId()); + cm.setProductId(record.getId()); WxCouponMerchant rcm = wxCouponMerchantMapper.selectOne(cm); if (rcm != null) { rcm.setMerchantId(merchantParam.getLong("id")); @@ -141,7 +154,7 @@ public class WxCouponServiceImpl implements WxCouponService { } businessList.add(merchantParam.getInteger("business")); oldList.removeIf( - old->old.getCouponId().equals(record.getId()) && + old->old.getProductId().equals(record.getId()) && old.getMerchantId().equals(merchantParam.getLong("id"))); }); @@ -156,20 +169,22 @@ public class WxCouponServiceImpl implements WxCouponService { } else { record.setBusiness(businessList.get(0)); } + } - } else { - if (record.getMerchantId() != null) { - WxMerchant wxMerchant = wxMerchantMapper.selectByPrimaryKey(record.getMerchantId()); - if (wxMerchant != null) { - record.setBusiness(wxMerchant.getBusinessId()); - } + if (record.getStatus() != null) { + if (record.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) { + + //下架所有投放频道 + wxCouponChannelService + .updateStatusByCouponId(record.getId(), record.getTenantId(), EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()); + wxCouponSendService + .updateStatusByCouponId(record.getId(), record.getTenantId(), EnumCouponSendStatus.INVALID.getCode()); } } - record.setUpdateDate(new Date()); wxCouponMapper.updateByPrimaryKeySelective(record); } - return record.getId(); + return new ResultData(); } @Override @@ -177,26 +192,6 @@ public class WxCouponServiceImpl implements WxCouponService { wxCouponMapper.deleteByPrimaryKey(id); } - - @Override - @Transactional - public ResultData updateCoupon(WxCoupon wxCoupon) { - WxCoupon query = wxCouponMapper.selectByPrimaryKey(wxCoupon.getId()); - if (wxCoupon.getStatus() != null) { - if (query.getStatus().equals(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()) - && wxCoupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) { - - //下架所有投放频道 - wxCouponChannelService - .updateStatusByCouponId(wxCoupon.getId(), query.getTenantId(), EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()); - wxCouponSendService - .updateStatusByCouponId(query.getId(), query.getTenantId(), EnumCouponSendStatus.INVALID.getCode()); - } - } - return new ResultData(saveOrUpdate(wxCoupon)); - - } - @Override public void reduceInventory(Long id, Integer number) { wxCouponMapper.reduceInventory(id,number); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java index 7897e4234..079f17164 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java @@ -7,6 +7,7 @@ import com.iformall.common.IdWorker; import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.domain.po.*; +import com.iformall.domain.vo.WxMerchantVo; import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.*; @@ -72,6 +73,9 @@ public class WxMerchantServiceImpl implements WxMerchantService { @Autowired WxMerchantTaxMapper wxMerchantTaxMapper; + @Autowired + WxCouponMerchantMapper wxCouponMerchantMapper; + @Override public PageInfo listAsPage(WxMerchant record, Integer pageIndex, Integer pageSize) { @@ -168,6 +172,17 @@ public class WxMerchantServiceImpl implements WxMerchantService { wxMerchantMapper.deleteByPrimaryKey(id); } + + private boolean isCouponMerchantValid(Long couponId) { + Map paramMap = new HashMap<>(); + paramMap.put("productId",couponId); + List merchantVoList = wxCouponMerchantMapper.findMerchantVoList(paramMap); + if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID)))){ + return true; + } + return false; + } + @Transactional(rollbackFor = {Exception.class}) @Override public void disable(Long id) { @@ -208,13 +223,17 @@ public class WxMerchantServiceImpl implements WxMerchantService { wxMerchantBUserMapper.updateByPrimaryKeySelective(wxMerchantBUser); } //作废卡券 + WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); + wxCouponMerchant.setMerchantId(wxMerchant.getId()); + wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); + List wxCouponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); + List couponIds = wxCouponMerchantList.stream().map(cm->cm.getProductId()).collect(Collectors.toList()); WxCoupon wxCoupon = new WxCoupon(); - wxCoupon.setMerchantId(wxMerchant.getId()); - List wxCouponList = wxCouponMapper.findList(wxCoupon); - for (WxCoupon c : wxCouponList) { - c.setStatus(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode()); - wxCouponService.updateCoupon(c); - } + couponIds.parallelStream().filter(cid->!isCouponMerchantValid(cid)).forEach(cid->{ + wxCoupon.setId(cid); + wxCoupon.setStatus(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode()); + wxCouponService.saveOrUpdate(wxCoupon); + }); } @Transactional(rollbackFor = {Exception.class}) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java index 74ebefd71..1389d8938 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java @@ -6,6 +6,7 @@ import com.iformall.common.ErrorCode; import com.iformall.common.IdWorker; import com.iformall.common.ResultData; import com.iformall.domain.po.*; +import com.iformall.domain.vo.WxMerchantVo; import com.iformall.domain.vo.WxOrderCouponVo; import com.iformall.domain.vo.WxOrderPayVo; import com.iformall.enums.*; @@ -82,6 +83,9 @@ public class WxOrderServiceImpl implements WxOrderService { @Autowired WxProfitSharingOrderService wxProfitSharingOrderService; + @Autowired + WxCouponMerchantMapper wxCouponMerchantMapper; + @Override public PageInfo listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxOrderMapper.findList(record)); @@ -283,6 +287,16 @@ public class WxOrderServiceImpl implements WxOrderService { } } + private boolean isCouponMerchantValid(Long couponId) { + Map paramMap = new HashMap<>(); + paramMap.put("productId",couponId); + List merchantVoList = wxCouponMerchantMapper.findMerchantVoList(paramMap); + if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID)))){ + return true; + } + return false; + } + @Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) public WxOrder saveCouponOrder(WxCUser user, Long couponChannelId, Long couponId) { @@ -298,20 +312,16 @@ public class WxOrderServiceImpl implements WxOrderService { logger.error("券不存在, couponId: " + couponIdStr); throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); } + if (coupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) { logger.error("券已下架, couponId: " + couponIdStr); throw new MallinkException(ErrorCode.COUPON_ORDER_IS_INVALID); } - WxMerchant wxMerchant = wxMerchantMapper.selectByPrimaryKey(coupon.getMerchantId()); - if (wxMerchant == null) { + if (!isCouponMerchantValid(couponId)) { logger.error("商户不存在, couponId: " + couponIdStr); throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND); } - if (wxMerchant.getStatus().equals(EnumMerchantStatus.NOT_VALID.getCode())) { - logger.error("商户已禁用, couponId: " + couponIdStr); - throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_VALID); - } // 减库存操作 stockReduce(user, coupon, couponIdStr); @@ -327,11 +337,11 @@ public class WxOrderServiceImpl implements WxOrderService { // tenant_id + merchant_id + title + subtitle String bodyStr = ""; try { - bodyStr = Utility.substring(wxMerchant.getName(), Math.min(64, wxMerchant.getName().getBytes().length), "utf-8") + + bodyStr =// Utility.substring(wxMerchant.getName(), Math.min(64, wxMerchant.getName().getBytes().length), "utf-8") + Utility.substring(coupon.getTitle(), Math.min(62, coupon.getTitle().getBytes().length), "utf-8"); } catch (Exception e) { logger.error("body:" + e.getMessage()); - bodyStr = wxMerchant.getName() + "-" + EnumCouponType.getEnum(coupon.getType()); + bodyStr = /*wxMerchant.getName() + */ "-" + EnumCouponType.getEnum(coupon.getType()); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRefundOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRefundOrderServiceImpl.java index 2f7a5976c..cff737ed5 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRefundOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRefundOrderServiceImpl.java @@ -238,7 +238,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { WxCoupon wxCoupon = wxCouponMapper.selectByPrimaryKey(wxOrder.getPorductId()); if (wxCoupon != null) { WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); - wxCouponMerchant.setCouponId(wxCoupon.getId()); + wxCouponMerchant.setProductId(wxCoupon.getId()); wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); List couponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); if (couponMerchantList.stream().anyMatch(cm->cm.getMerchantId().equals(merchantId))){ diff --git a/mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml index 80058d85a..74fcbe6e5 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml @@ -5,7 +5,6 @@ - @@ -13,7 +12,7 @@ - `id`,`tenant_id`,`park_id`,`merchant_id`,`vendor_type`,`vendor_params`,`create_date`,`update_date` + `id`,`tenant_id`,`park_id`,`vendor_type`,`vendor_params`,`create_date`,`update_date` @@ -32,12 +31,7 @@ and `park_id` = #{parkId} - - - - and `merchant_id` = #{merchantId} - - + and `vendor_type` = #{vendorType} @@ -91,7 +85,6 @@ - @@ -115,26 +108,21 @@ + - c.tenant_id,c.merchant_id,c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_quantity,c.target_ad,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business, + c.id,c.tenant_id,c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_quantity,c.target_ad,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business, car.vendor_type, car.vendor_params - select from wx_coupon c,wx_coupon_car car where c.id = car.id - - and c.id = #{id} - - - and c.tenant_id = #{tenantId} - - + and c.id = #{id} diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml index 8b76d4ff4..c432bf46a 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml @@ -145,7 +145,7 @@ cc.id,cc.coupon_id,cc.target_ad,cc.begin_time,cc.end_time, - c.tenant_id,c.merchant_id,c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_quantity,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business + c.tenant_id,c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_quantity,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business @@ -156,7 +156,6 @@ - @@ -187,12 +186,12 @@ - select from wx_coupon_channel cc left join wx_coupon c on cc.coupon_id = c.id - + where cc.id = #{id} diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index 99d3c3f35..51c1032a0 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -147,6 +147,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number}