|
|
|
@ -14,6 +14,7 @@ import com.hai.service.HighCouponAgentService; |
|
|
|
|
import com.hai.service.HighCouponCodeService; |
|
|
|
|
import com.hai.service.HighCouponService; |
|
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
@ -130,8 +131,13 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { |
|
|
|
|
criteria.andAgentIdEqualTo(MapUtils.getLong(map, "agentId")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (MapUtils.getInteger(map, "status") != null) { |
|
|
|
|
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); |
|
|
|
|
if (StringUtils.isNotBlank(MapUtils.getString(map, "status"))) { |
|
|
|
|
String[] strings = MapUtils.getString(map, "status").split(","); |
|
|
|
|
List<Integer> statusList = new ArrayList<>(); |
|
|
|
|
for (String i : strings) { |
|
|
|
|
statusList.add(Integer.parseInt(i)); |
|
|
|
|
} |
|
|
|
|
criteria.andStatusIn(statusList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
example.setOrderByClause("create_time desc"); |
|
|
|
@ -157,6 +163,11 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { |
|
|
|
|
couponAgentCode.setStatus(2); // 状态:1.待销售 2.未使用 3.已使用
|
|
|
|
|
highCouponAgentCodeMapper.updateByPrimaryKey(couponAgentCode); |
|
|
|
|
|
|
|
|
|
HighCouponAgentRel couponAgent = getRelByCouponAgent(couponAgentCode.getCouponId(), couponAgentCode.getAgentId()); |
|
|
|
|
couponAgent.setStockCount(couponAgent.getStockCount() - 1); |
|
|
|
|
couponAgent.setSalesCount(couponAgent.getSalesCount() + 1); |
|
|
|
|
highCouponAgentRelMapper.updateByPrimaryKey(couponAgent); |
|
|
|
|
|
|
|
|
|
HighCouponCode couponCode = highCouponCodeService.getCouponCodeById(couponAgentCode.getCouponCodeId()); |
|
|
|
|
couponCode.setStatus(2); |
|
|
|
|
couponCode.setReceiveTime(new Date()); |
|
|
|
@ -181,8 +192,8 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { |
|
|
|
|
BigDecimal surplusPrice = new BigDecimal(highCouponAgentRel.getStockCount()).multiply((highCouponAgentRel.getSalesPrice())); |
|
|
|
|
surplusCountPrice = surplusCountPrice.add(surplusPrice); |
|
|
|
|
|
|
|
|
|
BigDecimal salesPrice = new BigDecimal(highCouponAgentRel.getStockCount()).multiply((highCouponAgentRel.getSalesPrice())); |
|
|
|
|
surplusCountPrice = surplusCountPrice.add(salesPrice); |
|
|
|
|
BigDecimal salesPrice = new BigDecimal(highCouponAgentRel.getSalesCount()).multiply((highCouponAgentRel.getSalesPrice())); |
|
|
|
|
salesCountPrice = salesCountPrice.add(salesPrice); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 计算使用有效期
|
|
|
|
@ -203,6 +214,10 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { |
|
|
|
|
Map<String, Object> returnMap = new HashMap<>(); |
|
|
|
|
returnMap.put("orderCount", agentSales.getCount()); |
|
|
|
|
returnMap.put("turnoverPrice", agentSales.getSalesCountPrice()); |
|
|
|
|
|
|
|
|
|
returnMap.put("laveStockCount", highCouponAgentRelMapper.getAgentCodeCount(agentId, "1")); // 库存数量
|
|
|
|
|
returnMap.put("soldCount", highCouponAgentRelMapper.getAgentCodeCount(agentId, "2,3")); // 销售数量
|
|
|
|
|
|
|
|
|
|
returnMap.put("surplusCountPrice", surplusCountPrice); // 剩余总额
|
|
|
|
|
returnMap.put("salesCountPrice", salesCountPrice); // 销售总额
|
|
|
|
|
returnMap.put("list", list); |
|
|
|
|