Ver Fonte

Merge branch 'coupon_sr' into pre

zoujiajian há 3 anos atrás
pai
commit
3ba42d65c0

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/mapper/manage/coupon/CouponRecommendMapper.java

@@ -23,5 +23,5 @@ public interface CouponRecommendMapper extends BaseMapper<CouponRecommend> {
 
 	List<CouponAvailableRecommendView> getRecommendCouponList(@Param("userId") Long userId, @Param("isNewUser") Boolean isNewUser);
 
-	Page<CouponRecommendView> getRecommendCouponViewList(@Param("userId") Long userId, @Param("isNewUser") Boolean isNewUser, @Param("page") IPage<CouponRecommendView> page);
+	Page<CouponRecommendView> getRecommendCouponViewList(@Param("userId") Long userId, @Param("isNewUser") Boolean isNewUser, @Param("page") IPage<CouponRecommendView> page, @Param("couponId") Long couponId);
 }

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/mapper/manage/coupon/CouponUserMapper.java

@@ -24,7 +24,7 @@ public interface CouponUserMapper extends BaseMapper<CouponUser> {
 
 	Page<CouponActiveView> couponCenterList(@Param("userId") Long userId, IPage<CouponUserView> page);
 
-	Page<CouponUserView> couponPersonalList(@Param("userId") Long userId, @Param("page") Page<CouponUserView> page);
+	Page<CouponUserView> couponPersonalList(@Param("userId") Long userId, @Param("page") Page<CouponUserView> page, @Param("couponId") Long couponId);
 
 	CouponUserView getNewUserWelfareCouponsByUserId(@Param("userId") long userId, @Param("channel") CouponUser.Channel channel, @Param("now") DateTime now);
 }

+ 3 - 0
netflix-dao/src/main/resources/mapper/CouponRecommendMapper.xml

@@ -35,6 +35,9 @@
         from coupon_recommend cr left join coupon c on c.id = cr.coupon_id
         left join coupon_user cu on cu.coupon_id = c.id and cu.user_id = #{userId}
         where cr.deleted is true and c.deleted is true and cr.status = 1
+        <if test="couponId != null">
+            and c.id = #{couponId}
+        </if>
         <if test='!isNewUser'>
             and c.scope !='newUser'
         </if>)s where couponStatus not in ('used','expired','noEffective') and flag is true order by `order`

+ 4 - 1
netflix-dao/src/main/resources/mapper/CouponUserMapper.xml

@@ -173,7 +173,10 @@
                  left join `coupon` c on c.id = cu.coupon_id
                  left join `coupon_active` ca on ca.id = cu.coupon_active_id
         where cu.user_id = #{userId}
-          and cu.channel != 'exCode'
+        <if test="couponId !=null">
+            and cu.coupon_id = #{couponId}
+        </if>
+        and cu.channel != 'exCode'
         order by `orderby`)s where s.couponUserStatus != 'expired' and s.couponUserStatus != 'invalid'
     </select>
 

+ 30 - 26
netflix-service/src/main/java/com/cyksj/service/exchange/impl/ExchangeCodeServiceImpl.java

@@ -303,37 +303,41 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
 			orderDon.setNum(1);
 			orderDon.setGoodsId(sku.getGoodsId());
 			orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
+			if (relation.getStartTime() == null || relation.getExpiryTime() == null) {
+				orderDon.setStatus(OrderDon.Status.hasPayment);
+			}
 			//兑换码兑换
 			orderDon.setType(orderDonTye);
 			orderDon.setUserId(user.getId());
 			orderDonMapper.insert(orderDon);
+			log.info("用户{}兑换规格:{}车位成功", user.getId(), orderDon.getSkuId());
 		}
-		if (StrUtil.isNotEmpty(user.getOpenId())) {
-			//发送模板消息
-			THREAD_POOL_TASK_EXECUTOR.execute(() -> {
-				try {
-					if (StrUtil.isNotEmpty(user.getOpenId())) {
-						log.info("用户{}兑换车位成功,发送新订单模板消息", user.getId());
-						templateCommonService.newOderSendMsgByType(orderDon, goodsDon, user, user.getOpenId(), false);
-					}
-				} catch (Exception e) {
-					log.info("用户{}兑换车位成功,发送消息失败:{}", user.getId(), e);
-				}
-			});
-		}
-
-		THREAD_POOL_TASK_EXECUTOR.execute(() -> {
-			try {
-				//发送至客服消息
-				List<CustomerService> customerServices = customerServiceMapper.selectList(null);
-				for (CustomerService customerService : customerServices) {
-					log.info("向客服{}发送用户兑换码兑换车票消息通知..", customerService.getNickName());
-					templateCommonService.newOderSendMsgByType(orderDon, goodsDon, user, customerService.getOpenId(), true);
-				}
-			} catch (Exception e) {
-				log.error("向客服发送用户{}兑换码兑换车票成功,发送消息失败:{}", user.getId(), e);
-			}
-		});
+//		if (StrUtil.isNotEmpty(user.getOpenId())) {
+//			//发送模板消息
+//			THREAD_POOL_TASK_EXECUTOR.execute(() -> {
+//				try {
+//					if (StrUtil.isNotEmpty(user.getOpenId())) {
+//						log.info("用户{}兑换车位成功,发送新订单模板消息", user.getId());
+//						templateCommonService.newOderSendMsgByType(orderDon, goodsDon, user, user.getOpenId(), false);
+//					}
+//				} catch (Exception e) {
+//					log.info("用户{}兑换车位成功,发送消息失败:{}", user.getId(), e);
+//				}
+//			});
+//		}
+//
+//		THREAD_POOL_TASK_EXECUTOR.execute(() -> {
+//			try {
+//				//发送至客服消息
+//				List<CustomerService> customerServices = customerServiceMapper.selectList(null);
+//				for (CustomerService customerService : customerServices) {
+//					log.info("向客服{}发送用户兑换码兑换车票消息通知..", customerService.getNickName());
+//					templateCommonService.newOderSendMsgByType(orderDon, goodsDon, user, customerService.getOpenId(), true);
+//				}
+//			} catch (Exception e) {
+//				log.error("向客服发送用户{}兑换码兑换车票成功,发送消息失败:{}", user.getId(), e);
+//			}
+//		});
 		relation.setOrderId(orderDon.getId());
 		return relation;
 	}

+ 2 - 0
netflix-service/src/main/java/com/cyksj/service/mange/goods/CmsGoodsDonSpecServiceImpl.java

@@ -23,6 +23,7 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.util.*;
@@ -43,6 +44,7 @@ public class CmsGoodsDonSpecServiceImpl extends ServiceImpl<GoodsDonSpecMapper,
 	private final GoodsDonSkuMapper goodsDonSkuMapper;
 
 	@Override
+	@Transactional(rollbackFor = Throwable.class)
 	public void insertOrUpdateSkuSpec(ReqGoodsSkuInsert insert, Boolean isUpdate) throws Exception {
 		GoodsDon goods = goodsDonMapper.selectById(insert.getGoodsId());
 		if (null == goods) {

+ 4 - 0
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -1962,6 +1962,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 	 * 使用优惠营销 订单金额抵扣
 	 */
 	public void deductOrderMoney(OrderDon orderDon, CouponUser couponUser, BigDecimal balance, User user, BigDecimal skuMoney, Integer goodsType) {
+		BigDecimal first_money = orderDon.getMoney();
 		//存在优惠券
 		if (couponUser != null) {
 			Long couponId = couponUser.getCouponId();
@@ -1981,6 +1982,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				orderDon.setMoney(subtractMoney);
 				couponMoney = orderDon.getRealMoney().subtract(subtractMoney);
 			}
+			if (couponMoney != null && couponMoney.compareTo(first_money) >= 0) {
+				throw BusinessRuntimeException.getInstance("支付金额不能小于优惠金额");
+			}
 			orderDon.setCouponMoney(couponMoney);
 			orderDon.setCouponUserId(couponUser.getId());
 		}

+ 5 - 1
netflix-service/src/main/java/com/cyksj/service/order/impl/UserRealOrderBenefitsImpl.java

@@ -26,7 +26,10 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
 
 /*
  *项目名: netflix
@@ -57,6 +60,7 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
 	@Override
 	public Boolean getPayRealGoodsBenefits(Long userId, Long orderId, List<GoodsDonSku> skuIds) {
 		Boolean isReceivedAll = true;
+		log.info("用户:{}实物订单orderId:{}发货,兑换权益规格数量:{}", userId, orderId, skuIds.size());
 		for (GoodsDonSku sku : skuIds) {
 			Long skuId = sku.getId();
 			sku = goodsDonSkuMapper.selectById(skuId);

+ 4 - 4
netflix-web/src/main/java/com/cyksj/web/controller/coupon/CouponFrontController.java

@@ -89,9 +89,9 @@ public class CouponFrontController {
 	 * 个人优惠券列表
 	 */
 	@GetMapping("/personal/list")
-	public Result<Page<CouponUserView>> couponPersonalList(@RequestParam(defaultValue = "1") Long start, @RequestParam(defaultValue = "5") Long limit) {
+	public Result<Page<CouponUserView>> couponPersonalList(@RequestParam(defaultValue = "1") Long start, @RequestParam(defaultValue = "5") Long limit, Long couponId) {
 		Long userId = StpUserUtil.getLoginIdAsLong();
-		Page<CouponUserView> page = couponUserMapper.couponPersonalList(userId, new Page<>(start, limit));
+		Page<CouponUserView> page = couponUserMapper.couponPersonalList(userId, new Page<>(start, limit), couponId);
 		page.getRecords().forEach(data -> {
 			String str = couponSkuMapper.selectGoodsSkuStr(data.getCouponId());
 			data.setGoodsSkuStr(str.replaceAll(",", "/").replaceAll(";", ""));
@@ -146,14 +146,14 @@ public class CouponFrontController {
 	 * 推荐优惠券列表
 	 */
 	@GetMapping("/recommend/list")
-	public Result<Page<CouponRecommendView>> getRecommendList(@RequestParam(defaultValue = "1") Long start, @RequestParam(defaultValue = "5") Long limit) {
+	public Result<Page<CouponRecommendView>> getRecommendList(@RequestParam(defaultValue = "1") Long start, @RequestParam(defaultValue = "5") Long limit, Long couponId) {
 		Long userId = StpUserUtil.getLoginIdAsLong();
 		CouponNewUserView couponNewUserView = beanSearcher.searchFirst(CouponNewUserView.class, MapUtils.builder().field(CouponNewUserView::getUserId, userId).op(Operator.Equal).build());
 		Boolean isNewUser = true;
 		if (couponNewUserView != null) {
 			isNewUser = false;
 		}
-		Page<CouponRecommendView> page = couponRecommendMapper.getRecommendCouponViewList(userId, isNewUser, new Page<>(start, limit));
+		Page<CouponRecommendView> page = couponRecommendMapper.getRecommendCouponViewList(userId, isNewUser, new Page<>(start, limit), couponId);
 		page.getRecords().forEach(data -> {
 			if (data.getCouponStatus() == CouponActiveView.CouponStatus.received) {
 				data.setValidStartTime(data.getUserValidStartTime());