Authored by tanling

test

package com.yoho.ufo.common.util;
import com.netflix.config.DynamicPropertyFactory;
import com.yoho.core.common.utils.AES;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AddressUtil {
private final static Logger logger = LoggerFactory.getLogger(AddressUtil.class);
/**
* 解密地址
* @param str
* @return
*/
public static String getDecryptStr(String str){
String decryptStr = str;
try{
str = str.replace(' ','+');
decryptStr = AES.decrypt(DynamicPropertyFactory.getInstance().getStringProperty("password.aes.key", "yoho9646yoho9646").get(), str);
}catch (Exception e){
logger.error("getDecryptStr failed. str is {}, e is {}", str, e);
}
logger.info("getDecryptStr, str is {}, decryptStr is {}", str, decryptStr);
return decryptStr;
}
}
... ...
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
... ... @@ -10,9 +15,20 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.0.4" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.0.b2" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-trace:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-common:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-redis-cluster:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config-client:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-client-simple:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-common:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-alarm:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-cache:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:uic-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:social-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-trace:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.netflix.hystrix:hystrix-core:1.4.21" level="project" />
<orderEntry type="library" name="Maven: io.reactivex:rxjava:1.0.14" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.6.3" level="project" />
... ... @@ -27,30 +43,29 @@
<orderEntry type="library" name="Maven: com.esotericsoftware:kryo-shaded:3.0.3" level="project" />
<orderEntry type="library" name="Maven: com.esotericsoftware:minlog:1.3.0" level="project" />
<orderEntry type="library" name="Maven: org.objenesis:objenesis:2.1" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.netflix.archaius:archaius-zookeeper:0.7.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.zookeeper:zookeeper:3.4.6" level="project" />
<orderEntry type="library" name="Maven: jline:jline:0.9.94" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty:3.7.0.Final" level="project" />
<orderEntry type="library" name="Maven: org.apache.curator:curator-framework:2.9.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.curator:curator-client:2.9.1" level="project" />
<orderEntry type="library" name="Maven: com.yoho.common:error-code:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="error-code" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.13.sec01" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-test:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.14" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-common:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-common:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.apache.curator:curator-recipes:2.9.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.3" level="project" />
<orderEntry type="library" name="Maven: net.sf.dozer:dozer:5.5.1" level="project" />
<orderEntry type="library" name="Maven: net.sf.dozer:dozer-spring:5.5.1" level="project" />
<orderEntry type="library" name="Maven: org.xerial.snappy:snappy-java:1.1.2.6" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-redis-cluster:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config-client:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-redis-cluster:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config-client:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-redis:1.8.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-keyvalue:1.2.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:1.13.10.RELEASE" level="project" />
... ... @@ -68,9 +83,9 @@
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp3:logging-interceptor:3.8.1" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-client-simple:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-client-simple:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.2" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-common:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-common:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-mapper-asl:1.9.13" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-core-asl:1.9.13" level="project" />
<orderEntry type="library" name="Maven: io.protostuff:protostuff-core:1.4.4" level="project" />
... ... @@ -80,13 +95,13 @@
<orderEntry type="library" name="Maven: io.netty:netty-all:4.1.6.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.6.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.6.Final" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-alarm:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-alarm:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance-model:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.apache.curator:curator-x-discovery:2.9.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpasyncclient:4.1.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore-nio:4.4.5" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-cache:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-cache:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: net.spy:spymemcached:2.12.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.3.8.RELEASE" level="project" />
... ... @@ -116,6 +131,7 @@
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.5" level="project" />
<orderEntry type="library" name="Maven: commons-httpclient:commons-httpclient:3.1" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.0.4" level="project" />
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.6.3" level="project" />
... ... @@ -133,16 +149,17 @@
<orderEntry type="library" name="Maven: javax.mail:mail:1.4.1" level="project" />
<orderEntry type="library" name="Maven: javax.activation:activation:1.1" level="project" />
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.2" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:uic-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:social-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="uic-service-model" />
<orderEntry type="library" name="Maven: com.yoho.service.model:social-service-model:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.8.7" level="project" />
<orderEntry type="library" name="Maven: org.jdom:jdom:1.1" level="project" />
<orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.0.b2" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk16:1.46" level="project" />
<orderEntry type="library" name="Maven: com.squareup.retrofit:retrofit:1.9.0" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.14.4" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:resource-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:users-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:shops-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="resource-service-model" />
<orderEntry type="module" module-name="users-service-model" />
<orderEntry type="module" module-name="shops-service-model" />
</component>
</module>
\ No newline at end of file
... ...
package com.yohoufo.order.dal;
import com.yohoufo.order.dal.model.SellerOrder;
import org.apache.ibatis.annotations.Param;
public interface SellerOrderMapper {
int deleteByPrimaryKey(Integer id);
... ... @@ -11,6 +12,8 @@ public interface SellerOrderMapper {
SellerOrder selectByPrimaryKey(Integer id);
SellerOrder selectBySkup(@Param("skup") Integer skup);
int updateByPrimaryKeySelective(SellerOrder record);
int updateByPrimaryKey(SellerOrder record);
... ...
... ... @@ -27,6 +27,18 @@ public class SellerOrderGoods {
private Byte status;
private String imageUrl;
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public Integer getId() {
return id;
}
... ...
<?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="com.yohoufo.order.dal.SellerOrderGoodsMapper">
<resultMap id="BaseResultMap" type="com.yohoufo.order.dal.model.SellerOrderGoods">
<resultMap id="BaseResultMap" type="om.yohoufo.order.dal.model.SellerOrderGoods">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="product_id" jdbcType="INTEGER" property="productId" />
<result column="product_name" jdbcType="VARCHAR" property="productName" />
... ... @@ -14,10 +14,11 @@
<result column="color_name" jdbcType="VARCHAR" property="colorName" />
<result column="goods_price" jdbcType="DECIMAL" property="goodsPrice" />
<result column="status" jdbcType="TINYINT" property="status" />
<result column="image_url" jdbcType="VARCHAR" property="imageUrl" />
</resultMap>
<sql id="Base_Column_List">
id, product_id, product_name, storage_id, depot_no, size_id, size_name, goods_id,
color_id, color_name, goods_price, status
color_id, color_name, goods_price, status, image_url
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
... ... @@ -25,11 +26,16 @@
from seller_order_goods
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from seller_order_goods
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.order.dal.model.SellerOrderGoods" useGeneratedKeys="true">
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="om.yohoufo.order.dal.model.SellerOrderGoods" useGeneratedKeys="true">
insert into seller_order_goods (product_id, product_name, storage_id,
depot_no, size_id, size_name,
goods_id, color_id, color_name,
... ... @@ -39,7 +45,7 @@
#{goodsId,jdbcType=INTEGER}, #{colorId,jdbcType=SMALLINT}, #{colorName,jdbcType=VARCHAR},
#{goodsPrice,jdbcType=DECIMAL}, #{status,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.order.dal.model.SellerOrderGoods" useGeneratedKeys="true">
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="om.yohoufo.order.dal.model.SellerOrderGoods" useGeneratedKeys="true">
insert into seller_order_goods
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="productId != null">
... ... @@ -112,7 +118,7 @@
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.order.dal.model.SellerOrderGoods">
<update id="updateByPrimaryKeySelective" parameterType="om.yohoufo.order.dal.model.SellerOrderGoods">
update seller_order_goods
<set>
<if test="productId != null">
... ... @@ -151,7 +157,7 @@
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yohoufo.order.dal.model.SellerOrderGoods">
<update id="updateByPrimaryKey" parameterType="om.yohoufo.order.dal.model.SellerOrderGoods">
update seller_order_goods
set product_id = #{productId,jdbcType=INTEGER},
product_name = #{productName,jdbcType=VARCHAR},
... ...
... ... @@ -25,6 +25,16 @@
from seller_order
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectBySkup" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from seller_order
where skup = #{skup,jdbcType=INTEGER}
limit 1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from seller_order
where id = #{id,jdbcType=INTEGER}
... ...
... ... @@ -25,5 +25,9 @@
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>com.yohoufo.fore</groupId>
<artifactId>yohoufo-fore-dal</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
... ...
package com.yohoufo.order.common;
public enum SellerOrderStatus {
WAITING_PAY(0, "待付保证金"),
SELLER_CANCEL_PAY(1, "上架关闭(卖家取消支付)"),
SELLER_CANCEL_TIMEOUT(2, "上架关闭(卖家支付超时)"),
HAS_PAYED(3, "已支付"),
SELLER_CANCEL_SELL(4, "上架关闭(卖家取消出售)"),
BACKGROUNP_CANCEL_SELL(5, "上架关闭(平台取消出售)"),
HAS_SELLED(6, "已售出");
SellerOrderStatus(int code, String desc) {
this.code = code;
this.desc = desc;
}
int code;
String desc;
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
}
... ...
package com.yohoufo.order.common;
public enum SkupStatus {
CAN_SELL(1),
CAN_NOT_SELL(0);
SkupStatus(int code) {
this.code = code;
}
int code;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
}
... ...
package com.yohoufo.order.constants;
public interface OrderConstant {
// 在线支付
int PAYMENT_ONLINE = 1;
String PAYMENT_ONLINE_NAME = "在线支付";
// 顺丰快递
int DELIVERY_WAY_SF = 2;
String DELIVERY_WAY_SF_NAME = "顺丰速运";
int DELIVERY_WAY_SF_COST = 15;
String GOODS_PRICE = "商品金额";
String DELIVERY_DESC = "运费";
String GOODS_REAL_PRICE = "实付金额";
String MONEY_SIGN = "¥";
String PLUS_SIGN = "+";
String DAMAGES_DESC = "如卖家原因导致交易失败,您将获得赔偿金";
String MONEY_UNIT = "元";
}
... ...
... ... @@ -19,10 +19,20 @@ public class ShoppingController {
IShoppingService shoppingService;
/**
* 结算
* @param shoppingRequest
* @return
*/
@RequestMapping("/payment")
@ResponseBody
public ShoppingPaymentResponse payment(@RequestBody ShoppingRequest shoppingRequest){
return null;
return shoppingService.payment(shoppingRequest);
}
}
... ...
... ... @@ -5,7 +5,20 @@ import lombok.Data;
@Data
public class ShoppingRequest {
private String skup;
private int skup;
private int uid;
/**
* 加密过的地址Id
*/
private String addressId;
/**
* 客户端类型
*/
private String clientType;
private String uid;
}
... ...
package com.yohoufo.order.response;
import lombok.Data;
import lombok.ToString;
import java.math.BigDecimal;
import java.util.List;
@Data
@ToString
public class ShoppingPaymentResponse {
/**
* 支付方式:在线支付
*/
PaymentWay paymentWay;
/**
* 快递方式
*/
DeliveryWay deliveryWay;
/**
* 商品情报
*/
List<Goods> goodsList;
/**
* 费用列表
*/
List<PromotionFormula> promotionFormulaList;
/**
* 赔偿金文案
*/
String damagesDesc;
@Data
@ToString
public static class PaymentWay{
private int paymentType;
private String paymentTypeName;
}
@Data
@ToString
public static class DeliveryWay{
/**
* 快递方式
*/
private int deliveryWayId;
private String deliveryWayName;
private int deliveryWayCost;
}
@Data
@ToString
public static class Goods{
// 封面图
private String goodsImg;
private String productName;
private int colorId;
private String color;
private int sizeId;
private String sizeName;
private int buyNumber;
private BigDecimal salePrice;
}
@Data
@ToString
public static class PromotionFormula{
private String promotion;
private String promotionAmount;
}
}
... ...
package com.yohoufo.order.service;
import com.yohoufo.order.request.ShoppingRequest;
import com.yohoufo.order.response.ShoppingPaymentResponse;
public interface IShoppingService {
/**
* 结算页数据
* @param shoppingRequest
* @return
*/
public ShoppingPaymentResponse payment(ShoppingRequest shoppingRequest);
}
... ...
package com.yohoufo.order.service.impl;
import com.yoho.core.common.utils.DateUtil;
import com.yohoufo.order.common.SellerOrderStatus;
import com.yohoufo.order.common.SkupStatus;
import com.yohoufo.order.dal.*;
import com.yohoufo.order.dal.model.BuyerOrder;
import com.yohoufo.order.dal.model.SellerOrder;
import com.yohoufo.order.dal.model.SellerOrderGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class OrdeCreationServiceImpl {
@Autowired
SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Autowired
SellerOrderMapper sellerOrderMapper;
@Autowired
BuyerOrderMapper buyerOrderMapper;
@Autowired
BuyerOrderGoodsMapper buyerOrderGoodsMapper;
@Autowired
BuyerOrderMetaMapper buyerOrderMetaMapper;
/**
* 创建订单
*/
@Transactional
public void create(int skup, int productId, long orderCode, int uid, String clientType){
try{
// 扣减库存,入口参数:skup, product_id TODO
// 1.skup不可售
// 2.卖家订单,skup已经售出
SellerOrderGoods sellerOrderGoods = new SellerOrderGoods();
sellerOrderGoods.setId(skup);
sellerOrderGoods.setStatus((byte)SkupStatus.CAN_NOT_SELL.getCode());
sellerOrderGoodsMapper.updateByPrimaryKeySelective(sellerOrderGoods);
// 根据skup 查询卖家订单 ==> 卖家uid
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
sellerOrder.setUpdateTime(DateUtil.getCurrentTimeSecond());
sellerOrder.setStatus((byte) SellerOrderStatus.HAS_SELLED.getCode());
sellerOrderMapper.updateByPrimaryKeySelective(sellerOrder);
// 订单入口
BuyerOrder buyerOrder = new BuyerOrder();
buyerOrder.setUid(uid);
buyerOrder.setOrderCode(orderCode);
buyerOrder.setSellerUid(sellerOrder.getUid());
// buyerOrder.setPaymentType();
buyerOrderMapper.insert(buyerOrder);
}catch (Exception e){
throw e;
}
}
}
... ...
... ... @@ -2,31 +2,124 @@ package com.yohoufo.order.service.impl;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.consts.Constant;
import com.yohoufo.order.common.SkupStatus;
import com.yohoufo.order.constants.OrderConstant;
import com.yohoufo.order.dal.SellerOrderGoodsMapper;
import com.yohoufo.order.dal.model.SellerOrderGoods;
import com.yohoufo.order.request.ShoppingRequest;
import com.yohoufo.order.response.ShoppingPaymentResponse;
import com.yohoufo.order.service.IShoppingService;
import com.yohoufo.order.service.support.ShoppingSupport;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Arrays;
@Service
public class ShoppingServiceImpl implements IShoppingService{
private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
ShoppingSupport shoppingSupport;
@Autowired
SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Autowired
OrderCodeGenerator orderCodeGenerator;
/**
* 结算页数据
* @param shoppingRequest
* @return
*/
public ShoppingPaymentResponse payment(ShoppingRequest shoppingRequest){
// 入口参数检查
if (StringUtils.isEmpty(shoppingRequest.getUid())
|| StringUtils.isEmpty(shoppingRequest.getSkup())){
if (shoppingRequest.getUid()<0
|| shoppingRequest.getSkup()<0){
logger.warn("payment uid or skup is null");
// TODO
throw new ServiceException(ServiceError.ORDER_REQUEST_ERROR);
}
// skup是否是可售状态
SellerOrderGoods skup = sellerOrderGoodsMapper.selectByPrimaryKey(shoppingRequest.getSkup());
if (skup == null){
logger.warn("payment skup not exist, skup is {}", shoppingRequest.getSkup());
// TODO
throw new ServiceException(ServiceError.ORDER_REQUEST_ERROR);
}
// 不可售
if (skup.getStatus()!=null
&& skup.getStatus().intValue() != SkupStatus.CAN_SELL.getCode()){
logger.warn("payment skup status, skup is {}", shoppingRequest.getSkup());
throw new ServiceException(ServiceError.ORDER_REQUEST_ERROR);
}
ShoppingPaymentResponse response = new ShoppingPaymentResponse();
response.setPaymentWay(shoppingSupport.getPaymentWay());
response.setDeliveryWay(shoppingSupport.getDeliverWay());
response.setGoodsList(Arrays.asList(shoppingSupport.getGoodsInfo(skup)));
response.setPromotionFormulaList(shoppingSupport.getPromotionFormula(skup));
return null;
// TODO 赔偿金计算
response.setDamagesDesc(shoppingSupport.getDamagesDesc(null));
return response;
}
public void submit(ShoppingRequest shoppingRequest){
// 入口参数检查
if (shoppingRequest.getSkup() < 0
|| shoppingRequest.getUid() < 0
|| StringUtils.isEmpty(shoppingRequest.getAddressId())){
logger.warn("submit param is null");
// TODO
throw new ServiceException(ServiceError.ORDER_REQUEST_ERROR);
}
// 创建订单
// 校验 skup是否是可售
SellerOrderGoods skup = sellerOrderGoodsMapper.selectByPrimaryKey(shoppingRequest.getSkup());
if (skup == null){
logger.warn("payment skup not exist, skup is {}", shoppingRequest.getSkup());
// TODO
throw new ServiceException(ServiceError.ORDER_REQUEST_ERROR);
}
// 不可售
if (skup.getStatus()!=null
&& skup.getStatus().intValue() != SkupStatus.CAN_SELL.getCode()){
logger.warn("payment skup status, skup is {}", shoppingRequest.getSkup());
throw new ServiceException(ServiceError.ORDER_REQUEST_ERROR);
}
// 生成订单号 TODO
long orderCode = orderCodeGenerator.generate();
// 减库存,skup更新成不可售,入库
// 返回结果
}
}
... ...
package com.yohoufo.order.service.support;
import com.yohoufo.order.constants.OrderConstant;
import com.yohoufo.order.dal.model.SellerOrderGoods;
import com.yohoufo.order.response.ShoppingPaymentResponse;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
@Service
public class ShoppingSupport {
/**
* 支付方式
* @return
*/
public ShoppingPaymentResponse.PaymentWay getPaymentWay() {
// 支付方式: 在线支付
ShoppingPaymentResponse.PaymentWay paymentWay = new ShoppingPaymentResponse.PaymentWay();
paymentWay.setPaymentType(OrderConstant.PAYMENT_ONLINE);
paymentWay.setPaymentTypeName(OrderConstant.PAYMENT_ONLINE_NAME);
return paymentWay;
}
/**
* 配送方式
* @return
*/
public ShoppingPaymentResponse.DeliveryWay getDeliverWay() {
// 快递方式
ShoppingPaymentResponse.DeliveryWay deliveryWay = new ShoppingPaymentResponse.DeliveryWay();
deliveryWay.setDeliveryWayId(OrderConstant.DELIVERY_WAY_SF);
deliveryWay.setDeliveryWayCost(OrderConstant.DELIVERY_WAY_SF_COST);
deliveryWay.setDeliveryWayName(OrderConstant.DELIVERY_WAY_SF_NAME);
return deliveryWay;
}
/**
* 商品情报
* @param skup
* @return
*/
public ShoppingPaymentResponse.Goods getGoodsInfo(SellerOrderGoods skup) {
ShoppingPaymentResponse.Goods goods = new ShoppingPaymentResponse.Goods();
goods.setProductName(skup.getProductName());
goods.setColorId(skup.getColorId() == null ? 0 : skup.getColorId());
goods.setColor(skup.getColorName());
goods.setSizeId(skup.getSizeId() == null ? 0:skup.getSizeId());
goods.setSizeName(skup.getSizeName());
goods.setSalePrice(skup.getGoodsPrice());
goods.setGoodsImg(skup.getImageUrl());
return goods;
}
/**
* 付款信息
* @param skup
* @return
*/
public List<ShoppingPaymentResponse.PromotionFormula> getPromotionFormula(SellerOrderGoods skup) {
ShoppingPaymentResponse.PromotionFormula formula1 = new ShoppingPaymentResponse.PromotionFormula();
formula1.setPromotion(OrderConstant.GOODS_PRICE);
formula1.setPromotionAmount(OrderConstant.MONEY_SIGN + skup.getGoodsPrice());
ShoppingPaymentResponse.PromotionFormula formula2 = new ShoppingPaymentResponse.PromotionFormula();
formula2.setPromotion(OrderConstant.DELIVERY_DESC);
formula2.setPromotionAmount(OrderConstant.PLUS_SIGN + OrderConstant.MONEY_SIGN + OrderConstant.DELIVERY_WAY_SF_COST);
ShoppingPaymentResponse.PromotionFormula formula3 = new ShoppingPaymentResponse.PromotionFormula();
formula3.setPromotion(OrderConstant.GOODS_REAL_PRICE);
formula3.setPromotionAmount(OrderConstant.MONEY_SIGN + skup.getGoodsPrice().add(new BigDecimal(OrderConstant.DELIVERY_WAY_SF_COST)));
return Arrays.asList(formula1, formula2, formula3);
}
/**
* 赔偿金文案
* @param damagedPrice
* @return
*/
public String getDamagesDesc(BigDecimal damagedPrice){
StringBuilder damagesDesc = new StringBuilder();
damagesDesc.append(OrderConstant.DAMAGES_DESC);
damagesDesc.append(OrderConstant.MONEY_SIGN);
damagesDesc.append(damagedPrice);
damagesDesc.append(OrderConstant.MONEY_UNIT);
return damagesDesc.toString();
}
}
... ...
package com.yohoufo.order.service.support.codegenerator;
public interface OrderCodeGenerator {
/**
* 根据产生订单号
* @return
*/
long generate();
}
... ...
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
... ... @@ -10,10 +15,21 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.0.4" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.0.b2" level="project" />
<orderEntry type="module" module-name="yohoufo-fore-common" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-trace:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-common:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-redis-cluster:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config-client:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-client-simple:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-common:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-alarm:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-cache:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:uic-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:social-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="yohoufo-fore-common" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-trace:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.netflix.hystrix:hystrix-core:1.4.21" level="project" />
<orderEntry type="library" name="Maven: io.reactivex:rxjava:1.0.14" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.6.3" level="project" />
... ... @@ -28,7 +44,7 @@
<orderEntry type="library" name="Maven: com.esotericsoftware:kryo-shaded:3.0.3" level="project" />
<orderEntry type="library" name="Maven: com.esotericsoftware:minlog:1.3.0" level="project" />
<orderEntry type="library" name="Maven: org.objenesis:objenesis:2.1" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.netflix.archaius:archaius-zookeeper:0.7.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.zookeeper:zookeeper:3.4.6" level="project" />
<orderEntry type="library" name="Maven: jline:jline:0.9.94" level="project" />
... ... @@ -37,22 +53,21 @@
<orderEntry type="library" name="Maven: io.netty:netty:3.7.0.Final" level="project" />
<orderEntry type="library" name="Maven: org.apache.curator:curator-framework:2.9.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.curator:curator-client:2.9.1" level="project" />
<orderEntry type="library" name="Maven: com.yoho.common:error-code:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="error-code" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-test:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.14" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-common:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-common:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.apache.curator:curator-recipes:2.9.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.3" level="project" />
<orderEntry type="library" name="Maven: net.sf.dozer:dozer:5.5.1" level="project" />
<orderEntry type="library" name="Maven: net.sf.dozer:dozer-spring:5.5.1" level="project" />
<orderEntry type="library" name="Maven: org.xerial.snappy:snappy-java:1.1.2.6" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-redis-cluster:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config-client:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-redis-cluster:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config-client:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-redis:1.8.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-keyvalue:1.2.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:1.13.10.RELEASE" level="project" />
... ... @@ -70,9 +85,9 @@
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp3:logging-interceptor:3.8.1" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-client-simple:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-client-simple:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.2" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-common:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-common:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-mapper-asl:1.9.13" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-core-asl:1.9.13" level="project" />
<orderEntry type="library" name="Maven: io.protostuff:protostuff-core:1.4.4" level="project" />
... ... @@ -82,13 +97,13 @@
<orderEntry type="library" name="Maven: io.netty:netty-all:4.1.6.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.6.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.6.Final" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-alarm:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-alarm:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance-model:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.apache.curator:curator-x-discovery:2.9.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpasyncclient:4.1.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore-nio:4.4.5" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-cache:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-cache:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: net.spy:spymemcached:2.12.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.3.8.RELEASE" level="project" />
... ... @@ -118,6 +133,7 @@
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.5" level="project" />
<orderEntry type="library" name="Maven: commons-httpclient:commons-httpclient:3.1" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.0.4" level="project" />
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.1" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.6.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.6.3" level="project" />
... ... @@ -132,21 +148,29 @@
<orderEntry type="library" name="Maven: javax.mail:mail:1.4.1" level="project" />
<orderEntry type="library" name="Maven: javax.activation:activation:1.1" level="project" />
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.2" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:uic-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:social-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="uic-service-model" />
<orderEntry type="library" name="Maven: com.yoho.service.model:social-service-model:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.8.7" level="project" />
<orderEntry type="library" name="Maven: org.jdom:jdom:1.1" level="project" />
<orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.0.b2" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk16:1.46" level="project" />
<orderEntry type="library" name="Maven: com.squareup.retrofit:retrofit:1.9.0" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.14.4" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:resource-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:users-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:shops-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:order-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="resource-service-model" />
<orderEntry type="module" module-name="users-service-model" />
<orderEntry type="module" module-name="shops-service-model" />
<orderEntry type="module" module-name="order-service-model" />
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.13.sec01" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:product-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:promotion-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="product-service-model" />
<orderEntry type="module" module-name="promotion-service-model" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" />
<orderEntry type="module" module-name="yohoufo-fore-dal" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-dbcp2:2.1.1" level="project" />
<orderEntry type="library" name="Maven: commons-dbcp:commons-dbcp:1.4" level="project" />
<orderEntry type="library" name="Maven: commons-pool:commons-pool:20030825.183949" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:1.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.2.6" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.30" level="project" />
</component>
</module>
\ No newline at end of file
... ...
... ... @@ -8,6 +8,7 @@ import com.yoho.core.common.utils.MD5;
import org.junit.Test;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.Date;
import java.util.List;
... ... @@ -31,11 +32,14 @@ public class PayTest {
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", "31945075157");
data.put("merOrderId", "31942222222222");
data.put("mid", "898310148160568"); //商户号 仅用于支付宝和云闪付
data.put("tid","00000001"); //终端号
data.put("instMid", "APPDEFAULT"); // 机构商户号
data.put("totalAmount", 1);
// 回调接口 http://api-test3.dev.yohocorp.com/payment/weixin_notify
data.put("notifyUrl", "http://testapi.yohops.com/payment/weixin_notify");
data.put("sign", getSign(data));
... ... @@ -126,19 +130,25 @@ public class PayTest {
* 订单查询接口
*/
@Test
public void testQuary(){
public void testQuary() throws Exception{
JSONObject data = new JSONObject();
data.put("msgSrc","WWW.TEST.COM");
// 支付宝
data.put("msgType", "query"); // 微信:wx.unifiedOrder, 支付宝:trade.precreate, 全民付:qmf.order, 银联云闪付:uac.appOrder
data.put("requestTimestamp", DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss"));
data.put("merOrderId", "24455075157");
data.put("merOrderId", "319450751581111111");
data.put("mid", "898310148160568"); //商户号 仅用于支付宝和云闪付
data.put("tid","00000001"); //终端号
data.put("instMid", "APPDEFAULT"); // 机构商户号
data.put("sign", getSign(data));
HttpClient httpClient = new HttpClient();
httpClient.init();
String result = httpClient.post(url, JSON.toJSONString(data));
System.out.println(result);
}
... ... @@ -146,20 +156,25 @@ public class PayTest {
* 订单退款
*/
@Test
public void testRefund(){
public void testRefund()throws Exception{
JSONObject data = new JSONObject();
data.put("msgSrc","WWW.TEST.COM");
// 支付宝
data.put("msgType", "refund"); // 微信:wx.unifiedOrder, 支付宝:trade.precreate, 全民付:qmf.order, 银联云闪付:uac.appOrder
data.put("requestTimestamp", DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss"));
data.put("merOrderId", "24455075157");
data.put("merOrderId", "319450751589999");
data.put("mid", "898310148160568"); //商户号 仅用于支付宝和云闪付
data.put("tid","00000001"); //终端号
data.put("instMid", "APPDEFAULT"); // 机构商户号
data.put("refundAmount",1);
data.put("sign", getSign(data));
HttpClient httpClient = new HttpClient();
httpClient.init();
String result = httpClient.post(url, JSON.toJSONString(data));
System.out.println(result);
}
/**
... ... @@ -184,4 +199,13 @@ public class PayTest {
// 回调接口
@Test
public void tes(){
BigDecimal bigDecimal = new BigDecimal("22.88");
System.out.println(bigDecimal);
}
}
... ...
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.0.4" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.0.b2" level="project" />
<orderEntry type="module" module-name="yohoufo-fore-common" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-trace:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-common:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-redis-cluster:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config-client:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-client-simple:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-common:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-alarm:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-cache:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:uic-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:social-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="yohoufo-fore-common" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-trace:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.netflix.hystrix:hystrix-core:1.4.21" level="project" />
<orderEntry type="library" name="Maven: io.reactivex:rxjava:1.0.14" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.6.3" level="project" />
... ... @@ -27,32 +44,29 @@
<orderEntry type="library" name="Maven: com.esotericsoftware:kryo-shaded:3.0.3" level="project" />
<orderEntry type="library" name="Maven: com.esotericsoftware:minlog:1.3.0" level="project" />
<orderEntry type="library" name="Maven: org.objenesis:objenesis:2.1" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.netflix.archaius:archaius-zookeeper:0.7.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.zookeeper:zookeeper:3.4.6" level="project" />
<orderEntry type="library" name="Maven: jline:jline:0.9.94" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty:3.7.0.Final" level="project" />
<orderEntry type="library" name="Maven: org.apache.curator:curator-framework:2.9.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.curator:curator-client:2.9.1" level="project" />
<orderEntry type="library" name="Maven: com.yoho.common:error-code:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="error-code" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.13.sec01" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-test:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.14" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-common:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-common:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.apache.curator:curator-recipes:2.9.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.3" level="project" />
<orderEntry type="library" name="Maven: net.sf.dozer:dozer:5.5.1" level="project" />
<orderEntry type="library" name="Maven: net.sf.dozer:dozer-spring:5.5.1" level="project" />
<orderEntry type="library" name="Maven: org.xerial.snappy:snappy-java:1.1.2.6" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-redis-cluster:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config-client:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-redis-cluster:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-config-client:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-redis:1.8.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-keyvalue:1.2.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:1.13.10.RELEASE" level="project" />
... ... @@ -70,9 +84,9 @@
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp3:logging-interceptor:3.8.1" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-client-simple:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-client-simple:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.2" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-common:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-common:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-mapper-asl:1.9.13" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-core-asl:1.9.13" level="project" />
<orderEntry type="library" name="Maven: io.protostuff:protostuff-core:1.4.4" level="project" />
... ... @@ -82,13 +96,13 @@
<orderEntry type="library" name="Maven: io.netty:netty-all:4.1.6.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.6.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.6.Final" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-alarm:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-alarm:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-rest-governance-model:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.apache.curator:curator-x-discovery:2.9.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpasyncclient:4.1.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore-nio:4.4.5" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-cache:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.core:yoho-core-cache:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: net.spy:spymemcached:2.12.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.3.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.3.8.RELEASE" level="project" />
... ... @@ -118,6 +132,7 @@
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.5" level="project" />
<orderEntry type="library" name="Maven: commons-httpclient:commons-httpclient:3.1" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.0.4" level="project" />
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.1" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.6.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.6.3" level="project" />
... ... @@ -132,21 +147,31 @@
<orderEntry type="library" name="Maven: javax.mail:mail:1.4.1" level="project" />
<orderEntry type="library" name="Maven: javax.activation:activation:1.1" level="project" />
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.2" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:uic-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:social-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="uic-service-model" />
<orderEntry type="library" name="Maven: com.yoho.service.model:social-service-model:1.4.5-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.8.7" level="project" />
<orderEntry type="library" name="Maven: org.jdom:jdom:1.1" level="project" />
<orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.0.b2" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk16:1.46" level="project" />
<orderEntry type="library" name="Maven: com.squareup.retrofit:retrofit:1.9.0" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.14.4" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:resource-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:users-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:shops-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="resource-service-model" />
<orderEntry type="module" module-name="users-service-model" />
<orderEntry type="module" module-name="shops-service-model" />
<orderEntry type="module" module-name="yohoufo-fore-order" />
<orderEntry type="library" name="Maven: com.yoho.service.model:order-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:product-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.yoho.service.model:promotion-service-model:1.4.4-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="order-service-model" />
<orderEntry type="module" module-name="product-service-model" />
<orderEntry type="module" module-name="promotion-service-model" />
<orderEntry type="module" module-name="yohoufo-fore-dal" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-dbcp2:2.1.1" level="project" />
<orderEntry type="library" name="Maven: commons-dbcp:commons-dbcp:1.4" level="project" />
<orderEntry type="library" name="Maven: commons-pool:commons-pool:20030825.183949" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:1.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.2.6" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.30" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>
\ No newline at end of file
... ...