|
|
|
@@ -10,6 +10,7 @@ import com.iformall.domain.po.WxCouponChannel; |
|
|
|
import com.iformall.domain.po.WxCouponPassword; |
|
|
|
import com.iformall.domain.po.WxFlowModel; |
|
|
|
import com.iformall.domain.po.WxMerchant; |
|
|
|
import com.iformall.domain.po.WxMerchantBUser; |
|
|
|
import com.iformall.domain.po.base.TenantEntity; |
|
|
|
import com.iformall.domain.vo.WxCouponStatisVo; |
|
|
|
import com.iformall.enums.*; |
|
|
|
@@ -102,16 +103,28 @@ public class WxCouponController extends BaseController { |
|
|
|
return wxCouponService.list(wxCoupon, pageNum, pageSize); //全列表 |
|
|
|
} |
|
|
|
|
|
|
|
private Map<String,Object> generateFlowParams(EnumFlowKey flowType,EnumCouponAppType approvalType, Long couponId,String remark) { |
|
|
|
private Map<String,Object> generateFlowParams(EnumFlowKey flowType,EnumCouponAppType approvalType, WxCoupon wxCoupon,String remark,String phone) { |
|
|
|
Map<String,Object> map = new HashMap<String,Object>(); |
|
|
|
map.put("businessId", String.valueOf(couponId)); |
|
|
|
map.put("businessId", String.valueOf(wxCoupon.getId())); |
|
|
|
map.put("businessType", flowType.getCode()); |
|
|
|
map.put("remark", remark); |
|
|
|
map.put("phone", phone); |
|
|
|
List<Map> variablesList = new ArrayList<Map>(); |
|
|
|
Map contractTypeMap = new HashMap<String,Object>(); |
|
|
|
contractTypeMap.put("key","approvalType"); |
|
|
|
contractTypeMap.put("value",String.valueOf(approvalType.getCode())); |
|
|
|
variablesList.add(contractTypeMap); |
|
|
|
|
|
|
|
Map couponNameMap = new HashMap<String,Object>(); |
|
|
|
couponNameMap.put("key","couponName"); |
|
|
|
couponNameMap.put("value",wxCoupon.getTitle()); |
|
|
|
variablesList.add(couponNameMap); |
|
|
|
|
|
|
|
Map couponTypeMap = new HashMap<String,Object>(); |
|
|
|
couponTypeMap.put("key","couponType"); |
|
|
|
couponTypeMap.put("value",wxCoupon.getType()); |
|
|
|
variablesList.add(couponTypeMap); |
|
|
|
|
|
|
|
map.put("variables", variablesList); |
|
|
|
return map; |
|
|
|
} |
|
|
|
@@ -126,16 +139,22 @@ public class WxCouponController extends BaseController { |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean hasMerchantCouponFlow() { |
|
|
|
return hasFlow(EnumFlowKey.B_COUPON_MERCHANT_CREATE,getTenantInfo()); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("查询是否有审批流程") |
|
|
|
@PostMapping("hasFlow") |
|
|
|
public ResultData hasFlow() { |
|
|
|
if (hasFlow(EnumFlowKey.B_COUPON_MERCHANT_CREATE,getTenantInfo())) { |
|
|
|
if (hasMerchantCouponFlow()) { |
|
|
|
return new ResultData(1); |
|
|
|
}else { |
|
|
|
return new ResultData(0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("提交审批") |
|
|
|
@PostMapping("apply") |
|
|
|
@@ -150,10 +169,11 @@ public class WxCouponController extends BaseController { |
|
|
|
return new ResultData(Result.ERROR,"非B端券,不能进行此操作"); |
|
|
|
} |
|
|
|
|
|
|
|
if (!hasFlow(EnumFlowKey.B_COUPON_MERCHANT_CREATE,coupon)) { |
|
|
|
if (!hasMerchantCouponFlow()) { |
|
|
|
return new ResultData(Result.ERROR,EnumFlowKey.B_COUPON_MERCHANT_CREATE.getMessage()+"未配置审批流程"); |
|
|
|
} |
|
|
|
wxFlowService.start(generateFlowParams(EnumFlowKey.B_COUPON_MERCHANT_CREATE,EnumCouponAppType.PUT,wxCoupon.getId(),wxCoupon.getRemark()), getBuserId(), getUser().getName(), wxCoupon); |
|
|
|
WxMerchantBUser buser = getUser(); |
|
|
|
wxFlowService.start(generateFlowParams(EnumFlowKey.B_COUPON_MERCHANT_CREATE,EnumCouponAppType.PUT,wxCoupon,wxCoupon.getRemark(), buser.getPhone()), getBuserId(), buser.getName(), wxCoupon); |
|
|
|
return new ResultData(Result.SUCCESS,"提交审批成功"); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -162,6 +182,9 @@ public class WxCouponController extends BaseController { |
|
|
|
@ApiOperation("新增接口") |
|
|
|
@PostMapping("add") |
|
|
|
public ResultData add(@RequestBody WxCoupon wxCoupon) { |
|
|
|
if (!hasMerchantCouponFlow()) { |
|
|
|
return new ResultData(Result.ERROR,EnumFlowKey.B_COUPON_MERCHANT_CREATE.getMessage()+"未配置审批流程"); |
|
|
|
} |
|
|
|
logger.debug("[" + getIpAddr() + "] WxCouponController::add"); |
|
|
|
TenantEntity tenantEntity = getTenantInfo(); |
|
|
|
wxCoupon.updateTenantInfo(tenantEntity); |
|
|
|
@@ -193,6 +216,9 @@ public class WxCouponController extends BaseController { |
|
|
|
@ApiOperation("根据id更新接口") |
|
|
|
@PostMapping("update") |
|
|
|
public ResultData update(@RequestBody WxCoupon wxCoupon) { |
|
|
|
if (!hasMerchantCouponFlow()) { |
|
|
|
return new ResultData(Result.ERROR,EnumFlowKey.B_COUPON_MERCHANT_CREATE.getMessage()+"未配置审批流程"); |
|
|
|
} |
|
|
|
logger.debug("[" + getIpAddr() + "] WxCouponController::update"); |
|
|
|
if (wxCoupon.getId() == null) { |
|
|
|
return new ResultData(ResultData.ERROR, "缺少id"); |
|
|
|
@@ -219,27 +245,15 @@ public class WxCouponController extends BaseController { |
|
|
|
return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId()); |
|
|
|
} |
|
|
|
redisLock.setCouponStock(wxCoupon.getId(), coupon.getRemainInventory()); |
|
|
|
//启动审批流 |
|
|
|
if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) { |
|
|
|
logger.info("------coupon.update().businessType:"+wxCoupon.getFlowParams().get("businessType")); |
|
|
|
wxCoupon.getFlowParams().put("businessId",wxCoupon.getId()); |
|
|
|
wxFlowService.start(wxCoupon.getFlowParams(), getBuserId(), getUser().getName(), getTenantInfo()); |
|
|
|
//作废审批 |
|
|
|
if (EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wxCoupon.getStatus())) { |
|
|
|
wxCoupon.setCancleApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); |
|
|
|
return new ResultData(wxCoupon); |
|
|
|
} else { |
|
|
|
//投放审批 |
|
|
|
wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return wxCouponService.saveOrUpdate(wxCoupon); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("根据id更新库存及有效期接口") |
|
|
|
@PostMapping("updateStokeAndValidDate") |
|
|
|
public ResultData updateStokeAndValidDate(@RequestBody WxCoupon wxCoupon) { |
|
|
|
if (!hasMerchantCouponFlow()) { |
|
|
|
return new ResultData(Result.ERROR,EnumFlowKey.B_COUPON_MERCHANT_CREATE.getMessage()+"未配置审批流程"); |
|
|
|
} |
|
|
|
logger.debug("[" + getIpAddr() + "] WxCouponController::updateStokeAndValidDate"); |
|
|
|
if (wxCoupon.getId() == null) { |
|
|
|
logger.error("缺少id"); |
|
|
|
@@ -301,58 +315,17 @@ public class WxCouponController extends BaseController { |
|
|
|
return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//启动审批流 |
|
|
|
if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) { |
|
|
|
List<Map<String, Object>> variables = (List) wxCoupon.getFlowParams().get("variables"); |
|
|
|
Map<String, Object> map = new HashedMap(); |
|
|
|
map.put("key", "inventory"); |
|
|
|
map.put("value", wxCoupon.getInventory()); |
|
|
|
variables.add(map); |
|
|
|
map = new HashedMap(); |
|
|
|
map.put("key", "remainInventory"); |
|
|
|
map.put("value", wxCoupon.getRemainInventory()); |
|
|
|
variables.add(map); |
|
|
|
map = new HashedMap(); |
|
|
|
map.put("key", "type"); |
|
|
|
map.put("value", wxCoupon.getType()); |
|
|
|
variables.add(map); |
|
|
|
map = new HashedMap(); |
|
|
|
map.put("key", "validEndDate"); |
|
|
|
map.put("value", wxCoupon.getValidEndDate()); |
|
|
|
map = new HashedMap(); |
|
|
|
map.put("key", "validStartDate"); |
|
|
|
map.put("value", wxCoupon.getValidStartDate()); |
|
|
|
map = new HashedMap(); |
|
|
|
map.put("key", "validType"); |
|
|
|
map.put("value", wxCoupon.getValidType()); |
|
|
|
variables.add(map); |
|
|
|
map = new HashedMap(); |
|
|
|
map.put("key", "validDays"); |
|
|
|
map.put("value", wxCoupon.getValidDays()); |
|
|
|
variables.add(map); |
|
|
|
wxCoupon.getFlowParams().put("businessId",wxCoupon.getId()); |
|
|
|
wxFlowService.start(wxCoupon.getFlowParams(), getBuserId(), getUser().getName(), wxCoupon); |
|
|
|
//更新状态 |
|
|
|
WxCoupon updateCoupon = new WxCoupon(); |
|
|
|
updateCoupon.updateTenantInfo(wxCoupon); |
|
|
|
updateCoupon.setId(wxCoupon.getId()); |
|
|
|
updateCoupon.setStockApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); |
|
|
|
updateCoupon.setUpdateDate(new Date()); |
|
|
|
wxCouponService.update(updateCoupon); |
|
|
|
redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory()); |
|
|
|
} else { |
|
|
|
redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory()); |
|
|
|
return wxCouponService.updateCouponStockAndEndTime(wxCoupon); |
|
|
|
} |
|
|
|
|
|
|
|
return new ResultData(); |
|
|
|
redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory()); |
|
|
|
return wxCouponService.updateCouponStockAndEndTime(wxCoupon); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("根据id删除接口") |
|
|
|
@GetMapping("/del") |
|
|
|
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) |
|
|
|
public ResultData delete(Long id) { |
|
|
|
if (!hasMerchantCouponFlow()) { |
|
|
|
return new ResultData(Result.ERROR,EnumFlowKey.B_COUPON_MERCHANT_CREATE.getMessage()+"未配置审批流程"); |
|
|
|
} |
|
|
|
logger.debug("[" + getIpAddr() + "] WxCouponController::delete"); |
|
|
|
wxCouponService.deleteById(id); |
|
|
|
return new ResultData(Result.SUCCESS, "删除成功", null); |
|
|
|
|