Commit ecbce47d by 程裕兵

feat:bind cashier record

parent 3f4c105e
package com.jiejing.fitness.finance.api.cashier.request; package com.jiejing.fitness.finance.api.cashier.request;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.util.List; import java.util.List;
...@@ -30,4 +31,7 @@ public class BindStudioCashierRequest { ...@@ -30,4 +31,7 @@ public class BindStudioCashierRequest {
@NotBlank(message = "子订单号不能为空") @NotBlank(message = "子订单号不能为空")
private String subOrderNo; private String subOrderNo;
@ApiModelProperty(value = "扩展信息")
private JSONObject extra;
} }
package com.jiejing.fitness.finance.api.cashier.vo; package com.jiejing.fitness.finance.api.cashier.vo;
import com.alibaba.fastjson.JSONObject;
import com.jiejing.common.swagger.EnumMapping; import com.jiejing.common.swagger.EnumMapping;
import com.jiejing.fitness.enums.finance.BrandCashierTransStateEnum; import com.jiejing.fitness.enums.finance.BrandCashierTransStateEnum;
import com.jiejing.fitness.enums.finance.BrandCashierTransTypeEnum; import com.jiejing.fitness.enums.finance.BrandCashierTransTypeEnum;
......
...@@ -50,7 +50,7 @@ public class StudioCashierController implements StudioCashierApi { ...@@ -50,7 +50,7 @@ public class StudioCashierController implements StudioCashierApi {
@PostMapping(value = "/private/studioCashier/bind") @PostMapping(value = "/private/studioCashier/bind")
@Override @Override
public JsonResult<Void> bind(@Valid @RequestBody BindStudioCashierRequest request) { public JsonResult<Void> bind(@Valid @RequestBody BindStudioCashierRequest request) {
studioCashierService.bind(request.getIds(), request.getSubOrderNo()); studioCashierService.bind(request.getIds(), request.getSubOrderNo(), request.getExtra());
return JsonResult.success(); return JsonResult.success();
} }
......
...@@ -182,6 +182,11 @@ public class StudioCashierRecord implements Serializable { ...@@ -182,6 +182,11 @@ public class StudioCashierRecord implements Serializable {
private String failMessage; private String failMessage;
/** /**
* 扩展信息
*/
private String extra;
/**
* 备注: 交易发生时间 是否允许为null: YES * 备注: 交易发生时间 是否允许为null: YES
*/ */
private Date tradingTime; private Date tradingTime;
...@@ -259,6 +264,8 @@ public class StudioCashierRecord implements Serializable { ...@@ -259,6 +264,8 @@ public class StudioCashierRecord implements Serializable {
public static final String FAIL_MESSAGE = "fail_message"; public static final String FAIL_MESSAGE = "fail_message";
public static final String EXTRA = "extra";
public static final String TRADING_TIME = "trading_time"; public static final String TRADING_TIME = "trading_time";
public static final String SUCCESS_TIME = "success_time"; public static final String SUCCESS_TIME = "success_time";
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, trans_no, order_no, sub_order_no, order_type, trans_type, brand_id, studio_id, studio_name, merchant_id, merchant_no, channel_no, sub_channel, trans_amount, fee_rate, fee, actual_amount, trans_state, buyer_name, buyer_phone, goods, remark, exist_related_trans, related_trans_no, third_trans_no, fail_message, trading_time, success_time, in_time, create_time, update_time id, trans_no, order_no, sub_order_no, order_type, trans_type, brand_id, studio_id, studio_name, merchant_id, merchant_no, channel_no, sub_channel, trans_amount, fee_rate, fee, actual_amount, trans_state, buyer_name, buyer_phone, goods, remark, exist_related_trans, related_trans_no, third_trans_no, fail_message, extra, trading_time, success_time, in_time, create_time, update_time
</sql> </sql>
<select id="sumRefundActualAmountByPayTransNo" resultType="java.math.BigDecimal"> <select id="sumRefundActualAmountByPayTransNo" resultType="java.math.BigDecimal">
......
package com.jiejing.fitness.finance.service.cashier; package com.jiejing.fitness.finance.service.cashier;
import com.alibaba.fastjson.JSONObject;
import com.jiejing.common.model.PageVO; import com.jiejing.common.model.PageVO;
import com.jiejing.fitness.finance.api.cashier.vo.StudioCashierRecordVO; import com.jiejing.fitness.finance.api.cashier.vo.StudioCashierRecordVO;
import com.jiejing.fitness.finance.api.cashier.vo.StudioCashierStatisticVO; import com.jiejing.fitness.finance.api.cashier.vo.StudioCashierStatisticVO;
...@@ -29,7 +30,7 @@ public interface StudioCashierService { ...@@ -29,7 +30,7 @@ public interface StudioCashierService {
* @param ids 流水ID集合 * @param ids 流水ID集合
* @param subOrderNo 业务子订单号 * @param subOrderNo 业务子订单号
*/ */
void bind(List<Long> ids, String subOrderNo); void bind(List<Long> ids, String subOrderNo, JSONObject extra);
/** /**
* 解绑收银流水 * 解绑收银流水
......
package com.jiejing.fitness.finance.service.cashier.impl; package com.jiejing.fitness.finance.service.cashier.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jiejing.common.exception.BizException; import com.jiejing.common.exception.BizException;
import com.jiejing.common.model.PageVO; import com.jiejing.common.model.PageVO;
import com.jiejing.common.utils.collection.CollectionUtil; import com.jiejing.common.utils.collection.CollectionUtil;
...@@ -63,13 +64,15 @@ public class StudioCashierServiceImpl implements StudioCashierService { ...@@ -63,13 +64,15 @@ public class StudioCashierServiceImpl implements StudioCashierService {
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
@Override @Override
public void bind(List<Long> ids, String subOrderNo) { public void bind(List<Long> ids, String subOrderNo, JSONObject extra) {
List<StudioCashierRecord> records = studioCashierRecordRpService.getListByIds(ids); List<StudioCashierRecord> records = studioCashierRecordRpService.getListByIds(ids);
if (records.stream().anyMatch(e -> StringUtil.isNotBlank(e.getSubOrderNo()))) { if (records.stream().anyMatch(e -> StringUtil.isNotBlank(e.getSubOrderNo()))) {
throw new BizException(FinanceErrorEnums.EXIST_BIND_RECORD); throw new BizException(FinanceErrorEnums.EXIST_BIND_RECORD);
} }
studioCashierRecordRpService.updateByIds( studioCashierRecordRpService.updateByIds(
StudioCashierRecord.builder().subOrderNo(subOrderNo).updateTime(new Date()).build(), ids); StudioCashierRecord.builder().subOrderNo(subOrderNo)
.extra(Optional.ofNullable(extra).orElse(new JSONObject()).toJSONString())
.updateTime(new Date()).build(), ids);
} }
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
......
...@@ -21,6 +21,7 @@ import com.jiejing.fitness.finance.service.pay.params.StudioMerchantPayParams; ...@@ -21,6 +21,7 @@ import com.jiejing.fitness.finance.service.pay.params.StudioMerchantPayParams;
import com.jiejing.fitness.finance.service.utils.FeeUtil; import com.jiejing.fitness.finance.service.utils.FeeUtil;
import com.jiejing.fitness.finance.service.utils.MoneyUtil; import com.jiejing.fitness.finance.service.utils.MoneyUtil;
import com.jiejing.paycenter.common.model.vo.MerchantVO; import com.jiejing.paycenter.common.model.vo.MerchantVO;
import com.jiejing.paycenter.common.model.vo.PayVO;
import com.jiejing.paycenter.common.model.vo.SettleVO; import com.jiejing.paycenter.common.model.vo.SettleVO;
import com.jiejing.paycenter.common.model.vo.SubChannelVO; import com.jiejing.paycenter.common.model.vo.SubChannelVO;
import com.jiejing.paycenter.api.pay.request.PayRequest; import com.jiejing.paycenter.api.pay.request.PayRequest;
...@@ -60,7 +61,7 @@ public class PayConvert { ...@@ -60,7 +61,7 @@ public class PayConvert {
request.setTransNo(record.getTransNo()); request.setTransNo(record.getTransNo());
request.setMerchantId(record.getMerchantId()); request.setMerchantId(record.getMerchantId());
request.setChannelNo(record.getChannelNo()); request.setChannelNo(record.getChannelNo());
request.setExtra(new JSONObject() request.setExtra(Optional.ofNullable(params.getExtra()).orElse(new JSONObject())
.fluentPut("studioId", record.getStudioId()) .fluentPut("studioId", record.getStudioId())
.fluentPut("buyerName", record.getBuyerName()) .fluentPut("buyerName", record.getBuyerName())
.fluentPut("buyerPhone", record.getBuyerPhone()) .fluentPut("buyerPhone", record.getBuyerPhone())
...@@ -95,6 +96,7 @@ public class PayConvert { ...@@ -95,6 +96,7 @@ public class PayConvert {
.buyerPhone(params.getBuyerPhone()) .buyerPhone(params.getBuyerPhone())
.goods(params.getGoods()) .goods(params.getGoods())
.remark(params.getRemark()) .remark(params.getRemark())
.extra(Optional.ofNullable(params.getExtra()).orElse(new JSONObject()).toJSONString())
.existRelatedTrans(false) .existRelatedTrans(false)
.tradingTime(new Date()) .tradingTime(new Date())
.createTime(new Date()) .createTime(new Date())
...@@ -279,4 +281,17 @@ public class PayConvert { ...@@ -279,4 +281,17 @@ public class PayConvert {
.failMsg(vo.getFailMsg()) .failMsg(vo.getFailMsg())
.updateTime(new Date()).build(); .updateTime(new Date()).build();
} }
public static PayEvent convertEvent(PayRequest request, PayVO vo) {
return PayEvent.builder()
.id(Long.parseLong(vo.getTransNo()))
.transNo(vo.getTransNo())
.payState(vo.getPayState())
.channelNo(vo.getChannelNo())
.merchantId(request.getMerchantId())
.thirdTransNo(vo.getThirdTransNo())
.failMsg(vo.getFailMsg())
.finishTime(vo.getFinishTime())
.build();
}
} }
...@@ -39,8 +39,10 @@ import com.jiejing.fitness.finance.service.rpc.StudioRpcService; ...@@ -39,8 +39,10 @@ import com.jiejing.fitness.finance.service.rpc.StudioRpcService;
import com.jiejing.fitness.finance.service.utils.DingUtil; import com.jiejing.fitness.finance.service.utils.DingUtil;
import com.jiejing.fitness.finance.service.utils.FeeUtil; import com.jiejing.fitness.finance.service.utils.FeeUtil;
import com.jiejing.fitness.finance.service.utils.MoneyUtil; import com.jiejing.fitness.finance.service.utils.MoneyUtil;
import com.jiejing.message.event.SendCommonMsgEvent;
import com.jiejing.paycenter.common.enums.common.PayChannelEnums; import com.jiejing.paycenter.common.enums.common.PayChannelEnums;
import com.jiejing.paycenter.common.enums.common.TransStateEnums; import com.jiejing.paycenter.common.enums.common.TransStateEnums;
import com.jiejing.paycenter.common.enums.pay.PayStateEnums;
import com.jiejing.paycenter.common.enums.pay.PayTypeEnums; import com.jiejing.paycenter.common.enums.pay.PayTypeEnums;
import com.jiejing.paycenter.common.model.vo.MerchantVO; import com.jiejing.paycenter.common.model.vo.MerchantVO;
import com.jiejing.paycenter.api.pay.request.PayRequest; import com.jiejing.paycenter.api.pay.request.PayRequest;
...@@ -53,6 +55,7 @@ import com.jiejing.paycenter.common.model.vo.SettleVO; ...@@ -53,6 +55,7 @@ import com.jiejing.paycenter.common.model.vo.SettleVO;
import com.jiejing.studio.api.studio.vo.StudioVO; import com.jiejing.studio.api.studio.vo.StudioVO;
import com.jiejing.wechat.WeChatAuthService; import com.jiejing.wechat.WeChatAuthService;
import com.jiejing.wechat.vo.weChat.BaseAuthInfoVO; import com.jiejing.wechat.vo.weChat.BaseAuthInfoVO;
import com.xiaomai.event.EventAgent;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.Date; import java.util.Date;
...@@ -169,7 +172,9 @@ public class PayServiceImpl implements PayService { ...@@ -169,7 +172,9 @@ public class PayServiceImpl implements PayService {
record.setFee(FeeUtil.calPayFee(record.getFeeRate(), params.getTransAmount())); record.setFee(FeeUtil.calPayFee(record.getFeeRate(), params.getTransAmount()));
record.setActualAmount(MoneyUtil.subtract(params.getTransAmount(), record.getFee())); record.setActualAmount(MoneyUtil.subtract(params.getTransAmount(), record.getFee()));
studioCashierRecordRpService.insert(record); studioCashierRecordRpService.insert(record);
return payRpcService.pay(request); PayVO vo = payRpcService.pay(request);
this.payCallback(PayConvert.convertEvent(request, vo));
return vo;
} }
@Override @Override
...@@ -185,6 +190,10 @@ public class PayServiceImpl implements PayService { ...@@ -185,6 +190,10 @@ public class PayServiceImpl implements PayService {
StudioCashierRecord toModify = PayConvert.convertPay(record, event); StudioCashierRecord toModify = PayConvert.convertPay(record, event);
studioCashierRecordRpService.updateById(toModify); studioCashierRecordRpService.updateById(toModify);
if (PayStateEnums.SUCCESS.getCode().equals(event.getPayState())) {
this.sendPaySuccessMessage(event);
}
} }
@Override @Override
...@@ -357,6 +366,9 @@ public class PayServiceImpl implements PayService { ...@@ -357,6 +366,9 @@ public class PayServiceImpl implements PayService {
return req; return req;
} }
private void sendPaySuccessMessage(PayEvent event) {
// EventAgent.of(SendCommonMsgEvent.class).triggerEvent();
}
@Data @Data
private static class AliInfo { private static class AliInfo {
......
...@@ -86,4 +86,7 @@ public class StudioMerchantPayParams { ...@@ -86,4 +86,7 @@ public class StudioMerchantPayParams {
@NotNull(message = "过期时间不能为空") @NotNull(message = "过期时间不能为空")
private Integer timeExpire; private Integer timeExpire;
@ApiModelProperty(name = "业务扩展信息")
private JSONObject extra;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment