Authored by Lixiaodi

提交商家充值

... ... @@ -14,4 +14,11 @@ public interface EntrySellerRechargeOrderMapper {
int updateByPrimaryKeySelective(EntrySellerRechargeOrder record);
int updateByPrimaryKey(EntrySellerRechargeOrder record);
void updateByOrderCode(EntrySellerRechargeOrder order);
EntrySellerRechargeOrder selectByOrderCodeUid(long orderCode, int uid);
EntrySellerRechargeOrder selectByOrderCode(long orderCode);
}
\ No newline at end of file
... ...
... ... @@ -54,4 +54,6 @@ public interface OrdersPayMapper {
* @mbggenerated
*/
int updateByPrimaryKey(OrdersPay record);
int addMoney(OrdersPay record);
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order;
import org.apache.ibatis.annotations.Param;
import com.yohoufo.dal.order.model.SellerWallet;
public interface SellerWalletMapper {
... ... @@ -14,4 +16,11 @@ public interface SellerWalletMapper {
int updateByPrimaryKeySelective(SellerWallet record);
int updateByPrimaryKey(SellerWallet record);
SellerWallet selectByUidAndType(@Param("uid") Integer uid, @Param("type") int type);
int addMoney(SellerWallet sw);
int returnMoney(SellerWallet sw);
}
\ No newline at end of file
... ...
... ... @@ -9,9 +9,9 @@ public class SellerWallet {
private BigDecimal amount;
private Byte status;
private Integer status;
private Byte type;
private Integer type;
private Integer createTime;
... ... @@ -41,19 +41,19 @@ public class SellerWallet {
this.amount = amount;
}
public Byte getStatus() {
public Integer getStatus() {
return status;
}
public void setStatus(Byte status) {
public void setStatus(Integer status) {
this.status = status;
}
public Byte getType() {
public Integer getType() {
return type;
}
public void setType(Byte type) {
public void setType(Integer type) {
this.type = type;
}
... ...
... ... @@ -13,7 +13,7 @@ public class SellerWalletDetail {
private BigDecimal amount;
private Byte type;
private Integer type;
private Integer createTime;
... ... @@ -59,11 +59,11 @@ public class SellerWalletDetail {
this.amount = amount;
}
public Byte getType() {
public Integer getType() {
return type;
}
public void setType(Byte type) {
public void setType(Integer type) {
this.type = type;
}
... ...
... ... @@ -138,4 +138,34 @@
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByOrderCode" parameterType="com.yohoufo.dal.order.model.BuyerOrder">
update entry_seller_recharge_order
set
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="payment != null">
payment = #{payment,jdbcType=INTEGER},
</if>
update_time = #{updateTime,jdbcType=INTEGER}
where order_code = #{orderCode,jdbcType=BIGINT}
</update>
<select id="selectByOrderCodeUid" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from entry_seller_recharge_order
where order_code = #{orderCode,jdbcType=BIGINT}
and uid = #{uid,jdbcType=INTEGER}
limit 1
</select>
<select id="selectByOrderCode" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from entry_seller_recharge_order
where order_code = #{orderCode,jdbcType=BIGINT}
limit 1
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -188,4 +188,9 @@
create_time = #{createTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="addMoney" parameterType="com.yohoufo.dal.order.model.OrdersPay" >
update orders_pay set amount = amount + #{amount,jdbcType=DECIMAL},update_time = #{updateTime,jdbcType=INTEGER} where order_code = #{orderCode,jdbcType=BIGINT}
and uid = #{uid,jdbcType=INTEGER} and amount + #{amount,jdbcType=DECIMAL} &gt;= 0
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -24,7 +24,7 @@
delete from seller_wallet_detail
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yohoufo.dal.order.model.SellerWalletDetail" >
<insert id="insert" parameterType="com.yohoufo.dal.order.model.SellerWalletDetail" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into seller_wallet_detail (id, wallet_id, uid,
order_code, amount, type,
create_time, update_time)
... ... @@ -32,7 +32,7 @@
#{orderCode,jdbcType=BIGINT}, #{amount,jdbcType=DECIMAL}, #{type,jdbcType=TINYINT},
#{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yohoufo.dal.order.model.SellerWalletDetail" >
<insert id="insertSelective" parameterType="com.yohoufo.dal.order.model.SellerWalletDetail" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into seller_wallet_detail
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
... ...
... ... @@ -5,8 +5,8 @@
<id column="id" property="id" jdbcType="INTEGER" />
<result column="uid" property="uid" jdbcType="INTEGER" />
<result column="amount" property="amount" jdbcType="DECIMAL" />
<result column="status" property="status" jdbcType="TINYINT" />
<result column="type" property="type" jdbcType="TINYINT" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="type" property="type" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
... ... @@ -23,15 +23,15 @@
delete from seller_wallet
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yohoufo.dal.order.model.SellerWallet" >
<insert id="insert" parameterType="com.yohoufo.dal.order.model.SellerWallet" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into seller_wallet (id, uid, amount,
status, type, create_time,
update_time)
values (#{id,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER}, #{amount,jdbcType=DECIMAL},
#{status,jdbcType=TINYINT}, #{type,jdbcType=TINYINT}, #{createTime,jdbcType=INTEGER},
#{status,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER},
#{updateTime,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yohoufo.dal.order.model.SellerWallet" >
<insert id="insertSelective" parameterType="com.yohoufo.dal.order.model.SellerWallet" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into seller_wallet
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
... ... @@ -67,10 +67,10 @@
#{amount,jdbcType=DECIMAL},
</if>
<if test="status != null" >
#{status,jdbcType=TINYINT},
#{status,jdbcType=INTEGER},
</if>
<if test="type != null" >
#{type,jdbcType=TINYINT},
#{type,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
... ... @@ -90,10 +90,10 @@
amount = #{amount,jdbcType=DECIMAL},
</if>
<if test="status != null" >
status = #{status,jdbcType=TINYINT},
status = #{status,jdbcType=INTEGER},
</if>
<if test="type != null" >
type = #{type,jdbcType=TINYINT},
type = #{type,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
... ... @@ -108,10 +108,25 @@
update seller_wallet
set uid = #{uid,jdbcType=INTEGER},
amount = #{amount,jdbcType=DECIMAL},
status = #{status,jdbcType=TINYINT},
type = #{type,jdbcType=TINYINT},
status = #{status,jdbcType=INTEGER},
type = #{type,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByUidAndType" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from seller_wallet
where uid = #{uid,jdbcType=INTEGER} and type = #{type,jdbcType=INTEGER}
</select>
<update id="addMoney" parameterType="com.yohoufo.dal.order.model.SellerWallet" >
update seller_wallet set amount = amount + #{amount,jdbcType=DECIMAL},update_time = #{updateTime,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER} and amount + #{amount,jdbcType=DECIMAL} &gt;= 0 and status=1
</update>
<update id="returnMoney" parameterType="com.yohoufo.dal.order.model.SellerWallet" >
update seller_wallet set amount = 0 ,status = 0,update_time = #{updateTime,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER} and amount = #{amount,jdbcType=DECIMAL} and status=1
</update>
</mapper>
\ No newline at end of file
... ...
package com.yohoufo.order.common;
public enum Payment {
WALLET(11, "wallet", "钱包"),
MINIAPP(3, "miniapp", "微信小程序"),
ALIPAY(2, "alipay", "支付宝"),
WECHAT(1, "wechat", "微信");
... ...
package com.yohoufo.order.service;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohoufo.common.alarm.CommonAlarmEventPublisher;
import com.yohoufo.common.utils.TimeUtils;
import com.yohoufo.dal.order.EntrySellerRechargeOrderMapper;
import com.yohoufo.dal.order.OrdersPayMapper;
import com.yohoufo.dal.order.SellerWalletDetailMapper;
import com.yohoufo.dal.order.SellerWalletMapper;
import com.yohoufo.dal.order.model.EntrySellerRechargeOrder;
import com.yohoufo.dal.order.model.OrdersPay;
import com.yohoufo.dal.order.model.SellerWallet;
import com.yohoufo.dal.order.model.SellerWalletDetail;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.model.request.PaymentRequest;
import com.yohoufo.order.model.response.PrepayResponse;
import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.service.cache.CacheKeyBuilder;
@Service
public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
private final Logger logger = LoggerFactory.getLogger(getClass());
private static final int TYPE_FIRST_RECHARGE = 1;
@Autowired
SellerWalletMapper sellerWalletMapper;
@Autowired
SellerWalletDetailMapper sellerWalletDetailMapper;
@Autowired
EntrySellerRechargeOrderMapper entrySellerRechargeOrderMapper;
@Autowired
OrdersPayMapper ordersPayDao;
@Autowired
private CacheCleaner cacheCleaner;
/**
* 更新订单状态
* @param orderInfo
*/
public void updateOrderStatusPaid(OrderInfo orderInfo) {
EntrySellerRechargeOrder order = new EntrySellerRechargeOrder();
order.setOrderCode(orderInfo.getOrderCode());
order.setStatus(OrderStatus.HAS_PAYED.getCode());
order.setUpdateTime(DateUtil.getCurrentTimeSecond());
// order.setPayment(orderInfo.getPayment());
entrySellerRechargeOrderMapper.updateByOrderCode(order);
orderInfo.setStatus(OrderStatus.HAS_PAYED.getCode());
}
@Override
public void processAfterPay(OrderInfo orderInfo) {
// 首次充值,调用认证成功接口
if (orderInfo.getType() == TYPE_FIRST_RECHARGE) {
// TODO
}
BigDecimal amount = orderInfo.getAmount();
SellerWallet sw = sellerWalletMapper.selectByUidAndType(orderInfo.getUid(), 1);
if (orderInfo.getType() == TYPE_FIRST_RECHARGE) {
if (sw != null) {
logger.error("首次充值保证金余额{},发现钱包已存在,uid={}", amount, orderInfo.getUid());
CommonAlarmEventPublisher.publish("首次充值保证金余额失败", "ufo.order.recharge", "钱包已存在:uid=" + orderInfo.getUid() + ",充值订单号为:" + orderInfo.getOrderCode()+", 充值金额为:"+amount);
return;
}
// 首次充值,创建钱包信息
sw = new SellerWallet();
sw.setUid(orderInfo.getUid());
sw.setAmount(orderInfo.getAmount());
sw.setStatus(1);
sw.setType(1);
sw.setCreateTime(TimeUtils.getTimeStampSecond());
sw.setUpdateTime(0);
sellerWalletMapper.insert(sw);
} else {
// 修改钱包余额
if (sw == null) {
logger.error("充值保证金余额{},钱包不存在,uid={}", amount, orderInfo.getUid());
CommonAlarmEventPublisher.publish("充值保证金余额失败", "ufo.order.recharge", "钱包不存在uid=" + orderInfo.getUid() + ",充值订单号为:" + orderInfo.getOrderCode()+", 充值金额为:"+amount);
return;
}
if (sw.getStatus() == null || sw.getStatus() == 0) {
logger.error("充值保证金余额{},钱包不可用,uid={}", amount, orderInfo.getUid());
CommonAlarmEventPublisher.publish("充值保证金余额失败", "ufo.order.recharge", "钱包不可用uid=" + orderInfo.getUid() + ",充值订单号为:" + orderInfo.getOrderCode()+", 充值金额为:"+amount);
return;
}
sw.setAmount(orderInfo.getAmount());
sw.setUpdateTime(TimeUtils.getTimeStampSecond());
if (sellerWalletMapper.addMoney(sw) == 0) {
logger.error("充值保证金余额{},更新表返回0,uid={}", amount, orderInfo.getUid());
CommonAlarmEventPublisher.publish("充值保证金余额失败", "ufo.order.recharge", "更新表返回0,uid=" + orderInfo.getUid() + ",充值订单号为:" + orderInfo.getOrderCode()+", 充值金额为:"+amount);
return;
}
}
// 增加充值记录
SellerWalletDetail swd = new SellerWalletDetail();
swd.setOrderCode(orderInfo.getOrderCode());
swd.setType(1);
swd.setUid(orderInfo.getUid());
swd.setWalletId(sw.getId());
swd.setAmount(orderInfo.getAmount());
swd.setCreateTime(TimeUtils.getTimeStampSecond());
sellerWalletDetailMapper.insert(swd);
cacheCleaner.delete(Arrays.asList(
CacheKeyBuilder.orderListKey(orderInfo.getUid(), TabType.BUY.getValue()),
CacheKeyBuilder.orderDetailKey(orderInfo.getUid(), TabType.BUY.getValue(), orderInfo.getOrderCode())));
}
/**
* 订单是否是待支付状态
* @param orderInfo
* @return
*/
public boolean isOrderWaitingPay(OrderInfo orderInfo){
if (orderInfo.getStatus() != null && orderInfo.getStatus().intValue() == OrderStatus.WAITING_PAY.getCode()){
return true;
}
return false;
}
/**
* 订单是 已支付的订单
* @param orderInfo
* @return
*/
public boolean isOrderPaid(OrderInfo orderInfo){
if (orderInfo.getStatus() != null && orderInfo.getStatus().intValue() == OrderStatus.HAS_PAYED.getCode()){
return true;
}
return false;
}
final static List<Integer> canRefundStatusList = Arrays.asList(OrderStatus.SELLER_CANCEL_AFTER_PAY.getCode(),
OrderStatus.SEND_OUT_TIMEOUT.getCode(), OrderStatus.CHECKING_FAKE.getCode());
@Override
public boolean canRefund(OrderInfo orderInfo) {
if (orderInfo.getStatus() != null && canRefundStatusList.contains(orderInfo.getStatus().intValue())){
return true;
}
return false;
}
/**
* 保存前回预支付结果
* @param orderInfo
* @param response
*/
public void saveAppPayRequest(OrderInfo orderInfo, PrepayResponse response) {
}
/**
* 获取前回的访问结果
* @param request
* @return
*/
public PrepayResponse getAppPayRequest(PaymentRequest request) {
return null;
}
/**
* 检查状态
* @param orderInfo
*/
public void checkOrderStatus(OrderInfo orderInfo){
// 订单不是未付款的状态
if (orderInfo.getStatus() == null || orderInfo.getStatus().intValue() != OrderStatus.WAITING_PAY.getCode()){
logger.warn("payment status not allow {}, orderCode is {}, uid is {}", orderInfo.getStatus(),
orderInfo.getOrderCode(), orderInfo.getUid());
throw new ServiceException(ServiceError.ORDER_PAY_NOT_ALLOW);
}
}
/**
* 预支付方式更新
* @param orderInfo
*/
public void updatePayment(OrderInfo orderInfo, int payment){
EntrySellerRechargeOrder order = new EntrySellerRechargeOrder();
order.setOrderCode(orderInfo.getOrderCode());
order.setUid(orderInfo.getUid());
// 更新预支付方式
order.setPayment(payment);
order.setUpdateTime(DateUtil.getCurrentTimeSecond());
entrySellerRechargeOrderMapper.updateByOrderCode(order);
}
/**
* 获取订单情报
* @param orderCode
* @param uid
* @return
*/
public OrderInfo getOrderInfo(long orderCode, int uid) {
EntrySellerRechargeOrder order = entrySellerRechargeOrderMapper.selectByOrderCodeUid(orderCode, uid);
if (order == null){
logger.warn("getOrderInfo order not exist, orderCode is {}, uid is {}", orderCode, uid);
throw new ServiceException(ServiceError.ORDER_NULL);
}
return buildOrderInfo(order);
}
private OrderInfo buildOrderInfo(EntrySellerRechargeOrder order) {
OrderInfo orderInfo = OrderInfo.builder()
.id(order.getId())
.uid(order.getUid())
.orderCode(order.getOrderCode())
.payment(order.getPayment())
.status(order.getStatus())
.amount(order.getAmount())
.createTime(order.getCreateTime())
.orderCodeType(OrderCodeType.BUYER_TYPE)
.sourceStatus(order.getStatus())
.type(order.getType())
.build();
return orderInfo;
}
/**
* 获取订单情报
* @param orderCode
* @return
*/
public OrderInfo getOrderInfo(long orderCode) {
EntrySellerRechargeOrder buyerOrder = entrySellerRechargeOrderMapper.selectByOrderCode(orderCode);
if (buyerOrder == null){
logger.warn("getOrderInfo order not exist, orderCode is {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
return buildOrderInfo(buyerOrder);
}
// 支付保证金:总账修改
public SellerWallet useEarnest(Integer uid, BigDecimal money) {
return changeEarnest(uid, money, "支付保证金");
}
// 修改价格保证金差价:总账修改
public SellerWallet changePriceUseEarnest(Integer uid, BigDecimal money) {
return changeEarnest(uid, money, "支付保证金(修改价格)");
}
// 退还保证金:总账修改
public SellerWallet cancelRefundEarnest(Integer uid, BigDecimal money) {
return changeEarnest(uid, money, "退还保证金");
}
// 支付保证金:明细
public void addUseEarnestDetail(SellerWallet sw, BigDecimal money) {
long orderCode = 0;
BigDecimal amount = null;
Integer uid = sw.getId();
SellerWalletDetail swd = new SellerWalletDetail();
swd.setOrderCode(orderCode);
swd.setType(2);
swd.setUid(uid);
swd.setWalletId(sw.getId());
swd.setAmount(amount);
swd.setCreateTime(TimeUtils.getTimeStampSecond());
sellerWalletDetailMapper.insert(swd);
}
// 退还保证金
public void refundEarnestDetail(SellerWallet sw, long orderCode, BigDecimal amount) {
SellerWalletDetail swd = new SellerWalletDetail();
swd.setOrderCode(orderCode);
swd.setType(3); // 单笔退还
swd.setUid(sw.getUid());
swd.setWalletId(sw.getId());
swd.setAmount(amount);
swd.setCreateTime(TimeUtils.getTimeStampSecond());
sellerWalletDetailMapper.insert(swd);
}
// 退出入驻:归还所有保证金 总账+明细
public BigDecimal returnEarnest(Integer uid, long orderCode) {
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
if (sw == null) {
logger.error("退还所有保证金,钱包不存在,uid={}", uid);
CommonAlarmEventPublisher.publish("退还所有保证金失败", "ufo.order.recharge", "钱包不存在uid=" + uid);
return null;
}
BigDecimal amount = sw.getAmount();
if (sw.getStatus() == null || sw.getStatus() == 0) {
logger.error("退还所有保证金{},钱包不可用,uid={}", amount, uid);
CommonAlarmEventPublisher.publish("退还所有保证金失败", "ufo.order.recharge", "钱包不可用uid=" + uid+", 退还金额为:"+amount);
return null;
}
sw.setAmount(amount);
sw.setUpdateTime(TimeUtils.getTimeStampSecond());
if (sellerWalletMapper.returnMoney(sw) == 0) {
logger.error("退还所有证金失败,更新表返回0,uid={}", uid);
CommonAlarmEventPublisher.publish("退还所有保证金失败", "ufo.order.recharge", "更新表返回0,uid=" + uid + ", 退还金额为:"+ amount);
return null;
}
// 增加充值记录
SellerWalletDetail swd = new SellerWalletDetail();
swd.setOrderCode(orderCode);
swd.setType(5);// 退还所有保证金
swd.setUid(uid);
swd.setWalletId(sw.getId());
swd.setAmount(amount);
swd.setCreateTime(TimeUtils.getTimeStampSecond());
sellerWalletDetailMapper.insert(swd);
return amount;
}
private SellerWallet changeEarnest(Integer uid, BigDecimal money, String message) {
// 使用钱包余额,支付保证金
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
if (sw == null) {
logger.error(message + "失败,钱包不存在,uid={}", uid);
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.recharge", "钱包不存在uid=" + uid+", 金额为:"+money);
return null;
}
if (sw.getStatus() == null || sw.getStatus() == 0) {
logger.error(message + "{}失败,钱包不可用,uid={}", money, uid);
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.recharge", "钱包不可用uid=" + uid+", 金额为:"+money);
return null;
}
if (sw.getAmount().compareTo(money) < 0) {
logger.error(message + "{}失败,钱包余额不足,uid={}", money, uid);
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.recharge", "钱包余额不足uid=" + uid+", 金额为:"+money+", 账户余额为:"+sw.getAmount());
return null;
}
sw.setAmount(money.multiply(new BigDecimal("-1")));
sw.setUpdateTime(TimeUtils.getTimeStampSecond());
if (sellerWalletMapper.addMoney(sw) == 0) {
logger.error(message + "失败,(并发)更新表返回0,uid={}", uid);
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.recharge", "(并发)更新表返回0,uid=" + uid + ", 金额为:"+ money);
return null;
}
return sw;
}
public void addOrdersPay(SellerWalletDetail swd) {
// 增加支付记录
OrdersPay ordersPay = new OrdersPay();
ordersPay.setOrderCode(swd.getOrderCode());
ordersPay.setUid(swd.getUid());
ordersPay.setPayment(Payment.WALLET.getCode());
ordersPay.setAmount(swd.getAmount());
ordersPay.setPayOrderCode(String.valueOf(swd.getOrderCode()));
ordersPay.setSerialNo(Integer.toString(swd.getId()));
ordersPay.setCreateTime(TimeUtils.getTimeStampSecond());
JSONObject attach = new JSONObject();
attach.put("order_type", OrderCodeType.SELLER_TYPE.getType());
ordersPay.setAttach(attach.toJSONString());
ordersPayDao.insertSelective(ordersPay);
}
public void changePriceUpdateOrdersPay(SellerWalletDetail swd) {
// 增加支付记录
OrdersPay ordersPay = new OrdersPay();
ordersPay.setOrderCode(swd.getOrderCode());
ordersPay.setUid(swd.getUid());
ordersPay.setAmount(swd.getAmount());
String message = "修改保证金order_pay记录金额";
if (ordersPayDao.addMoney(ordersPay) == 0) {
logger.error(message + "{}失败,修改DB返回记录数为0,orderCode={}", swd.getAmount(), swd.getOrderCode());
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.changePriceOrdersPay", "修改DB返回记录数为0,orderCode=" + swd.getOrderCode()+", 金额为:"+swd.getAmount());
}
}
}
... ...
... ... @@ -29,10 +29,12 @@ import com.yohoufo.order.model.response.PrepayResponse;
import com.yohoufo.order.service.AbstractOrderPaymentService;
import com.yohoufo.order.service.BuyerOrderPaymentService;
import com.yohoufo.order.service.IPaymentService;
import com.yohoufo.order.service.MerchantOrderPaymentService;
import com.yohoufo.order.service.SellerOrderPaymentService;
import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler;
import com.yohoufo.order.service.pay.AbstractPayService;
import com.yohoufo.order.service.pay.alipay.AlipayOuyinService;
import com.yohoufo.order.service.pay.wallet.WalletPayService;
import com.yohoufo.order.service.pay.weixin.WeixinMiniappPayService;
import com.yohoufo.order.service.pay.weixin.WeixinPayUFORealAppService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
... ... @@ -74,6 +76,9 @@ public class PaymentServiceImpl implements IPaymentService {
@Autowired
SellerOrderPaymentService sellerOrderPaymentService;
@Autowired
MerchantOrderPaymentService merchantOrderPaymentService;
@Autowired
OrderCodeGenerator orderCodeGenerator;
... ... @@ -109,6 +114,9 @@ public class PaymentServiceImpl implements IPaymentService {
WeixinMiniappPayService weixinMiniappPayService;
@Autowired
WalletPayService walletPayService;
@Autowired
BuyerOrderMapper buyerOrderMapper;
@Autowired
... ... @@ -144,8 +152,7 @@ public class PaymentServiceImpl implements IPaymentService {
}else if(codeMeta.getType() == OrderCodeType.SELLER_TYPE.getType()){
paymentService = this.sellerOrderPaymentService;
}else if(codeMeta.getType() == OrderCodeType.SELLER_RECHARGE_EARNEST_TYPE.getType()){
// TODO
paymentService = this.sellerOrderPaymentService;
paymentService = this.merchantOrderPaymentService;
}
return paymentService;
... ... @@ -173,6 +180,8 @@ public class PaymentServiceImpl implements IPaymentService {
payService = alipayService;
}else if(payment == Payment.MINIAPP){
payService = weixinMiniappPayService;
}else if(payment == Payment.WALLET){
payService = walletPayService;
}
return payService;
... ... @@ -283,7 +292,7 @@ public class PaymentServiceImpl implements IPaymentService {
ordersPayDao.insertSelective(ordersPay);
// 支付方式适配
// 流水记录表支付方式适配
Integer recordPayment = orderInfo.getPayment();
if (recordPayment != null && recordPayment == 1) {
if (recordPayment == 1) {
... ... @@ -300,7 +309,10 @@ public class PaymentServiceImpl implements IPaymentService {
}
addPayBuyRecord(orderInfo.getUid(), orderInfo.getSellerUid(), goods.getSkup(), orderCode, recordPayment,
ordersPay.getAmount());
} else {
} else if (codeMeta.getType() == OrderCodeType.SELLER_TYPE.getType()) {
addPayEnsureRecord(orderInfo.getUid(), orderInfo.getSkup(), orderCode, recordPayment,
ordersPay.getAmount());
} else if (codeMeta.getType() == OrderCodeType.SELLER_RECHARGE_EARNEST_TYPE.getType()) {
addPayEnsureRecord(orderInfo.getUid(), orderInfo.getSkup(), orderCode, recordPayment,
ordersPay.getAmount());
}
... ...