Authored by tanling

订单

... ... @@ -19,6 +19,8 @@ public interface BuyerOrderMapper {
int updateByPrimaryKeySelective(BuyerOrder record);
int updateByOrderCode(BuyerOrder record);
int selectCntByUidStatus(@Param("uid") int uid, @Param("status") List<Integer> status);
List<BuyerOrder> selectListByUidStatus(@Param("uid") int uid, @Param("status") List<Integer> status,
... ...
... ... @@ -19,4 +19,6 @@ public interface SellerOrderMapper {
int updateByPrimaryKeySelective(SellerOrder record);
int updateByPrimaryKey(SellerOrder record);
int updateByOrderCode(SellerOrder record);
}
\ No newline at end of file
... ...
... ... @@ -264,4 +264,17 @@
channel_no = #{channelNo,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByOrderCode" parameterType="com.yohoufo.dal.order.model.BuyerOrder">
update buyer_order
set
status = #{status,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
where uid = #{uid,jdbcType=INTEGER}
and order_code = #{orderCode,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -186,4 +186,15 @@
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByOrderCode" parameterType="com.yohoufo.dal.order.model.SellerOrder">
update seller_order
set
status = #{status,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
where uid = #{uid,jdbcType=INTEGER}
and order_code = #{orderCode,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -97,4 +97,6 @@
meta_value = #{metaValue,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -12,9 +12,6 @@ public class PaymentConfirmRsp {
long orderCode;
String status;
String isPaid;
String isCancle;
}
... ...
... ... @@ -105,6 +105,21 @@ public abstract class AbstractOrderPaymentService {
/**
* 订单是否 已支付 状态
* @param orderInfo
* @return
*/
public abstract boolean isOrderPaid(OrderInfo orderInfo);
/**
* 更新订单状态
* @param orderInfo
*/
public abstract void updateOrderStatusPaid(OrderInfo orderInfo);
/**
* 检查并更新预支付方式
* @param request
* @return
... ...
... ... @@ -35,6 +35,21 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
/**
* 更新订单状态
* @param orderInfo
*/
public void updateOrderStatusPaid(OrderInfo orderInfo){
BuyerOrder buyerOrder = new BuyerOrder();
buyerOrder.setOrderCode(orderInfo.getOrderCode());
buyerOrder.setUid(orderInfo.getUid());
buyerOrder.setStatus(OrderStatus.HAS_PAYED.getCode());
buyerOrderMapper.updateByOrderCode(buyerOrder);
}
/**
* 订单是否是待支付状态
* @param orderInfo
* @return
... ... @@ -50,6 +65,22 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
/**
* 订单是 已支付的订单
* @param orderInfo
* @return
*/
public boolean isOrderPaid(OrderInfo orderInfo){
if (orderInfo.getStatus() != null && orderInfo.getStatus().intValue() == OrderStatus.HAS_PAYED.getCode()){
return true;
}
return false;
}
/**
* 保存前回预支付结果
* @param orderInfo
* @param response
... ...
... ... @@ -7,10 +7,12 @@ import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.dal.order.SellerOrderMapper;
import com.yohoufo.dal.order.SellerOrderMetaMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderMeta;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderMeta;
import com.yohoufo.order.common.OrderCodeType;
import com.yohoufo.order.common.OrderStatus;
import com.yohoufo.order.common.SellerOrderStatus;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.model.OrderInfo;
... ... @@ -36,6 +38,19 @@ public class SellerOrderPaymentService extends AbstractOrderPaymentService {
SellerOrderMetaMapper sellerOrderMetaMapper;
/**
* 更新订单状态
* @param orderInfo
*/
public void updateOrderStatusPaid(OrderInfo orderInfo){
SellerOrder sellerOrder = new SellerOrder();
sellerOrder.setOrderCode(orderInfo.getOrderCode());
sellerOrder.setUid(orderInfo.getUid());
sellerOrder.setStatus(OrderStatus.HAS_PAYED.getCode());
sellerOrderMapper.updateByOrderCode(sellerOrder);
}
... ... @@ -53,6 +68,20 @@ public class SellerOrderPaymentService extends AbstractOrderPaymentService {
return false;
}
/**
* 订单是否 已支付 状态
* @param orderInfo
* @return
*/
public boolean isOrderPaid(OrderInfo orderInfo){
if (orderInfo.getStatus() == null || orderInfo.getStatus().intValue() != SellerOrderStatus.HAS_PAYED.getCode()){
return true;
}
return false;
}
/**
* 保存前回预支付结果
... ...
... ... @@ -104,16 +104,22 @@ public class PaymentServiceImpl implements IPaymentService {
// 获取订单信息
OrderInfo orderInfo = paymentService.getOrderInfo(request);
PaymentConfirmRsp paymentConfirmRsp = PaymentConfirmRsp.builder()
.orderCode(request.getOrderCode())
.isPaid(OrderConstant.Y_STR)
.build();
// 已支付的状态,直接返回
if (paymentService.isOrderPaid(orderInfo)){
return paymentConfirmRsp;
}
// payment!=null && 待付款,其他直接返回
PaymentConfirmRsp paymentConfirmRsp = PaymentConfirmRsp.builder().orderCode(request.getOrderCode()).build();
if (orderInfo.getPayment() == null || !paymentService.isOrderWaitingPay(orderInfo)){
return paymentConfirmRsp;
}
// 未支付订单
// 未支付状态,通过第三方查询
Payment payment = Payment.getPayment(orderInfo.getPayment());
JSONObject result = paymentService.accessUnionPay(paymentService.buildQueryOrderData(request, payment));
... ... @@ -121,7 +127,8 @@ public class PaymentServiceImpl implements IPaymentService {
String stauts = result.getString("status");
if ("TRADE_SUCCESS".equals(stauts)){
// 支付成功 TODO
// 支付成功
paymentService.updateOrderStatusPaid(orderInfo);
}
}
... ...
... ... @@ -18,7 +18,7 @@ import java.util.stream.Collectors;
public class PayTest {
public static final String url = "https://qr-test2.chinaums.com/netpay-route-server/api/";
public static final String url = "https://qr.chinaums.com/netpay-route-server/api/";
@Test
... ... @@ -36,16 +36,15 @@ public class PayTest {
@Test
public void testPrepay() throws Exception {
// TODO 30分钟之后,再跑一遍这个接口
JSONObject data = new JSONObject();
data.put("msgSrc","WWW.TEST.COM");
data.put("msgSrc","WWW.YHJSSMFW.COM");
// 支付宝
data.put("msgType", "trade.precreate"); // 微信:wx.unifiedOrder, 支付宝:trade.precreate, 全民付:qmf.order, 银联云闪付:uac.appOrder
data.put("requestTimestamp", DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss"));
// 支付宝- 31945075157
data.put("merOrderId", "31949755697176593");
data.put("mid", "898310148160568"); //商户号 仅用于支付宝和云闪付
data.put("tid","00000001"); //终端号
data.put("merOrderId", "45579757019037753");
data.put("mid", "898320153990115"); //商户号 仅用于支付宝和云闪付
data.put("tid","A0048322"); //终端号
data.put("instMid", "APPDEFAULT"); // 机构商户号
data.put("totalAmount", 1);
// 回调接口 http://api-test3.dev.yohocorp.com/payment/weixin_notify
... ... @@ -170,7 +169,7 @@ public class PayTest {
Collections.sort(list);
String param = list.stream().collect(Collectors.joining("&"));
String sign = MD5.md5(param+"fcAmtnx7MwismjWNhNKdHC44mNXtnEQeJkRrhKJwyrW2ysRR");
String sign = MD5.md5(param+"YStPz5p2aKXd6z24x6HeXYFCZQz5wRY4sbQ6hA8j72mEMBW2");
return sign;
}
... ...