Authored by LUOXC

Merge branch 'gray' into hotfix-transfer

# Conflicts:
#	order/src/main/java/com/yohoufo/order/service/impl/PaymentServiceImpl.java
Showing 100 changed files with 916 additions and 216 deletions

Too many changes to show.

To preserve performance only 100 of 100+ files are displayed.

... ... @@ -6,18 +6,24 @@ import lombok.ToString;
@Data
@ToString
@EqualsAndHashCode(callSuper=false)
@EqualsAndHashCode(callSuper = false)
public class SmsAlarmEvent extends Event {
private String name;
private String type;
private String content;
private Throwable throwable;
public SmsAlarmEvent() {
}
public SmsAlarmEvent(String name, String type, String content) {
this(name, type, content, null);
}
public SmsAlarmEvent(String name, String type, String content, Throwable throwable) {
this.name = name;
this.type = type;
this.content = content;
this.throwable = throwable;
}
}
\ No newline at end of file
... ...
... ... @@ -5,7 +5,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
@Component
public class SmsAlarmEventHandler implements IEventHandler<SmsAlarmEvent> {
private Logger logger = LoggerFactory.getLogger(getClass());
... ... @@ -17,7 +19,11 @@ public class SmsAlarmEventHandler implements IEventHandler<SmsAlarmEvent> {
@Subscribe
public void handle(SmsAlarmEvent event) {
logger.info("begin to handle sms alarm event:{}", event);
publisher.publishEvent(new SendSmsEvent(event.getName(), event.getType(), event.getContent()));
StringBuilder smsContent = new StringBuilder(event.getContent());
if (event.getThrowable() != null) {
smsContent.append(" Caused by: ").append(event.getThrowable().toString());
}
publisher.publishEvent(new SendSmsEvent(event.getName(), event.getType(), smsContent.toString()));
logger.info("end to handle sms alarm event");
}
}
\ No newline at end of file
... ...
... ... @@ -16,7 +16,7 @@ import java.util.concurrent.TimeUnit;
public enum CacheKeyEnum {
// user - passport -authorize
AUTHORIZE_INFO_KEY("ufo:user:authorizeInfo:","实名认证信息", 15, TimeUnit.MINUTES),
AUTHORIZE_INFO_KEY("ufo:user:authorizeInfo:","实名认证信息", 10, TimeUnit.MINUTES),
ZHI_MA_CERT_KEY("ufo:user:zhiMaCert:","芝麻认证信息", 10, TimeUnit.MINUTES),
... ...
... ... @@ -3,11 +3,13 @@ package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.BuyerOrderMeta;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface BuyerOrderMetaMapper {
int insert(BuyerOrderMeta record);
int insertSelective(BuyerOrderMeta record);
int insertBatch(@Param( "list" ) List<BuyerOrderMeta> list);
BuyerOrderMeta selectByPrimaryKey(Integer id);
... ...
... ... @@ -26,8 +26,6 @@ public interface SellerWalletMapper {
SellerWallet selectByUidNType(SellerWallet condition);
void updateMoneyForTest();
int changeAllMoneyToAvail(@Param("uid") Integer uid, @Param("updateTime") Integer updateTime);
int rejoin(@Param("uid") Integer uid, @Param("amount") BigDecimal amount
... ...
... ... @@ -6,7 +6,7 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* @author caoyan
... ...
... ... @@ -30,6 +30,9 @@ public class BuyerOrder {
private Integer status;
// 原始状态
private Integer originalStatus;
private Integer createTime;
private Integer updateTime;
... ... @@ -55,6 +58,17 @@ public class BuyerOrder {
@Getter@Setter
private Integer sellerDeliveryDealAgain;//48小时处理,操作员是否已经处理:0:未处理 ,1 :已处理
@Getter@Setter
private Integer activityType;//活动类型:0:普通,18:砍价
public Integer getOriginalStatus() {
return originalStatus;
}
public void setOriginalStatus(Integer originalStatus) {
this.originalStatus = originalStatus;
}
public Integer getId() {
return id;
}
... ...
... ... @@ -20,6 +20,11 @@ public class BuyerOrderGoods {
*/
private BigDecimal couponCutAmount;
/**
* 优惠券减免金额
*/
private BigDecimal activityCutAmount;
public Integer getUid() {
return uid;
}
... ... @@ -75,4 +80,12 @@ public class BuyerOrderGoods {
public void setCouponCutAmount(BigDecimal couponCutAmount) {
this.couponCutAmount = couponCutAmount;
}
public BigDecimal getActivityCutAmount() {
return activityCutAmount;
}
public void setActivityCutAmount(BigDecimal activityCutAmount) {
this.activityCutAmount = activityCutAmount;
}
}
\ No newline at end of file
... ...
... ... @@ -3,7 +3,7 @@ package com.yohoufo.dal.order.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
... ...
... ... @@ -3,7 +3,7 @@ package com.yohoufo.dal.order.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
@Data
@Builder
... ...
... ... @@ -2,7 +2,7 @@ package com.yohoufo.dal.order.model;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
... ...
... ... @@ -2,7 +2,7 @@ package com.yohoufo.dal.order.model;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
... ...
... ... @@ -33,7 +33,10 @@ public class TradeBills {
//yoho收入
private BigDecimal systemAmount;
//100:成功;200:失败,201:没有支付宝账号;202:金额不合法;299:转账失败
/**
* 100:成功;200:失败,201:没有支付宝账号;202:金额不合法;299:转账失败
* {@link com.yohoufo.order.common.BillTradeStatus}
*/
private Integer tradeStatus;
private Integer createTime;
... ... @@ -50,6 +53,7 @@ public class TradeBills {
//打款关联id
private Integer dealRelateId = 0;
@Deprecated
public static enum Status {
TRANSFER_WAITING(90);
... ...
... ... @@ -19,4 +19,6 @@ public interface ProductMapper {
List<Product> selectByIds(List<Integer> ids);
List<Product> selectByProductCode(@Param("productCode") String productCode);
String selectIntroByProductId(Integer id);
}
\ No newline at end of file
... ...
package com.yohoufo.dal.product;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yohoufo.dal.product.model.SelfSize;
public interface SelfSizeMapper {
int insertBatch(@Param("list") List<SelfSize> list);
List<SelfSize> selectByProductIdAndSizeId(@Param("productId") Integer productId, @Param("sizeIdList") List<Integer> sizeIdList);
}
\ No newline at end of file
... ...
package com.yohoufo.dal.product;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yohoufo.dal.product.model.SelfSizeUid;
public interface SelfSizeUidMapper {
int insertBatch(@Param("list") List<SelfSizeUid> list);
List<SelfSizeUid> selectByProductIdAndSizeId(@Param("productId") Integer productId, @Param("sizeIdList") List<Integer> sizeIdList);
}
\ No newline at end of file
... ...
... ... @@ -3,6 +3,8 @@ package com.yohoufo.dal.product;
import com.yohoufo.dal.product.model.Size;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface SizeMapper {
int insert(Size record);
... ... @@ -14,4 +16,11 @@ public interface SizeMapper {
int updateByPrimaryKey(Size record);
List<Size> selectByIds(List<Integer> ids);
/**
* 根据品类查询所有的尺码
* @param sortId
* @return
*/
List<Size> selectAllSizeBySortIdList(@Param("sortIdList") List<Integer> sortIdList);
}
\ No newline at end of file
... ...
package com.yohoufo.dal.product.model;
public class SelfSize {
private Integer id;
private Integer productId;
private Integer goodsId;
private Integer sizeId;
private Integer auditTime;
private Integer auditUid;
private Integer status;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getProductId() {
return productId;
}
public void setProductId(Integer productId) {
this.productId = productId;
}
public Integer getGoodsId() {
return goodsId;
}
public void setGoodsId(Integer goodsId) {
this.goodsId = goodsId;
}
public Integer getSizeId() {
return sizeId;
}
public void setSizeId(Integer sizeId) {
this.sizeId = sizeId;
}
public Integer getAuditTime() {
return auditTime;
}
public void setAuditTime(Integer auditTime) {
this.auditTime = auditTime;
}
public Integer getAuditUid() {
return auditUid;
}
public void setAuditUid(Integer auditUid) {
this.auditUid = auditUid;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}
\ No newline at end of file
... ...
package com.yohoufo.dal.product.model;
public class SelfSizeUid {
private Integer id;
private Integer productId;
private Integer goodsId;
private Integer sizeId;
private Integer uid;
private Integer createTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getProductId() {
return productId;
}
public void setProductId(Integer productId) {
this.productId = productId;
}
public Integer getGoodsId() {
return goodsId;
}
public void setGoodsId(Integer goodsId) {
this.goodsId = goodsId;
}
public Integer getSizeId() {
return sizeId;
}
public void setSizeId(Integer sizeId) {
this.sizeId = sizeId;
}
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
}
\ No newline at end of file
... ...
package com.yohoufo.dal.promotion.model;
import lombok.Data;
import lombok.experimental.Builder;
import lombok.Builder;
@Data
@Builder
... ...
... ... @@ -25,4 +25,6 @@ public interface IInBoxDao {
void insertInbox(@Param("tableName")String tableName, @Param("inBox")InBox inBox);
InBox selectNewUserGuideInBox(@Param("tableName")String tableName, @Param("businessType") Integer businessType, @Param("uid") Integer uid);
int insertBatch(@Param("tableName") String tableName, @Param("list") List<InBox> list);
}
... ...
package com.yohoufo.dal.user;
import com.yohoufo.dal.user.model.UserAuthorizeInfo;
import org.apache.ibatis.annotations.Param;
public interface IUserAuthorizeInfoDao {
//获取生效的认证信息
UserAuthorizeInfo selectValidAuthorizeInfoByUid(int uid);
//失效信息
int updateToUnValidStatusByUid(@Param("uid") int uid,@Param("updateTime") long updateTime);
int insert(UserAuthorizeInfo userAuthorizeInfo);
int insertSelective(UserAuthorizeInfo userAuthorizeInfo);
... ...
... ... @@ -9,9 +9,10 @@
<result column="goods_price" jdbcType="DECIMAL" property="goodsPrice" />
<result column="goods_amount" jdbcType="DECIMAL" property="goodsAmount" />
<result column="coupon_cut_amount" jdbcType="DECIMAL" property="couponCutAmount" />
<result column="activity_cut_amount" jdbcType="DECIMAL" property="activityCutAmount" />
</resultMap>
<sql id="Base_Column_List">
id, order_code, skup, goods_price, goods_amount, uid,coupon_cut_amount
id, order_code, skup, goods_price, goods_amount, uid,coupon_cut_amount,activity_cut_amount
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
... ... @@ -87,6 +88,9 @@
<if test="couponCutAmount != null">
coupon_cut_amount,
</if>
<if test="activityCutAmount != null">
activity_cut_amount,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderCode != null">
... ... @@ -107,6 +111,9 @@
<if test="couponCutAmount != null">
#{couponCutAmount,jdbcType=DECIMAL},
</if>
<if test="activityCutAmount != null">
#{activityCutAmount,jdbcType=DECIMAL}
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.BuyerOrderGoods">
... ...
... ... @@ -23,11 +23,12 @@
<result column="seller_delivery_status" jdbcType="INTEGER" property="sellerDeliveryStatus" />
<result column="seller_delivery_deal" jdbcType="INTEGER" property="sellerDeliveryDeal" />
<result column="seller_delivery_deal_again" jdbcType="INTEGER" property="sellerDeliveryDealAgain" />
<result column="activity_type" jdbcType="INTEGER" property="activityType" />
</resultMap>
<sql id="Base_Column_List">
id, uid, order_code, seller_uid, client_type, payment, payment_type, is_cancel, amount,
ship_fee, status, create_time, update_time, buyer_order_status, seller_order_status, channel_no, attributes,platform_delivery_status,
seller_delivery_status,seller_delivery_deal,seller_delivery_deal_again
seller_delivery_status,seller_delivery_deal,seller_delivery_deal_again,activity_type
</sql>
... ... @@ -143,14 +144,15 @@
is_cancel, amount, ship_fee,
status, create_time, update_time,
buyer_order_status, seller_order_status, channel_no, attributes,platform_delivery_status,
seller_delivery_status,seller_delivery_deal,seller_delivery_deal_again)
seller_delivery_status,seller_delivery_deal,seller_delivery_deal_again,activity_type)
values (#{uid,jdbcType=INTEGER}, #{orderCode,jdbcType=BIGINT}, #{sellerUid,jdbcType=INTEGER},
#{clientType,jdbcType=INTEGER}, #{payment,jdbcType=INTEGER}, #{paymentType,jdbcType=TINYINT},
#{isCancel,jdbcType=TINYINT}, #{amount,jdbcType=DECIMAL}, #{shipFee,jdbcType=DECIMAL},
#{status,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER},
#{buyerOrderStatus,jdbcType=INTEGER}, #{sellerOrderStatus,jdbcType=INTEGER}, #{channelNo,jdbcType=VARCHAR},
#{attributes,jdbcType=INTEGER},#{platformDeliveryStatus,jdbcType=INTEGER},
#{sellerDeliveryStatus,jdbcType=INTEGER},#{sellerDeliveryDeal,jdbcType=INTEGER},#{sellerDeliveryDealAgain,jdbcType=INTEGER})
#{sellerDeliveryStatus,jdbcType=INTEGER},#{sellerDeliveryDeal,jdbcType=INTEGER},
#{sellerDeliveryDealAgain,jdbcType=INTEGER},#{activityType,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.BuyerOrder" useGeneratedKeys="true">
insert into buyer_order
... ... @@ -349,6 +351,9 @@
update_time = #{updateTime,jdbcType=INTEGER}
where uid = #{uid,jdbcType=INTEGER}
and order_code = #{orderCode,jdbcType=BIGINT}
<if test="originalStatus != null">
and status = #{originalStatus,jdbcType=INTEGER}
</if>
</update>
... ...
... ... @@ -40,6 +40,15 @@
values (#{orderCode,jdbcType=BIGINT}, #{uid,jdbcType=INTEGER}, #{metaKey,jdbcType=VARCHAR},
#{metaValue,jdbcType=VARCHAR})
</insert>
<insert id="insertBatch" parameterType="java.util.List">
insert into buyer_order_meta (order_code, uid, meta_key, meta_value)
values
<foreach collection="list" item="record" separator=",">
(#{record.orderCode,jdbcType=BIGINT}, #{record.uid,jdbcType=INTEGER}, #{record.metaKey,jdbcType=VARCHAR}, #{record.metaValue,jdbcType=VARCHAR})
</foreach>
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.BuyerOrderMeta" useGeneratedKeys="true">
insert into buyer_order_meta
<trim prefix="(" suffix=")" suffixOverrides=",">
... ...
... ... @@ -180,8 +180,4 @@
update seller_wallet set amount = amount + lock_amount ,lock_amount = 0,update_time = #{updateTime,jdbcType=INTEGER} where uid = #{uid}
</update>
<update id="updateMoneyForTest">
update seller_wallet set amount = amount + 10 where id = 3
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -90,4 +90,9 @@
from product
where product_code = #{productCode,jdbcType=VARCHAR}
</select>
<select id="selectIntroByProductId" parameterType="java.lang.Integer" resultType="java.lang.String">
select product_intro
from product_intro
where product_id = #{productId} limit 1
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -27,8 +27,8 @@
<select id="selectValid" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from sale_category where status=0
order by order_by
from sale_category where status=0 and level=1
order by order_by desc
</select>
<select id="selectByPidList" resultMap="BaseResultMap">
... ... @@ -37,7 +37,7 @@
<foreach item="item" index="index" collection="pidList" open="(" separator="," close=")">
#{item}
</foreach>
and status=0 order by order_by
and status=0 order by order_by desc
</select>
</mapper>
\ No newline at end of file
... ...
<?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.dal.product.SelfSizeMapper">
<resultMap id="BaseResultMap" type="com.yohoufo.dal.product.model.SelfSize">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="product_id" jdbcType="INTEGER" property="productId" />
<result column="goods_id" jdbcType="INTEGER" property="goodsId" />
<result column="size_id" jdbcType="INTEGER" property="sizeId" />
<result column="audit_time" jdbcType="INTEGER" property="auditTime" />
<result column="audit_uid" jdbcType="INTEGER" property="auditUid" />
<result column="status" jdbcType="INTEGER" property="status" />
</resultMap>
<insert id="insertBatch">
insert into self_size(
product_id,
goods_id,
size_id)values
<foreach collection="list" separator="," item="item">
(#{item.productId},#{item.goodsId},#{item.sizeId})
</foreach>
</insert>
<select id="selectByProductIdAndSizeId" resultMap="BaseResultMap">
select id, product_id, goods_id, size_id
from self_size
where status=0 and product_id=#{productId} and size_id in
<foreach item="sizeId" index="index" collection="sizeIdList" open="(" separator="," close=")">
#{sizeId}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
<?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.dal.product.SelfSizeUidMapper">
<resultMap id="BaseResultMap" type="com.yohoufo.dal.product.model.SelfSizeUid">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="product_id" jdbcType="INTEGER" property="productId" />
<result column="goods_id" jdbcType="INTEGER" property="goodsId" />
<result column="size_id" jdbcType="INTEGER" property="sizeId" />
<result column="uid" jdbcType="INTEGER" property="uid" />
<result column="create_time" jdbcType="INTEGER" property="createTime" />
</resultMap>
<insert id="insertBatch">
insert into self_size_uid(
product_id,
goods_id,
size_id,
uid,
create_time)values
<foreach collection="list" separator="," item="item">
(#{item.productId}, #{item.goodsId}, #{item.sizeId}, #{item.uid}, UNIX_TIMESTAMP())
</foreach>
</insert>
<select id="selectByProductIdAndSizeId" resultMap="BaseResultMap">
select product_id, goods_id, size_id, uid, create_time
from self_size_uid
where product_id=#{productId} and size_id in
<foreach item="sizeId" index="index" collection="sizeIdList" open="(" separator="," close=")">
#{sizeId}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -45,4 +45,16 @@
</foreach>
order by order_by
</select>
<select id="selectAllSizeBySortIdList" resultMap="BaseResultMap">
select s.id, s.size_name,ss.order_by
from size s inner join sort_size ss on s.id = ss.size_id where ss.del = 0
<if test="sortIdList != null and sortIdList.size() >0 ">
and ss.sort_id in
<foreach item="item" index="index" collection="sortIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
order by ss.order_by, ss.id
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -25,6 +25,12 @@
order by id desc limit 1
</select>
<update id="updateToUnValidStatusByUid">
update authorize_info
set valid_status = 0,update_time = #{updateTime}
where uid = #{uid,jdbcType=INTEGER} and valid_status = 1
</update>
<insert id="insert" parameterType="com.yohoufo.dal.user.model.UserAuthorizeInfo" >
insert into authorize_info (uid, valid_status, alipay_account, cert_name, create_time, update_time)
values (#{uid},#{validStatus},
... ...
... ... @@ -59,4 +59,15 @@
FROM ${tableName} where uid = #{uid} and business_type = #{businessType}
limit 1
</select>
<insert id="insertBatch">
insert into ${tableName}
(uid,title,content,type,is_read,create_time,is_del, business_type,action)
values
<foreach collection="list" separator="," item="inBox">
(#{inBox.uid},#{inBox.title},#{inBox.content},#{inBox.type},#{inBox.isRead},
#{inBox.createTime},#{inBox.isDel},#{inBox.businessType},#{inBox.action})
</foreach>
</insert>
</mapper>
\ No newline at end of file
... ...
... ... @@ -14,4 +14,8 @@ public class UrlConstant {
public String getInboxAddUrl(){
return baseUrl+"&method=ufo.users.addInbox";
}
public String getInboxAddBatchUrl() {
return baseUrl+"&method=ufo.users.addBatchInbox";
}
}
... ...
... ... @@ -39,7 +39,16 @@ public class InboxController {
logger.info("InboxController.addInbox call result is {}",result);
return "SUCCESS";
}
@RequestMapping(value = "/addBatchInboxForPlatform")
@IgnoreSession
@IgnoreSignature
public String addBatchInboxForPlatform(@RequestBody InboxReqVO reqVO){
logger.info("InboxController.addInbox with param is {}", reqVO);
InBoxResponse result = inBoxSDK.addBatchInbox(reqVO);
logger.info("InboxController.addBatchInbox call result is {}",result);
return "SUCCESS";
}
@RequestMapping(value = "/sendSmsForPlatform")
@IgnoreSession
... ...
... ... @@ -10,6 +10,7 @@ public class InboxReqVO extends BaseVO{
private Integer type;
private Integer businessType;
private String params;
private String uids;
public String getParams() {
return params;
... ... @@ -42,4 +43,13 @@ public class InboxReqVO extends BaseVO{
public void setBusinessType(Integer businessType) {
this.businessType = businessType;
}
public String getUids() {
return uids;
}
public void setUids(String uids) {
this.uids = uids;
}
}
... ...
... ... @@ -37,4 +37,12 @@ public class InBoxSDK {
log.info("addInbox call result is {}",result);
return result;
}
public InBoxResponse addBatchInbox(InboxReqVO reqVO){
log.info("addBatchInbox with param is {}", reqVO);
InBoxResponse result = restTemplate.getForObject(urlConstant.getInboxAddBatchUrl()+"&uids={1}&type={2}&businessType={3}&params={4}",InBoxResponse.class,
reqVO.getUids(),reqVO.getType(),reqVO.getBusinessType(),reqVO.getParams());
log.info("addBatchInbox call result is {}",result);
return result;
}
}
... ...
package com.yohoufo.order.annotation;
import com.yohoufo.order.common.BlackTypeEnum;
import org.springframework.stereotype.Component;
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
@Component
public @interface BlackUserType {
BlackTypeEnum blackType();
}
... ...
... ... @@ -4,6 +4,7 @@ import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.order.charge.model.ChargeGoods;
import com.yohoufo.order.charge.model.ChargeParam;
import com.yohoufo.order.charge.model.ChargeResult;
import com.yohoufo.order.charge.model.ActivityPrice;
import lombok.Data;
import lombok.ToString;
import lombok.Builder;
... ... @@ -20,6 +21,7 @@ public class ChargeContext {
//--------------input ------------//
private ChargeParam chargeParam;
private ChargeGoods chargeGoods;
private ActivityPrice activityPrice;
private boolean shipFeeRequird;
private Pair<AddressInfo, AddressInfo> userAddressPair;
... ...
... ... @@ -15,6 +15,7 @@ import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
... ... @@ -71,16 +72,46 @@ public class ChargeService {
* @param chargeContext
*/
private void calculateGoodsAmount(ChargeContext chargeContext) {
ChargeResult chargeResult = chargeContext.getChargeResult();
//算费商品
ChargeGoods chargeGoods = chargeContext.getChargeGoods();
chargeContext.getChargeResult().setGoodsAmount(chargeGoods.getGoodsAmount().doubleValue());
chargeContext.getChargeResult().setFinalAmount(chargeGoods.getGoodsAmount().doubleValue());
chargeResult.setGoodsAmount(chargeGoods.getRealPrice().doubleValue());
chargeResult.setFinalAmount(chargeGoods.getRealPrice().doubleValue());
logger.info("[{}] step goods charge,goodsPrice:{},goodsAmount:{},amount:{}",
chargeContext.getChargeParam().getUid(),
chargeGoods.getGoodsPrice(),
chargeContext.getChargeResult().getGoodsAmount(),
chargeContext.getChargeResult().getFinalAmount());
chargeResult.getGoodsAmount(),
chargeResult.getFinalAmount());
//活动优惠
ActivityPrice activityPrice = chargeContext.getActivityPrice();
if (activityPrice.getCutPrice() == null) {
return;
}
//最终优惠的金额
BigDecimal realCutPrice = chargeGoods.getGoodsPrice().min(activityPrice.getCutPrice());
chargeGoods.setActivityCutPrice(realCutPrice);
double oldFinalAmount = chargeResult.getFinalAmount();
double newFinalAmount = Math.max(0, YHMath.sub(oldFinalAmount, realCutPrice.doubleValue()));
chargeResult.setFinalAmount(newFinalAmount);
ActivityCutResult activityCutResult = ActivityCutResult.builder()
.userActivityId(activityPrice.getUserActivityId())
.activityType(activityPrice.getActivityTypeEnum().getCode())
.activityCutAmount(realCutPrice.doubleValue())
.build();
chargeResult.setActivityCutResult(activityCutResult);
logger.info("[{}] step activity charge,goodsPrice:{},realPrice:{},oldFinalAmount:{},newFinalAmount:{},activityPrice:{},activityCutResult:{}",
chargeContext.getChargeParam().getUid(),
chargeGoods.getGoodsPrice(),
chargeGoods.getRealPrice(),
oldFinalAmount, chargeResult.getFinalAmount(),
activityPrice,
chargeResult.getActivityCutResult());
}
... ... @@ -177,7 +208,7 @@ public class ChargeService {
*/
UserCouponsBo userCouponsBo = getOneUsableUserCouponBo(chargeContext);
//券金额 取最小
double couponPayAmount = Math.min(chargeContext.getChargeGoods().getGoodsAmount().doubleValue(), userCouponsBo.getCouponAmount().doubleValue());
double couponPayAmount = Math.min(chargeContext.getChargeGoods().getRealPrice().doubleValue(), userCouponsBo.getCouponAmount().doubleValue());
ChargeResult chargeResult = chargeContext.getChargeResult();
... ...
... ... @@ -127,7 +127,7 @@ public class CouponRuleMatcher {
return true;
} else if (limitTypeEnum == CouponUseLimitTypeEnum.AMOUNT_LIMIT) {
//金额
return chargeGoods.getGoodsAmount().compareTo(BigDecimal.valueOf(Double.parseDouble(couponsBo.getUseLimitValue()))) >= 0;
return chargeGoods.getRealPrice().compareTo(BigDecimal.valueOf(Double.parseDouble(couponsBo.getUseLimitValue()))) >= 0;
} else {
//不应该存在
return false;
... ...
package com.yohoufo.order.charge.model;
import lombok.Builder;
import lombok.Data;
import lombok.ToString;
/**
* Created by jiexiang.wu on 2019/5/22.
* 活动优惠结果
*/
@Data
@ToString
@Builder
public class ActivityCutResult {
//用户活动记录
private int userActivityId;
//活动类型
private int activityType;
/**
* 活动减免金额
*/
private double activityCutAmount;
}
... ...
package com.yohoufo.order.charge.model;
import com.yohoufo.order.constants.ActivityTypeEnum;
import lombok.*;
import java.math.BigDecimal;
/**
* Created by jiexiang.wu on 2019/5/21.
* 活动价
* 参与活动的商品可以减免一定的金额
*/
@Data
@ToString
@Builder
public class ActivityPrice {
//用户活动记录
private int userActivityId;
//活动类型
private ActivityTypeEnum activityTypeEnum;
//减免金额
private BigDecimal cutPrice;
}
... ...
... ... @@ -2,7 +2,7 @@ package com.yohoufo.order.charge.model;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
... ... @@ -25,12 +25,18 @@ public class ChargeGoods {
*/
private BigDecimal goodsPrice;
/**
* 商品金额
* 活动减免金额
*/
private BigDecimal activityCutPrice;
/**
* 实际价格
*
* @return
*/
public BigDecimal getGoodsAmount() {
return goodsPrice;
public BigDecimal getRealPrice() {
return goodsPrice.subtract(activityCutPrice);
}
}
... ...
... ... @@ -2,7 +2,7 @@ package com.yohoufo.order.charge.model;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Builder;
import lombok.Builder;
import java.util.List;
... ...
... ... @@ -26,20 +26,26 @@ public class ChargeResult {
*/
private int deliveryWay;
/**
* 最终实付金额
*/
private double finalAmount;
/**
* 优惠券支付结果
* 活动优惠结果
*/
private CouponPayResult couponPayResult;
private ActivityCutResult activityCutResult;
/**
* 最终实付金额
* 优惠券支付结果
*/
private double finalAmount;
private CouponPayResult couponPayResult;
public ChargeResult() {
//init
this.couponPayResult = CouponPayResult.builder().build();
this.activityCutResult = ActivityCutResult.builder().build();
}
}
... ...
package com.yohoufo.order.common;
/**
* 100:成功;200:失败,201:没有支付宝账号;202:金额不合法;299:转账失败
* Created by chao.chen on 2018/10/24.
*/
public enum BillTradeStatus {
SUCCESS(100),FAIL(200);
TRANSFER_WAITING(90),
SUCCESS(100),
FAIL(200),
NOT_EXIST_ALI_ACCOUNT(201),
AMOUNT_IS_ILLEGAL(202),
TRANSFER_FAIL(299);
int code;
... ...
package com.yohoufo.order.constants;
import java.util.stream.Stream;
/**
* Created by jiexiang.wu on 2019/5/21.
*/
public enum ActivityTypeEnum {
//普通,无活动
COMMON(0, true),
//砍价
BARGAIN(18, false);
private int code;
//券标记
private boolean couponFlag;
ActivityTypeEnum(int code,boolean couponFlag) {
this.code = code;
this.couponFlag = couponFlag;
}
public int getCode() {
return code;
}
public boolean isCouponFlag() {
return couponFlag;
}
public static ActivityTypeEnum find(int code) {
return Stream.of(values()).filter((e) -> e.getCode() == code)
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("unknown code +(" + code + ")"));
}
}
... ...
... ... @@ -17,6 +17,11 @@ public interface MetaKey {
String BUYER_DELIVERY_HIDDEN_ADDRESS = "hidden_delivery_address";
/**
* 活动信息
*/
String ACTIVITY_KEY = "activity";
String SELLER_FEE = "fee";
/**
... ...
... ... @@ -2,9 +2,12 @@ package com.yohoufo.order.controller;
import com.yoho.core.rest.annotation.ServiceDesc;
import com.yoho.tools.common.beans.ApiResponse;
import com.yohobuy.ufo.model.order.constants.AllowChangeAddrStatus;
import com.yohobuy.ufo.model.order.req.BuyerOrderMetaUpdateReq;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.order.service.IBuyerOrderMetaService;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.commons.lang3.StringUtils;
... ... @@ -22,6 +25,9 @@ public class BuyerOrderMeta4PlatformController {
@Autowired
private IBuyerOrderMetaService buyerOrderMetaService;
@Autowired
BuyerOrderMapper buyerOrderMapper;
/**
* 更新物流数据
* 提供给运营平台使用
... ... @@ -36,6 +42,15 @@ public class BuyerOrderMeta4PlatformController {
if(req.getUid()<=0||req.getOrderCode()<=0|| StringUtils.isBlank(req.getAddress())){
return new ApiResponse.ApiResponseBuilder().code(400).message("参数校验不通过").build();
}
// check status
BuyerOrder buyerOrder=buyerOrderMapper.selectOnlyByOrderCode(req.getOrderCode());
if(buyerOrder==null){
return new ApiResponse.ApiResponseBuilder().code(400).message("订单不存在").build();
}
if(buyerOrder.getStatus()==null||!AllowChangeAddrStatus.isAllowChangeAddrByPlatform(buyerOrder.getStatus().intValue())){
logger.warn("BuyerOrderMeta4PlatformController updateDeliveryAddress not allow status {} param req is {}",buyerOrder.getStatus(), req);
return new ApiResponse.ApiResponseBuilder().code(400).message("订单状态不允许变更地址").build();
}
String result =buyerOrderMetaService.updateDeliveryAddress(req);
return new ApiResponse.ApiResponseBuilder().code(200)
.data(result).message("更新地址成功").build();
... ...
... ... @@ -10,8 +10,8 @@ import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.order.annotation.BlackUserType;
import com.yohoufo.order.common.BlackTypeEnum;
import com.yohoufo.order.interceptor.BlackUserInterceptor;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.OrderSubmitResp;
... ... @@ -92,6 +92,7 @@ public class SellerOrderController {
*/
@RequestMapping(params = "method=ufo.sellerOrder.publishPrd")
@ResponseBody
@BlackUserType(blackType = BlackTypeEnum.SELL)
public ApiResponse publishPrd(@RequestParam(name = "uid", required = true)int uid,
@RequestParam(name = "storage_id", required = true)int storage_id,
@RequestParam(name="price", required = true)String price,
... ... @@ -108,8 +109,6 @@ public class SellerOrderController {
.build();
logger.info("in ufo.sellerOrder.publishPrd, req {}", req);
BlackUserInterceptor.getBlackUserInteceptor(BlackTypeEnum.SELL.getCode()).before(uid);
OrderSubmitResp resp = sellerOrderService.publishPrd(req);
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("发布成功").build();
}
... ... @@ -524,6 +523,7 @@ public class SellerOrderController {
*/
@RequestMapping(params = "method=ufo.seller.publishImperfectPrd")
@ResponseBody
@BlackUserType(blackType = BlackTypeEnum.SELL)
public ApiResponse publishImperfectPrd(@RequestParam(name = "uid")int uid,
@RequestParam(name = "storage_id")int storage_id,
@RequestParam(name="price")String price,
... ... @@ -548,8 +548,6 @@ public class SellerOrderController {
.build();
logger.info("in ufo.sellerOrder.publishImperfectPrd, req {}", req);
BlackUserInterceptor.getBlackUserInteceptor(BlackTypeEnum.SELL.getCode()).before(uid);
OrderSubmitResp resp = imperfectGoodsService.publish(req);
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("发布成功").build();
}
... ...
... ... @@ -2,12 +2,14 @@ package com.yohoufo.order.controller;
import com.google.common.collect.Lists;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.order.constants.ActivityTypeEnum;
import com.yohoufo.order.annotation.BlackUserType;
import com.yohoufo.order.common.BlackTypeEnum;
import com.yohoufo.order.constants.CouponConstants;
import com.yohoufo.order.model.request.ShoppingRequest;
import com.yohoufo.order.model.response.*;
import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.service.IShoppingService;
import com.yohoufo.order.service.impl.SellerOrderService;
import com.yohoufo.order.service.impl.SellerOrderViewService;
import com.yohoufo.order.utils.CouponCodeUtils;
import com.yohoufo.order.utils.LoggerUtils;
... ... @@ -41,10 +43,17 @@ public class ShoppingController {
@RequestMapping(params = "method=ufo.order.payment")
public ApiResponse payment(@RequestParam(name = "uid") int uid,
@RequestParam(name = "skup") int skup,
@RequestParam(name = "user_activity_id", required = false, defaultValue = "0") int userActivityId,
@RequestParam(name = "activity_type", required = false, defaultValue = "0") int activityType,
@RequestParam(value = "app_version", required = false)String appVersion){
//活动类型
ActivityTypeEnum activityTypeEnum = ActivityTypeEnum.find(activityType);
//AUTO 自动匹配
ShoppingRequest req = ShoppingRequest.builder().uid(uid).skup(skup)
.couponCodes(CouponConstants.AUTO_RECOMMENDED_COUPON_CODES)
.couponCodes(activityTypeEnum.isCouponFlag() ? CouponConstants.AUTO_RECOMMENDED_COUPON_CODES : null)
.userActivityId(userActivityId).activityType(activityTypeEnum)
.appVersion(appVersion).build();
logger.info("in ufo.order.payment, req {}", req);
PaymentResponse paymentResponse = buyerOrderService.payment(req);
... ... @@ -80,12 +89,18 @@ public class ShoppingController {
@RequestParam(name = "skup") int skup,
@RequestParam(name = "coupon_code",required = false) String couponCode,
@RequestParam(name = "addressId", required = false) String addressId,
@RequestParam(name = "user_activity_id", required = false, defaultValue = "0") int userActivityId,
@RequestParam(name = "activity_type", required = false, defaultValue = "0") int activityType,
@RequestParam(value = "app_version", required = false)String appVersion) {
//活动类型
ActivityTypeEnum activityTypeEnum = ActivityTypeEnum.find(activityType);
ShoppingRequest req = ShoppingRequest.builder().uid(uid)
.skup(skup)
.couponCodes(CouponCodeUtils.asList(couponCode))
.couponCodes(activityTypeEnum.isCouponFlag() ? CouponCodeUtils.asList(couponCode) : null)
.addressId(addressId)
.userActivityId(userActivityId).activityType(activityTypeEnum)
.appVersion(appVersion)
.build();
logger.info("in ufo.order.compute, req {}", req);
... ... @@ -99,16 +114,27 @@ public class ShoppingController {
* @return
*/
@RequestMapping(params = "method=ufo.order.submit")
@BlackUserType(blackType = BlackTypeEnum.BUY)
public ApiResponse submit(@RequestParam(name = "uid") int uid,
@RequestParam(name = "skup") int skup,
@RequestParam(name = "coupon_code",required = false) String couponCode,
@RequestParam(name = "channelNo", required = false) String channelNo,
@RequestParam(name = "addressId") String addressId,
@RequestParam(name = "user_activity_id", required = false, defaultValue = "0") int userActivityId,
@RequestParam(name = "activity_type", required = false, defaultValue = "0") int activityType,
@RequestParam(name = "client_type", required = false) String clientType){
if(StringUtils.isBlank(channelNo)){
channelNo = "2919";
}
ShoppingRequest request = ShoppingRequest.builder().uid(uid).skup(skup).couponCodes(CouponCodeUtils.asList(couponCode)).channelNo(channelNo).clientType(clientType).addressId(addressId).build();
//活动类型
ActivityTypeEnum activityTypeEnum = ActivityTypeEnum.find(activityType);
ShoppingRequest request = ShoppingRequest.builder().uid(uid).skup(skup)
.couponCodes(activityTypeEnum.isCouponFlag() ? CouponCodeUtils.asList(couponCode) : null)
.channelNo(channelNo).clientType(clientType).addressId(addressId)
.userActivityId(userActivityId).activityType(activityTypeEnum)
.build();
logger.info("in ufo.order.submit, req {}", request);
OrderSubmitResponse submitResponse = buyerOrderService.submit(request);
logger.info("out ufo.order.submit,resp:{}", submitResponse);
... ... @@ -131,4 +157,4 @@ public class ShoppingController {
return new ApiResponse.ApiResponseBuilder().code(200).data(Lists.newArrayList(orderSummaryResp1, orderSummaryResp2)).message("查询成功").build();
}
}
}
\ No newline at end of file
... ...
... ... @@ -4,7 +4,7 @@ import com.yohoufo.common.alarm.Event;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by chao.chen on 2019/4/12.
... ...
... ... @@ -6,7 +6,7 @@ import com.yohoufo.order.service.handler.SellerOrderSubmitHandler;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by chao.chen on 2018/11/20.
... ...
... ... @@ -5,7 +5,7 @@ import com.yohoufo.common.alarm.Event;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
... ...
... ... @@ -3,7 +3,7 @@ package com.yohoufo.order.event;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.common.alarm.Event;
import lombok.*;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
... ...
... ... @@ -5,7 +5,7 @@ import com.yohoufo.order.common.RefundCase;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
... ...
... ... @@ -4,7 +4,7 @@ import com.yohoufo.common.alarm.Event;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by chenchao on 2018/10/10.
... ...
... ... @@ -4,7 +4,7 @@ import com.yohoufo.common.alarm.Event;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by chenchao on 2018/9/30.
... ...
... ... @@ -4,7 +4,7 @@ import com.yohoufo.common.alarm.Event;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by craig.qin
... ...
... ... @@ -4,7 +4,7 @@ import com.yohoufo.common.alarm.Event;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by craig.qin
... ...
... ... @@ -4,7 +4,7 @@ import com.yohoufo.common.alarm.Event;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by craig.qin
... ...
... ... @@ -4,7 +4,7 @@ import com.yohoufo.common.alarm.Event;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by chao.chen on 2018/12/27.
... ...
... ... @@ -5,7 +5,7 @@ import com.yohoufo.dal.order.model.SellerOrderGoods;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by chenchao on 2018/10/15.
... ...
... ... @@ -4,7 +4,7 @@ import com.yohoufo.common.alarm.Event;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by chenchao on 2018/9/26.
... ...
... ... @@ -5,7 +5,7 @@ import com.yohoufo.order.common.EnterQuitEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
@Data
@Builder
... ...
... ... @@ -4,7 +4,7 @@ import com.yohoufo.common.alarm.Event;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
... ...
... ... @@ -5,7 +5,7 @@ import com.yohobuy.ufo.model.order.common.TabType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by chenchao on 2018/10/15.
... ...
... ... @@ -7,7 +7,7 @@ import com.yohobuy.ufo.model.order.common.TabType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by chenchao on 2018/9/25.
... ...
... ... @@ -5,7 +5,7 @@ import com.yohoufo.dal.order.model.SellerOrderGoods;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by chenchao on 2018/9/30.
... ...
... ... @@ -4,7 +4,7 @@ import com.yohoufo.common.alarm.Event;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by craig.qin on 2019/3/20.
... ...
package com.yohoufo.order.interceptor;
import com.google.common.collect.Maps;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.dal.order.BlackUserMapper;
import com.yohoufo.dal.order.model.BlackUser;
import com.yohoufo.order.annotation.BlackUserType;
import com.yohoufo.order.common.BlackTypeEnum;
import org.apache.commons.collections.CollectionUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import java.lang.annotation.Annotation;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Aspect
@Component
public class BlackUserAspect {
private static Map<Integer, AbstractBlackUserInterceptor> blackUserInteceptorMap = Maps.newHashMap();
Logger logger = LoggerFactory.getLogger(AbstractBlackUserInterceptor.class);
@Pointcut("@annotation(com.yohoufo.order.annotation.BlackUserType)")
private void pointId(){
}
public static final String UID= "uid";
@Before("pointId()")
private void before(JoinPoint joinPoint) throws Throwable{
int uid = getParamUidValue(joinPoint);
if (uid == -1){
return;
}
BlackUserType blackUserAnnotation = ((MethodSignature) joinPoint.getSignature()).getMethod().getAnnotation(BlackUserType.class);
blackUserInteceptorMap.get(blackUserAnnotation.blackType().getCode()).before(uid);
}
public int getParamUidValue(JoinPoint joinPoint){
try{
int paramUidIndex = -1;
String[] paramNames = ((MethodSignature)joinPoint.getSignature()).getParameterNames();
for (int i = 0; i< paramNames.length; i++){
if (UID.equals(paramNames[i])){
paramUidIndex = i;
break;
}
}
if (paramUidIndex == -1){
return -1;
}
Object[] argValues = joinPoint.getArgs();
for (int i = 0; i < argValues.length; i++){
if (i == paramUidIndex){
return (int)argValues[i];
}
}
}catch (Exception e){
logger.warn("black user aspect param uis. e {}",e);
return -1;
}
return -1;
}
private abstract static class AbstractBlackUserInterceptor implements ApplicationContextAware {
Logger logger = LoggerFactory.getLogger(AbstractBlackUserInterceptor.class);
@Autowired
BlackUserMapper blackUserMapper;
public void before(int uid){
if (uid<0){
logger.warn("uid null");
return;
}
List<BlackUser> blackUserList = blackUserMapper.selectByUid(uid);
blackUserList = blackUserList.stream().filter(x->{
if(x.getBlackType() == getBlackType() && x.getStatus() == 1){
return true;
}
return false;
}).collect(Collectors.toList());
// 黑名单向外抛出异常
if (CollectionUtils.isNotEmpty(blackUserList)){
logger.warn("not allow black user buy .uid is {}", uid);
throw getServiceException();
}
}
abstract int getBlackType();
abstract ServiceException getServiceException();
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
Map<String, AbstractBlackUserInterceptor> map = applicationContext.getBeansOfType(AbstractBlackUserInterceptor.class);
for (String beanName : map.keySet()){
AbstractBlackUserInterceptor abstractBlackUserInterceptor = map.get(beanName);
blackUserInteceptorMap.put(abstractBlackUserInterceptor.getBlackType(), abstractBlackUserInterceptor);
}
}
}
@Component
private static class BuyBlackUserInterceptor extends AbstractBlackUserInterceptor {
@Override
int getBlackType() {
return BlackTypeEnum.BUY.getCode();
}
@Override
ServiceException getServiceException() {
return new ServiceException(ServiceError.NOT_ALLOW_BLACK_UID_BUY);
}
}
@Component
private static class SellBlackUserInterceptor extends AbstractBlackUserInterceptor {
@Override
int getBlackType() {
return BlackTypeEnum.SELL.getCode();
}
@Override
ServiceException getServiceException() {
return new ServiceException(ServiceError.NOT_ALLOW_BLACK_UID_SELL);
}
}
}
... ...
package com.yohoufo.order.interceptor;
import com.google.common.collect.Maps;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.dal.order.BlackUserMapper;
import com.yohoufo.dal.order.model.BlackUser;
import com.yohoufo.order.common.BlackTypeEnum;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public abstract class BlackUserInterceptor implements ApplicationContextAware {
Logger logger = LoggerFactory.getLogger(BlackUserInterceptor.class);
@Autowired
BlackUserMapper blackUserMapper;
public void before(int uid){
if (uid<0){
logger.warn("uid null");
return;
}
List<BlackUser> blackUserList = blackUserMapper.selectByUid(uid);
blackUserList = blackUserList.stream().filter(x->{
if(x.getBlackType() == getBlackType() && x.getStatus() == 1){
return true;
}
return false;
}).collect(Collectors.toList());
// 黑名单向外抛出异常
if (CollectionUtils.isNotEmpty(blackUserList)){
logger.warn("not allow black user buy .uid is {}", uid);
throw getServiceException();
}
}
abstract int getBlackType();
private static final Map<Integer, BlackUserInterceptor> blackUserInteceptorMap = Maps.newHashMap();
public static BlackUserInterceptor getBlackUserInteceptor(Integer code){
return blackUserInteceptorMap.get(code);
}
abstract ServiceException getServiceException();
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
// 重构map中的拦截器key,value
Map<String, BlackUserInterceptor> map = applicationContext.getBeansOfType(BlackUserInterceptor.class);
for (String beanName: map.keySet()){
BlackUserInterceptor interceptor = (BlackUserInterceptor) applicationContext.getBean(beanName);
blackUserInteceptorMap.put(interceptor.getBlackType(), interceptor);
}
}
}
package com.yohoufo.order.interceptor;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.order.common.BlackTypeEnum;
import org.springframework.stereotype.Component;
@Component
public class BuyBlackUserInterceptor extends BlackUserInterceptor {
@Override
int getBlackType() {
return BlackTypeEnum.BUY.getCode();
}
@Override
ServiceException getServiceException() {
return new ServiceException(ServiceError.NOT_ALLOW_BLACK_UID_BUY);
}
}
\ No newline at end of file
package com.yohoufo.order.interceptor;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.order.common.BlackTypeEnum;
import org.springframework.stereotype.Component;
@Component
public class SellBlackUserInterceptor extends BlackUserInterceptor {
@Override
int getBlackType() {
return BlackTypeEnum.SELL.getCode();
}
@Override
ServiceException getServiceException() {
return new ServiceException(ServiceError.NOT_ALLOW_BLACK_UID_SELL);
}
}
\ No newline at end of file
... ... @@ -2,7 +2,7 @@ package com.yohoufo.order.model;
import lombok.Data;
import lombok.experimental.Accessors;
import lombok.experimental.Builder;
import lombok.Builder;
import java.util.List;
... ...
package com.yohoufo.order.model.bo;
import lombok.Builder;
import lombok.Data;
import lombok.ToString;
import java.math.BigDecimal;
/**
* Created by jiexiang.wu on 2019/5/21.
*/
@Data
@ToString
@Builder
public class ActivityBo {
//用户活动记录
private int userActivityId;
//活动类型
private int activityType;
//减免金额
private BigDecimal activityCutAmount;
//json需要
public ActivityBo() {
}
public ActivityBo(int userActivityId, int activityType, BigDecimal activityCutAmount) {
this.userActivityId = userActivityId;
this.activityType = activityType;
this.activityCutAmount = activityCutAmount;
}
}
... ...
... ... @@ -2,7 +2,7 @@ package com.yohoufo.order.model.bo;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
... ...
... ... @@ -3,7 +3,7 @@ package com.yohoufo.order.model.bo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
... ...
... ... @@ -3,7 +3,7 @@ package com.yohoufo.order.model.bo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
... ...
... ... @@ -5,7 +5,7 @@ import com.yohoufo.dal.order.model.SellerOrderGoods;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by chenchao on 2018/10/11.
... ...
... ... @@ -3,7 +3,7 @@ package com.yohoufo.order.model.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
... ...
... ... @@ -7,7 +7,7 @@ import com.yohoufo.dal.order.model.SellerOrderGoods;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
import java.util.Map;
... ...
... ... @@ -5,7 +5,7 @@ import com.yohoufo.dal.order.model.SellerWallet;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
... ...
... ... @@ -3,10 +3,11 @@ package com.yohoufo.order.model.dto;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.model.bo.ActivityBo;
import com.yohoufo.order.model.bo.CouponBo;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
... ... @@ -49,4 +50,9 @@ public class OrderBuilder {
Integer attributes;
SellerOrderGoods sellerOrderGoods;
/**
* 活动信息
*/
ActivityBo activityBo;
}
... ...
... ... @@ -3,7 +3,7 @@ package com.yohoufo.order.model.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
import java.util.concurrent.TimeUnit;
... ...
... ... @@ -8,7 +8,7 @@ import com.yohoufo.dal.order.model.SellerOrderGoods;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
... ...
... ... @@ -5,7 +5,7 @@ import com.yohoufo.dal.order.model.SellerOrderGoods;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by chao.chen on 2018/11/22.
... ...
... ... @@ -4,7 +4,7 @@ import com.yohobuy.ufo.model.order.common.TabType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
@Data
@Builder
... ...
... ... @@ -5,7 +5,7 @@ import com.yohoufo.order.event.OrderCancelEvent;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
@Data
@Builder
... ...
... ... @@ -6,7 +6,7 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Builder;
import lombok.Builder;
@Data
@Builder
... ...
... ... @@ -3,7 +3,7 @@ package com.yohoufo.order.model.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
... ...
... ... @@ -3,7 +3,7 @@ package com.yohoufo.order.model.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by chao.chen on 2018/12/20.
... ...
package com.yohoufo.order.model.request;
import com.yohoufo.order.constants.ActivityTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
import java.util.List;
... ... @@ -51,4 +52,15 @@ public class ShoppingRequest {
*/
private String appVersion;
/**
* 用户活动id
*/
private int userActivityId;
/**
* 活动类型
* @link ActivityTypeEnum
*/
private ActivityTypeEnum activityType;
}
... ...
... ... @@ -9,7 +9,7 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Builder;
import lombok.Builder;
import java.math.BigDecimal;
import java.util.function.BiFunction;
... ...
package com.yohoufo.order.model.response;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Builder;
import lombok.Data;
import lombok.ToString;
/**
* Created by jiexiang.wu on 2019/5/22.
*/
@Data
@ToString
@Builder
public class ActivityInfo {
//用户活动记录
@JSONField(name = "user_activity_id")
private int userActivityId;
//活动类型
@JSONField(name = "activity_type")
private int activityType;
}
... ...
... ... @@ -3,7 +3,7 @@ package com.yohoufo.order.model.response;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
@Builder
@Data
... ...
... ... @@ -3,7 +3,7 @@ package com.yohoufo.order.model.response;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by jiexiang.wu on 2018/11/19.
... ...
... ... @@ -8,7 +8,7 @@ import com.yohobuy.ufo.model.order.vo.AddressInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import java.util.List;
... ... @@ -167,6 +167,11 @@ public class OrderDetailInfo {
String feePrice;
/**
* 活动优惠金额
*/
String activityCutPrice;
/**
* 优惠券金额
*/
String couponCutPrice;
... ...
... ... @@ -3,7 +3,7 @@ package com.yohoufo.order.model.response;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
/**
* Created by chenchao on 2018/9/29.
... ...