Merge remote-tracking branch 'origin/master'

This commit is contained in:
齐天大圣 2024-01-19 10:28:03 +08:00
commit f5805e7659
4 changed files with 17 additions and 12 deletions

View File

@ -2,9 +2,9 @@ package com.fuint.api.fuyou.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fuint.api.fuyou.entity.MerchantConfig; import com.fuint.api.fuyou.entity.MerchantConfig;
import io.lettuce.core.dynamic.annotation.Param; import org.apache.ibatis.annotations.Param;
public interface MerchantConfigMapper extends BaseMapper<MerchantConfig> { public interface MerchantConfigMapper extends BaseMapper<MerchantConfig> {
MerchantConfig getConfig(@Param("storeId") Integer storeId, @Param("mchntCd") String mchntCd); MerchantConfig getConfig(@Param("storeId") Integer storeId, @Param("mchntCd") String mchntCd);
int subtractAmount(@Param("storeId") Integer storeId,@Param("changeTheAmount") String changeTheAmount); int subtractAmount(@Param("id") Integer id,@Param("changeTheAmount") Double changeTheAmount);
} }

View File

@ -3,12 +3,13 @@
<mapper namespace="com.fuint.api.fuyou.mapper.MerchantConfigMapper"> <mapper namespace="com.fuint.api.fuyou.mapper.MerchantConfigMapper">
<update id="subtractAmount"> <update id="subtractAmount">
update Merchant_config set amount = amount-#{changeTheAmount} update Merchant_config set amount = amount-#{changeTheAmount}
where store_id = #{storeId} where id = #{id}
</update> </update>
<select id="getConfig" resultType="com.fuint.api.fuyou.entity.MerchantConfig"> <select id="getConfig" resultType="com.fuint.api.fuyou.entity.MerchantConfig">
select * select *
from Merchant_config from merchant_config
where store_id = #{storeId} where
store_id = #{storeId}
and and
mchnt_cd = #{mchntCd} mchnt_cd = #{mchntCd}
limit 1 limit 1

View File

@ -187,13 +187,17 @@ public class MerchantConfigServiceImpl extends ServiceImpl<MerchantConfigMapper,
String lock = "MerchantConfig"+storeId+mchntCd; String lock = "MerchantConfig"+storeId+mchntCd;
redisLock.lock(lock); redisLock.lock(lock);
try { try {
if (ObjectUtil.isNotEmpty(mchntCd)) {
MerchantConfig config = baseMapper.getConfig(storeId,mchntCd); MerchantConfig config = baseMapper.getConfig(storeId,mchntCd);
if (ObjectUtil.isNotEmpty(config)) { if (ObjectUtil.isNotEmpty(config)) {
if (new BigDecimal(changeTheAmount).compareTo(new BigDecimal(config.getAmount().toString()))<=0) { if (new BigDecimal(changeTheAmount).compareTo(new BigDecimal(config.getAmount().toString()))<=0) {
baseMapper.subtractAmount(storeId, changeTheAmount); baseMapper.subtractAmount(config.getId(), Double.parseDouble(changeTheAmount));
} }
} }
}
}catch (Exception e){ }catch (Exception e){
e.printStackTrace();
return false; return false;
} finally { } finally {
redisLock.unlock(lock); redisLock.unlock(lock);

View File

@ -194,7 +194,7 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
} }
log.info("支付返回信息{}",refund); log.info("支付返回信息{}",refund);
// 处理退款结果 // 处理退款结果
if ("SUCCESS".equals(refund.get("result_msg"))) { if ("SUCCESS".equals(refund.get("result_msg")) || "订单已全额退款".equals(refund.get("result_msg")) ) {
// 修改该总订单的数据 // 修改该总订单的数据
allOrderInfo.setStatus("refund"); allOrderInfo.setStatus("refund");
allOrderInfo.setReasonRefund(map.get("refundRemark")); allOrderInfo.setReasonRefund(map.get("refundRemark"));
@ -224,7 +224,7 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
} }
if (!flag) { if (!flag) {
String mchntCd = refund.get("mchnt_cd"); String mchntCd = refund.get("mchnt_cd");
merchantConfigService.subtractAmount(allOrderInfo.getStoreId(), map.get("refundAmt"),mchntCd); merchantConfigService.subtractAmount(allOrderInfo.getStoreId(), allOrderInfo.getPayMoney().toString(),mchntCd);
} }
// 修改商户配置 // 修改商户配置