Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
SongZhang 2024-10-14 09:02:46 +08:00
commit 45dc370713
4 changed files with 27 additions and 7 deletions

View File

@ -44,6 +44,7 @@ public class NotifyController {
String payOrderId = bizData.getString("payOrderId"); String payOrderId = bizData.getString("payOrderId");
String payType = bizData.getString("payType"); String payType = bizData.getString("payType");
String payTime = bizData.getString("payTime"); String payTime = bizData.getString("payTime");
long amount = bizData.getLongValue("amount");
long paidTime = DateUtil.parseDateTime(payTime).getTime(); long paidTime = DateUtil.parseDateTime(payTime).getTime();
if (!"TRADE_SUCCESS".equals(state)) { if (!"TRADE_SUCCESS".equals(state)) {
log.error("支付失败:{},{}", state, note); log.error("支付失败:{},{}", state, note);
@ -51,10 +52,11 @@ public class NotifyController {
} }
TbOrderInfo entity = orderService.selectByPayOrderNo(payOrderId); TbOrderInfo entity = orderService.selectByPayOrderNo(payOrderId);
if (entity == null) { if (entity == null) {
log.error("订单不存在:{}", payOrderId);
return Result.fail("订单不存在"); return Result.fail("订单不存在");
} }
entity.setPaidTime(paidTime); entity.setPaidTime(paidTime);
orderService.payCallbackCloseOrder(entity, payType); orderService.payCallbackCloseOrder(entity, payType, amount);
return Result.success(CodeEnum.SUCCESS); return Result.success(CodeEnum.SUCCESS);
} }

View File

@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
@ -462,7 +463,7 @@ public class OrderService {
if (product.getStockNumber() == null) { if (product.getStockNumber() == null) {
product.setStockNumber(0); product.setStockNumber(0);
} }
if ( product.getStockNumber() - num <= product.getWarnLine()) { if (product.getStockNumber() - num <= product.getWarnLine()) {
List<TbShopOpenId> shopOpenIds = shopOpenIdMapper.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.STOCK_MSG.getType()); List<TbShopOpenId> shopOpenIds = shopOpenIdMapper.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.STOCK_MSG.getType());
shopOpenIds.forEach(item -> { shopOpenIds.forEach(item -> {
wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(), wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(),
@ -1864,11 +1865,13 @@ public class OrderService {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void payCallbackCloseOrder(TbOrderInfo entity, String payType) { public void payCallbackCloseOrder(TbOrderInfo entity, String payType, long actualPayAmount) {
mPOrderInfoMapper.update(null, new LambdaUpdateWrapper<TbOrderInfo>() mPOrderInfoMapper.update(null, new LambdaUpdateWrapper<TbOrderInfo>()
.eq(TbOrderInfo::getId, entity.getId()) .eq(TbOrderInfo::getId, entity.getId())
.eq(TbOrderInfo::getStatus, "paying") .eq(TbOrderInfo::getStatus, "paying")
.set(TbOrderInfo::getStatus, "closed") .set(TbOrderInfo::getStatus, "closed")
.set(TbOrderInfo::getPayType, payType)
.set(TbOrderInfo::getPayAmount, NumberUtil.div(actualPayAmount, 100))
.set(TbOrderInfo::getPaidTime, entity.getPaidTime()) .set(TbOrderInfo::getPaidTime, entity.getPaidTime())
.set(TbOrderInfo::getUpdatedAt, System.currentTimeMillis()) .set(TbOrderInfo::getUpdatedAt, System.currentTimeMillis())
); );

View File

@ -150,7 +150,7 @@ public class PayService {
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>() mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId()) .eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState())); .set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
}else { } else {
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>() mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, orderInfo.getTableId()) .eq(TbShopTable::getQrcode, orderInfo.getTableId())
.set(TbShopTable::getStatus, TableStateEnum.CLEANING.getState())); .set(TbShopTable::getStatus, TableStateEnum.CLEANING.getState()));
@ -1902,6 +1902,19 @@ public class PayService {
return "QR" + date + randomNum; return "QR" + date + randomNum;
} }
/**
* {"userId":"ojC-S6iKBL7sHUb-E0UYq-Q1J4AA","shopId":"11","payType":"WECHAT","payAmount":"0.01","remark":"","orderId":"5835"}
*
* @param ip
* @param userId
* @param payType
* @param shopId
* @param orderId
* @param amount
* @param remark
* @return
* @throws JsonProcessingException
*/
public Result createOrder(String ip, String userId, String payType, String shopId, String orderId, public Result createOrder(String ip, String userId, String payType, String shopId, String orderId,
BigDecimal amount, String remark) throws JsonProcessingException { BigDecimal amount, String remark) throws JsonProcessingException {
@ -1924,10 +1937,11 @@ public class PayService {
if (ObjectUtil.isNull(orderInfo)) { if (ObjectUtil.isNull(orderInfo)) {
return Result.fail(CodeEnum.ORDERNOEXIST); return Result.fail(CodeEnum.ORDERNOEXIST);
} }
orderInfo.setDiscountAmount(orderInfo.getOrderAmount().subtract(amount));
if (StrUtil.isNotBlank(remark)) { if (StrUtil.isNotBlank(remark)) {
orderInfo.setRemark(remark); orderInfo.setRemark(remark);
tbOrderInfoMapper.updateByPrimaryKey(orderInfo);
} }
tbOrderInfoMapper.updateByPrimaryKey(orderInfo);
} else { } else {
orderInfo = new TbOrderInfo(); orderInfo = new TbOrderInfo();
@ -1942,6 +1956,7 @@ public class PayService {
orderInfo.setPayType(payType); orderInfo.setPayType(payType);
orderInfo.setPayAmount(amount); orderInfo.setPayAmount(amount);
orderInfo.setOrderAmount(amount); orderInfo.setOrderAmount(amount);
orderInfo.setDiscountAmount(BigDecimal.ZERO);
orderInfo.setSendType("QR"); orderInfo.setSendType("QR");
orderInfo.setStatus("WAIT_PAY"); orderInfo.setStatus("WAIT_PAY");
orderInfo.setMerchantId(shopInfo.getMerchantId()); orderInfo.setMerchantId(shopInfo.getMerchantId());
@ -1985,7 +2000,7 @@ public class PayService {
String reqbody = "店铺收款码"; String reqbody = "店铺收款码";
PublicResp<JspayResp> publicResp = thirdPayService.jspay(url, thirdApply.getAppId(), thirdApply.getAppToken(), PublicResp<JspayResp> publicResp = thirdPayService.jspay(url, thirdApply.getAppId(), thirdApply.getAppToken(),
reqbody, reqbody, orderInfo.getOrderAmount().multiply(new BigDecimal(100)).longValue(), reqbody, reqbody, amount.multiply(new BigDecimal(100)).longValue(),
payType, thirdApply.getSmallAppid(), userId, ip, payType, thirdApply.getSmallAppid(), userId, ip,
DateUtils.getSsdfTimes(), thirdApply.getStoreId(), backUrl, backUrl); DateUtils.getSsdfTimes(), thirdApply.getStoreId(), backUrl, backUrl);

View File

@ -143,7 +143,7 @@
<select id="selectByShopIdAndSkuIdAndProductId" resultMap="BaseResultMap"> <select id="selectByShopIdAndSkuIdAndProductId" resultMap="BaseResultMap">
select * from tb_prosku_con where product_sku_id=#{skuId} and shop_id=#{shopId} and product_id=#{productId} and status=1 select * from tb_prosku_con where product_sku_id=#{skuId} or product_sku_id='0' and shop_id=#{shopId} and product_id=#{productId} and status=1
</select> </select>
<select id="selectByShopIdAndSkuIdAndProductIdAndCheck" resultMap="BaseResultMap"> <select id="selectByShopIdAndSkuIdAndProductIdAndCheck" resultMap="BaseResultMap">