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

fix press bug

release_toaliyun_real
zhengfangyuan 3 лет назад
Родитель
Сommit
1483430760
4 измененных файлов: 60 добавлений и 9 удалений
  1. +48
    -8
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxPressBatchController.java
  2. +1
    -0
      mallinkService/src/main/java/com/iformall/service/WxPressBatchService.java
  3. +7
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxPressBatchServiceImpl.java
  4. +4
    -1
      mallinkService/src/main/resources/mapper/WxPressBatchItemMapper.xml

+ 48
- 8
mallinkAdmin/src/main/java/com/iformall/controller/market/WxPressBatchController.java Просмотреть файл

@@ -184,16 +184,56 @@ public class WxPressBatchController extends BaseController {
return new ResultData(Result.ERROR,"参数错误");
}
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);
}
return new ResultData();


+ 1
- 0
mallinkService/src/main/java/com/iformall/service/WxPressBatchService.java Просмотреть файл

@@ -42,6 +42,7 @@ public interface WxPressBatchService {
PageInfo<WxPressBatchItem> getItemPage(Long batchId,String tenantId, Integer pageIndex, Integer pageSize);
List<WxPressBatchItem> getItemList(Long batchId,String tenantId);
List<Long> getItemCouponIdList(Long batchId,String tenantId);
List<Long> getCouponIds(String tenantId);
void saveItems(WxPressBatch pressBatch,List<Long> couponIds);


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

@@ -110,6 +110,13 @@ public class WxPressBatchServiceImpl implements WxPressBatchService {
return wxPressBatchItemMapper.getCouponIds(batchId, tenantId, null);
}
@Override
public List<Long> getCouponIds(String tenantId) {
WxPressBatchItem iteq = new WxPressBatchItem();
iteq.setTenantId(tenantId);
return wxPressBatchItemMapper.getCouponIds(null, tenantId, null);
}
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public void saveItems(WxPressBatch pressBatch, List<Long> couponIds) {


+ 4
- 1
mallinkService/src/main/resources/mapper/WxPressBatchItemMapper.xml Просмотреть файл

@@ -91,7 +91,10 @@
</delete>
<select id="getCouponIds" parameterType="java.util.HashMap" resultType="Long">
select coupon_id from wx_press_batch_item where `press_batch_id` = #{pressBatchId} and tenant_id=#{tenantId}
select coupon_id from wx_press_batch_item where tenant_id=#{tenantId}
<if test=" null != pressBatchId">
and `press_batch_id` = #{pressBatchId}
</if>
<if test=" null != pressBatchStatus">
and `press_batch_status` = #{pressBatchStatus}
</if>


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