Просмотр исходного кода

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

release_toaliyun_real
xhxu 5 лет назад
Родитель
Сommit
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.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);


+ 16
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java Просмотреть файл

@@ -492,6 +492,14 @@ public class WxFlowServiceImpl implements WxFlowService {
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
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = {Exception.class})
public ResultData start(Map<String, Object> params,Long userId,String userName,TenantEntity tenantEntity) {
@@ -510,7 +518,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+"");
@@ -548,7 +561,8 @@ public class WxFlowServiceImpl implements WxFlowService {
//给审批人发送代办通知短信
List<MallUserInfo> 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();
}


Загрузка…
Отмена
Сохранить