|
|
|
@@ -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<String,Object> generateFlowParams(EnumFlowKey flowType,EnumCouponAppType approvalType, Long couponId,String remark) { |
|
|
|
Map<String,Object> map = new HashMap<String,Object>(); |
|
|
|
map.put("businessId", String.valueOf(couponId)); |
|
|
|
map.put("businessType", flowType.getCode()); |
|
|
|
map.put("remark", remark); |
|
|
|
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.put("variables", variablesList); |
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
private boolean hasFlow(EnumFlowKey flowType,TenantEntity tenantEntity) { |
|
|
|
WxFlowModel wxFlowModel = new WxFlowModel(); |
|
|
|
wxFlowModel.setFlowType(flowType.getCode()); |
|
|
|
wxFlowModel.updateTenantInfo(tenantEntity); |
|
|
|
List<WxFlowModel> 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) { |
|
|
|
|