退款成功

This commit is contained in:
clunt 2022-10-12 14:40:14 +08:00
parent ff2c4e92be
commit 6640c56dc6
2 changed files with 23 additions and 14 deletions

View File

@ -7,6 +7,8 @@ import com.alibaba.fastjson.JSONObject;
import com.ghy.common.adapay.model.AdapayStatusEnum; import com.ghy.common.adapay.model.AdapayStatusEnum;
import com.ghy.common.adapay.model.PaymentDTO; import com.ghy.common.adapay.model.PaymentDTO;
import com.ghy.common.core.domain.AjaxResult; import com.ghy.common.core.domain.AjaxResult;
import com.ghy.common.enums.PayStatus;
import com.ghy.common.enums.PayTypeEnum;
import com.ghy.common.exception.base.BaseException; import com.ghy.common.exception.base.BaseException;
import com.ghy.common.utils.DateUtils; import com.ghy.common.utils.DateUtils;
import com.ghy.common.utils.ObjectUtils; import com.ghy.common.utils.ObjectUtils;
@ -122,7 +124,7 @@ public class AfterServiceRecordServiceImpl implements IAfterServiceRecordService
AfterServiceRecord afterServiceRecord = this.selectAfterServiceRecordById(param.getId()); AfterServiceRecord afterServiceRecord = this.selectAfterServiceRecordById(param.getId());
Assert.notNull(afterServiceRecord, "售后记录不存在!"); Assert.notNull(afterServiceRecord, "售后记录不存在!");
// 实际同意,需要发起退款减少原单分账金额-调用退款接口 // 实际同意,需要发起退款减少原单分账金额-调用退款接口
if(param.getCustomerFinalCheck() == 1){ if(param.getCustomerFinalCheck() != null && param.getCustomerFinalCheck() == 1){
OrderDetail orderDetail = orderDetailService.selectById(afterServiceRecord.getOrderDetailId()); OrderDetail orderDetail = orderDetailService.selectById(afterServiceRecord.getOrderDetailId());
Assert.notNull(orderDetail, "子单不存在!"); Assert.notNull(orderDetail, "子单不存在!");
FinancialDetail financialDetail = financialDetailService.selectByOrderDetailId(afterServiceRecord.getOrderDetailId()); FinancialDetail financialDetail = financialDetailService.selectByOrderDetailId(afterServiceRecord.getOrderDetailId());
@ -144,14 +146,17 @@ public class AfterServiceRecordServiceImpl implements IAfterServiceRecordService
Assert.notNull(orderMaster, "找不到对应的订单"); Assert.notNull(orderMaster, "找不到对应的订单");
FinancialMaster financialMaster = financialMasterService.selectByOrderMasterId(orderDetail.getOrderMasterId()); FinancialMaster financialMaster = financialMasterService.selectByOrderMasterId(orderDetail.getOrderMasterId());
Assert.notNull(financialMaster, "找不到订单"); Assert.notNull(financialMaster, "找不到订单");
Assert.isTrue(financialMaster.getPayStatus() == 1, "订单未支付"); if(PayTypeEnum.ALIPAY_QR.getCode().equals(orderMaster.getPayType()) && ! PayStatus.PAID.getCode().equals(financialMaster.getPayStatus())){
financialMaster.setPayMoney(financialMaster.getPayMoney().subtract(refundMoney));
financialMasterService.updateFinancialMaster(financialMaster);
financialDetailService.updateFinancialDetail(financialDetail);
}else {
Assert.hasText(financialMaster.getPaymentId(), "找不到订单的支付记录,请联系管理员"); Assert.hasText(financialMaster.getPaymentId(), "找不到订单的支付记录,请联系管理员");
JSONObject response = null; JSONObject response = null;
try { try {
response = adapayService.payReverse(orderMaster.getDeptId(), financialMaster.getPaymentId(), String.valueOf(refundMoney)); response = adapayService.payReverse(orderMaster.getDeptId(), financialMaster.getPaymentId(), String.valueOf(refundMoney));
if (AdapayStatusEnum.succeeded.code.equals(response.getString("status"))) { if (AdapayStatusEnum.succeeded.code.equals(response.getString("status"))) {
if (AdapayStatusEnum.succeeded.code.equals(response.getString("status"))) { if (AdapayStatusEnum.succeeded.code.equals(response.getString("status"))) {
afterServiceRecord.setCustomerFinalCheck(1L);
financialDetailService.updateFinancialDetail(financialDetail); financialDetailService.updateFinancialDetail(financialDetail);
} }
} }
@ -159,8 +164,9 @@ public class AfterServiceRecordServiceImpl implements IAfterServiceRecordService
throw new BaseException("发起退款异常!"); throw new BaseException("发起退款异常!");
} }
} }
afterServiceRecord.setUpdateTime(DateUtils.getNowDate()); }
return afterServiceRecordMapper.updateAfterServiceRecord(afterServiceRecord); param.setUpdateTime(DateUtils.getNowDate());
return afterServiceRecordMapper.updateAfterServiceRecord(param);
} }
/** /**

View File

@ -40,6 +40,9 @@
<if test="refund != null "> and refund = #{refund}</if> <if test="refund != null "> and refund = #{refund}</if>
<if test="agreedRefund != null "> and agreed_refund = #{agreedRefund}</if> <if test="agreedRefund != null "> and agreed_refund = #{agreedRefund}</if>
<if test="customerFinalCheck != null "> and customer_final_check = #{customerFinalCheck}</if> <if test="customerFinalCheck != null "> and customer_final_check = #{customerFinalCheck}</if>
<if test="customerFinalCheck == null">
and ( customer_final_check = '0' or customer_final_check is null )
</if>
</where> </where>
</select> </select>
@ -113,7 +116,7 @@
</delete> </delete>
<delete id="deleteAfterServiceRecordByIds" parameterType="String"> <delete id="deleteAfterServiceRecordByIds" parameterType="String">
delete from after_service_record where customer_final_check != 1 and id in delete from after_service_record where (customer_final_check is NULL or customer_final_check = 0) and id in
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>