|
|
|
@ -10,10 +10,7 @@ import com.hai.dao.HighCouponCodeMapper; |
|
|
|
|
import com.hai.dao.HighCouponCodeMapperExt; |
|
|
|
|
import com.hai.entity.*; |
|
|
|
|
import com.hai.model.UserInfoModel; |
|
|
|
|
import com.hai.service.HighCouponCodeService; |
|
|
|
|
import com.hai.service.HighCouponService; |
|
|
|
|
import com.hai.service.HighOrderService; |
|
|
|
|
import com.hai.service.HighUserCouponService; |
|
|
|
|
import com.hai.service.*; |
|
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
@ -49,6 +46,9 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { |
|
|
|
|
@Resource |
|
|
|
|
private HighUserCouponService highUserCouponService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private HighCouponAgentService highCouponAgentService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void insertCouponCode(HighCouponCode highCouponCode) { |
|
|
|
|
highCouponCodeMapper.insert(highCouponCode); |
|
|
|
@ -105,21 +105,29 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { |
|
|
|
|
salesCode.setStatus(3); |
|
|
|
|
updateCouponCode(salesCode); |
|
|
|
|
|
|
|
|
|
//修改 用户与卡卷的关系
|
|
|
|
|
HighUserCoupon userCoupon = highUserCouponService.getDetailByCodeId(salesCode.getId()); |
|
|
|
|
if (userCoupon == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡卷状态异常"); |
|
|
|
|
// 代理商
|
|
|
|
|
if (salesCode.getIsAssignAgent() == true) { |
|
|
|
|
HighCouponAgentCode couponAgentCode = highCouponAgentService.getAgentCodeByCodeIdAgent(salesCode.getId(), salesCode.getAgentId()); |
|
|
|
|
if (couponAgentCode != null) { |
|
|
|
|
couponAgentCode.setStatus(3); |
|
|
|
|
highCouponAgentService.updateCouponAgentCode(couponAgentCode); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HighChildOrder order = highOrderService.getChildOrderByUserGoods(userCoupon.getUserId(), 1, userCoupon.getCouponId()); |
|
|
|
|
if (order == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单"); |
|
|
|
|
//修改 用户与卡卷的关系
|
|
|
|
|
HighUserCoupon userCoupon = highUserCouponService.getDetailByCodeId(salesCode.getId()); |
|
|
|
|
// 可能是分卡卡券,分发卡券没有绑定用户
|
|
|
|
|
if (userCoupon != null) { |
|
|
|
|
HighChildOrder order = highOrderService.getChildOrderByUserGoods(userCoupon.getUserId(), 1, userCoupon.getCouponId()); |
|
|
|
|
if (order == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单"); |
|
|
|
|
} |
|
|
|
|
userCoupon.setStoreId(userInfoModel.getMerchantStore().getId()); |
|
|
|
|
userCoupon.setConsumeTime(new Date()); |
|
|
|
|
userCoupon.setStatus(2); // 状态 0:已过期 1:未使用 2:已使用
|
|
|
|
|
highUserCouponService.updateUserCoupon(userCoupon); |
|
|
|
|
highOrderService.childOrderComplete(order.getId()); |
|
|
|
|
} |
|
|
|
|
userCoupon.setStoreId(userInfoModel.getMerchantStore().getId()); |
|
|
|
|
userCoupon.setConsumeTime(new Date()); |
|
|
|
|
userCoupon.setStatus(2); // 状态 0:已过期 1:未使用 2:已使用
|
|
|
|
|
highUserCouponService.updateUserCoupon(userCoupon); |
|
|
|
|
highOrderService.childOrderComplete(order.getId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -134,6 +142,16 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("status", "1"); |
|
|
|
|
map.put("couponCodeId", code.getId()); |
|
|
|
|
|
|
|
|
|
// 代理商
|
|
|
|
|
if (code.getIsAssignAgent() == true) { |
|
|
|
|
HighCouponAgentCode couponAgentCode = highCouponAgentService.getAgentCodeByCodeIdAgent(code.getId(), code.getAgentId()); |
|
|
|
|
if (couponAgentCode != null) { |
|
|
|
|
couponAgentCode.setStatus(3); |
|
|
|
|
highCouponAgentService.updateCouponAgentCode(couponAgentCode); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<HighUserCoupon> list = highUserCouponService.getUserCouponList(map); |
|
|
|
|
if (list.size() > 0) { |
|
|
|
|
for (HighUserCoupon userCoupon : list) { |
|
|
|
@ -200,7 +218,7 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { |
|
|
|
|
@Override |
|
|
|
|
public List<HighCouponCode> getNoSaleCode(Long couponId) { |
|
|
|
|
HighCouponCodeExample example = new HighCouponCodeExample(); |
|
|
|
|
example.createCriteria().andCouponIdEqualTo(couponId).andStatusEqualTo(1); |
|
|
|
|
example.createCriteria().andCouponIdEqualTo(couponId).andStatusEqualTo(1).andIsAssignAgentEqualTo(false); |
|
|
|
|
return highCouponCodeMapper.selectByExample(example); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|