ソースを参照

Merge branch 'release_real_200809' of https://git.malls.iformall.com/server/formallProject into release_real_200809

release_toaliyun_real
xhxu 5年前
コミット
28458d25e6
2個のファイルの変更55行の追加68行の削除
  1. +39
    -66
      mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java
  2. +16
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java

+ 39
- 66
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.WxCouponPassword;
import com.iformall.domain.po.WxFlowModel; import com.iformall.domain.po.WxFlowModel;
import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.WxMerchantBUser;
import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxCouponStatisVo; import com.iformall.domain.vo.WxCouponStatisVo;
import com.iformall.enums.*; import com.iformall.enums.*;
@@ -102,16 +103,28 @@ public class WxCouponController extends BaseController {
return wxCouponService.list(wxCoupon, pageNum, pageSize); //全列表 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<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("businessType", flowType.getCode());
map.put("remark", remark); map.put("remark", remark);
map.put("phone", phone);
List<Map> variablesList = new ArrayList<Map>(); List<Map> variablesList = new ArrayList<Map>();
Map contractTypeMap = new HashMap<String,Object>(); Map contractTypeMap = new HashMap<String,Object>();
contractTypeMap.put("key","approvalType"); contractTypeMap.put("key","approvalType");
contractTypeMap.put("value",String.valueOf(approvalType.getCode())); contractTypeMap.put("value",String.valueOf(approvalType.getCode()));
variablesList.add(contractTypeMap); 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); map.put("variables", variablesList);
return map; return map;
} }
@@ -126,16 +139,22 @@ public class WxCouponController extends BaseController {
} }
return false; return false;
} }
private boolean hasMerchantCouponFlow() {
return hasFlow(EnumFlowKey.B_COUPON_MERCHANT_CREATE,getTenantInfo());
}


@ApiOperation("查询是否有审批流程") @ApiOperation("查询是否有审批流程")
@PostMapping("hasFlow") @PostMapping("hasFlow")
public ResultData hasFlow() { public ResultData hasFlow() {
if (hasFlow(EnumFlowKey.B_COUPON_MERCHANT_CREATE,getTenantInfo())) {
if (hasMerchantCouponFlow()) {
return new ResultData(1); return new ResultData(1);
}else { }else {
return new ResultData(0); return new ResultData(0);
} }
} }

@ApiOperation("提交审批") @ApiOperation("提交审批")
@PostMapping("apply") @PostMapping("apply")
@@ -150,10 +169,11 @@ public class WxCouponController extends BaseController {
return new ResultData(Result.ERROR,"非B端券,不能进行此操作"); 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()+"未配置审批流程"); 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,"提交审批成功"); return new ResultData(Result.SUCCESS,"提交审批成功");
} }
@@ -162,6 +182,9 @@ public class WxCouponController extends BaseController {
@ApiOperation("新增接口") @ApiOperation("新增接口")
@PostMapping("add") @PostMapping("add")
public ResultData add(@RequestBody WxCoupon wxCoupon) { public ResultData add(@RequestBody WxCoupon wxCoupon) {
if (!hasMerchantCouponFlow()) {
return new ResultData(Result.ERROR,EnumFlowKey.B_COUPON_MERCHANT_CREATE.getMessage()+"未配置审批流程");
}
logger.debug("[" + getIpAddr() + "] WxCouponController::add"); logger.debug("[" + getIpAddr() + "] WxCouponController::add");
TenantEntity tenantEntity = getTenantInfo(); TenantEntity tenantEntity = getTenantInfo();
wxCoupon.updateTenantInfo(tenantEntity); wxCoupon.updateTenantInfo(tenantEntity);
@@ -193,6 +216,9 @@ public class WxCouponController extends BaseController {
@ApiOperation("根据id更新接口") @ApiOperation("根据id更新接口")
@PostMapping("update") @PostMapping("update")
public ResultData update(@RequestBody WxCoupon wxCoupon) { public ResultData update(@RequestBody WxCoupon wxCoupon) {
if (!hasMerchantCouponFlow()) {
return new ResultData(Result.ERROR,EnumFlowKey.B_COUPON_MERCHANT_CREATE.getMessage()+"未配置审批流程");
}
logger.debug("[" + getIpAddr() + "] WxCouponController::update"); logger.debug("[" + getIpAddr() + "] WxCouponController::update");
if (wxCoupon.getId() == null) { if (wxCoupon.getId() == null) {
return new ResultData(ResultData.ERROR, "缺少id"); return new ResultData(ResultData.ERROR, "缺少id");
@@ -219,27 +245,15 @@ public class WxCouponController extends BaseController {
return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId()); return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId());
} }
redisLock.setCouponStock(wxCoupon.getId(), coupon.getRemainInventory()); 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); return wxCouponService.saveOrUpdate(wxCoupon);
} }


@ApiOperation("根据id更新库存及有效期接口") @ApiOperation("根据id更新库存及有效期接口")
@PostMapping("updateStokeAndValidDate") @PostMapping("updateStokeAndValidDate")
public ResultData updateStokeAndValidDate(@RequestBody WxCoupon wxCoupon) { public ResultData updateStokeAndValidDate(@RequestBody WxCoupon wxCoupon) {
if (!hasMerchantCouponFlow()) {
return new ResultData(Result.ERROR,EnumFlowKey.B_COUPON_MERCHANT_CREATE.getMessage()+"未配置审批流程");
}
logger.debug("[" + getIpAddr() + "] WxCouponController::updateStokeAndValidDate"); logger.debug("[" + getIpAddr() + "] WxCouponController::updateStokeAndValidDate");
if (wxCoupon.getId() == null) { if (wxCoupon.getId() == null) {
logger.error("缺少id"); logger.error("缺少id");
@@ -301,58 +315,17 @@ public class WxCouponController extends BaseController {
return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR); 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删除接口") @ApiOperation("根据id删除接口")
@GetMapping("/del") @GetMapping("/del")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData delete(Long id) { public ResultData delete(Long id) {
if (!hasMerchantCouponFlow()) {
return new ResultData(Result.ERROR,EnumFlowKey.B_COUPON_MERCHANT_CREATE.getMessage()+"未配置审批流程");
}
logger.debug("[" + getIpAddr() + "] WxCouponController::delete"); logger.debug("[" + getIpAddr() + "] WxCouponController::delete");
wxCouponService.deleteById(id); wxCouponService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null); return new ResultData(Result.SUCCESS, "删除成功", null);


+ 16
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java ファイルの表示

@@ -492,6 +492,14 @@ public class WxFlowServiceImpl implements WxFlowService {
return null; return null;
} }


private Map<String,Object> generatSimpleStarter(String userName,String phone) {
Map<String,Object> map = new HashMap<String,Object>();
map.put("name", userName);
map.put("phone", phone);
map.put("email","");
return map;
}
@Override @Override
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = {Exception.class}) @Transactional(propagation = Propagation.REQUIRED,rollbackFor = {Exception.class})
public ResultData start(Map<String, Object> params,Long userId,String userName,TenantEntity tenantEntity) { public ResultData start(Map<String, Object> params,Long userId,String userName,TenantEntity tenantEntity) {
@@ -510,7 +518,12 @@ public class WxFlowServiceImpl implements WxFlowService {
// map info,设置发起人等信息 // map info,设置发起人等信息
Date startDate = new Date(); Date startDate = new Date();
MallUserInfo starterInfo = this.mallUserInfoService.getById(userId); 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("startTime", startDate.getTime());
map.put("startDate", startDate); map.put("startDate", startDate);
map.put("businessId",businessId+""); map.put("businessId",businessId+"");
@@ -548,7 +561,8 @@ public class WxFlowServiceImpl implements WxFlowService {
//给审批人发送代办通知短信 //给审批人发送代办通知短信
List<MallUserInfo> mallUserInfoList = getUserByProcessInstanceId(processInstance.getId()); List<MallUserInfo> mallUserInfoList = getUserByProcessInstanceId(processInstance.getId());
for (MallUserInfo mallUserInfo:mallUserInfoList) { 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(); return new ResultData();
} }


読み込み中…
キャンセル
保存