|
|
|
@@ -21,6 +21,7 @@ import io.swagger.models.auth.In; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.log4j.Logger; |
|
|
|
import org.apache.poi.hmef.attribute.MAPIAttribute; |
|
|
|
import org.omg.PortableInterceptor.INACTIVE; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
@@ -183,28 +184,32 @@ public class WxCarController extends BaseController |
|
|
|
@PostMapping("add") |
|
|
|
public ResultData add(@RequestBody WxCouponCarVo coupon) { |
|
|
|
logger.info(coupon.toString()); |
|
|
|
/* |
|
|
|
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 |
|
|
|
Date curDate = new Date(); |
|
|
|
MallUserInfo user = getUser(); |
|
|
|
// check 同一个模板的券分配额是否超了 |
|
|
|
if (StringUtils.isBlank(coupon.getVendorParams())) { |
|
|
|
logger.error("请填充停车厂商优免券参数"); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "停车厂商参数为空"); |
|
|
|
} |
|
|
|
JSONObject vendorParamsObj = JSON.parseObject(coupon.getVendorParams()); |
|
|
|
Long templateId = vendorParamsObj.getLong("id"); |
|
|
|
Integer amount = vendorParamsObj.getInteger("amount"); |
|
|
|
Integer avaliavleNum = vendorParamsObj.getInteger("avaliavleNum"); |
|
|
|
Integer amtCount = wxCouponCarService.getAmtCountByTemplateId(templateId); |
|
|
|
Integer availCount = wxCouponCarService.getAvaibleCountByTemplateId(templateId); |
|
|
|
if (amtCount >= amount) { |
|
|
|
logger.error("已达到停车厂商优免券数量限制"); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "已达到停车厂商优免券数量限制"); |
|
|
|
} |
|
|
|
if (availCount >= avaliavleNum) { |
|
|
|
logger.error("已达到停车厂商优免券数量限制"); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "已达到停车厂商优免券数量限制"); |
|
|
|
} |
|
|
|
// check End |
|
|
|
|
|
|
|
|
|
|
|
WxCoupon wxCoupon = new WxCoupon(); |
|
|
|
wxCoupon.setTenantId(user.getTenantId()); |
|
|
|
@@ -278,6 +283,22 @@ public class WxCarController extends BaseController |
|
|
|
return new ResultData(map); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("优免券模板库存总数") |
|
|
|
@GetMapping("/templateAvaiCount") |
|
|
|
@ApiImplicitParams({ |
|
|
|
@ApiImplicitParam(name="templateId",value="模板ID",dataType="Long", paramType = "query",required=true)}) |
|
|
|
public ResultData getTemplateAvailSum(Long templateId) { |
|
|
|
Map map = new HashMap(); |
|
|
|
Integer availCount = 0; |
|
|
|
try { |
|
|
|
availCount = wxCouponCarService.getAvaibleCountByTemplateId(templateId); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
} |
|
|
|
map.put("availCount", availCount); |
|
|
|
return new ResultData(map); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("停车券detail") |
|
|
|
@GetMapping("/detail") |
|
|
|
public ResultData getCouponCarDetail(@ModelAttribute WxCoupon coupon) { |
|
|
|
|