From a124b1c5de835cd1c773663e71afd371ab36373e Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Wed, 9 Sep 2020 18:05:18 +0800 Subject: [PATCH 1/4] fix --- .../controller/WxCouponController.java | 85 +++++-------------- 1 file changed, 22 insertions(+), 63 deletions(-) diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java index 4b3a3c124..6b770a6d4 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java @@ -126,16 +126,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,7 +156,7 @@ 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); @@ -162,6 +168,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 +202,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 +231,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 +301,17 @@ public class WxCouponController extends BaseController { return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR); } } - - //启动审批流 - if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) { - List> variables = (List) wxCoupon.getFlowParams().get("variables"); - Map 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); From 3c99bc9135c54c9126b651367cdb620c89adf5d6 Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Wed, 9 Sep 2020 19:27:31 +0800 Subject: [PATCH 2/4] fix flow bug --- .../iformall/controller/WxCouponController.java | 7 +++++-- .../iformall/service/impl/WxFlowServiceImpl.java | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java index 6b770a6d4..0d2415702 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java @@ -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,11 +103,12 @@ public class WxCouponController extends BaseController { return wxCouponService.list(wxCoupon, pageNum, pageSize); //全列表 } - private Map generateFlowParams(EnumFlowKey flowType,EnumCouponAppType approvalType, Long couponId,String remark) { + private Map generateFlowParams(EnumFlowKey flowType,EnumCouponAppType approvalType, Long couponId,String remark,String phone) { Map map = new HashMap(); map.put("businessId", String.valueOf(couponId)); map.put("businessType", flowType.getCode()); map.put("remark", remark); + map.put("phone", phone); List variablesList = new ArrayList(); Map contractTypeMap = new HashMap(); contractTypeMap.put("key","approvalType"); @@ -159,7 +161,8 @@ public class WxCouponController extends BaseController { 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.getId(),wxCoupon.getRemark(), buser.getPhone()), getBuserId(), buser.getName(), wxCoupon); return new ResultData(Result.SUCCESS,"提交审批成功"); } 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 a8b738348..c9c476cd2 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java @@ -491,6 +491,14 @@ public class WxFlowServiceImpl implements WxFlowService { return null; } + private Map generatSimpleStarter(String userName,String phone) { + Map map = new HashMap(); + map.put("name", userName); + map.put("phone", phone); + map.put("email",""); + return map; + } + @Override @Transactional(propagation = Propagation.REQUIRED,rollbackFor = {Exception.class}) public ResultData start(Map params,Long userId,String userName,TenantEntity tenantEntity) { @@ -509,7 +517,12 @@ public class WxFlowServiceImpl implements WxFlowService { // map info,设置发起人等信息 Date startDate = new Date(); MallUserInfo starterInfo = this.mallUserInfoService.getById(userId); - map.put("starter", mallUserInfoToMap(starterInfo)); + if (null != starterInfo) { + map.put("starter", mallUserInfoToMap(starterInfo)); + }else { + String phone = params.get("phone").toString(); + map.put("starter", generatSimpleStarter(userName,phone)); + } map.put("startTime", startDate.getTime()); map.put("startDate", startDate); map.put("businessId",businessId+""); From be3ce712f5e21e8210dde6025c41dd8cbc446778 Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Thu, 10 Sep 2020 09:46:36 +0800 Subject: [PATCH 3/4] fix flow bug --- .../main/java/com/iformall/service/impl/WxFlowServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 c9c476cd2..ca00d3234 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java @@ -560,7 +560,8 @@ public class WxFlowServiceImpl implements WxFlowService { //给审批人发送代办通知短信 List mallUserInfoList = getUserByProcessInstanceId(processInstance.getId()); for (MallUserInfo mallUserInfo:mallUserInfoList) { - sendAssigneeMsgAndEmail(tenantEntity, mallUserInfo.getPhone(), mallUserInfo.getEmail(), starterInfo.getName(), businessId, flowType, variables); + //sendAssigneeMsgAndEmail(tenantEntity, mallUserInfo.getPhone(), mallUserInfo.getEmail(), starterInfo.getName(), businessId, flowType, variables); + sendAssigneeMsgAndEmail(tenantEntity, mallUserInfo.getPhone(), mallUserInfo.getEmail(), userName, businessId, flowType, variables); } return new ResultData(); } From 8a5d9d9256cd217c30847553d5af686d8c7b37eb Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Thu, 10 Sep 2020 13:57:17 +0800 Subject: [PATCH 4/4] fix coupon flow --- .../iformall/controller/WxCouponController.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java index 0d2415702..41660ac40 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java @@ -103,9 +103,9 @@ public class WxCouponController extends BaseController { return wxCouponService.list(wxCoupon, pageNum, pageSize); //全列表 } - private Map generateFlowParams(EnumFlowKey flowType,EnumCouponAppType approvalType, Long couponId,String remark,String phone) { + private Map generateFlowParams(EnumFlowKey flowType,EnumCouponAppType approvalType, WxCoupon wxCoupon,String remark,String phone) { Map map = new HashMap(); - 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); @@ -114,6 +114,17 @@ public class WxCouponController extends BaseController { contractTypeMap.put("key","approvalType"); contractTypeMap.put("value",String.valueOf(approvalType.getCode())); variablesList.add(contractTypeMap); + + Map couponNameMap = new HashMap(); + couponNameMap.put("key","couponName"); + couponNameMap.put("value",wxCoupon.getTitle()); + variablesList.add(couponNameMap); + + Map couponTypeMap = new HashMap(); + couponTypeMap.put("key","couponType"); + couponTypeMap.put("value",wxCoupon.getType()); + variablesList.add(couponTypeMap); + map.put("variables", variablesList); return map; } @@ -162,7 +173,7 @@ public class WxCouponController extends BaseController { return new ResultData(Result.ERROR,EnumFlowKey.B_COUPON_MERCHANT_CREATE.getMessage()+"未配置审批流程"); } WxMerchantBUser buser = getUser(); - wxFlowService.start(generateFlowParams(EnumFlowKey.B_COUPON_MERCHANT_CREATE,EnumCouponAppType.PUT,wxCoupon.getId(),wxCoupon.getRemark(), buser.getPhone()), getBuserId(), buser.getName(), wxCoupon); + wxFlowService.start(generateFlowParams(EnumFlowKey.B_COUPON_MERCHANT_CREATE,EnumCouponAppType.PUT,wxCoupon,wxCoupon.getRemark(), buser.getPhone()), getBuserId(), buser.getName(), wxCoupon); return new ResultData(Result.SUCCESS,"提交审批成功"); }