parent
fdc83d4550
commit
0a14b530b6
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>product</artifactId>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>order-biz-api</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- Mall 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>common-framework</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
@ -1,16 +0,0 @@
|
||||
package cn.iocoder.mall.order.biz.enums.order;
|
||||
|
||||
/**
|
||||
* 支付 AppId
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-04-08 19:54
|
||||
*/
|
||||
public class PayAppId {
|
||||
|
||||
/**
|
||||
* 电商
|
||||
*/
|
||||
public static final String APP_ID_SHOP_ORDER = "POd4RC6a";
|
||||
|
||||
}
|
||||
@ -1,67 +0,0 @@
|
||||
package cn.iocoder.mall.order.api.constant;
|
||||
|
||||
/**
|
||||
* 订单错误码
|
||||
*
|
||||
* 错误码区间 [1-008-000-000 ~ 1-008-000-000]
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-03-23 11:23
|
||||
*/
|
||||
public enum OrderErrorCodeEnum {
|
||||
|
||||
// order
|
||||
ORDER_NOT_EXISTENT(1008000000, "获取订单不存在!"),
|
||||
ORDER_GET_SKU_FAIL(1008000001, "获取商品失败!"),
|
||||
ORDER_GET_SKU_NOT_EXISTENT(1008000002, "获取的商品不存在!"),
|
||||
ORDER_PAY_AMOUNT_NOT_NEGATIVE(1008000003, "支付金额不能为负数!"),
|
||||
ORDER_STATUS_NOT_CANCEL(1008000004, "订单状态不能取消!"),
|
||||
ORDER_DELIVERY_INCORRECT_DATA(1008000005, "订单发货数据不正确!"),
|
||||
ORDER_INSUFFICIENT_INVENTORY(1008000006, "库存不足!"),
|
||||
ORDER_GOODS_AMOUNT_INCORRECT(1008000007, "商品金额非法!"),
|
||||
ORDER_GET_GOODS_INFO_INCORRECT(1008000008, "获取额商品信息不正确!"),
|
||||
ORDER_GET_USER_ADDRESS_FAIL(1008000009, "获取用户地址失败!"),
|
||||
ORDER_GET_PAY_FAIL(1008000010, "调用pay失败!"),
|
||||
ORDER_NOT_USER_ORDER(1008000011, "不是该用户的订单!"),
|
||||
ORDER_UNABLE_CONFIRM_ORDER(1008000012, "状态不对不能确认订单!"),
|
||||
ORDER_CREATE_CART_IS_EMPTY(1008000013, "购物车无选中的商品,无法创建订单"),
|
||||
ORDER_STATUS_NOT_WAITING_PAYMENT(1008000014, "订单不处于等待支付状态"),
|
||||
ORDER_PAY_AMOUNT_ERROR(1008000015, "订单金额不正确"),
|
||||
|
||||
// order item
|
||||
ORDER_ITEM_ONLY_ONE(1008000200, "订单Item只有一个!"),
|
||||
|
||||
// 订单退货
|
||||
ORDER_RETURN_NO_RETURN_APPLY(1008000400, "未退货申请"),
|
||||
ORDER_RETURN_NOT_EXISTENT(1008000401, "退货订单不存在"),
|
||||
ORDER_RETURN_REFUND_FAILED(1008000402, "退款失败"),
|
||||
|
||||
// ========== 购物车 ==========
|
||||
CARD_ITEM_NOT_FOUND(1008003000, "购物车项不存在"),
|
||||
CARD_ITEM_SKU_NOT_FOUND(1008003001, "商品不存在"),
|
||||
CARD_ITEM_SKU_QUANTITY_NOT_ENOUGH(1008003002, "商品库存不足"),
|
||||
|
||||
// 工具类服务 1008004000
|
||||
DICT_SERVER_INVOKING_FAIL(1008004000, "字典服务调用失败!"),
|
||||
ORDER_LOGISTICS_INVOKING_FAIL(1008004001, "订单物流调用失败!"),
|
||||
|
||||
|
||||
;
|
||||
|
||||
private final int code;
|
||||
private final String message;
|
||||
|
||||
OrderErrorCodeEnum(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
package cn.iocoder.mall.order.api.constant;
|
||||
|
||||
/**
|
||||
* 支付 AppId
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-04-08 19:54
|
||||
*/
|
||||
public class PayAppId {
|
||||
|
||||
/**
|
||||
* 电商
|
||||
*/
|
||||
public static final String APP_ID_SHOP_ORDER = "POd4RC6a";
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.mall.pay.api.constant;
|
||||
package cn.iocoder.mall.payservice.enums.transaction;
|
||||
|
||||
/**
|
||||
* 支付交易状态枚举
|
||||
@ -1 +0,0 @@
|
||||
package cn.iocoder.mall.payservice.rpc;
|
||||
@ -1,10 +1,19 @@
|
||||
package cn.iocoder.mall.payservice.rpc.transaction;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionCreateReqDTO;
|
||||
|
||||
/**
|
||||
* 支付交易单 RPC 接口
|
||||
*/
|
||||
public interface PayTransactionRpc {
|
||||
|
||||
|
||||
/**
|
||||
* 创建支付交易单
|
||||
*
|
||||
* @param createReqDTO 创建信息
|
||||
* @return 支付交易单号
|
||||
*/
|
||||
CommonResult<Integer> createPayTransaction(PayTransactionCreateReqDTO createReqDTO);
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
package cn.iocoder.mall.payservice.convert.app;
|
||||
|
||||
import cn.iocoder.mall.payservice.dal.mysql.dataobject.app.PayAppDO;
|
||||
import cn.iocoder.mall.payservice.rpc.app.dto.PayAppRespDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface PayAppConvert {
|
||||
|
||||
PayAppConvert INSTANCE = Mappers.getMapper(PayAppConvert.class);
|
||||
|
||||
PayAppRespDTO convert(PayAppDO bean);
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.mall.payservice.convert.transaction;
|
||||
|
||||
import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.PayTransactionDO;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionCreateReqDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface PayTransactionConvert {
|
||||
|
||||
PayTransactionConvert INSTANCE = Mappers.getMapper(PayTransactionConvert.class);
|
||||
|
||||
PayTransactionDO convert(PayTransactionCreateReqDTO bean);
|
||||
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
package cn.iocoder.mall.payservice.convert.transaction;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface TransactionConvert {
|
||||
|
||||
TransactionConvert INSTANCE = Mappers.getMapper(TransactionConvert.class);
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package cn.iocoder.mall.payservice.dal.mysql.mapper.app;
|
||||
|
||||
import cn.iocoder.mall.payservice.dal.mysql.dataobject.app.PayAppDO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface PayAppMapper extends BaseMapper<PayAppDO> {
|
||||
}
|
||||
@ -1,4 +1,22 @@
|
||||
package cn.iocoder.mall.payservice.rpc.transaction;
|
||||
|
||||
public class PayTransactionRpcImpl {
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionCreateReqDTO;
|
||||
import cn.iocoder.mall.payservice.service.transaction.PayTransactionService;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
@DubboService
|
||||
public class PayTransactionRpcImpl implements PayTransactionRpc {
|
||||
|
||||
@Autowired
|
||||
private PayTransactionService payTransactionService;
|
||||
|
||||
@Override
|
||||
public CommonResult<Integer> createPayTransaction(PayTransactionCreateReqDTO createReqDTO) {
|
||||
return success(payTransactionService.createPayTransaction(createReqDTO));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,25 +1,38 @@
|
||||
package cn.iocoder.mall.payservice.service.app.impl;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.mall.payservice.convert.app.PayAppConvert;
|
||||
import cn.iocoder.mall.payservice.dal.mysql.dataobject.app.PayAppDO;
|
||||
import cn.iocoder.mall.payservice.dal.mysql.mapper.app.PayAppMapper;
|
||||
import cn.iocoder.mall.payservice.rpc.app.dto.PayAppRespDTO;
|
||||
import cn.iocoder.mall.payservice.service.app.PayAppService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import static cn.iocoder.mall.payservice.enums.PayErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 支付应用 Service 实现类
|
||||
*/
|
||||
@Service
|
||||
public class PayAppServiceImpl implements PayAppService {
|
||||
|
||||
@Autowired
|
||||
private PayAppMapper payAppMapper;
|
||||
|
||||
|
||||
// public PayAppDO validPayApp(String appId) {
|
||||
// PayAppDO payAppDO = payAppMapper.selectById(appId);
|
||||
// // 校验是否存在
|
||||
// if (payAppDO == null) {
|
||||
// throw ServiceExceptionUtil.exception(PayErrorCodeEnum.PAY_APP_NOT_FOUND.getCode());
|
||||
// }
|
||||
// // 校验是否禁用
|
||||
// if (CommonStatusEnum.DISABLE.getValue().equals(payAppDO.getStatus())) {
|
||||
// throw ServiceExceptionUtil.exception(PayErrorCodeEnum.PAY_APP_IS_DISABLE.getCode());
|
||||
// }
|
||||
// return payAppDO;
|
||||
// }
|
||||
@Override
|
||||
public PayAppRespDTO validPayApp(String payAppId) {
|
||||
PayAppDO payAppDO = payAppMapper.selectById(payAppId);
|
||||
// 校验是否存在
|
||||
if (payAppDO == null) {
|
||||
throw ServiceExceptionUtil.exception(PAY_APP_NOT_FOUND);
|
||||
}
|
||||
// 校验是否禁用
|
||||
if (CommonStatusEnum.DISABLE.getValue().equals(payAppDO.getStatus())) {
|
||||
throw ServiceExceptionUtil.exception(PAY_APP_IS_DISABLE);
|
||||
}
|
||||
return PayAppConvert.INSTANCE.convert(payAppDO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,10 +1,18 @@
|
||||
package cn.iocoder.mall.payservice.service.transaction;
|
||||
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionCreateReqDTO;
|
||||
|
||||
/**
|
||||
* 支付交易单 Service 接口
|
||||
*/
|
||||
public interface PayTransactionService {
|
||||
|
||||
|
||||
/**
|
||||
* 创建支付交易单
|
||||
*
|
||||
* @param createReqDTO 创建信息
|
||||
* @return 支付交易单号
|
||||
*/
|
||||
Integer createPayTransaction(PayTransactionCreateReqDTO createReqDTO);
|
||||
|
||||
}
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
package cn.iocoder.mall.pay.biz.convert;
|
||||
|
||||
import cn.iocoder.mall.pay.api.bo.transaction.PayTransactionBO;
|
||||
import cn.iocoder.mall.pay.api.dto.transaction.PayTransactionCreateDTO;
|
||||
import cn.iocoder.mall.pay.api.dto.transaction.PayTransactionSubmitDTO;
|
||||
import cn.iocoder.mall.pay.biz.dataobject.PayTransactionDO;
|
||||
import cn.iocoder.mall.pay.biz.dataobject.PayTransactionExtensionDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface PayTransactionConvert {
|
||||
|
||||
PayTransactionConvert INSTANCE = Mappers.getMapper(PayTransactionConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
PayTransactionDO convert(PayTransactionCreateDTO payTransactionCreateDTO);
|
||||
|
||||
@Mappings({})
|
||||
PayTransactionBO convert(PayTransactionDO payTransactionDO);
|
||||
|
||||
@Mappings({})
|
||||
List<PayTransactionBO> convertList(List<PayTransactionDO> list);
|
||||
|
||||
@Mappings({})
|
||||
PayTransactionExtensionDO convert(PayTransactionSubmitDTO payTransactionSubmitDTO);
|
||||
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
##################### 业务模块 #####################
|
||||
@ -1,65 +0,0 @@
|
||||
spring:
|
||||
# datasource
|
||||
datasource:
|
||||
url: jdbc:mysql://s1.iocoder.cn:3306/mall_pay?useSSL=false&useUnicode=true&characterEncoding=UTF-8
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: 3WLiVUBEwTbvAfsh
|
||||
|
||||
# Spring Cloud 配置项
|
||||
cloud:
|
||||
nacos:
|
||||
# Spring Cloud Nacos Discovery 配置项
|
||||
discovery:
|
||||
server-addr: s1.iocoder.cn:8848 # Nacos 服务器地址
|
||||
|
||||
# mybatis
|
||||
mybatis-plus:
|
||||
config-location: classpath:mybatis-config.xml
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
type-aliases-package: cn.iocoder.mall.pay.biz.dataobject
|
||||
|
||||
# Dubbo 配置项
|
||||
dubbo:
|
||||
# Dubbo 注册中心
|
||||
registry:
|
||||
address: spring-cloud://s1.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
|
||||
# Spring Cloud Alibaba Dubbo 专属配置
|
||||
cloud:
|
||||
subscribed-services: admin-application # 设置订阅的应用列表,默认为 * 订阅所有应用
|
||||
# Dubbo 提供者的协议
|
||||
protocol:
|
||||
name: dubbo
|
||||
port: -1
|
||||
# Dubbo 提供服务的扫描基础包
|
||||
scan:
|
||||
base-packages: cn.iocoder.mall.pay.biz.service
|
||||
# Dubbo 服务提供者的配置
|
||||
provider:
|
||||
filter: -exception
|
||||
PayTransactionService:
|
||||
version: 1.0.0
|
||||
PayRefundService:
|
||||
version: 1.0.0
|
||||
|
||||
# rocketmq
|
||||
rocketmq:
|
||||
name-server: s1.iocoder.cn:9876
|
||||
producer:
|
||||
group: pay-producer-group
|
||||
|
||||
# Seata 配置项
|
||||
seata:
|
||||
tx-service-group: default # Seata 事务组编号,用于 TC 集群名
|
||||
# 服务配置项,对应 ServiceProperties 类
|
||||
service:
|
||||
# 虚拟组和分组的映射
|
||||
vgroup-mapping:
|
||||
default: default
|
||||
# Seata 注册中心配置项
|
||||
registry:
|
||||
type: nacos # 注册中心类型
|
||||
nacos:
|
||||
serverAddr: ${spring.cloud.nacos.discovery.server-addr} # Nacos 服务地址
|
||||
namespace: # Nacos 命名空间
|
||||
cluster: default # 使用的 Seata 分组
|
||||
@ -1,37 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.mall.pay.biz.dao.PayAppMapper">
|
||||
|
||||
<sql id="FIELDS">
|
||||
id, name, notify_url, refund_notify_url, status, create_time
|
||||
</sql>
|
||||
|
||||
<!--<insert id="insert" parameterType="RoleDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">-->
|
||||
<!--INSERT INTO role (-->
|
||||
<!--name, create_time, deleted-->
|
||||
<!--) VALUES (-->
|
||||
<!--#{name}, #{createTime}, #{deleted}-->
|
||||
<!--)-->
|
||||
<!--</insert>-->
|
||||
|
||||
<!--<update id="update" parameterType="RoleDO">-->
|
||||
<!--UPDATE role-->
|
||||
<!--<set>-->
|
||||
<!--<if test="name != null">-->
|
||||
<!--, name = #{name}-->
|
||||
<!--</if>-->
|
||||
<!--<if test="deleted != null">-->
|
||||
<!--, deleted = #{deleted}-->
|
||||
<!--</if>-->
|
||||
<!--</set>-->
|
||||
<!--WHERE id = #{id}-->
|
||||
<!--</update>-->
|
||||
|
||||
<select id="selectById" parameterType="String" resultType="PayAppDO">
|
||||
SELECT
|
||||
<include refid="FIELDS"/>
|
||||
FROM app
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.mall.tradeservice.client.pay;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.PayTransactionRpc;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionCreateReqDTO;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class PayTransactionClient {
|
||||
|
||||
@DubboReference(version = "${dubbo.consumer.PayTransactionRpc.version}")
|
||||
private PayTransactionRpc payTransactionRpc;
|
||||
|
||||
public Integer createPayTransaction(PayTransactionCreateReqDTO createReqDTO) {
|
||||
CommonResult<Integer> createPayTransactionResult = payTransactionRpc.createPayTransaction(createReqDTO);
|
||||
createPayTransactionResult.checkError();
|
||||
return createPayTransactionResult.getData();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue