diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCarController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCarController.java index 8ed97d77c..d0897e9cc 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCarController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCarController.java @@ -9,10 +9,7 @@ import com.simple.common.ResultData; import com.simple.domain.po.*; import com.simple.enums.EnumCarCmd; import com.simple.enums.EnumCarVendor; -import com.simple.service.WxCUserCarService; -import com.simple.service.WxCarCmdLogService; -import com.simple.service.WxMerchantService; -import com.simple.service.WxParkService; +import com.simple.service.*; import com.simple.utils.ETCPUtil; import com.simple.utils.TJDCarUtil; import io.swagger.annotations.ApiImplicitParam; @@ -50,6 +47,12 @@ public class WxCarController extends BaseController @Autowired WxCarCmdLogService wxCarCmdLogService; + @Autowired + WxCouponService wxCouponService; + + @Autowired + WxCouponCarService wxCouponCarService; + private WxPark getCurrentPark(MallUserInfo user) { WxPark parkQ = new WxPark(); parkQ.setTenantId(user.getTenantId()); @@ -171,4 +174,68 @@ public class WxCarController extends BaseController businessId = objParams1.getString("businessId"); return businessId; } + + @ApiOperation("新增接口") + @PostMapping("add") + @ApiImplicitParams({ + @ApiImplicitParam(name="coupon",value="coupon",dataType="WxCoupon", paramType = "body",required=true), + @ApiImplicitParam(name="vendorParams",value="vendor_params",dataType="String", paramType = "body",required=true)}) + public ResultData add(@RequestBody WxCoupon coupon, String vendorParams) { + /* + amount: 1000 + avaliavleNum: 1000 + businessId: "IgWGUtpAX68=" + businessName: "fmtest5678" + category: "1" + categoryValue: "2.00" + couponType: "0" + coverImg: "http://202.165.179.86:8081/images/5411b414-b90e-4f51-bdd4-834fca86a722.png" + effectiveEnd: "2018-11-30" + effectiveStart: "2018-08-26" + name: "优免2小时券" + priceStr: "2.00元" + type: "5" + validEndDate: "undefined 00:00:00" + validStartDate: "undefined 00:00:00" + */ + //Assert.notNull(wxCoupon.getName(), "角色名不能为空"); + //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); + // Save to wx_counpon + if(StringUtils.isNotEmpty(coupon.getSalePriceStr())){ + coupon.setSalePrice((int)Double.parseDouble(coupon.getSalePriceStr())*100); + } + if(StringUtils.isNotEmpty(coupon.getUsePriceStr())){ + coupon.setUsePrice((int)Double.parseDouble(coupon.getUsePriceStr())*100); + } + if(StringUtils.isNotEmpty(coupon.getPriceStr())){ + coupon.setPrice((int)Double.parseDouble(coupon.getPriceStr())*100); + } + if(StringUtils.isNotBlank(coupon.getBusiness())) { + String[] arys = coupon.getBusiness().split(","); + coupon.setBusiness(JSON.toJSONString(arys)); + } + coupon.setTenantId(getUser().getTenantId()); + coupon.setChannels(""); + Long id = wxCouponService.saveOrUpdate(coupon); + + + // Save to wx_coupon_car + WxCouponCar couponCar = new WxCouponCar(); + couponCar.setId(id); + couponCar.setTenantId(coupon.getTenantId()); + couponCar.setMerchantId(coupon.getMerchantId()); + + MallUserInfo user = getUser(); + WxPark park = getCurrentPark(user); + couponCar.setParkId(park.getId()); + couponCar.setVendorType(park.getVendorType()); + couponCar.setVendorParams(vendorParams); + Date curDate = new Date(); + couponCar.setCreateDate(curDate); + couponCar.setUpdateDate(curDate); + wxCouponCarService.save(couponCar); + + + return new ResultData(id); + } } diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponCarController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponCarController.java index 6da6ef31d..bd347e99e 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponCarController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponCarController.java @@ -40,14 +40,14 @@ public class WxCouponCarController extends BaseController public ResultData add(@RequestBody WxCouponCar wxCouponCar) { //Assert.notNull(wxCouponCar.getName(), "角色名不能为空"); //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); - wxCouponCarService.saveOrUpdate(wxCouponCar); + wxCouponCarService.save(wxCouponCar); return new ResultData(); } @ApiOperation("根据id更新接口") @PostMapping("update") public ResultData update(@RequestBody WxCouponCar wxCouponCar) { - wxCouponCarService.saveOrUpdate(wxCouponCar); + wxCouponCarService.update(wxCouponCar); return new ResultData(); } diff --git a/mallinkCApi/src/main/java/com/simple/controller/WxCouponCarController.java b/mallinkCApi/src/main/java/com/simple/controller/WxCouponCarController.java index c0a37482a..eaa69c093 100644 --- a/mallinkCApi/src/main/java/com/simple/controller/WxCouponCarController.java +++ b/mallinkCApi/src/main/java/com/simple/controller/WxCouponCarController.java @@ -42,14 +42,14 @@ public class WxCouponCarController extends BaseController public ResultData add(@RequestBody WxCouponCar wxCouponCar) { //Assert.notNull(wxCouponCar.getName(), "角色名不能为空"); //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); - wxCouponCarService.saveOrUpdate(wxCouponCar); + wxCouponCarService.save(wxCouponCar); return new ResultData(); } @ApiOperation("根据id更新接口") @PostMapping("update") public ResultData update(@RequestBody WxCouponCar wxCouponCar) { - wxCouponCarService.saveOrUpdate(wxCouponCar); + wxCouponCarService.update(wxCouponCar); return new ResultData(); } diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxCouponCar.java b/mallinkService/src/main/java/com/simple/domain/po/WxCouponCar.java index 691e410c7..a523d1de2 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxCouponCar.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxCouponCar.java @@ -43,7 +43,7 @@ public class WxCouponCar implements Serializable { /*租户ID**/ @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") - private Long tenantId; + private String tenantId; /*停车场ID**/ @io.swagger.annotations.ApiModelProperty(value="停车场ID",name="parkId") private Long parkId; @@ -62,10 +62,10 @@ public class WxCouponCar implements Serializable { /*更新时间**/ @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") private Date updateDate; - public Long getTenantId() { + public String getTenantId() { return tenantId; } - public void setTenantId(Long _tenantId) { + public void setTenantId(String _tenantId) { tenantId = _tenantId; } public Long getParkId() { diff --git a/mallinkService/src/main/java/com/simple/service/WxCouponCarService.java b/mallinkService/src/main/java/com/simple/service/WxCouponCarService.java index 6aca30ceb..eb1d4625b 100644 --- a/mallinkService/src/main/java/com/simple/service/WxCouponCarService.java +++ b/mallinkService/src/main/java/com/simple/service/WxCouponCarService.java @@ -24,12 +24,19 @@ public interface WxCouponCarService { */ WxCouponCar getById(Long id); - /** + /** * 保存或更新实体 * * @param record */ - void saveOrUpdate(WxCouponCar record); + void save(WxCouponCar record); + + /** + * 更新实体 + * + * @param record + */ + void update(WxCouponCar record); /** * 根据Id删除实体 diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCouponCarServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCouponCarServiceImpl.java index 584a3fdd3..e2913ca1f 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCouponCarServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCouponCarServiceImpl.java @@ -28,15 +28,13 @@ public class WxCouponCarServiceImpl implements WxCouponCarService { } @Override - public void saveOrUpdate(WxCouponCar record) { - if (record.getId() == null) { - //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); - final IdWorker idWorker = IdWorker.get(); - record.setId(idWorker.nextId()); + public void save(WxCouponCar record) { wxCouponCarMapper.insertSelective(record); - } else { - wxCouponCarMapper.updateByPrimaryKeySelective(record); - } + } + + @Override + public void update(WxCouponCar record) { + wxCouponCarMapper.updateByPrimaryKey(record); } @Override