| @@ -9,10 +9,7 @@ import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.*; | import com.simple.domain.po.*; | ||||
| import com.simple.enums.EnumCarCmd; | import com.simple.enums.EnumCarCmd; | ||||
| import com.simple.enums.EnumCarVendor; | 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.ETCPUtil; | ||||
| import com.simple.utils.TJDCarUtil; | import com.simple.utils.TJDCarUtil; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| @@ -50,6 +47,12 @@ public class WxCarController extends BaseController | |||||
| @Autowired | @Autowired | ||||
| WxCarCmdLogService wxCarCmdLogService; | WxCarCmdLogService wxCarCmdLogService; | ||||
| @Autowired | |||||
| WxCouponService wxCouponService; | |||||
| @Autowired | |||||
| WxCouponCarService wxCouponCarService; | |||||
| private WxPark getCurrentPark(MallUserInfo user) { | private WxPark getCurrentPark(MallUserInfo user) { | ||||
| WxPark parkQ = new WxPark(); | WxPark parkQ = new WxPark(); | ||||
| parkQ.setTenantId(user.getTenantId()); | parkQ.setTenantId(user.getTenantId()); | ||||
| @@ -171,4 +174,68 @@ public class WxCarController extends BaseController | |||||
| businessId = objParams1.getString("businessId"); | businessId = objParams1.getString("businessId"); | ||||
| return 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); | |||||
| } | |||||
| } | } | ||||
| @@ -40,14 +40,14 @@ public class WxCouponCarController extends BaseController | |||||
| public ResultData add(@RequestBody WxCouponCar wxCouponCar) { | public ResultData add(@RequestBody WxCouponCar wxCouponCar) { | ||||
| //Assert.notNull(wxCouponCar.getName(), "角色名不能为空"); | //Assert.notNull(wxCouponCar.getName(), "角色名不能为空"); | ||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | ||||
| wxCouponCarService.saveOrUpdate(wxCouponCar); | |||||
| wxCouponCarService.save(wxCouponCar); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @ApiOperation("根据id更新接口") | @ApiOperation("根据id更新接口") | ||||
| @PostMapping("update") | @PostMapping("update") | ||||
| public ResultData update(@RequestBody WxCouponCar wxCouponCar) { | public ResultData update(@RequestBody WxCouponCar wxCouponCar) { | ||||
| wxCouponCarService.saveOrUpdate(wxCouponCar); | |||||
| wxCouponCarService.update(wxCouponCar); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -42,14 +42,14 @@ public class WxCouponCarController extends BaseController | |||||
| public ResultData add(@RequestBody WxCouponCar wxCouponCar) { | public ResultData add(@RequestBody WxCouponCar wxCouponCar) { | ||||
| //Assert.notNull(wxCouponCar.getName(), "角色名不能为空"); | //Assert.notNull(wxCouponCar.getName(), "角色名不能为空"); | ||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | ||||
| wxCouponCarService.saveOrUpdate(wxCouponCar); | |||||
| wxCouponCarService.save(wxCouponCar); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @ApiOperation("根据id更新接口") | @ApiOperation("根据id更新接口") | ||||
| @PostMapping("update") | @PostMapping("update") | ||||
| public ResultData update(@RequestBody WxCouponCar wxCouponCar) { | public ResultData update(@RequestBody WxCouponCar wxCouponCar) { | ||||
| wxCouponCarService.saveOrUpdate(wxCouponCar); | |||||
| wxCouponCarService.update(wxCouponCar); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -43,7 +43,7 @@ public class WxCouponCar implements Serializable { | |||||
| /*租户ID**/ | /*租户ID**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | ||||
| private Long tenantId; | |||||
| private String tenantId; | |||||
| /*停车场ID**/ | /*停车场ID**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="停车场ID",name="parkId") | @io.swagger.annotations.ApiModelProperty(value="停车场ID",name="parkId") | ||||
| private Long parkId; | private Long parkId; | ||||
| @@ -62,10 +62,10 @@ public class WxCouponCar implements Serializable { | |||||
| /*更新时间**/ | /*更新时间**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | ||||
| private Date updateDate; | private Date updateDate; | ||||
| public Long getTenantId() { | |||||
| public String getTenantId() { | |||||
| return tenantId; | return tenantId; | ||||
| } | } | ||||
| public void setTenantId(Long _tenantId) { | |||||
| public void setTenantId(String _tenantId) { | |||||
| tenantId = _tenantId; | tenantId = _tenantId; | ||||
| } | } | ||||
| public Long getParkId() { | public Long getParkId() { | ||||
| @@ -24,12 +24,19 @@ public interface WxCouponCarService { | |||||
| */ | */ | ||||
| WxCouponCar getById(Long id); | WxCouponCar getById(Long id); | ||||
| /** | |||||
| /** | |||||
| * 保存或更新实体 | * 保存或更新实体 | ||||
| * | * | ||||
| * @param record | * @param record | ||||
| */ | */ | ||||
| void saveOrUpdate(WxCouponCar record); | |||||
| void save(WxCouponCar record); | |||||
| /** | |||||
| * 更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void update(WxCouponCar record); | |||||
| /** | /** | ||||
| * 根据Id删除实体 | * 根据Id删除实体 | ||||
| @@ -28,15 +28,13 @@ public class WxCouponCarServiceImpl implements WxCouponCarService { | |||||
| } | } | ||||
| @Override | @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); | wxCouponCarMapper.insertSelective(record); | ||||
| } else { | |||||
| wxCouponCarMapper.updateByPrimaryKeySelective(record); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void update(WxCouponCar record) { | |||||
| wxCouponCarMapper.updateByPrimaryKey(record); | |||||
| } | } | ||||
| @Override | @Override | ||||