商户号退款
This commit is contained in:
parent
0fe66f0d65
commit
130f002dd1
@ -2,9 +2,9 @@ package com.fuint.api.fuyou.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
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> {
|
||||
MerchantConfig getConfig(@Param("storeId") Integer storeId,@Param("mchntCd") String mchntCd);
|
||||
int subtractAmount(@Param("storeId") Integer storeId,@Param("changeTheAmount") String changeTheAmount);
|
||||
MerchantConfig getConfig(@Param("storeId") Integer storeId, @Param("mchntCd") String mchntCd);
|
||||
int subtractAmount(@Param("id") Integer id,@Param("changeTheAmount") Double changeTheAmount);
|
||||
}
|
||||
|
@ -3,12 +3,13 @@
|
||||
<mapper namespace="com.fuint.api.fuyou.mapper.MerchantConfigMapper">
|
||||
<update id="subtractAmount">
|
||||
update Merchant_config set amount = amount-#{changeTheAmount}
|
||||
where store_id = #{storeId}
|
||||
where id = #{id}
|
||||
</update>
|
||||
<select id="getConfig" resultType="com.fuint.api.fuyou.entity.MerchantConfig">
|
||||
select *
|
||||
from Merchant_config
|
||||
where store_id = #{storeId}
|
||||
from merchant_config
|
||||
where
|
||||
store_id = #{storeId}
|
||||
and
|
||||
mchnt_cd = #{mchntCd}
|
||||
limit 1
|
||||
|
@ -187,13 +187,17 @@ public class MerchantConfigServiceImpl extends ServiceImpl<MerchantConfigMapper,
|
||||
String lock = "MerchantConfig"+storeId+mchntCd;
|
||||
redisLock.lock(lock);
|
||||
try {
|
||||
MerchantConfig config = baseMapper.getConfig(storeId,mchntCd);
|
||||
if (ObjectUtil.isNotEmpty(config)) {
|
||||
if (new BigDecimal(changeTheAmount).compareTo(new BigDecimal(config.getAmount().toString()))<=0) {
|
||||
baseMapper.subtractAmount(storeId, changeTheAmount);
|
||||
if (ObjectUtil.isNotEmpty(mchntCd)) {
|
||||
MerchantConfig config = baseMapper.getConfig(storeId,mchntCd);
|
||||
if (ObjectUtil.isNotEmpty(config)) {
|
||||
if (new BigDecimal(changeTheAmount).compareTo(new BigDecimal(config.getAmount().toString()))<=0) {
|
||||
baseMapper.subtractAmount(config.getId(), Double.parseDouble(changeTheAmount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
redisLock.unlock(lock);
|
||||
|
@ -194,7 +194,7 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
|
||||
}
|
||||
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.setReasonRefund(map.get("refundRemark"));
|
||||
@ -224,7 +224,7 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
|
||||
}
|
||||
if (!flag) {
|
||||
String mchntCd = refund.get("mchnt_cd");
|
||||
merchantConfigService.subtractAmount(allOrderInfo.getStoreId(), map.get("refundAmt"),mchntCd);
|
||||
merchantConfigService.subtractAmount(allOrderInfo.getStoreId(), allOrderInfo.getPayMoney().toString(),mchntCd);
|
||||
|
||||
}
|
||||
// 修改商户配置
|
||||
|
Loading…
Reference in New Issue
Block a user