Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
1e29682782
|
|
@ -2,6 +2,7 @@ package com.czg.controller.admin;
|
|||
|
||||
import com.czg.annotation.Debounce;
|
||||
import com.czg.annotation.SaStaffCheckPermission;
|
||||
import com.czg.config.RabbitPublisher;
|
||||
import com.czg.order.dto.OrderInfoAddDTO;
|
||||
import com.czg.order.dto.OrderInfoPrintDTO;
|
||||
import com.czg.order.dto.OrderInfoQueryDTO;
|
||||
|
|
@ -35,6 +36,8 @@ public class AdminOrderController {
|
|||
private OrderInfoService orderInfoService;
|
||||
@Resource
|
||||
private PayService payService;
|
||||
@Resource
|
||||
private RabbitPublisher rabbitPublisher;
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
|
|
@ -91,7 +94,11 @@ public class AdminOrderController {
|
|||
@PostMapping("/refundOrder")
|
||||
@Debounce(value = "#refundDTO.orderId")
|
||||
public CzgResult<Object> refundOrder(@Validated @RequestBody OrderInfoRefundDTO refundDTO) {
|
||||
return payService.refundOrderBefore(refundDTO);
|
||||
CzgResult<Object> result = payService.refundOrderBefore(refundDTO);
|
||||
if (result.getCode() == 200 && refundDTO.getRefundDetails() != null && !refundDTO.getRefundDetails().isEmpty()) {
|
||||
rabbitPublisher.sendOrderReturnPrintMsg(refundDTO.getOrderId().toString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -53,6 +53,15 @@ public class RabbitPublisher {
|
|||
sendMsg(RabbitConstants.Queue.ORDER_PRINT_QUEUE, orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款订单打印消息
|
||||
* @param orderId 订单id
|
||||
*/
|
||||
public void sendOrderReturnPrintMsg(String orderId) {
|
||||
//厨房票
|
||||
sendMsg(RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE, orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 交班小票打印消息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -24,11 +24,12 @@ public interface ShopActivateService extends IService<ShopActivate> {
|
|||
|
||||
/**
|
||||
* @param memAmount 充值金额
|
||||
* @param activateId 参加活动Id
|
||||
* @param relationId 关联Id
|
||||
* 霸王餐时 订单id
|
||||
* 充值奖励 的关联id 是tb_shop_user_flow的充值 记录id
|
||||
* 支付/退款 tb_order_payment.id
|
||||
*/
|
||||
void giveActivate(ShopUser shopUser, BigDecimal memAmount, Long relationId);
|
||||
void giveActivate(ShopUser shopUser, BigDecimal memAmount, Long activateId, Long relationId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ public class OrderDetailSmallVO implements Serializable {
|
|||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
private String productImg;
|
||||
private String productName;
|
||||
private String skuName;
|
||||
|
|
|
|||
|
|
@ -81,11 +81,11 @@ public class ShopActivateServiceImpl extends ServiceImpl<ShopActivateMapper, Sho
|
|||
}
|
||||
|
||||
@Override
|
||||
public void giveActivate(ShopUser shopUser, BigDecimal memAmount, Long relationId) {
|
||||
ShopActivate activate = queryChain().select().eq(ShopActivate::getShopId, shopUser.getShopId())
|
||||
.le(ShopActivate::getAmount, memAmount)
|
||||
.orderBy(ShopActivate::getGiftAmount, false)
|
||||
.one();
|
||||
public void giveActivate(ShopUser shopUser, BigDecimal memAmount, Long activateId, Long relationId) {
|
||||
if (activateId == null) {
|
||||
return;
|
||||
}
|
||||
ShopActivate activate = getById(activateId);
|
||||
if (ObjectUtil.isNull(activate)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -162,8 +162,14 @@ public class ShopActivateServiceImpl extends ServiceImpl<ShopActivateMapper, Sho
|
|||
* 获取优惠券详细信息 目前仅返回 id 名称 剩余数量 赠送数量
|
||||
*/
|
||||
private List<ShopCoupon> getCoupons(String couponJson) {
|
||||
Map<String, Integer> couponMap = JSONObject.parseObject(couponJson, new TypeReference<>() {
|
||||
});
|
||||
Map<String, Integer> couponMap;
|
||||
try {
|
||||
couponMap = JSONObject.parseObject(couponJson, new TypeReference<>() {
|
||||
});
|
||||
} catch (Exception e) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
if (couponMap.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -268,11 +268,21 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
|||
@Override
|
||||
public ShopUserDetailDTO getInfo(Long shopId, long userId) {
|
||||
ShopUser shopUser = getOne(new QueryWrapper().eq(ShopUser::getShopId, shopId).eq(ShopUser::getUserId, userId));
|
||||
long couponNum = 0;
|
||||
if (shopUser == null) {
|
||||
return null;
|
||||
UserInfo userInfo = userInfoService.getById(userId);
|
||||
if (userInfo == null) {
|
||||
throw new ApiNotPrintException("用户信息不存在");
|
||||
}
|
||||
shopUser = BeanUtil.copyProperties(userInfo, ShopUser.class);
|
||||
shopUser.setShopId(shopId);
|
||||
shopUser.setId(null);
|
||||
shopUser.setUserId(userId);
|
||||
save(shopUser);
|
||||
shopUser = getById(shopUser.getId());
|
||||
}else {
|
||||
couponNum = shopActivateCouponRecordService.count(new QueryWrapper().eq(ShopActivateCouponRecord::getShopUserId, shopUser.getId()).eq(ShopActivateCouponRecord::getStatus, 0));
|
||||
}
|
||||
|
||||
long couponNum = shopActivateCouponRecordService.count(new QueryWrapper().eq(ShopActivateCouponRecord::getShopUserId, shopUser.getId()).eq(ShopActivateCouponRecord::getStatus, 0));
|
||||
ShopUserDetailDTO shopUserDetailDTO = BeanUtil.copyProperties(shopUser, ShopUserDetailDTO.class);
|
||||
shopUserDetailDTO.setCouponNum(couponNum);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ public class VipPayParamDTO {
|
|||
@NotNull(message = "店铺不能为空")
|
||||
private Long shopId;
|
||||
private Long shopUserId;
|
||||
private Long activateId;
|
||||
/**
|
||||
* 霸王餐使用
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -429,13 +429,13 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
couponNum = couponNum.subtract(orderDetail.getNum());
|
||||
} else {
|
||||
orderDetail.setCouponNum(couponNum);
|
||||
orderDetail.setPayAmount((orderDetail.getNum().subtract(orderDetail.getReturnNum()).subtract(couponNum)).multiply(orderDetail.getUnitPrice()));
|
||||
orderDetail.setPayAmount((orderDetail.getNum().subtract(orderDetail.getReturnNum()).subtract(couponNum)).multiply(orderDetail.getUnitPrice()).setScale(2, RoundingMode.DOWN));
|
||||
couponNum = BigDecimal.ZERO;
|
||||
}
|
||||
prodCouponAmount.setPrice((prodCouponAmount.getPrice().add(orderDetail.getUnitPrice())).multiply(orderDetail.getCouponNum()));
|
||||
prodCouponAmount.setPrice((prodCouponAmount.getPrice().add(orderDetail.getUnitPrice())).multiply(orderDetail.getCouponNum()).setScale(2, RoundingMode.DOWN));
|
||||
} else {
|
||||
orderDetail.setCouponNum(BigDecimal.ZERO);
|
||||
orderDetail.setPayAmount((orderDetail.getNum().subtract(orderDetail.getReturnNum())).multiply(orderDetail.getUnitPrice()));
|
||||
orderDetail.setPayAmount((orderDetail.getNum().subtract(orderDetail.getReturnNum())).multiply(orderDetail.getUnitPrice()).setScale(2, RoundingMode.DOWN));
|
||||
}
|
||||
totalAmount.setPrice(totalAmount.getPrice().add(orderDetail.getPayAmount()));
|
||||
resultList.add(orderDetail);
|
||||
|
|
@ -535,8 +535,10 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
} else {
|
||||
shopUserMoneyEditDTO.setBizEnum(ShopUserFlowBizEnum.CASH_IN);
|
||||
}
|
||||
String extParam = czgCallBackDto.getExtParam();
|
||||
JSONObject jsonObject = JSONObject.parseObject(extParam);
|
||||
if (isFree) {
|
||||
if (StrUtil.isBlank(czgCallBackDto.getExtParam())) {
|
||||
if (StrUtil.isBlank(jsonObject.getString("orderId"))) {
|
||||
throw new ValidateException("霸王餐支付,订单号处理失败");
|
||||
}
|
||||
shopUserMoneyEditDTO.setBizEnum(ShopUserFlowBizEnum.FREE_IN);
|
||||
|
|
@ -550,8 +552,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
Long flowId = shopUserService.updateMoney(shopUser.getShopId(), shopUserMoneyEditDTO);
|
||||
if (!isFree) {
|
||||
//会员活动
|
||||
activateService.giveActivate(shopUser,
|
||||
new BigDecimal(czgCallBackDto.getAmount()).divide(new BigDecimal(100), 2, RoundingMode.DOWN), flowId);
|
||||
activateService.giveActivate(shopUser, new BigDecimal(czgCallBackDto.getAmount()).divide(new BigDecimal(100), 2, RoundingMode.DOWN),
|
||||
StrUtil.isNotBlank(jsonObject.getString("activateId")) ? jsonObject.getLong("activateId") : null, flowId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ public class PayServiceImpl implements PayService {
|
|||
BigDecimalDTO totalAmount = new BigDecimalDTO(BigDecimal.ZERO);
|
||||
//最终打包费
|
||||
BigDecimalDTO packAmount = new BigDecimalDTO(BigDecimal.ZERO);
|
||||
orderInfoService.processOrderDetails2(orderDetails, null, null, totalAmount, packAmount, payParam.isAllPack(), null,true);
|
||||
orderInfoService.processOrderDetails2(orderDetails, null, null, totalAmount, packAmount, payParam.isAllPack(), null, true);
|
||||
BigDecimal payAmount = (totalAmount.getPrice().add(packAmount.getPrice())).multiply(BigDecimal.TWO);
|
||||
if (payAmount.compareTo(payParam.getAmount()) != 0) {
|
||||
throw new ValidateException("霸王餐支付金额不正确");
|
||||
|
|
@ -338,7 +338,7 @@ public class PayServiceImpl implements PayService {
|
|||
Long flowId = shopUserService.updateMoney(shopUser.getShopId(), shopUserMoneyEditDTO);
|
||||
if (!isFree) {
|
||||
//会员活动
|
||||
shopActivateService.giveActivate(shopUser, payParam.getAmount(), flowId);
|
||||
shopActivateService.giveActivate(shopUser, payParam.getAmount(), payParam.getActivateId(), flowId);
|
||||
}
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
|
@ -353,7 +353,10 @@ public class PayServiceImpl implements PayService {
|
|||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
String payOrderNo = payParam.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), isFree ? "free" : "memberIn", payOrderNo, "", payParam.getAmount()));
|
||||
String extParam = payParam.getOrderId() == null ? "" : payParam.getOrderId().toString();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("orderId", payParam.getOrderId() == null ? "" : payParam.getOrderId().toString());
|
||||
jsonObject.put("activateId", payParam.getActivateId() == null ? "" : payParam.getActivateId().toString());
|
||||
String extParam = jsonObject.toJSONString();
|
||||
return jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, payParam.getAmount().multiply(MONEY_RATE).longValue(),
|
||||
"会员充值", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), extParam));
|
||||
}
|
||||
|
|
@ -368,7 +371,10 @@ public class PayServiceImpl implements PayService {
|
|||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
String payOrderNo = payParam.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), isFree ? "free" : "memberIn", payOrderNo, "", payParam.getAmount()));
|
||||
String extParam = payParam.getOrderId() == null ? "" : payParam.getOrderId().toString();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("orderId", payParam.getOrderId() == null ? "" : payParam.getOrderId().toString());
|
||||
jsonObject.put("activateId", payParam.getActivateId() == null ? "" : payParam.getActivateId().toString());
|
||||
String extParam = jsonObject.toJSONString();
|
||||
return ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, payParam.getAmount().multiply(MONEY_RATE).longValue(),
|
||||
payParam.getPayType(), "会员充值", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), extParam));
|
||||
}
|
||||
|
|
@ -381,7 +387,10 @@ public class PayServiceImpl implements PayService {
|
|||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||
String payOrderNo = payParam.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), isFree ? "free" : "memberIn", payOrderNo, "", payParam.getAmount()));
|
||||
String extParam = payParam.getOrderId() == null ? "" : payParam.getOrderId().toString();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("orderId", payParam.getOrderId() == null ? "" : payParam.getOrderId().toString());
|
||||
jsonObject.put("activateId", payParam.getActivateId() == null ? "" : payParam.getActivateId().toString());
|
||||
String extParam = jsonObject.toJSONString();
|
||||
return scanPay(payParam.getShopId(), new CzgScanPayReq(payOrderNo, payParam.getAmount().multiply(MONEY_RATE).longValue(),
|
||||
"会员充值", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), extParam));
|
||||
}
|
||||
|
|
@ -395,7 +404,10 @@ public class PayServiceImpl implements PayService {
|
|||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||
String payOrderNo = payParam.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), isFree ? "free" : "memberIn", payOrderNo, payParam.getAuthCode(), payParam.getAmount()));
|
||||
String extParam = payParam.getOrderId() == null ? "" : payParam.getOrderId().toString();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("orderId", payParam.getOrderId() == null ? "" : payParam.getOrderId().toString());
|
||||
jsonObject.put("activateId", payParam.getActivateId() == null ? "" : payParam.getActivateId().toString());
|
||||
String extParam = jsonObject.toJSONString();
|
||||
return microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, payParam.getAmount().multiply(MONEY_RATE).longValue(),
|
||||
"会员充值", payParam.getAuthCode(), payParam.getBuyerRemark(), extParam));
|
||||
}
|
||||
|
|
@ -746,7 +758,8 @@ public class PayServiceImpl implements PayService {
|
|||
map = JSONObject.parseObject(JSONObject.toJSONString(h5PayResp.getPayInfo()));
|
||||
case CzgJsPayResp jsPayResp ->
|
||||
map = JSONObject.parseObject(JSONObject.toJSONString(jsPayResp.getPayInfo()));
|
||||
case CzgLtPayResp ltPayResp -> map = JSONObject.parseObject(JSONObject.toJSONString(ltPayResp.getPayInfo()));
|
||||
case CzgLtPayResp ltPayResp ->
|
||||
map = JSONObject.parseObject(JSONObject.toJSONString(ltPayResp.getPayInfo()));
|
||||
case CzgScanPayResp scanPayResp ->
|
||||
map = JSONObject.parseObject(JSONObject.toJSONString(scanPayResp.getPayInfo()));
|
||||
default -> throw new IllegalStateException("Unexpected value: " + data);
|
||||
|
|
|
|||
Loading…
Reference in New Issue