Browse Source

[停车券][新增]:库存接口

release_toaliyun_real
Stormeye.Wu 7 years ago
parent
commit
b381381496
5 changed files with 63 additions and 18 deletions
  1. +38
    -17
      mallinkAdmin/src/main/java/com/simple/controller/WxCarController.java
  2. +2
    -0
      mallinkService/src/main/java/com/simple/mapper/WxCouponCarMapper.java
  3. +7
    -0
      mallinkService/src/main/java/com/simple/service/WxCouponCarService.java
  4. +5
    -0
      mallinkService/src/main/java/com/simple/service/impl/WxCouponCarServiceImpl.java
  5. +11
    -1
      mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml

+ 38
- 17
mallinkAdmin/src/main/java/com/simple/controller/WxCarController.java View File

@@ -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) {


+ 2
- 0
mallinkService/src/main/java/com/simple/mapper/WxCouponCarMapper.java View File

@@ -14,6 +14,8 @@ public interface WxCouponCarMapper extends CommonMapper<WxCouponCar, String> {
Integer findTemplateAmtCount(Long templateId);

Integer findTemplateAvailCount(Long templateId);

WxCouponCarVo selectCouponCarDetail(WxCoupon coupon);
}

+ 7
- 0
mallinkService/src/main/java/com/simple/service/WxCouponCarService.java View File

@@ -54,6 +54,13 @@ public interface WxCouponCarService {
*/
Integer getAmtCountByTemplateId(Long templateId);

/**
* 根据templateId获取库存总数
*
* @param templateId
*/
Integer getAvaibleCountByTemplateId(Long templateId);

/**
* 根据coupon获得实体
*


+ 5
- 0
mallinkService/src/main/java/com/simple/service/impl/WxCouponCarServiceImpl.java View File

@@ -50,6 +50,11 @@ public class WxCouponCarServiceImpl implements WxCouponCarService {
return wxCouponCarMapper.findTemplateAmtCount(templateId);
}

@Override
public Integer getAvaibleCountByTemplateId(Long templateId) {
return wxCouponCarMapper.findTemplateAvailCount(templateId);
}

@Override
public WxCouponCarVo getByCoupon(WxCoupon coupon) {
return wxCouponCarMapper.selectCouponCarDetail(coupon);


+ 11
- 1
mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml View File

@@ -75,7 +75,17 @@
<select id="findTemplateAmtCount" parameterType="Long" resultType="Integer">
select sum(c.inventory) as count
from wx_coupon_car car, wx_coupon c
where car.id = c.id and json_extract(vendor_params,'$.id') = ${value}
where car.id = c.id
and c.status = 0
and json_extract(vendor_params,'$.id') = ${value}
</select>

<select id="findTemplateAvailCount" parameterType="Long" resultType="Integer">
select sum(c.remain_inventory) as count
from wx_coupon_car car, wx_coupon c
where car.id = c.id
and c.status = 0
and json_extract(vendor_params,'$.id') = ${value}
</select>

<resultMap id="CouponCarMap" type="com.simple.domain.vo.WxCouponCarVo">


Loading…
Cancel
Save