From dffd2efbd75bfe9380d9f8086968e16c20a5fd8e Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Wed, 9 Sep 2020 17:56:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AEB=E7=AB=AF=E5=8F=91=E5=88=B8?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WxCouponController.java | 58 +++++++++++++++++++ .../java/com/iformall/enums/EnumFlowKey.java | 2 + .../service/impl/WxFlowServiceImpl.java | 6 +- 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java index d949bf301..4b3a3c124 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java @@ -8,6 +8,7 @@ import com.iformall.common.ResultData; import com.iformall.domain.po.WxCoupon; 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.base.TenantEntity; import com.iformall.domain.vo.WxCouponStatisVo; @@ -101,6 +102,63 @@ public class WxCouponController extends BaseController { return wxCouponService.list(wxCoupon, pageNum, pageSize); //全列表 } + private Map generateFlowParams(EnumFlowKey flowType,EnumCouponAppType approvalType, Long couponId,String remark) { + Map map = new HashMap(); + map.put("businessId", String.valueOf(couponId)); + map.put("businessType", flowType.getCode()); + map.put("remark", remark); + List variablesList = new ArrayList(); + Map contractTypeMap = new HashMap(); + contractTypeMap.put("key","approvalType"); + contractTypeMap.put("value",String.valueOf(approvalType.getCode())); + variablesList.add(contractTypeMap); + map.put("variables", variablesList); + return map; + } + + private boolean hasFlow(EnumFlowKey flowType,TenantEntity tenantEntity) { + WxFlowModel wxFlowModel = new WxFlowModel(); + wxFlowModel.setFlowType(flowType.getCode()); + wxFlowModel.updateTenantInfo(tenantEntity); + List flows = wxFlowService.getModelBybusiness(wxFlowModel); + if (null != flows && flows.size() > 0) { + return true; + } + return false; + } + + @ApiOperation("查询是否有审批流程") + @PostMapping("hasFlow") + public ResultData hasFlow() { + if (hasFlow(EnumFlowKey.B_COUPON_MERCHANT_CREATE,getTenantInfo())) { + return new ResultData(1); + }else { + return new ResultData(0); + } + } + + @ApiOperation("提交审批") + @PostMapping("apply") + public ResultData apply(@RequestBody WxCoupon wxCoupon) { + logger.debug("[" + getIpAddr() + "] WxCouponController::add"); + if (wxCoupon.getId() == null) { + return new ResultData(ResultData.ERROR, "缺少id"); + } + WxCoupon coupon = wxCouponService.getById(wxCoupon.getId()); + + if(coupon.getSourceType().intValue() != EnumCouponSourceType.COUPONSource_Bapi.getCode().intValue()){ + return new ResultData(Result.ERROR,"非B端券,不能进行此操作"); + } + + if (!hasFlow(EnumFlowKey.B_COUPON_MERCHANT_CREATE,coupon)) { + 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); + return new ResultData(Result.SUCCESS,"提交审批成功"); + } + + + @ApiOperation("新增接口") @PostMapping("add") public ResultData add(@RequestBody WxCoupon wxCoupon) { diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumFlowKey.java b/mallinkService/src/main/java/com/iformall/enums/EnumFlowKey.java index 80fc582a8..7e5081ff9 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumFlowKey.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumFlowKey.java @@ -20,6 +20,8 @@ public enum EnumFlowKey { NEW_CARD_UPLINE(10, "卡审批"), NEW_GROUP_UPLINE(11, "拼团"), NEW_PRESS_UPLINE(12, "砍价审批"), + + B_COUPON_MERCHANT_CREATE(22,"B端创建券"), NEW_PRO_CONTRACT(13, "商铺物业合同签约"), NEW_PRO_END(14, "商铺物业合同终止"), diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java index f100221d9..a8b738348 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java @@ -357,7 +357,8 @@ public class WxFlowServiceImpl implements WxFlowService { } else if (EnumFlowKey.NEW_COUPON_UPLINE.getCode().equals(flowType) || EnumFlowKey.NEW_CARD_UPLINE.getCode().equals(flowType) || EnumFlowKey.NEW_GROUP_UPLINE.getCode().equals(flowType) - || EnumFlowKey.NEW_PRESS_UPLINE.getCode().equals(flowType)) { + || EnumFlowKey.NEW_PRESS_UPLINE.getCode().equals(flowType) + || EnumFlowKey.B_COUPON_MERCHANT_CREATE.getCode().equals(flowType)) { WxCoupon wxCoupon = new WxCoupon(); wxCoupon.setId(Long.parseLong(businessId)); wxCoupon.setUpdateDate(new Date()); @@ -409,7 +410,8 @@ public class WxFlowServiceImpl implements WxFlowService { wxCouponMapper.updateById(wxCoupon); //清除缓存 clearCache(wxCoupon); - }else if(EnumFlowKey.SETTLE.getCode().equals(flowType)){ + + } else if(EnumFlowKey.SETTLE.getCode().equals(flowType)){ WxBillSettle wxBillSettle = new WxBillSettle(); wxBillSettle.setId(Long.parseLong(businessId)); wxBillSettle.setApplyStatus(applyStatus);