| @@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONArray; | |||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.dto.WxCouponCarDto; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxCouponCarVo; | import com.iformall.domain.vo.WxCouponCarVo; | ||||
| import com.iformall.enums.EnumCarVendor; | import com.iformall.enums.EnumCarVendor; | ||||
| @@ -182,8 +181,6 @@ public class WxCarController extends BaseController { | |||||
| public ResultData save(@RequestBody WxCouponCarVo coupon) { | public ResultData save(@RequestBody WxCouponCarVo coupon) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCarController::save"); | logger.debug("[" + getIpAddr() + "] WxCarController::save"); | ||||
| logger.info(coupon.toString()); | logger.info(coupon.toString()); | ||||
| //Assert.notNull(wxCoupon.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| // Save to wx_counpon | // Save to wx_counpon | ||||
| Date curDate = new Date(); | Date curDate = new Date(); | ||||
| MallUserInfo user = getUser(); | MallUserInfo user = getUser(); | ||||
| @@ -207,56 +204,13 @@ public class WxCarController extends BaseController { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "已达到停车厂商优免券数量限制"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "已达到停车厂商优免券数量限制"); | ||||
| } | } | ||||
| // check End | // 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 | // Save to wx_coupon_car | ||||
| WxCouponCar couponCar = new WxCouponCar(); | WxCouponCar couponCar = new WxCouponCar(); | ||||
| couponCar.setId(id); | |||||
| couponCar.setId(coupon.getId()); | |||||
| couponCar.setTenantId(user.getTenantId()); | couponCar.setTenantId(user.getTenantId()); | ||||
| couponCar.setMerchantId(coupon.getMerchantId()); | |||||
| WxPark park = getCurrentPark(user); | WxPark park = getCurrentPark(user); | ||||
| couponCar.setParkId(park.getId()); | couponCar.setParkId(park.getId()); | ||||
| @@ -271,8 +225,7 @@ public class WxCarController extends BaseController { | |||||
| wxCouponCarService.update(couponCar); | wxCouponCarService.update(couponCar); | ||||
| } | } | ||||
| return new ResultData(id); | |||||
| return new ResultData(coupon.getId()); | |||||
| } | } | ||||
| @@ -312,26 +265,9 @@ public class WxCarController extends BaseController { | |||||
| @ApiOperation("停车券detail") | @ApiOperation("停车券detail") | ||||
| @GetMapping("/detail") | @GetMapping("/detail") | ||||
| public ResultData getCouponCarDetail(@ModelAttribute WxCoupon coupon) { | |||||
| public ResultData getCouponCarDetail(@RequestParam Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCarController::getCouponCarDetail"); | 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 = "停车场状态") | @ApiOperation(value = "停车场状态") | ||||
| @@ -2,9 +2,9 @@ package com.iformall.controller; | |||||
| import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.dto.WxCounponDto; | |||||
| import com.iformall.domain.po.WxCoupon; | import com.iformall.domain.po.WxCoupon; | ||||
| import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
| import com.iformall.domain.po.WxMerchant; | import com.iformall.domain.po.WxMerchant; | ||||
| @@ -38,8 +38,6 @@ public class WxCouponController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxCouponService wxCouponService; | private WxCouponService wxCouponService; | ||||
| @Autowired | |||||
| private WxMerchantService wxMerchantService; | |||||
| @Autowired | @Autowired | ||||
| private WxCouponChannelService wxCouponChannelService; | private WxCouponChannelService wxCouponChannelService; | ||||
| @@ -103,30 +101,7 @@ public class WxCouponController extends BaseController { | |||||
| @PostMapping("add") | @PostMapping("add") | ||||
| public ResultData add(@RequestBody WxCoupon wxCoupon) { | public ResultData add(@RequestBody WxCoupon wxCoupon) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::add"); | 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更新接口") | @ApiOperation("根据id更新接口") | ||||
| @@ -136,25 +111,7 @@ public class WxCouponController extends BaseController { | |||||
| if (wxCoupon.getId() == null) { | if (wxCoupon.getId() == null) { | ||||
| return new ResultData(ResultData.ERROR, "缺少id"); | 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删除接口") | @ApiOperation("根据id删除接口") | ||||
| @@ -169,16 +126,9 @@ public class WxCouponController extends BaseController { | |||||
| @ApiOperation("根据id查询接口") | @ApiOperation("根据id查询接口") | ||||
| @GetMapping("/findById") | @GetMapping("/findById") | ||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | @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)); | |||||
| } | } | ||||
| @@ -26,7 +26,6 @@ import org.springframework.web.bind.annotation.*; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.Date; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| @RestController | @RestController | ||||
| @@ -46,8 +46,6 @@ public class WxCouponOrderController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @ApiOperation("交易流水分页列表接口") | @ApiOperation("交易流水分页列表接口") | ||||
| @GetMapping("listUnverified") | @GetMapping("listUnverified") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -43,10 +43,8 @@ public class WxCouponController extends BaseController { | |||||
| logger.error("id转换失败" + couponChannelId); | logger.error("id转换失败" + couponChannelId); | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId转换失败" + 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) | if (wxCouponCVo == null) | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| @@ -69,9 +69,6 @@ public class WxCoupon implements Serializable { | |||||
| /*租户ID**/ | /*租户ID**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | ||||
| private String tenantId; | private String tenantId; | ||||
| /*商户id**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="商户id",name="merchantId") | |||||
| private Long merchantId; | |||||
| /*券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券)**/ | /*券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券)**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券)",name="type") | @io.swagger.annotations.ApiModelProperty(value="券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券)",name="type") | ||||
| private Integer type; | private Integer type; | ||||
| @@ -144,12 +141,6 @@ public class WxCoupon implements Serializable { | |||||
| public void setTenantId(String _tenantId) { | public void setTenantId(String _tenantId) { | ||||
| tenantId = _tenantId; | tenantId = _tenantId; | ||||
| } | } | ||||
| public Long getMerchantId() { | |||||
| return merchantId; | |||||
| } | |||||
| public void setMerchantId(Long _merchantId) { | |||||
| merchantId = _merchantId; | |||||
| } | |||||
| public Integer getType() { | public Integer getType() { | ||||
| return type; | return type; | ||||
| } | } | ||||
| @@ -46,9 +46,6 @@ public class WxCouponCar implements Serializable { | |||||
| /*停车场ID**/ | /*停车场ID**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="停车场ID",name="parkId") | @io.swagger.annotations.ApiModelProperty(value="停车场ID",name="parkId") | ||||
| private Long parkId; | private Long parkId; | ||||
| /*商户ID**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId") | |||||
| private Long merchantId; | |||||
| /*车场服务商类型(1: ETCP,2:停简单)**/ | /*车场服务商类型(1: ETCP,2:停简单)**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="车场服务商类型(1: ETCP,2:停简单)",name="vendorType") | @io.swagger.annotations.ApiModelProperty(value="车场服务商类型(1: ETCP,2:停简单)",name="vendorType") | ||||
| private Integer vendorType; | private Integer vendorType; | ||||
| @@ -73,12 +70,6 @@ public class WxCouponCar implements Serializable { | |||||
| public void setParkId(Long _parkId) { | public void setParkId(Long _parkId) { | ||||
| parkId = _parkId; | parkId = _parkId; | ||||
| } | } | ||||
| public Long getMerchantId() { | |||||
| return merchantId; | |||||
| } | |||||
| public void setMerchantId(Long _merchantId) { | |||||
| merchantId = _merchantId; | |||||
| } | |||||
| public Integer getVendorType() { | public Integer getVendorType() { | ||||
| return vendorType; | return vendorType; | ||||
| } | } | ||||
| @@ -111,7 +102,6 @@ public class WxCouponCar implements Serializable { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | ||||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | ||||
| ,ParkId_ASC("`parkId` ASC"),ParkId_DESC("`parkId` 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") | ,VendorType_ASC("`vendorType` ASC"),VendorType_DESC("`vendorType` DESC") | ||||
| ,VendorParams_ASC("`vendorParams` ASC"),VendorParams_DESC("`vendorParams` DESC") | ,VendorParams_ASC("`vendorParams` ASC"),VendorParams_DESC("`vendorParams` DESC") | ||||
| ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | ||||
| @@ -63,11 +63,11 @@ public class WxCouponMerchant implements Serializable { | |||||
| public Long getCouponId() { | |||||
| public Long getProductId() { | |||||
| return productId; | return productId; | ||||
| } | } | ||||
| public void setCouponId(Long productId) { | |||||
| public void setProductId(Long productId) { | |||||
| this.productId = productId; | this.productId = productId; | ||||
| } | } | ||||
| @@ -1,5 +1,7 @@ | |||||
| package com.iformall.domain.vo; | package com.iformall.domain.vo; | ||||
| import com.iformall.domain.po.WxCoupon; | |||||
| import javax.persistence.Id; | import javax.persistence.Id; | ||||
| import javax.persistence.Transient; | import javax.persistence.Transient; | ||||
| import java.io.Serializable; | import java.io.Serializable; | ||||
| @@ -7,339 +9,26 @@ import java.text.DecimalFormat; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| public class WxCouponCarVo implements Serializable { | |||||
| public class WxCouponCarVo extends WxCoupon implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> 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<Long> getIds() { | |||||
| return ids; | |||||
| } | |||||
| public void setIds(List<Long> 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") | @io.swagger.annotations.ApiModelProperty(value="车场厂商类型1:ETCP,2:TJD",name="vendorType") | ||||
| private String vendorType; | private String vendorType; | ||||
| /*车场厂商相关信息**/ | /*车场厂商相关信息**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="车场厂商相关信息",name="vendorParams") | @io.swagger.annotations.ApiModelProperty(value="车场厂商相关信息",name="vendorParams") | ||||
| private String 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() { | public String getVendorType() { | ||||
| return vendorType; | return vendorType; | ||||
| } | } | ||||
| public void setVendorType(String vendorType) { | public void setVendorType(String vendorType) { | ||||
| this.vendorType = vendorType; | this.vendorType = vendorType; | ||||
| } | } | ||||
| public String getVendorParams() { | |||||
| return vendorParams; | |||||
| } | |||||
| public String getVendorParams() { return vendorParams; } | |||||
| public void setVendorParams(String vendorParams) { | public void setVendorParams(String vendorParams) { | ||||
| this.vendorParams = 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; | |||||
| } | |||||
| } | } | ||||
| @@ -2,7 +2,7 @@ package com.iformall.mapper; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.iformall.common.CommonMapper; | 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.vo.WxCouponCarVo; | ||||
| import com.iformall.domain.po.WxCouponCar; | import com.iformall.domain.po.WxCouponCar; | ||||
| @@ -15,6 +15,5 @@ public interface WxCouponCarMapper extends CommonMapper<WxCouponCar, String> { | |||||
| Integer findTemplateAvailCount(Long templateId); | Integer findTemplateAvailCount(Long templateId); | ||||
| WxCouponCarVo selectCouponCarDetail(WxCoupon coupon); | |||||
| WxCouponCarVo findVoDetail(@Param("id")Long id); | |||||
| } | } | ||||
| @@ -5,6 +5,7 @@ import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
| import org.apache.ibatis.annotations.Param; | |||||
| public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, String> { | public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, String> { | ||||
| @@ -14,7 +15,7 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str | |||||
| List<WxCouponChannelVo> findVoList(WxCouponChannel wxCouponChannel); | List<WxCouponChannelVo> findVoList(WxCouponChannel wxCouponChannel); | ||||
| WxCouponCVo findVoDetail(WxCouponChannel wxCouponChannel); | |||||
| WxCouponCVo findVoDetail(@Param("id")Long id); | |||||
| void updateStatusByCouponId(WxCouponChannel wxCouponChannel); | void updateStatusByCouponId(WxCouponChannel wxCouponChannel); | ||||
| @@ -11,6 +11,8 @@ public interface WxCouponMapper extends CommonMapper<WxCoupon, Long> { | |||||
| List<WxCoupon> findList(WxCoupon wxCoupon); | List<WxCoupon> findList(WxCoupon wxCoupon); | ||||
| WxCouponCVo findVoDetail(@Param("id")Long id); | |||||
| void reduceInventory(@Param("id")Long id,@Param("number")Integer number); | void reduceInventory(@Param("id")Long id,@Param("number")Integer number); | ||||
| void offExpiriedCouponByValidDate(); | void offExpiriedCouponByValidDate(); | ||||
| @@ -3,11 +3,14 @@ package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.po.WxCouponMerchant; | import com.iformall.domain.po.WxCouponMerchant; | ||||
| import com.iformall.domain.vo.WxMerchantVo; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| public interface WxCouponMerchantMapper extends CommonMapper<WxCouponMerchant, Long> { | public interface WxCouponMerchantMapper extends CommonMapper<WxCouponMerchant, Long> { | ||||
| List<WxCouponMerchant> findList(WxCouponMerchant wxCouponMerchant); | List<WxCouponMerchant> findList(WxCouponMerchant wxCouponMerchant); | ||||
| List<WxMerchantVo> findMerchantVoList(Map paramMap); | |||||
| } | } | ||||
| @@ -63,11 +63,9 @@ public interface WxCouponCarService { | |||||
| /** | /** | ||||
| * 根据coupon获得实体 | * 根据coupon获得实体 | ||||
| * | * | ||||
| * @param coupon | |||||
| * @param id | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| WxCouponCarVo getByCoupon(WxCoupon coupon); | |||||
| WxCouponCarVo findDetailVo(Long id); | |||||
| } | } | ||||
| @@ -31,7 +31,7 @@ public interface WxCouponChannelService { | |||||
| */ | */ | ||||
| PageInfo<WxCouponChannelVo> listPageCVo(WxCouponChannel record, Integer pageIndex, Integer pageSize); | PageInfo<WxCouponChannelVo> listPageCVo(WxCouponChannel record, Integer pageIndex, Integer pageSize); | ||||
| WxCouponCVo findDetailVo(WxCouponChannel record); | |||||
| WxCouponCVo findDetailVo(Long id); | |||||
| /** | /** | ||||
| * 根据实体查询Vo分页列表 | * 根据实体查询Vo分页列表 | ||||
| @@ -44,12 +44,6 @@ public interface WxCouponOrderService { | |||||
| */ | */ | ||||
| void saveOrUpdate(WxCouponOrder record); | void saveOrUpdate(WxCouponOrder record); | ||||
| /** | |||||
| * 返回id | |||||
| * @param record | |||||
| * @return | |||||
| */ | |||||
| Long insertOne(WxCouponOrder record); | |||||
| /** | /** | ||||
| * 根据Id删除实体 | * 根据Id删除实体 | ||||
| @@ -34,13 +34,15 @@ public interface WxCouponService { | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| WxCoupon getById(Long id); | WxCoupon getById(Long id); | ||||
| /** | |||||
| WxCouponCVo getVoById(Long id); | |||||
| /** | |||||
| * 保存或更新实体 | * 保存或更新实体 | ||||
| * | * | ||||
| * @param record | * @param record | ||||
| */ | */ | ||||
| Long saveOrUpdate(WxCoupon record); | |||||
| ResultData saveOrUpdate(WxCoupon record); | |||||
| /** | /** | ||||
| * 根据Id删除实体 | * 根据Id删除实体 | ||||
| @@ -49,7 +51,6 @@ public interface WxCouponService { | |||||
| */ | */ | ||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| ResultData updateCoupon(WxCoupon wxCoupon); | |||||
| void reduceInventory(Long id,Integer number); | void reduceInventory(Long id,Integer number); | ||||
| @@ -57,8 +57,8 @@ public class WxCouponCarServiceImpl implements WxCouponCarService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public WxCouponCarVo getByCoupon(WxCoupon coupon) { | |||||
| return wxCouponCarMapper.selectCouponCarDetail(coupon); | |||||
| public WxCouponCarVo findDetailVo(Long id) { | |||||
| return wxCouponCarMapper.findVoDetail(id); | |||||
| } | } | ||||
| @@ -10,15 +10,15 @@ import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxCoupon; | import com.iformall.domain.po.WxCoupon; | ||||
| import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
| import com.iformall.domain.po.WxCouponMerchant; | |||||
| import com.iformall.domain.po.WxMerchant; | import com.iformall.domain.po.WxMerchant; | ||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelAddVo; | import com.iformall.domain.vo.WxCouponChannelAddVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | 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.WxCouponChannelMapper; | ||||
| import com.iformall.mapper.WxCouponMerchantMapper; | |||||
| import com.iformall.mapper.WxMerchantMapper; | import com.iformall.mapper.WxMerchantMapper; | ||||
| import com.iformall.service.WxCouponChannelService; | import com.iformall.service.WxCouponChannelService; | ||||
| import com.iformall.service.WxCouponService; | import com.iformall.service.WxCouponService; | ||||
| @@ -38,7 +38,8 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| WxCouponService wxCouponService; | WxCouponService wxCouponService; | ||||
| @Autowired | @Autowired | ||||
| WxMerchantMapper wxMerchantMapper; | WxMerchantMapper wxMerchantMapper; | ||||
| @Autowired | |||||
| WxCouponMerchantMapper wxCouponMerchantMapper; | |||||
| /** | /** | ||||
| * B端业务端 | * B端业务端 | ||||
| * @param record | * @param record | ||||
| @@ -104,6 +105,15 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| wxCouponChannelMapper.updateStatusByCouponId(wxCouponChannel); | wxCouponChannelMapper.updateStatusByCouponId(wxCouponChannel); | ||||
| } | } | ||||
| private boolean isCouponMerchantValid(Long couponId) { | |||||
| Map paramMap = new HashMap<>(); | |||||
| paramMap.put("productId",couponId); | |||||
| List<WxMerchantVo> 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){ | public WxCouponChannelAddVo addCouponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime){ | ||||
| @@ -137,23 +147,13 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| return vo; | return vo; | ||||
| } | } | ||||
| WxMerchant wxMerchant = new WxMerchant(); | |||||
| wxMerchant.setId(wxCoupon.getMerchantId()); | |||||
| List <WxMerchant> merchants = wxMerchantMapper.findList(wxMerchant); | |||||
| if(merchants.size() <= 0) { | |||||
| if(!isCouponMerchantValid(wxCoupon.getId())) { | |||||
| logger.debug(wxCoupon.getId()+couponid+ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage()); | logger.debug(wxCoupon.getId()+couponid+ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage()); | ||||
| vo.toCouponChannnelVo(wxCoupon,channelId); | vo.toCouponChannnelVo(wxCoupon,channelId); | ||||
| vo.setErrorMsg(ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage()); | vo.setErrorMsg(ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage()); | ||||
| return vo; | 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())){ //列表默认投放结束时间为有效时间之后 | if(channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_LIST.getCode())){ //列表默认投放结束时间为有效时间之后 | ||||
| beginTime = new Date(); | beginTime = new Date(); | ||||
| endTime = wxCoupon.getValidEndDate(); | endTime = wxCoupon.getValidEndDate(); | ||||
| @@ -197,8 +197,8 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public WxCouponCVo findDetailVo(WxCouponChannel record) { | |||||
| return wxCouponChannelMapper.findVoDetail(record); | |||||
| public WxCouponCVo findDetailVo(Long id) { | |||||
| return wxCouponChannelMapper.findVoDetail(id); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -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 | @Override | ||||
| public void deleteById(Long id) { | public void deleteById(Long id) { | ||||
| wxCouponOrderMapper.deleteByPrimaryKey(id); | wxCouponOrderMapper.deleteByPrimaryKey(id); | ||||
| @@ -192,16 +184,6 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| return new ResultData(PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findListOfCUser(record))); | 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<WxCouponOrderCarCVo> carlistCUserVo(WxCouponOrderCarCVo record) { | |||||
| return wxCouponOrderMapper.findCarListOfCUser(record); | |||||
| } | |||||
| @Override | @Override | ||||
| public ResultData detailCUserVo(Long cUserId, String couponOrderId) { | public ResultData detailCUserVo(Long cUserId, String couponOrderId) { | ||||
| WxCUser wxCuser = wxCUserMapper.selectByPrimaryKey(cUserId); | WxCUser wxCuser = wxCUserMapper.selectByPrimaryKey(cUserId); | ||||
| @@ -221,6 +203,17 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| return new ResultData(wxCouponOrderCVo); | 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<WxCouponOrderCarCVo> carlistCUserVo(WxCouponOrderCarCVo record) { | |||||
| return wxCouponOrderMapper.findCarListOfCUser(record); | |||||
| } | |||||
| @Override | @Override | ||||
| public ResultData detailBUserVo(Long bUserId, String couponOrderId) { | public ResultData detailBUserVo(Long bUserId, String couponOrderId) { | ||||
| WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectByPrimaryKey(bUserId); | WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectByPrimaryKey(bUserId); | ||||
| @@ -333,7 +326,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | ||||
| }else { | }else { | ||||
| WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); | WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); | ||||
| wxCouponMerchant.setCouponId(wxCoupon.getId()); | |||||
| wxCouponMerchant.setProductId(wxCoupon.getId()); | |||||
| wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | ||||
| List<WxCouponMerchant> couponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); | List<WxCouponMerchant> couponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); | ||||
| if (!couponMerchantList.stream().anyMatch(cm->cm.getMerchantId().equals(wxMerchantBUser.getMerchantId()))){ | if (!couponMerchantList.stream().anyMatch(cm->cm.getMerchantId().equals(wxMerchantBUser.getMerchantId()))){ | ||||
| @@ -1,18 +1,14 @@ | |||||
| package com.iformall.service.impl; | package com.iformall.service.impl; | ||||
| import java.time.LocalDate; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.alibaba.fastjson.JSONArray; | |||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.google.gson.JsonObject; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxCoupon; | import com.iformall.domain.po.WxCoupon; | ||||
| import com.iformall.domain.po.WxCouponChannel; | |||||
| import com.iformall.domain.po.WxCouponMerchant; | import com.iformall.domain.po.WxCouponMerchant; | ||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.mapper.WxCouponMapper; | import com.iformall.mapper.WxCouponMapper; | ||||
| @@ -66,14 +62,38 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| return wxCouponMapper.selectByPrimaryKey(id); | return wxCouponMapper.selectByPrimaryKey(id); | ||||
| } | } | ||||
| @Override | |||||
| public WxCouponCVo getVoById(Long id) { | |||||
| return wxCouponMapper.findVoDetail(id); | |||||
| } | |||||
| @Override | @Override | ||||
| @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | @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(); | 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<JSONObject> merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); | List<JSONObject> merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); | ||||
| List<WxCouponMerchant> couponMerchantList = new ArrayList<>(); | List<WxCouponMerchant> couponMerchantList = new ArrayList<>(); | ||||
| @@ -83,7 +103,7 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| cm.setId(idWorker.nextId()); | cm.setId(idWorker.nextId()); | ||||
| cm.setMerchantId(merchantParam.getLong("id")); | cm.setMerchantId(merchantParam.getLong("id")); | ||||
| cm.setParameter(merchantParam.getString("param")); | cm.setParameter(merchantParam.getString("param")); | ||||
| cm.setCouponId(record.getId()); | |||||
| cm.setProductId(record.getId()); | |||||
| cm.setCreateDate(new Date()); | cm.setCreateDate(new Date()); | ||||
| cm.setUpdateDate(new Date()); | cm.setUpdateDate(new Date()); | ||||
| cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | ||||
| @@ -95,35 +115,28 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| } else { | } else { | ||||
| record.setBusiness(businessList.get(0)); | record.setBusiness(businessList.get(0)); | ||||
| } | } | ||||
| wxCouponMerchantMapper.insertList(couponMerchantList); | 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.setId(idWorker.nextId()); | ||||
| record.setCreateDate(new Date()); | record.setCreateDate(new Date()); | ||||
| record.setUpdateDate(new Date()); | record.setUpdateDate(new Date()); | ||||
| wxCouponMapper.insertSelective(record); | wxCouponMapper.insertSelective(record); | ||||
| } else { | } else { | ||||
| if (record.getType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) | |||||
| && !record.getMerchantParams().isEmpty()) | |||||
| { | |||||
| if (!record.getMerchantParams().isEmpty()) { | |||||
| List<JSONObject> merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); | List<JSONObject> merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); | ||||
| WxCouponMerchant cmParam = new WxCouponMerchant(); | WxCouponMerchant cmParam = new WxCouponMerchant(); | ||||
| cmParam.setCouponId(record.getId()); | |||||
| cmParam.setProductId(record.getId()); | |||||
| List<WxCouponMerchant> oldList = wxCouponMerchantMapper.findList(cmParam); | List<WxCouponMerchant> oldList = wxCouponMerchantMapper.findList(cmParam); | ||||
| List<Integer> businessList= new ArrayList<>(); | List<Integer> businessList= new ArrayList<>(); | ||||
| merchantParamList.stream().forEach(merchantParam -> { | merchantParamList.stream().forEach(merchantParam -> { | ||||
| WxCouponMerchant cm = new WxCouponMerchant(); | WxCouponMerchant cm = new WxCouponMerchant(); | ||||
| cm.setMerchantId(merchantParam.getLong("id")); | cm.setMerchantId(merchantParam.getLong("id")); | ||||
| cm.setCouponId(record.getId()); | |||||
| cm.setProductId(record.getId()); | |||||
| WxCouponMerchant rcm = wxCouponMerchantMapper.selectOne(cm); | WxCouponMerchant rcm = wxCouponMerchantMapper.selectOne(cm); | ||||
| if (rcm != null) { | if (rcm != null) { | ||||
| rcm.setMerchantId(merchantParam.getLong("id")); | rcm.setMerchantId(merchantParam.getLong("id")); | ||||
| @@ -141,7 +154,7 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| } | } | ||||
| businessList.add(merchantParam.getInteger("business")); | businessList.add(merchantParam.getInteger("business")); | ||||
| oldList.removeIf( | oldList.removeIf( | ||||
| old->old.getCouponId().equals(record.getId()) && | |||||
| old->old.getProductId().equals(record.getId()) && | |||||
| old.getMerchantId().equals(merchantParam.getLong("id"))); | old.getMerchantId().equals(merchantParam.getLong("id"))); | ||||
| }); | }); | ||||
| @@ -156,20 +169,22 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| } else { | } else { | ||||
| record.setBusiness(businessList.get(0)); | 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()); | record.setUpdateDate(new Date()); | ||||
| wxCouponMapper.updateByPrimaryKeySelective(record); | wxCouponMapper.updateByPrimaryKeySelective(record); | ||||
| } | } | ||||
| return record.getId(); | |||||
| return new ResultData(); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -177,26 +192,6 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| wxCouponMapper.deleteByPrimaryKey(id); | 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 | @Override | ||||
| public void reduceInventory(Long id, Integer number) { | public void reduceInventory(Long id, Integer number) { | ||||
| wxCouponMapper.reduceInventory(id,number); | wxCouponMapper.reduceInventory(id,number); | ||||
| @@ -7,6 +7,7 @@ import com.iformall.common.IdWorker; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxMerchantVo; | |||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| @@ -72,6 +73,9 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| @Autowired | @Autowired | ||||
| WxMerchantTaxMapper wxMerchantTaxMapper; | WxMerchantTaxMapper wxMerchantTaxMapper; | ||||
| @Autowired | |||||
| WxCouponMerchantMapper wxCouponMerchantMapper; | |||||
| @Override | @Override | ||||
| public PageInfo<WxMerchant> listAsPage(WxMerchant record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMerchant> listAsPage(WxMerchant record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -168,6 +172,17 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| wxMerchantMapper.deleteByPrimaryKey(id); | wxMerchantMapper.deleteByPrimaryKey(id); | ||||
| } | } | ||||
| private boolean isCouponMerchantValid(Long couponId) { | |||||
| Map paramMap = new HashMap<>(); | |||||
| paramMap.put("productId",couponId); | |||||
| List<WxMerchantVo> merchantVoList = wxCouponMerchantMapper.findMerchantVoList(paramMap); | |||||
| if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID)))){ | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| @Override | @Override | ||||
| public void disable(Long id) { | public void disable(Long id) { | ||||
| @@ -208,13 +223,17 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| wxMerchantBUserMapper.updateByPrimaryKeySelective(wxMerchantBUser); | wxMerchantBUserMapper.updateByPrimaryKeySelective(wxMerchantBUser); | ||||
| } | } | ||||
| //作废卡券 | //作废卡券 | ||||
| WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); | |||||
| wxCouponMerchant.setMerchantId(wxMerchant.getId()); | |||||
| wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | |||||
| List<WxCouponMerchant> wxCouponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); | |||||
| List<Long> couponIds = wxCouponMerchantList.stream().map(cm->cm.getProductId()).collect(Collectors.toList()); | |||||
| WxCoupon wxCoupon = new WxCoupon(); | WxCoupon wxCoupon = new WxCoupon(); | ||||
| wxCoupon.setMerchantId(wxMerchant.getId()); | |||||
| List<WxCoupon> 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}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| @@ -6,6 +6,7 @@ import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxMerchantVo; | |||||
| import com.iformall.domain.vo.WxOrderCouponVo; | import com.iformall.domain.vo.WxOrderCouponVo; | ||||
| import com.iformall.domain.vo.WxOrderPayVo; | import com.iformall.domain.vo.WxOrderPayVo; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| @@ -82,6 +83,9 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| @Autowired | @Autowired | ||||
| WxProfitSharingOrderService wxProfitSharingOrderService; | WxProfitSharingOrderService wxProfitSharingOrderService; | ||||
| @Autowired | |||||
| WxCouponMerchantMapper wxCouponMerchantMapper; | |||||
| @Override | @Override | ||||
| public PageInfo<WxOrder> listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxOrder> listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxOrderMapper.findList(record)); | 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<WxMerchantVo> merchantVoList = wxCouponMerchantMapper.findMerchantVoList(paramMap); | |||||
| if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID)))){ | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| @Override | @Override | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public WxOrder saveCouponOrder(WxCUser user, Long couponChannelId, Long couponId) { | public WxOrder saveCouponOrder(WxCUser user, Long couponChannelId, Long couponId) { | ||||
| @@ -298,20 +312,16 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| logger.error("券不存在, couponId: " + couponIdStr); | logger.error("券不存在, couponId: " + couponIdStr); | ||||
| throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| if (coupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) { | if (coupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) { | ||||
| logger.error("券已下架, couponId: " + couponIdStr); | logger.error("券已下架, couponId: " + couponIdStr); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_INVALID); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_INVALID); | ||||
| } | } | ||||
| WxMerchant wxMerchant = wxMerchantMapper.selectByPrimaryKey(coupon.getMerchantId()); | |||||
| if (wxMerchant == null) { | |||||
| if (!isCouponMerchantValid(couponId)) { | |||||
| logger.error("商户不存在, couponId: " + couponIdStr); | logger.error("商户不存在, couponId: " + couponIdStr); | ||||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND); | 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); | stockReduce(user, coupon, couponIdStr); | ||||
| @@ -327,11 +337,11 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| // tenant_id + merchant_id + title + subtitle | // tenant_id + merchant_id + title + subtitle | ||||
| String bodyStr = ""; | String bodyStr = ""; | ||||
| try { | 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"); | Utility.substring(coupon.getTitle(), Math.min(62, coupon.getTitle().getBytes().length), "utf-8"); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("body:" + e.getMessage()); | logger.error("body:" + e.getMessage()); | ||||
| bodyStr = wxMerchant.getName() + "-" + EnumCouponType.getEnum(coupon.getType()); | |||||
| bodyStr = /*wxMerchant.getName() + */ "-" + EnumCouponType.getEnum(coupon.getType()); | |||||
| } | } | ||||
| @@ -238,7 +238,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||||
| WxCoupon wxCoupon = wxCouponMapper.selectByPrimaryKey(wxOrder.getPorductId()); | WxCoupon wxCoupon = wxCouponMapper.selectByPrimaryKey(wxOrder.getPorductId()); | ||||
| if (wxCoupon != null) { | if (wxCoupon != null) { | ||||
| WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); | WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); | ||||
| wxCouponMerchant.setCouponId(wxCoupon.getId()); | |||||
| wxCouponMerchant.setProductId(wxCoupon.getId()); | |||||
| wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | ||||
| List<WxCouponMerchant> couponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); | List<WxCouponMerchant> couponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); | ||||
| if (couponMerchantList.stream().anyMatch(cm->cm.getMerchantId().equals(merchantId))){ | if (couponMerchantList.stream().anyMatch(cm->cm.getMerchantId().equals(merchantId))){ | ||||
| @@ -5,7 +5,6 @@ | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | <id column="id" jdbcType="BIGINT" property="id" /> | ||||
| <result column="tenant_id" jdbcType="BIGINT" property="tenantId" /> | <result column="tenant_id" jdbcType="BIGINT" property="tenantId" /> | ||||
| <result column="park_id" jdbcType="BIGINT" property="parkId" /> | <result column="park_id" jdbcType="BIGINT" property="parkId" /> | ||||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | |||||
| <result column="vendor_type" jdbcType="INTEGER" property="vendorType" /> | <result column="vendor_type" jdbcType="INTEGER" property="vendorType" /> | ||||
| <result column="vendor_params" jdbcType="VARCHAR" property="vendorParams" /> | <result column="vendor_params" jdbcType="VARCHAR" property="vendorParams" /> | ||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | ||||
| @@ -13,7 +12,7 @@ | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `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` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -32,12 +31,7 @@ | |||||
| <if test=" null != parkId "> | <if test=" null != parkId "> | ||||
| and `park_id` = #{parkId} | and `park_id` = #{parkId} | ||||
| </if> | |||||
| <if test=" null != merchantId "> | |||||
| and `merchant_id` = #{merchantId} | |||||
| </if> | |||||
| </if> | |||||
| <if test=" null != vendorType "> | <if test=" null != vendorType "> | ||||
| and `vendor_type` = #{vendorType} | and `vendor_type` = #{vendorType} | ||||
| @@ -91,7 +85,6 @@ | |||||
| <resultMap id="CouponCarMap" type="com.iformall.domain.vo.WxCouponCarVo"> | <resultMap id="CouponCarMap" type="com.iformall.domain.vo.WxCouponCarVo"> | ||||
| <id column="id" jdbcType="BIGINT" property="id" /> | <id column="id" jdbcType="BIGINT" property="id" /> | ||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | ||||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | |||||
| <result column="type" jdbcType="INTEGER" property="type" /> | <result column="type" jdbcType="INTEGER" property="type" /> | ||||
| <result column="cover_img" jdbcType="VARCHAR" property="coverImg" /> | <result column="cover_img" jdbcType="VARCHAR" property="coverImg" /> | ||||
| <result column="title" jdbcType="VARCHAR" property="title" /> | <result column="title" jdbcType="VARCHAR" property="title" /> | ||||
| @@ -115,26 +108,21 @@ | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | ||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | ||||
| <result column="business" jdbcType="VARCHAR" property="business" /> | <result column="business" jdbcType="VARCHAR" property="business" /> | ||||
| <result column="vendor_type" jdbcType="INTEGER" property="vendorType" /> | <result column="vendor_type" jdbcType="INTEGER" property="vendorType" /> | ||||
| <result column="vendor_params" jdbcType="VARCHAR" property="vendorParams" /> | <result column="vendor_params" jdbcType="VARCHAR" property="vendorParams" /> | ||||
| </resultMap> | </resultMap> | ||||
| <sql id="CouponCarColumns"> | <sql id="CouponCarColumns"> | ||||
| 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 | car.vendor_type, car.vendor_params | ||||
| </sql> | </sql> | ||||
| <select id="selectCouponCarDetail" parameterType="com.iformall.domain.vo.WxCouponCarVo" resultMap="CouponCarMap"> | |||||
| <select id="selectCouponCarDetail" parameterType="java.lang.Long" resultMap="CouponCarMap"> | |||||
| select <include refid="CouponCarColumns" /> | select <include refid="CouponCarColumns" /> | ||||
| from | from | ||||
| wx_coupon c,wx_coupon_car car | wx_coupon c,wx_coupon_car car | ||||
| where c.id = car.id | where c.id = car.id | ||||
| <if test=" null != id "> | |||||
| and c.id = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and c.tenant_id = #{tenantId} | |||||
| </if> | |||||
| and c.id = #{id} | |||||
| </select> | </select> | ||||
| @@ -145,7 +145,7 @@ | |||||
| <sql id="WxCouponCVoColumn"> | <sql id="WxCouponCVoColumn"> | ||||
| cc.id,cc.coupon_id,cc.target_ad,cc.begin_time,cc.end_time, | 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 | |||||
| </sql> | </sql> | ||||
| <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo"> | <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo"> | ||||
| @@ -156,7 +156,6 @@ | |||||
| <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/> | <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/> | ||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | ||||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/> | |||||
| <result column="type" jdbcType="INTEGER" property="type"/> | <result column="type" jdbcType="INTEGER" property="type"/> | ||||
| <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/> | <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/> | ||||
| <result column="title" jdbcType="VARCHAR" property="title"/> | <result column="title" jdbcType="VARCHAR" property="title"/> | ||||
| @@ -187,12 +186,12 @@ | |||||
| </collection> | </collection> | ||||
| </resultMap> | </resultMap> | ||||
| <select id="findVoDetail" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="WxCouponCVoMap"> | |||||
| <select id="findVoDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMap"> | |||||
| select | select | ||||
| <include refid="WxCouponCVoColumn"/> | <include refid="WxCouponCVoColumn"/> | ||||
| from wx_coupon_channel cc | from wx_coupon_channel cc | ||||
| left join wx_coupon c on cc.coupon_id = c.id | left join wx_coupon c on cc.coupon_id = c.id | ||||
| <include refid="dynamicWhereConditions" /> | |||||
| where cc.id = #{id} | |||||
| </select> | </select> | ||||
| @@ -147,6 +147,47 @@ | |||||
| <include refid="dynamicWhereConditions"/> | <include refid="dynamicWhereConditions"/> | ||||
| </select> | </select> | ||||
| <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo"> | |||||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||||
| <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/> | |||||
| <result column="title" jdbcType="VARCHAR" property="title"/> | |||||
| <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/> | |||||
| <result column="sale_price" jdbcType="INTEGER" property="salePrice"/> | |||||
| <result column="use_price" jdbcType="INTEGER" property="usePrice"/> | |||||
| <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/> | |||||
| <result column="send_type" jdbcType="INTEGER" property="sendType"/> | |||||
| <result column="valid_type" jdbcType="INTEGER" property="validType"/> | |||||
| <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/> | |||||
| <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/> | |||||
| <result column="valid_days" jdbcType="INTEGER" property="validDays"/> | |||||
| <result column="detail" jdbcType="VARCHAR" property="detail"/> | |||||
| <result column="price" jdbcType="INTEGER" property="price"/> | |||||
| <result column="unit" jdbcType="INTEGER" property="unit"/> | |||||
| <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/> | |||||
| <result column="inventory" jdbcType="INTEGER" property="inventory"/> | |||||
| <result column="remark" jdbcType="VARCHAR" property="remark"/> | |||||
| <result column="status" jdbcType="INTEGER" property="status"/> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||||
| <result column="business" jdbcType="INTEGER" property="business"/> | |||||
| <collection column="{productId=coupon_id}" property="merchantVoList" | |||||
| ofType="com.iformall.domain.vo.WxMerchantVo" | |||||
| javaType="java.util.ArrayList" | |||||
| select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" > | |||||
| </collection> | |||||
| </resultMap> | |||||
| <select id="findVoDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from wx_coupon | |||||
| where id = #{id} | |||||
| </select> | |||||
| <update id="reduceInventory"> | <update id="reduceInventory"> | ||||
| update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number} | update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number} | ||||
| </update> | </update> | ||||