修改商品参数校验以及充值回调接口

This commit is contained in:
pikachu 2021-06-26 16:48:06 +08:00
parent 701ea240ab
commit 5786cb9e55
6 changed files with 67 additions and 6 deletions

View File

@ -37,7 +37,8 @@ public class WalletLogBuyerController {
//获取当前登录用户 //获取当前登录用户
AuthUser authUser = UserContext.getCurrentUser(); AuthUser authUser = UserContext.getCurrentUser();
//构建查询 返回数据 //构建查询 返回数据
IPage<WalletLog> depositLogPage = walletLogService.page(PageUtil.initPage(page), new QueryWrapper<WalletLog>().eq("member_id", authUser.getId())); IPage<WalletLog> depositLogPage = walletLogService.page(PageUtil.initPage(page),
new QueryWrapper<WalletLog>().eq("member_id", authUser.getId()).orderByDesc("create_time"));
return ResultUtil.data(depositLogPage); return ResultUtil.data(depositLogPage);
} }
} }

View File

@ -41,7 +41,7 @@ public class CategoryParameterGroup extends BaseEntity {
@NotNull(message = "关联的分类不能为空") @NotNull(message = "关联的分类不能为空")
private String categoryId; private String categoryId;
/** /**
* * 排序
*/ */
@ApiModelProperty(value = "排序", hidden = true) @ApiModelProperty(value = "排序", hidden = true)
private Integer sort; private Integer sort;

View File

@ -16,13 +16,16 @@ import cn.lili.config.rocketmq.RocketmqCustomProperties;
import cn.lili.modules.goods.entity.dos.Category; import cn.lili.modules.goods.entity.dos.Category;
import cn.lili.modules.goods.entity.dos.Goods; import cn.lili.modules.goods.entity.dos.Goods;
import cn.lili.modules.goods.entity.dos.GoodsGallery; import cn.lili.modules.goods.entity.dos.GoodsGallery;
import cn.lili.modules.goods.entity.dos.Parameters;
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
import cn.lili.modules.goods.entity.dto.GoodsParamsItemDTO;
import cn.lili.modules.goods.entity.dto.GoodsSearchParams; import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
import cn.lili.modules.goods.entity.vos.GoodsSkuVO; import cn.lili.modules.goods.entity.vos.GoodsSkuVO;
import cn.lili.modules.goods.entity.vos.GoodsVO; import cn.lili.modules.goods.entity.vos.GoodsVO;
import cn.lili.modules.goods.entity.vos.ParameterGroupVO;
import cn.lili.modules.goods.mapper.GoodsMapper; import cn.lili.modules.goods.mapper.GoodsMapper;
import cn.lili.modules.goods.service.*; import cn.lili.modules.goods.service.*;
import cn.lili.modules.member.entity.dos.MemberEvaluation; import cn.lili.modules.member.entity.dos.MemberEvaluation;
@ -84,6 +87,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
//rocketMq配置 //rocketMq配置
@Autowired @Autowired
private RocketmqCustomProperties rocketmqCustomProperties; private RocketmqCustomProperties rocketmqCustomProperties;
@Autowired
private CategoryParameterGroupService categoryParameterGroupService;
@Override @Override
@ -108,6 +113,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods); this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods);
//添加商品参数 //添加商品参数
if (goodsOperationDTO.getGoodsParamsDTOList() != null && !goodsOperationDTO.getGoodsParamsDTOList().isEmpty()) { if (goodsOperationDTO.getGoodsParamsDTOList() != null && !goodsOperationDTO.getGoodsParamsDTOList().isEmpty()) {
//检测商品参数是否合法
//this.checkGoodsParams(goodsOperationDTO.getGoodsParamsDTOList(), goodsOperationDTO.getCategoryPath().substring(goodsOperationDTO.getCategoryPath().lastIndexOf(",") + 1));
//给商品参数填充值
goods.setParams(JSONUtil.toJsonStr(goodsOperationDTO.getGoodsParamsDTOList())); goods.setParams(JSONUtil.toJsonStr(goodsOperationDTO.getGoodsParamsDTOList()));
} }
//添加商品 //添加商品
@ -323,6 +331,52 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
goods.setThumbnail(goodsGallery.getThumbnail()); goods.setThumbnail(goodsGallery.getThumbnail());
} }
/**
* 检测商品参数是否非法传递
*
* @param goodsParamsDTOS 商品参数
* @param categoryId 分类id
*/
private void checkGoodsParams(List<GoodsParamsDTO> goodsParamsDTOS, String categoryId) {
//根据绑定的分了id查询出参数信息
List<ParameterGroupVO> parameterGroupVOS = categoryParameterGroupService.getCategoryParams(categoryId);
if (parameterGroupVOS.size() > 0) {
//绑定分类的参数集合
List<Parameters> parametersList = new ArrayList<>();
//循环分类绑定的参数信息 把它整理到新的分类参数集合中 用于最后的参数信息对比
for (ParameterGroupVO parameterGroupVO : parameterGroupVOS) {
List<Parameters> parameters = parameterGroupVO.getParams();
for (Parameters param : parameters) {
parametersList.add(param);
}
}
List<GoodsParamsItemDTO> goodsOperationParamList = new ArrayList<>();
//循环添加商品传递的参数信息 把它整理到新的分类参数集合中 用于最后的参数信息对比
for (GoodsParamsDTO goodsParamsDTO : goodsParamsDTOS) {
List<GoodsParamsItemDTO> goodsParamsItemDTOS = goodsParamsDTO.getGoodsParamsItemDTOList();
for (GoodsParamsItemDTO goodsParamsItemDTO : goodsParamsItemDTOS) {
goodsOperationParamList.add(goodsParamsItemDTO);
}
}
//两个参数集合进行对比
for (Parameters parameters :parametersList){
for (GoodsParamsItemDTO goodsParamsItemDTO :goodsOperationParamList){
if(parameters.getId().equals(goodsParamsItemDTO.getParamId())){
//校验是否可以索引参数是否正确
if(!parameters.getIsIndex().equals(goodsParamsItemDTO.getIsIndex())){
throw new ServiceException("商品参数错误,刷新后重试");
}
//校验是否必填参数是否正确
if(!parameters.getRequired().equals(goodsParamsItemDTO.getRequired())){
throw new ServiceException("商品参数错误,刷新后重试");
}
}
}
}
}
}
/** /**
* 检查商品信息 * 检查商品信息
* 如果商品是虚拟商品则无需配置配送模板 * 如果商品是虚拟商品则无需配置配送模板

View File

@ -37,8 +37,9 @@ public interface RechargeService extends IService<Recharge> {
* *
* @param sn 充值订单编号 * @param sn 充值订单编号
* @param receivableNo 流水no * @param receivableNo 流水no
* @param paymentMethod 支付方式
*/ */
void paySuccess(String sn, String receivableNo); void paySuccess(String sn, String receivableNo,String paymentMethod);
/** /**
* 根据充值订单号查询充值信息 * 根据充值订单号查询充值信息

View File

@ -1,9 +1,11 @@
package cn.lili.modules.order.trade.serviceimpl; package cn.lili.modules.order.trade.serviceimpl;
import cn.hutool.core.date.DateTime;
import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.security.AuthUser; import cn.lili.common.security.AuthUser;
import cn.lili.common.security.context.UserContext; import cn.lili.common.security.context.UserContext;
import cn.lili.common.utils.DateUtil;
import cn.lili.common.utils.PageUtil; import cn.lili.common.utils.PageUtil;
import cn.lili.common.utils.SnowFlake; import cn.lili.common.utils.SnowFlake;
import cn.lili.common.utils.StringUtils; import cn.lili.common.utils.StringUtils;
@ -68,19 +70,22 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
Date end = cn.hutool.core.date.DateUtil.parse(rechargeQueryVO.getEndDate()); Date end = cn.hutool.core.date.DateUtil.parse(rechargeQueryVO.getEndDate());
queryWrapper.between("pay_time", start, end); queryWrapper.between("pay_time", start, end);
} }
queryWrapper.orderByDesc("create_time");
//查询返回数据 //查询返回数据
return this.page(PageUtil.initPage(page), queryWrapper); return this.page(PageUtil.initPage(page), queryWrapper);
} }
@Override @Override
public void paySuccess(String sn, String receivableNo) { public void paySuccess(String sn, String receivableNo,String paymentMethod) {
//根据sn获取支付账单 //根据sn获取支付账单
Recharge recharge = this.getOne(new QueryWrapper<Recharge>().eq("recharge_sn", sn)); Recharge recharge = this.getOne(new QueryWrapper<Recharge>().eq("recharge_sn", sn));
//如果支付账单不为空则进行一下逻辑 //如果支付账单不为空则进行一下逻辑
if (recharge != null) { if (recharge != null && !recharge.getPayStatus().equals(PayStatusEnum.PAID.name())) {
//将此账单支付状态更改为已支付 //将此账单支付状态更改为已支付
recharge.setPayStatus(PayStatusEnum.PAID.name()); recharge.setPayStatus(PayStatusEnum.PAID.name());
recharge.setReceivableNo(receivableNo); recharge.setReceivableNo(receivableNo);
recharge.setPayTime(new DateTime());
recharge.setRechargeWay(paymentMethod);
//执行保存操作 //执行保存操作
this.updateById(recharge); this.updateById(recharge);
//增加预存款余额 //增加预存款余额

View File

@ -45,7 +45,7 @@ public class RechargeCashier implements CashierExecute {
public void paymentSuccess(PaymentSuccessParams paymentSuccessParams) { public void paymentSuccess(PaymentSuccessParams paymentSuccessParams) {
PayParam payParam = paymentSuccessParams.getPayParam(); PayParam payParam = paymentSuccessParams.getPayParam();
if (payParam.getOrderType().equals(CashierEnum.RECHARGE.name())) { if (payParam.getOrderType().equals(CashierEnum.RECHARGE.name())) {
rechargeService.paySuccess(payParam.getSn(), paymentSuccessParams.getReceivableNo()); rechargeService.paySuccess(payParam.getSn(), paymentSuccessParams.getReceivableNo(),paymentSuccessParams.getPaymentMethod());
log.info("会员充值-订单号{},第三方流水:{}", payParam.getSn(), paymentSuccessParams.getReceivableNo()); log.info("会员充值-订单号{},第三方流水:{}", payParam.getSn(), paymentSuccessParams.getReceivableNo());
} }
} }