Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -77,7 +77,10 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
||||
|
||||
SysUser user;
|
||||
// 员工账号登录
|
||||
if (StrUtil.isNotBlank(loginDTO.staffUserName())) {
|
||||
if (loginDTO.loginType() == 1) {
|
||||
if (StrUtil.isBlank(loginDTO.staffUserName())) {
|
||||
throw new ApiNotPrintException("员工账号不能为空");
|
||||
}
|
||||
// 查询主账号
|
||||
SysUser sysUser = sysUserService.queryChain().eq(SysUser::getAccount, loginDTO.username()).one();
|
||||
if (sysUser == null) {
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.czg.service.account.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.dto.ShopShareCouponDTO;
|
||||
import com.czg.account.dto.ShopShareDTO;
|
||||
import com.czg.account.entity.ShopCoupon;
|
||||
import com.czg.account.service.ShopCouponService;
|
||||
@@ -42,11 +44,13 @@ public class ShopShareServiceImpl extends ServiceImpl<ShopShareMapper, ShopShare
|
||||
if (shopShare != null) {
|
||||
BeanUtil.copyProperties(shopShare, shopShareVO);
|
||||
if (StrUtil.isNotBlank(shopShare.getRewardCoupon())) {
|
||||
shopShareVO.setRewardCouponList(shopCouponService.list(new QueryWrapper().eq(ShopCoupon::getShopId, shopId).in(ShopCoupon::getId, JSONArray.parseArray(shopShare.getRewardCoupon()))));
|
||||
// shopShareVO.setRewardCouponList(shopCouponService.list(new QueryWrapper().eq(ShopCoupon::getShopId, shopId).in(ShopCoupon::getId, JSONArray.parseArray(shopShare.getRewardCoupon()))));
|
||||
shopShareVO.setRewardCouponList(JSONArray.parseArray(shopShare.getRewardCoupon(), ShopShareCouponDTO.class));
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(shopShare.getNewCoupon())) {
|
||||
shopShareVO.setNewCouponList(shopCouponService.list(new QueryWrapper().eq(ShopCoupon::getShopId, shopId).in(ShopCoupon::getId, JSONArray.parseArray(shopShare.getNewCoupon()))));
|
||||
// shopShareVO.setNewCouponList(shopCouponService.list(new QueryWrapper().eq(ShopCoupon::getShopId, shopId).in(ShopCoupon::getId, JSONArray.parseArray(shopShare.getNewCoupon()))));
|
||||
shopShareVO.setNewCouponList(JSONArray.parseArray(shopShare.getNewCoupon(), ShopShareCouponDTO.class));
|
||||
}
|
||||
}
|
||||
return shopShareVO;
|
||||
@@ -54,26 +58,27 @@ public class ShopShareServiceImpl extends ServiceImpl<ShopShareMapper, ShopShare
|
||||
|
||||
@Override
|
||||
public Boolean add(Long shopId, ShopShareDTO shopShareDTO) {
|
||||
if (shopShareDTO.getNewCouponIdList() != null && !shopShareDTO.getRewardCouponIdList().isEmpty()) {
|
||||
long count = shopCouponService.count(new QueryWrapper().in(ShopCoupon::getId, shopShareDTO.getNewCouponIdList()).eq(ShopCoupon::getShopId, shopId));
|
||||
if (count != shopShareDTO.getNewCouponIdList().size()) {
|
||||
throw new ApiNotPrintException("优惠券不存在");
|
||||
}
|
||||
}
|
||||
|
||||
if (shopShareDTO.getRewardCouponIdList() != null && !shopShareDTO.getRewardCouponIdList().isEmpty()) {
|
||||
long count = shopCouponService.count(new QueryWrapper().in(ShopCoupon::getId, shopShareDTO.getRewardCouponIdList()).eq(ShopCoupon::getShopId, shopId));
|
||||
if (count != shopShareDTO.getRewardCouponIdList().size()) {
|
||||
throw new ApiNotPrintException("优惠券不存在");
|
||||
}
|
||||
}
|
||||
ShopShare shopShare = getOne(new QueryWrapper().eq(ShopShare::getShopId, shopId));
|
||||
if (shopShare == null) {
|
||||
shopShare = new ShopShareVO();
|
||||
shopShare.setShopId(shopId);
|
||||
}
|
||||
shopShare.setRewardCoupon(JSONArray.toJSONString(shopShareDTO.getRewardCouponIdList()));
|
||||
shopShare.setNewCoupon(JSONArray.toJSONString(shopShareDTO.getNewCouponIdList()));
|
||||
|
||||
if (shopShareDTO.getNewCouponList() != null && !shopShareDTO.getNewCouponList().isEmpty()) {
|
||||
long count = shopCouponService.count(new QueryWrapper().in(ShopCoupon::getId, shopShareDTO.getNewCouponList().stream().map(ShopShareCouponDTO::getId).toList()).eq(ShopCoupon::getShopId, shopId));
|
||||
if (count != shopShareDTO.getNewCouponList().size()) {
|
||||
throw new ApiNotPrintException("优惠券不存在");
|
||||
}
|
||||
shopShare.setNewCoupon(JSONArray.toJSONString(shopShareDTO.getNewCouponList()));
|
||||
}
|
||||
|
||||
if (shopShareDTO.getRewardCouponList() != null && !shopShareDTO.getRewardCouponList().isEmpty()) {
|
||||
long count = shopCouponService.count(new QueryWrapper().in(ShopCoupon::getId, shopShareDTO.getRewardCouponList().stream().map(ShopShareCouponDTO::getId).toList()).eq(ShopCoupon::getShopId, shopId));
|
||||
if (count != shopShareDTO.getRewardCouponList().size()) {
|
||||
throw new ApiNotPrintException("优惠券不存在");
|
||||
}
|
||||
shopShare.setRewardCoupon(JSONArray.toJSONString(shopShareDTO.getRewardCouponList()));
|
||||
}
|
||||
BeanUtil.copyProperties(shopShareDTO, shopShare);
|
||||
return saveOrUpdate(shopShare);
|
||||
}
|
||||
|
||||
@@ -54,12 +54,12 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
|
||||
List<SysMenu> allMenus;
|
||||
if (queryWrapper.hasCondition()) {
|
||||
allMenus = list(queryWrapper);
|
||||
allMenus = list(queryWrapper.orderBy(SysMenu::getMenuSort, false));
|
||||
return allMenus.stream()
|
||||
.map(item -> BeanUtil.copyProperties(item, MenuVO.class))
|
||||
.collect(Collectors.toList());
|
||||
}else {
|
||||
allMenus = list();
|
||||
allMenus = list(new QueryWrapper().orderBy(SysMenu::getMenuSort, false));
|
||||
return buildMenuTree(allMenus);
|
||||
}
|
||||
}
|
||||
@@ -94,15 +94,15 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
|
||||
|
||||
private void checkExIsis(String title, Integer id) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
if (id != null) {
|
||||
queryWrapper.ne(SysMenu::getMenuId, id);
|
||||
}
|
||||
queryWrapper.eq(SysMenu::getTitle, title);
|
||||
long count = count(queryWrapper);
|
||||
if (count > 0) {
|
||||
throw new ApiNotPrintException("名称已存在");
|
||||
}
|
||||
// QueryWrapper queryWrapper = new QueryWrapper();
|
||||
// if (id != null) {
|
||||
// queryWrapper.ne(SysMenu::getMenuId, id);
|
||||
// }
|
||||
// queryWrapper.eq(SysMenu::getTitle, title);
|
||||
// long count = count(queryWrapper);
|
||||
// if (count > 0) {
|
||||
// throw new ApiNotPrintException("名称已存在");
|
||||
// }
|
||||
}
|
||||
|
||||
private List<MenuVO> buildMenuTree(List<SysMenu> allMenus) {
|
||||
|
||||
@@ -13,5 +13,6 @@
|
||||
<if test="type != null">
|
||||
and c.type=#{type}
|
||||
</if>
|
||||
order by menu_sort desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -113,6 +113,9 @@ public class PayServiceImpl implements PayService {
|
||||
* @return 是否是霸王餐充值
|
||||
*/
|
||||
private boolean checkPayVip(VipPayParamDTO payParam) {
|
||||
if (payParam.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new ValidateException("充值金额不正确");
|
||||
}
|
||||
if (payParam.getOrderId() != null) {
|
||||
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
||||
@@ -135,7 +138,7 @@ public class PayServiceImpl implements PayService {
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Object> creditPayOrder(OrderPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getCreditBuyerId(), "挂账人不可为空");
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
@@ -149,7 +152,7 @@ public class PayServiceImpl implements PayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Object> cashPayOrder(OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
orderInfoService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
||||
@@ -163,7 +166,7 @@ public class PayServiceImpl implements PayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Object> vipPayOrder(OrderPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getCheckOrderPay().getUserId(), "会员支付,订单用户不能为空");
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
@@ -215,7 +218,7 @@ public class PayServiceImpl implements PayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Map<String, Object>> h5PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||
@@ -228,7 +231,7 @@ public class PayServiceImpl implements PayService {
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Map<String, Object>> jsPayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
@@ -242,7 +245,7 @@ public class PayServiceImpl implements PayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Map<String, Object>> js2PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||
@@ -262,7 +265,7 @@ public class PayServiceImpl implements PayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Map<String, Object>> ltPayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
@@ -276,7 +279,7 @@ public class PayServiceImpl implements PayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Map<String, Object>> scanPayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
|
||||
@@ -289,7 +292,7 @@ public class PayServiceImpl implements PayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Map<String, Object>> microPayOrder(OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
AssertUtil.isBlank(payParam.getAuthCode(), "扫描码不能为空");
|
||||
@@ -487,6 +490,9 @@ public class PayServiceImpl implements PayService {
|
||||
@Transactional
|
||||
public CzgResult<Object> refundOrderBefore(OrderInfoRefundDTO param) {
|
||||
OrderInfo orderInfo = orderInfoService.getById(param.getOrderId());
|
||||
if (orderInfo.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
|
||||
return CzgResult.failure("订单未支付,无法退款");
|
||||
}
|
||||
Map<String, BigDecimal> returnProMap = new HashMap<>();
|
||||
boolean isPay = true;
|
||||
String refPayOrderNo = "REFO" + IdUtil.getSnowflakeNextId();
|
||||
@@ -557,45 +563,23 @@ public class PayServiceImpl implements PayService {
|
||||
//总退款金额
|
||||
//TODO 退款 券 未处理
|
||||
if (isPay) {
|
||||
if (param.isModify()) {
|
||||
//非现金退款
|
||||
if (!param.isCash()) {
|
||||
if (orderInfo.getPayType().equals(PayEnums.VIP_PAY.getValue())) {
|
||||
ShopUser shopUser = shopUserService.getShopUserInfo(orderInfo.getShopId(), orderInfo.getUserId());
|
||||
//会员支付 退钱
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = ShopUserMoneyEditDTO.builder()
|
||||
.id(shopUser.getId())
|
||||
.money(param.getRefundAmount())
|
||||
.type(1)
|
||||
.relationId(orderInfo.getId())
|
||||
.bizEnum(ShopUserFlowBizEnum.ORDER_REFUND)
|
||||
.build();
|
||||
shopUserService.updateMoney(orderInfo.getShopId(), shopUserMoneyEditDTO);
|
||||
} else if (!orderInfo.getPayType().equals(PayEnums.CASH_PAY.getValue())) {
|
||||
//退款 param.getRefundAmount()
|
||||
refundOrder(orderInfo.getShopId(), orderInfo.getId(), orderInfo.getPayOrderId(),
|
||||
refPayOrderNo, param.getRefundReason(), param.getRefundAmount());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//非现金退款
|
||||
if (!param.isCash()) {
|
||||
if (orderInfo.getPayType().equals(PayEnums.VIP_PAY.getValue())) {
|
||||
ShopUser shopUser = shopUserService.getShopUserInfo(orderInfo.getShopId(), orderInfo.getUserId());
|
||||
//会员支付 退钱
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = ShopUserMoneyEditDTO.builder()
|
||||
.id(shopUser.getId())
|
||||
.money(param.getRefundAmount())
|
||||
.type(1)
|
||||
.relationId(orderInfo.getId())
|
||||
.bizEnum(ShopUserFlowBizEnum.ORDER_REFUND)
|
||||
.build();
|
||||
shopUserService.updateMoney(orderInfo.getShopId(), shopUserMoneyEditDTO);
|
||||
} else if (!orderInfo.getPayType().equals(PayEnums.CASH_PAY.getValue())) {
|
||||
//退款 param.getRefundAmount()
|
||||
refundOrder(orderInfo.getShopId(), orderInfo.getId(), orderInfo.getPayOrderId(),
|
||||
refPayOrderNo, param.getRefundReason(), param.getRefundAmount());
|
||||
}
|
||||
//非现金退款
|
||||
if (!param.isCash()) {
|
||||
if (orderInfo.getPayType().equals(PayEnums.VIP_PAY.getValue())) {
|
||||
ShopUser shopUser = shopUserService.getShopUserInfo(orderInfo.getShopId(), orderInfo.getUserId());
|
||||
//会员支付 退钱
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = ShopUserMoneyEditDTO.builder()
|
||||
.id(shopUser.getId())
|
||||
.money(param.getRefundAmount())
|
||||
.type(1)
|
||||
.relationId(orderInfo.getId())
|
||||
.bizEnum(ShopUserFlowBizEnum.ORDER_REFUND)
|
||||
.build();
|
||||
shopUserService.updateMoney(orderInfo.getShopId(), shopUserMoneyEditDTO);
|
||||
} else if (!orderInfo.getPayType().equals(PayEnums.CASH_PAY.getValue())) {
|
||||
//退款 param.getRefundAmount()
|
||||
refundOrder(orderInfo.getShopId(), orderInfo.getId(), orderInfo.getPayOrderId(),
|
||||
refPayOrderNo, param.getRefundReason(), param.getRefundAmount());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user