Ver código fonte

fix 实物权益车票多用户车票兼容;批发下单后短信通知

zoujiajian 1 ano atrás
pai
commit
eab5caf380

+ 10 - 0
netflix-common/src/main/java/com/cyksj/common/constant/Constant.java

@@ -415,4 +415,14 @@ public interface Constant {
 	 * 奈飞设备平台id
 	 */
 	Long NF_EP_GID = 15l;
+
+	/**
+	 * 批发通知手机号
+	 */
+	List<String> GOODS_WHOLESALE_PHONE = List.of("18658194165", "17681947535");
+
+	/**
+	 * 批发通知短信模板
+	 */
+	String GOODS_WHOLESALE_MSG = "%s用户批发%s个%s商品,请尽快配置账号【银河录像局】";
 }

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/mapper/GroupsRelationMapper.java

@@ -33,7 +33,7 @@ public interface GroupsRelationMapper extends BaseMapper<GroupsRelation> {
 
 	Long selectSimilarExpiredRelation(@Param("skuId") Long skuId, @Param("minExpiryTime") DateTime minExpiryTime, @Param("maxNum") Integer maxNum, @Param("ip") String ip);
 
-	List<GroupsRelationView> selectRelationByGoodsId(@Param("goodsId") Long goodsId, @Param("userId") Long userId, @Param("yhsId") Long yhsId);
+	List<GroupsRelationView> selectRelationByGoodsId(@Param("goodsId") Long goodsId, @Param("userIds") List<Long> userIds, @Param("yhsId") Long yhsId);
 
 	GroupsRelationView getGroupRelationViewByUserIdAndRelationId(@Param("userId") Long userId, @Param("relationId") Long relationId);
 

+ 12 - 9
netflix-dao/src/main/resources/mapper/GroupRelationMapper.xml

@@ -73,16 +73,19 @@
     <select id="selectRelationByGoodsId" resultType="com.cyksj.model.manage.views.GroupsRelationView">
         select gr.*
         from groups_relation gr
-                 left join groups_trips gt on gr.groups_id = gt.id
-                 left join account a on a.id = gt.account_id
-                 left join user u on gr.user_id = u.id
-                 left join goods_don g on a.goods_id = g.id
+        left join groups_trips gt on gr.groups_id = gt.id
+        left join account a on a.id = gt.account_id
+        left join user u on gr.user_id = u.id
+        left join goods_don g on a.goods_id = g.id
         where g.id = #{goodsId}
-          and gr.user_id = #{userId}
-          and gt.status = 'validity'
-          and gr.status = 'validity'
-          and gr.yhs_id = #{yhsId}
-          and gr.expiry_time > now()
+        and gr.user_id in
+        <foreach collection="userIds" item="item" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        and gt.status = 'validity'
+        and gr.status = 'validity'
+        and gr.yhs_id = #{yhsId}
+        and gr.expiry_time > now()
     </select>
 
     <select id="getGroupRelationViewByUserIdAndRelationId"

+ 19 - 1
netflix-service/src/main/java/com/cyksj/service/order/impl/GoodsWholesalePayServiceImpl.java

@@ -8,11 +8,13 @@ import cn.hutool.core.util.StrUtil;
 import com.alipay.api.internal.util.AlipaySignature;
 import com.alipay.api.response.AlipayTradeQueryResponse;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.cyksj.common.EnvCommonService;
 import com.cyksj.common.constant.Constant;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.snowflake.Sequence;
 import com.cyksj.common.util.Codec;
 import com.cyksj.common.util.Jsons;
+import com.cyksj.common.util.SmsUtil;
 import com.cyksj.common.util.StringUtil;
 import com.cyksj.config.zfb.BaseZfbConfig;
 import com.cyksj.mapper.*;
@@ -94,6 +96,8 @@ public class GoodsWholesalePayServiceImpl implements GoodsWholesalePayService {
 
 	private final GoodsWholesaleUserSkuPayRecordMapper goodsWholesaleUserSkuPayRecordMapper;
 
+	private final EnvCommonService envCommonService;
+
 	@Override
 	public GoodsWholesaleOrderDon unifiedPay(GoodsWholesaleOrderPayReq payReq) throws Exception {
 		Long userId = payReq.getUserId();
@@ -519,8 +523,22 @@ public class GoodsWholesalePayServiceImpl implements GoodsWholesalePayService {
 			GoodsDon goodsDon = goodsDonMapper.selectById(goodsId);
 			userBenefitsService.recordBalanceBySource(orderDon.getUserId(), orderDon.getBalance().negate(), UserBalanceSourceRecord.Source.wholesale_order, orderDon.getId(), goodsDon.getTitle() + UserBalanceSourceRecord.Source.wholesale_order.getDesc());
 		}
+		try {
+			//发送短信给新科
+			User user = userMapper.selectById(orderDon.getUserId());
+			Integer num = orderDon.getNum();
+			GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
+			List<String> phones = List.of("18260166919");
+			if (envCommonService.isPrdEnv()) {
+				phones = Constant.GOODS_WHOLESALE_PHONE;
+			}
+			String msg = String.format(Constant.GOODS_WHOLESALE_MSG, user.getNickname(), num, goodsDon.getTitle());
+			log.info("批发通知短信内容:{}", msg);
+			SmsUtil.batchSendLuoKey2Msg(phones, msg);
+		} catch (Exception e) {
+			log.error("发送批发通知短信失败:{}", StringUtil.getErrorText(e));
+		}
 	}
-
 	/**
 	 * 扣除余额
 	 */

+ 4 - 7
netflix-service/src/main/java/com/cyksj/service/order/impl/UserRealOrderBenefitsImpl.java

@@ -67,6 +67,7 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
 	public Boolean getPayRealGoodsBenefits(Long userId, Long orderId, Long yhsId, List<GoodsDonSku> skuIds) {
 		Boolean isReceivedAll = true;
 		log.info("用户:{}实物订单orderId:{}发货,兑换权益规格数量:{}", userId, orderId, skuIds.size());
+		List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
 		for (GoodsDonSku sku : skuIds) {
 			Long skuId = sku.getId();
 			sku = goodsDonSkuMapper.selectById(skuId);
@@ -77,7 +78,7 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
 //					.field(GroupsRelationView::getUserId, userId)
 //					.field(GroupsRelationView::getStatus, GroupsRelation.Status.validity.name())
 //					.build());
-			List<GroupsRelationView> relationViewList = groupsRelationMapper.selectRelationByGoodsId(goodsId, userId, yhsId);
+			List<GroupsRelationView> relationViewList = groupsRelationMapper.selectRelationByGoodsId(goodsId, userIdList, yhsId);
 			//是否有该规格车票,若无直接发放车票
 			if (CollUtil.isEmpty(relationViewList)) {
 				log.info("用户userId:{}未有skuId:{}车票,获取对应车票", userId, sku.getId());
@@ -99,10 +100,8 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
 					throw BusinessRuntimeException.getInstance("用户存在未发车的车票,请发车后再进行发货");
 				}
 				DateTime updateExpiryTime = DateUtil.offset(expiryTime, DateField.MONTH, sku.getMonths());
-				updateExpiryTime = DateUtil.offsetDay(updateExpiryTime, 3);
 				groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
 						.eq(GroupsRelation::getId, groupsRelationView.getId())
-						.eq(GroupsRelation::getUserId, userId)
 						.set(GroupsRelation::getExpiryTime, updateExpiryTime));
 				groupsRelationView.setUpdateExpiryTime(updateExpiryTime);
 				saveReceiveBenefitsRecord(userId, skuId, orderId, null, groupsRelationView.getId(), sku.getMonths(), sku.getDays(), 1);
@@ -223,12 +222,13 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
 		Long userId = orderDon.getUserId();
 		Long yhsId = orderDon.getYhsId();
 		List<Long> relationIds = new ArrayList<>();
+		List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
 		goodsDonSkus.forEach(sku -> {
 			Long skuId = sku.getId();
 			sku = goodsDonSkuMapper.selectById(skuId);
 			Long goodsId = sku.getGoodsId();
 			log.info("开始发放用户套餐优惠权益订单:{} 车票规格:{}", orderId, skuId);
-			List<GroupsRelationView> relationViewList = groupsRelationMapper.selectRelationByGoodsId(goodsId, userId, yhsId);
+			List<GroupsRelationView> relationViewList = groupsRelationMapper.selectRelationByGoodsId(goodsId, userIdList, yhsId);
 			//是否有该规格车票,若无直接发放车票
 			if (CollUtil.isEmpty(relationViewList)) {
 				log.info("用户userId:{}未有skuId:{}车票,获取对应车票", userId, sku.getId());
@@ -237,7 +237,6 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
 				relationIds.add(relation.getId());
 			} else if (relationViewList.size() == 1) {
 				//若有且只有一张增加时长
-				//TODO
 				GroupsRelationView groupsRelationView = relationViewList.get(0);
 				log.info("存在对应规格:{}的车票,增加车票:relationId:{}时长", sku.getId(), groupsRelationView.getId());
 				Date expiryTime = groupsRelationView.getExpiryTime();
@@ -245,10 +244,8 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
 					throw BusinessRuntimeException.getInstance("用户存在未发车的车票,请发车后再进行发货");
 				}
 				DateTime updateExpiryTime = DateUtil.offset(expiryTime, DateField.MONTH, sku.getMonths());
-				updateExpiryTime = DateUtil.offsetDay(updateExpiryTime, 3);
 				groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
 						.eq(GroupsRelation::getId, groupsRelationView.getId())
-						.eq(GroupsRelation::getUserId, userId)
 						.set(GroupsRelation::getExpiryTime, updateExpiryTime));
 				groupsRelationView.setUpdateExpiryTime(updateExpiryTime);
 				relationIds.add(groupsRelationView.getId());