|
|
@@ -184,16 +184,56 @@ public class WxPressBatchController extends BaseController { |
|
|
return new ResultData(Result.ERROR,"参数错误"); |
|
|
return new ResultData(Result.ERROR,"参数错误"); |
|
|
} |
|
|
} |
|
|
String[] cids = cidstr.split(","); |
|
|
String[] cids = cidstr.split(","); |
|
|
WxPressBatch order = wxPressBatchService.getById(record.getId(), tenantEntity.getTenantId()); |
|
|
|
|
|
List<Long> existsCids = wxPressBatchService.getItemCouponIdList(record.getId(), tenantEntity.getTenantId()); |
|
|
|
|
|
if (null != cids && cids.length > 0 ) { |
|
|
|
|
|
List<Long> rcids = new ArrayList<Long>(); |
|
|
|
|
|
for (String cid: cids) { |
|
|
|
|
|
rcids.add(Long.parseLong(cid)); |
|
|
|
|
|
|
|
|
if (null == cids || cids.length <= 0 ) { |
|
|
|
|
|
return new ResultData(Result.ERROR,"请选择砍价券"); |
|
|
|
|
|
} |
|
|
|
|
|
List<Long> rcids = new ArrayList<Long>(); |
|
|
|
|
|
for (String cid: cids) { |
|
|
|
|
|
rcids.add(Long.parseLong(cid)); |
|
|
|
|
|
} |
|
|
|
|
|
//已经存在了的不能再加入 |
|
|
|
|
|
List<Long> arrayCouponIds = wxPressBatchService.getCouponIds(tenantEntity.getTenantId()); |
|
|
|
|
|
if (null != arrayCouponIds && arrayCouponIds.size() > 0 ) { |
|
|
|
|
|
if (arrayCouponIds.containsAll(rcids)) { |
|
|
|
|
|
return new ResultData(Result.ERROR,"所选择的券已经加入了一个批次,不能再加"); |
|
|
} |
|
|
} |
|
|
if (null != existsCids && existsCids.size() > 0 ) { |
|
|
|
|
|
rcids.removeAll(existsCids); |
|
|
|
|
|
|
|
|
List<Long> extraCouponIds = new ArrayList<Long>(); |
|
|
|
|
|
extraCouponIds.addAll(rcids); |
|
|
|
|
|
extraCouponIds.removeAll(arrayCouponIds); |
|
|
|
|
|
|
|
|
|
|
|
List<Long> sameCouponIds = new ArrayList<Long>(); |
|
|
|
|
|
sameCouponIds.addAll(rcids); |
|
|
|
|
|
sameCouponIds.removeAll(extraCouponIds); |
|
|
|
|
|
|
|
|
|
|
|
if (sameCouponIds.size() > 0) { |
|
|
|
|
|
WxCoupon couponQ = new WxCoupon(); |
|
|
|
|
|
couponQ.updateTenantInfo(tenantEntity); |
|
|
|
|
|
couponQ.setIds(sameCouponIds); |
|
|
|
|
|
List<WxCoupon> couponList = wxCouponService.list(couponQ); |
|
|
|
|
|
if (null == couponList || couponList.size() <= 0 ) { |
|
|
|
|
|
return new ResultData(Result.ERROR,"未查询到这些券"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Map<Long,String> couponNameMap = new HashMap<Long,String>(); |
|
|
|
|
|
for (WxCoupon c: couponList) { |
|
|
|
|
|
couponNameMap.put(c.getId(),c.getTitle()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
StringBuffer sb = new StringBuffer("已经存在一个批次的券:"); |
|
|
|
|
|
for (Long _cid: sameCouponIds) { |
|
|
|
|
|
sb.append(couponNameMap.get(_cid)).append(","); |
|
|
|
|
|
} |
|
|
|
|
|
return new ResultData(Result.ERROR,sb.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<Long> batchCids = wxPressBatchService.getItemCouponIdList(record.getId(), tenantEntity.getTenantId()); |
|
|
|
|
|
if (null != cids && cids.length > 0 ) { |
|
|
|
|
|
|
|
|
|
|
|
if (null != batchCids && batchCids.size() > 0 ) { |
|
|
|
|
|
rcids.removeAll(batchCids); |
|
|
} |
|
|
} |
|
|
|
|
|
WxPressBatch order = wxPressBatchService.getById(record.getId(), tenantEntity.getTenantId()); |
|
|
wxPressBatchService.saveItems(order, rcids); |
|
|
wxPressBatchService.saveItems(order, rcids); |
|
|
} |
|
|
} |
|
|
return new ResultData(); |
|
|
return new ResultData(); |
|
|
|