补充大师傅的子订单的提现时间

This commit is contained in:
Hawking 2023-05-18 21:18:43 +08:00
parent 08b50407dd
commit 12438386bd
6 changed files with 37 additions and 12 deletions

View File

@ -74,6 +74,8 @@ public class AdapaySyncTimer {
String orderNo = AdapayUtils.createOrderNo(AdapayOrderType.DRAW_CASH);
JSONObject drawCash = adapayService.drawCash(deptId, orderNo, "T1", avlBalance, memberId, "提现", null);
log.info("Worker[{},{}]提现结果: {}", workerBank.getWorkerId(), workerBank.getName(), drawCash.toJSONString());
} else {
log.error("Worker[{},{}]查询账户余额失败: {}", workerBank.getWorkerId(), workerBank.getName(), accountBalance.toJSONString());
}
} catch (BaseAdaPayException e) {
log.error(e.getMessage(), e);
@ -101,6 +103,8 @@ public class AdapaySyncTimer {
String orderNo = AdapayUtils.createOrderNo(AdapayOrderType.DRAW_CASH);
JSONObject drawCash = adapayService.drawCash(deptId, orderNo, "T1", avlBalance, memberId, "提现", null);
log.info("Customer[{},{}]提现结果: {}", customer.getCustomerId(), customer.getName(), drawCash.toJSONString());
} else {
log.error("Customer[{},{}]查询账户余额失败: {}", customer.getCustomerId(), customer.getName(), accountBalance.toJSONString());
}
} catch (BaseAdaPayException e) {
log.error(e.getMessage(), e);
@ -108,6 +112,9 @@ public class AdapaySyncTimer {
}
}
/**
* 定时同步提现状态
*/
@Scheduled(fixedRate = 5 * 60 * 1000L)
public void syncDrawCash() {
List<DrawCashRecord> records = drawCashRecordMapper.selectByStatus("pending");
@ -147,7 +154,7 @@ public class AdapaySyncTimer {
// 更新提现记录表状态
drawCashRecordMapper.updateStatus(record.getId(), "succeeded");
// 更新子订单表状态
orderDetailService.updateDrawCashStatus(record.getId(), 2, new Date());
orderDetailService.updateDrawCashStatus(record.getId(), 2, null, new Date());
break;
// 提现失败
case "F":
@ -155,7 +162,7 @@ public class AdapaySyncTimer {
// 更新提现记录表状态
drawCashRecordMapper.updateStatus(record.getId(), "failed");
// 更新子订单表状态
orderDetailService.updateDrawCashStatus(record.getId(), -1, null);
orderDetailService.updateDrawCashStatus(record.getId(), -1, null, null);
break;
default:
break;

View File

@ -106,10 +106,12 @@ public interface OrderDetailMapper {
*
* @param drawCashId 发起提现后Adapay返回的对象ID
* @param drawCashStatus 提现状态见{@link OrderDetail#getDrawCashStatus()}
* @param drawCashTime 发起提现时间
* @param arrivalTime 提现到账时间
* @return 1
*/
int updateDrawCashStatus(@Param("drawCashId") String drawCashId, @Param("drawCashStatus") int drawCashStatus, @Param("arrivalTime") Date arrivalTime);
int updateDrawCashStatus(@Param("drawCashId") String drawCashId, @Param("drawCashStatus") int drawCashStatus,
@Param("drawCashTime") Date drawCashTime, @Param("arrivalTime") Date arrivalTime);
int deleteByMaster(Long masterId);
}

View File

@ -143,10 +143,11 @@ public interface OrderDetailService {
*
* @param drawCashId 发起提现后Adapay返回的对象ID
* @param drawCashStatus 提现状态见{@link OrderDetail#getDrawCashStatus()}
* @param drawCashTime 发起提现时间
* @param arrivalTime 提现到账时间
* @return 1
*/
int updateDrawCashStatus(String drawCashId, int drawCashStatus, Date arrivalTime);
int updateDrawCashStatus(String drawCashId, int drawCashStatus, Date drawCashTime, Date arrivalTime);
/**
* 退款成功时 退款回调接口里会调用这个方法

View File

@ -746,8 +746,8 @@ public class OrderDetailServiceImpl implements OrderDetailService {
}
@Override
public int updateDrawCashStatus(String drawCashId, int drawCashStatus, Date arrivalTime) {
return orderDetailMapper.updateDrawCashStatus(drawCashId, drawCashStatus, arrivalTime);
public int updateDrawCashStatus(String drawCashId, int drawCashStatus, Date drawCashTime, Date arrivalTime) {
return orderDetailMapper.updateDrawCashStatus(drawCashId, drawCashStatus, drawCashTime, arrivalTime);
}
@Override

View File

@ -307,7 +307,16 @@ public class OrderMasterServiceImpl implements OrderMasterService {
}
String amount = member.getAmount();
try {
drawCash(orderMaster.getDeptId(), memberId, amount);
String drawCashId = drawCash(orderMaster.getDeptId(), memberId, amount);
if (drawCashId != null) {
// 给大师傅的子单设置提现状态和提现时间 2023/5/18
for (OrderDetail orderDetail : orderDetails) {
if (orderMaster.getWorkerId().equals(orderDetail.getWorkerId())) {
orderDetailService.updateDrawCashStatus(drawCashId, 1, new Date(), null);
}
}
}
} catch (BaseAdaPayException e) {
logger.error("自动发起提现失败: orderMasterId={}, memberId={}, cashAmt={}", orderMasterId, memberId, amount, e);
}
@ -321,15 +330,18 @@ public class OrderMasterServiceImpl implements OrderMasterService {
* @param memberId Adapay实名账户ID
* @param amount 提现金额
*/
private void drawCash(Long deptId, String memberId, String amount) throws BaseAdaPayException {
private String drawCash(Long deptId, String memberId, String amount) throws BaseAdaPayException {
String orderNo = AdapayUtils.createOrderNo(AdapayOrderType.DRAW_CASH);
JSONObject response = adapayService.drawCash(deptId, orderNo, "T1", amount, memberId, "订单结算", null);
boolean status = AdapayStatusEnum.pending.code.equals(response.getString("status")) ||
AdapayStatusEnum.succeeded.code.equals(response.getString("status"));
if (!status) {
if (status) {
return response.getString("id");
} else {
//如果提现失败 把信息记录到error日志里
logger.error("提现失败: deptId={}, memberId={}, amount={}, 失败原因:{}", deptId, memberId, amount, response.getString("error_msg"));
return null;
}
}

View File

@ -392,9 +392,12 @@
</select>
<update id="updateDrawCashStatus">
UPDATE order_detail
SET draw_cash_status = #{drawCashStatus},
arrival_time = #{arrivalTime}
UPDATE order_detail SET
<if test="drawCashId != null">draw_cash_id = #{drawCashId},</if>
<if test="drawCashTime != null">draw_cash_time = #{drawCashTime},</if>
<if test="arrivalTime != null">arrival_time = #{arrivalTime},</if>
<if test="drawCashStatus != null">draw_cash_status = #{drawCashStatus},</if>
update_time = NOW()
WHERE draw_cash_id = #{drawCashId}
</update>
</mapper>