Authored by suibianqige

--task=null --user=杨长江 订单服务配置

Showing 29 changed files with 2200 additions and 0 deletions
package com.yoho.order.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @Author: 杨长江
* @Date: 2019-11-30 12:11
* @Description: 说明
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface MetaProperty {
/**
* 中文的字段说明,input框前面的名称
* @return
*/
String desc() default "";
/**
* 一级分组
* @return
*/
String rootGroup() default "";
/**
* 二级分组
* @return
*/
String childGroup() default "";
/**
* 只读属性,不允许修改,前台不展示该属性,为隐藏域
* @return
*/
boolean readOnly() default false;
}
... ...
package com.yoho.order.dal;
import com.yoho.order.model.MetaConfig;
import com.yoho.order.model.MetaConfigReq;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Author: 杨长江
* @Date: 2019-11-29 14:25
* @Description: 订单基础服务条款配置
*/
public interface MetaConfigMapper {
/**
* 根据主键查询
* @param id
* @return
*/
MetaConfig selectByPrimaryKey(@Param("id") int id);
/**
* 根据给定的code查询
* @param code
* @return
*/
MetaConfig selectByCode(@Param("code") String code);
/**
* 根据主键更新配置项
* @param config
* @return
*/
int updateByPrimaryKey(MetaConfig config);
/**
* 分页查询
* @param req
* @return
*/
List<MetaConfig> listByCondition(MetaConfigReq req);
/**
* 统计
* @param req
* @return
*/
int countByCondition(MetaConfigReq req);
}
... ...
package com.yoho.order.metaconfig;
import com.yoho.order.annotation.MetaProperty;
import lombok.Data;
import org.springframework.stereotype.Component;
/**
* @Author: 杨长江
* @Date: 2019-11-30 10:24
* @Description: 求购配置
*/
@Data
@Component("buyer_bid_config")
public class BuyerBidConfig {
private BaseConfig baseConfig;
private DConfig dConfig;
@Data
private static class BaseConfig{
@MetaProperty()
private Integer minBidPrice;
@MetaProperty()
private Double suggestRate;
}
@Data
private static class DConfig{
@MetaProperty()
private Double rate;
@MetaProperty()
private Integer min;
@MetaProperty()
private Integer max;
}
}
... ...
package com.yoho.order.metaconfig;
import com.yoho.order.annotation.MetaProperty;
import lombok.Data;
import org.springframework.stereotype.Component;
/**
* @Author: 杨长江
* @Date: 2019-11-30 10:24
* @Description: 买家订单费用
*/
@Data
@Component("buyer_order_fee")
public class BuyerOrderFee {
private HkInStock hk_in_stock;
private Deposit deposit;
private QuickDeliver quickDeliver;
private FastDelivery fastDelivery;
@Data
private static class HkInStock{
@MetaProperty()
private Double shipFee;
@MetaProperty()
private Double tariffRate;
}
@Data
private static class Deposit{
@MetaProperty()
private Double storageManagementFee;
}
@Data
private static class QuickDeliver{
@MetaProperty()
private Double storageManagementFee;
@MetaProperty()
private Double quickDeliverServiceFee;
}
@Data
private static class FastDelivery{
@MetaProperty()
private Double storageManagementFee;
}
}
... ...
package com.yoho.order.metaconfig;
import com.yoho.order.annotation.MetaProperty;
import lombok.Data;
import org.springframework.stereotype.Component;
/**
* @Author: 杨长江
* @Date: 2019-11-30 10:24
* @Description: 买家订单违规处罚
*/
@Data
@Component("buyer_order_violation_penalty")
public class BuyerOrderViolationPenalty {
private PullWool pullWool;
/**
* {
* "pullWool":{
* "rate":0.03,
* "moneyRange":{
* "min":15
* }
* }
* }
*/
@Data
private static class PullWool{
@MetaProperty()
private Double rate;
private MoneyRange moneyRange;
@Data
private static class MoneyRange{
@MetaProperty()
private Integer max;
@MetaProperty()
private Integer min;
}
}
}
... ...
package com.yoho.order.metaconfig;
import com.yoho.order.annotation.MetaProperty;
import lombok.Data;
import org.springframework.stereotype.Component;
/**
* @Author: 杨长江
* @Date: 2019-11-30 10:24
* @Description: 买家海外订单优惠策略
*/
@Data
@Component("buyer_overseas_order_cut_policy")
public class BuyerOverseasOrderCutPolicy {
private TariffAmount tariffAmount;
private ShipFee shipFee;
@Data
private static class TariffAmount{
@MetaProperty()
private Integer type;
@MetaProperty()
private Integer percent;
}
@Data
private static class ShipFee{
@MetaProperty()
private Integer type;
@MetaProperty()
private Integer amount;
}
}
... ...
package com.yoho.order.metaconfig;
import com.yoho.order.annotation.MetaProperty;
import lombok.Data;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @Author: 杨长江
* @Date: 2019-11-30 10:24
* @Description: 买家毁约处罚细则
*
* 嵌套太多,我也不知道字段啥意思
* TODO: 2019-11-30 之后理清字段意思之后再加注释
*/
@Data
@Component(value = "buyer_penalty")
public class BuyerPenalty {
private StockCaseMap stockCaseMap;
@Data
private static class StockCaseMap{
private GoodsInStock goodsInStock;
private AdvanceSale advanceSale;
@Data
private static class AdvanceSale{
@MetaProperty(desc = "预售名称", rootGroup = "预售规则", readOnly = true)
private String stockTypeName;
private TriggerCaseMap triggerCaseMap;
@Data
private static class TriggerCaseMap{
private BeforeDepotReceive beforeDepotReceive;
private BeforeSellerDeliver beforeSellerDeliver;
@Data
private static class BeforeDepotReceive{
@MetaProperty(desc = "名称",rootGroup ="预售规则", childGroup ="仓库收货前",readOnly=true)
private String name;
private List<StagedCollection> stagedCollection;
@Data
private static class StagedCollection{
@MetaProperty(desc = "排序",rootGroup ="预售规则", childGroup ="仓库收货前")
private Integer index;
private MoneyRange moneyRange;
@MetaProperty(desc = "比例",rootGroup ="预售规则", childGroup ="仓库收货前")
private Double rate;
private TimeRange timeRange;
/**
* 钱区间
*/
@Data
private static class MoneyRange{
@MetaProperty(desc = "最高罚款(元)",rootGroup ="预售规则", childGroup ="仓库收货前")
private Integer max;
@MetaProperty(desc = "最高罚款(元)",rootGroup ="预售规则", childGroup ="仓库收货前")
private Integer min;
}
/**
* 时间区间
*/
@Data
private static class TimeRange{
@MetaProperty(desc = "最大时间(分钟)",rootGroup ="预售规则", childGroup ="仓库收货前")
private Integer max;
@MetaProperty(desc = "最小时间(分钟)",rootGroup ="预售规则", childGroup ="仓库收货前")
private Integer min;
}
}
}
@Data
private static class BeforeSellerDeliver{
@MetaProperty(desc = "名称",rootGroup ="预售规则" ,childGroup = "卖家发货前",readOnly = true)
private String name;
private List<StagedCollection> stagedCollection;
@Data
private static class StagedCollection{
@MetaProperty(desc = "排序",rootGroup ="预售规则" ,childGroup = "卖家发货前")
private Integer index;
@MetaProperty(desc = "比例",rootGroup ="预售规则" ,childGroup = "卖家发货前")
private Double rate;
private MoneyRange moneyRange;
private TimeRange timeRange;
/**
* 钱区间
*/
@Data
private static class MoneyRange{
@MetaProperty(desc = "最小金额(元)",rootGroup ="预售规则" ,childGroup = "卖家发货前")
private Integer min;
@MetaProperty(desc = "最大金额(元)",rootGroup ="预售规则" ,childGroup = "卖家发货前")
private Integer max;
}
/**
* 时间区间
*/
@Data
private static class TimeRange{
@MetaProperty(desc = "最小时间(分钟)",rootGroup ="预售规则" ,childGroup = "卖家发货前")
private Integer min;
@MetaProperty(desc = "最大时间(分钟)",rootGroup ="预售规则" ,childGroup = "卖家发货前")
private Integer max;
}
}
}
}
}
@Data
private static class GoodsInStock{
@MetaProperty(desc = "名称", rootGroup = "现货规则",readOnly = true)
private String stockTypeName;
private TriggerCaseMap triggerCaseMap;
@Data
private static class TriggerCaseMap{
private BeforeSellerDeliver beforeSellerDeliver;
private BeforeDepotReceive beforeDepotReceive;
@Data
private static class BeforeDepotReceive{
@MetaProperty(desc = "名称", rootGroup = "现货规则", childGroup = "仓库收货前",readOnly = true)
private String name;
private List<StagedCollection> stagedCollection;
@Data
private static class StagedCollection{
@MetaProperty(desc = "排序", rootGroup = "现货规则", childGroup = "仓库收货前")
private Integer index;
@MetaProperty(desc = "比例", rootGroup = "现货规则", childGroup = "仓库收货前")
private Double rate;
private MoneyRange moneyRange;
private TimeRange timeRange;
/**
* 钱区间
*/
@Data
private static class MoneyRange{
@MetaProperty(desc = "最小金额(元)", rootGroup = "现货规则", childGroup = "仓库收货前")
private Integer min;
@MetaProperty(desc = "最大金额(元)", rootGroup = "现货规则", childGroup = "仓库收货前")
private Integer max;
}
/**
* 时间区间
*/
@Data
private static class TimeRange{
@MetaProperty(desc = "最小时间(分钟)", rootGroup = "现货规则", childGroup = "仓库收货前")
private Integer min;
@MetaProperty(desc = "最大时间(分钟)", rootGroup = "现货规则", childGroup = "仓库收货前")
private Integer max;
}
}
}
@Data
private static class BeforeSellerDeliver{
@MetaProperty(desc = "名称", rootGroup = "现货规则", childGroup = "卖家发货前", readOnly = true)
private String name;
private List<StagedCollection> stagedCollection;
@Data
private static class StagedCollection{
@MetaProperty(desc = "排序",rootGroup = "现货规则", childGroup = "卖家发货前")
private Integer index;
@MetaProperty(desc = "比例",rootGroup = "现货规则", childGroup = "卖家发货前")
private Double rate;
private MoneyRange moneyRange;
private TimeRange timeRange;
/**
* 钱区间
*/
@Data
private static class MoneyRange{
@MetaProperty(desc = "最小金额(元)",rootGroup = "现货规则", childGroup = "卖家发货前")
private Integer min;
@MetaProperty(desc = "最大金额(元)",rootGroup = "现货规则", childGroup = "卖家发货前")
private Integer max;
}
/**
* 时间区间
*/
@Data
private static class TimeRange{
@MetaProperty(desc = "最小时间(分钟)",rootGroup = "现货规则", childGroup = "卖家发货前")
private Integer min;
@MetaProperty(desc = "最大时间(分钟)",rootGroup = "现货规则", childGroup = "卖家发货前")
private Integer max;
}
}
}
}
}
}
}
... ...
package com.yoho.order.metaconfig;
import com.yoho.order.annotation.MetaProperty;
import lombok.Data;
import org.springframework.stereotype.Component;
/**
* @Author: 杨长江
* @Date: 2019-11-30 10:24
* @Description: 说明
*/
@Data
@Component(value = "depositFee")
public class DepositFee {
@MetaProperty(desc = "contract_fee",rootGroup = "违约费比例(两位小数)")
private Double contract_fee;
private Renew renew;
private Expired expired;
@Data
private static class Renew {
@MetaProperty(desc = "天数",rootGroup = "首次违约")
private Integer day;
@MetaProperty(desc = "比例",rootGroup = "首次违约")
private Double amount;
}
@Data
private static class Expired{
@MetaProperty(desc = "天数",rootGroup = "逾期")
private Integer day;
@MetaProperty(desc = "比例",rootGroup = "逾期")
private Double amount;
}
}
... ...
package com.yoho.order.metaconfig;
import com.yoho.order.annotation.MetaProperty;
import lombok.Data;
import org.springframework.stereotype.Component;
/**
* @Author: 杨长江
* @Date: 2019-11-30 10:24
* @Description: 订单生成时规则控制
*/
@Data
@Component("order_code_rule")
public class OrderCodeRule {
@MetaProperty()
private String env;
}
... ...
package com.yoho.order.metaconfig;
import com.yoho.order.annotation.MetaProperty;
import lombok.Data;
import org.springframework.stereotype.Component;
/**
* @Author: 杨长江
* @Date: 2019-11-30 10:24
* @Description: 预售订单阈值
*/
@Data
@Component("presale_threshold")
public class PresaleThreshold {
private Notice notice;
private AutoCancel autoCancel;
@Data
private static class Notice{
private TimeRange timeRange;
@Data
private static class TimeRange{
@MetaProperty()
private Integer min;
@MetaProperty()
private Integer max;
@MetaProperty()
private String timeUnit;
}
}
@Data
private static class AutoCancel{
private TimeRange timeRange;
@Data
private static class TimeRange{
@MetaProperty()
private Integer min;
@MetaProperty()
private Integer max;
@MetaProperty()
private String timeUnit;
}
}
}
... ...
package com.yoho.order.metaconfig;
import com.yoho.order.annotation.MetaProperty;
import lombok.Data;
import org.springframework.stereotype.Component;
/**
* @Author: 杨长江
* @Date: 2019-11-30 10:24
* @Description: 变现商品的各种费率
*/
@Data
@Component("seller_bid_goods_fee_rate")
public class SellerBidGoodsFeeRate {
private InStock inStock;
@Data
private static class InStock{
@MetaProperty()
private Double goodsPaymentRate;
@MetaProperty()
private Double earnestMoneyRate;
@MetaProperty()
private Double payChannelRate;
}
}
... ...
package com.yoho.order.metaconfig;
import com.yoho.order.annotation.MetaProperty;
import lombok.Data;
import org.springframework.stereotype.Component;
/**
* @Author: 杨长江
* @Date: 2019-11-30 10:24
* @Description: 卖家保证金配置
*/
@Data
@Component("seller_earnest_money")
public class SellerEarnestMoney {
private AdvanceSale advanceSale;
private Deposit deposit;
private InStock inStock;
private Flaw flaw;
private SecondHand secondHand;
private HkInStock hk_in_stock;
private FastDelivery fastDelivery;
@Data
private static class AdvanceSale{
@MetaProperty
private Integer max;
@MetaProperty
private Integer min;
@MetaProperty
private Double rate;
}
@Data
private static class Deposit{
@MetaProperty
private Integer max;
@MetaProperty
private Integer min;
@MetaProperty
private Double rate;
}
@Data
private static class InStock{
@MetaProperty
private Integer max;
@MetaProperty
private Integer min;
@MetaProperty
private Double rate;
}
@Data
private static class Flaw{
@MetaProperty
private Integer max;
@MetaProperty
private Integer min;
@MetaProperty
private Double rate;
}
@Data
private static class SecondHand{
@MetaProperty
private Integer max;
@MetaProperty
private Integer min;
@MetaProperty
private Double rate;
}
@Data
private static class HkInStock{
@MetaProperty
private Integer max;
@MetaProperty
private Integer min;
@MetaProperty
private Double rate;
}
@Data
private static class FastDelivery{
@MetaProperty
private Integer max;
@MetaProperty
private Integer min;
@MetaProperty
private Double rate;
}
}
... ...
package com.yoho.order.metaconfig;
import com.yoho.order.annotation.MetaProperty;
import lombok.Data;
import org.springframework.stereotype.Component;
/**
* @Author: 杨长江
* @Date: 2019-11-30 10:25
* @Description:卖家入驻预付费阈值
*/
@Data
@Component("seller_enter_threshold")
public class SellerEnterThreshold {
private SuperEntry SUPER_ENTRY;
private Common COMMON;
private LargeSettlement LARGE_SETTLEMENT;
private FastDeliverySuper FAST_DELIVERY_SUPER;
@Data
private static class SuperEntry{
@MetaProperty
private String entrySellerType;
@MetaProperty
private Integer goodsOnOffShelveAmount;
@MetaProperty
private Integer hiddenGoodsAmount;
@MetaProperty
private Integer prepaymentAmount;
}
@Data
private static class Common {
@MetaProperty
private String entrySellerType;
@MetaProperty
private Integer prepaymentAmount;
}
@Data
private static class LargeSettlement {
@MetaProperty
private String entrySellerType;
@MetaProperty
private Integer prepaymentAmount;
@MetaProperty
private Integer goodsOnOffShelveAmount;
@MetaProperty
private Integer hiddenGoodsAmount;
}
@Data
private static class FastDeliverySuper {
@MetaProperty
private String entrySellerType;
@MetaProperty
private Integer goodsOnOffShelveAmount;
@MetaProperty
private Integer hiddenGoodsAmount;
@MetaProperty
private Integer prepaymentAmount;
}
}
... ...
package com.yoho.order.metaconfig;
import com.yoho.order.annotation.MetaProperty;
import lombok.Data;
import org.springframework.stereotype.Component;
/**
* @Author: 杨长江
* @Date: 2019-11-30 10:24
* @Description: 平台服务费
*/
@Data
@Component("seller_goods_fee_rate")
public class SellerGoodsFeeRate {
private InStock inStock;
private Deposit deposit;
private PreSale preSale;
private Flaw flaw;
private SecondHand secondHand;
private HkInStock hk_in_stock;
private QuickDeliver quickDeliver;
private FastDelivery fastDelivery;
@Data
private static class InStock{
@MetaProperty()
private Double appraiseFee;
@MetaProperty()
private Double packageFee;
private GoodsServiceFeeRange goodsServiceFeeRange;
@Data
private static class GoodsServiceFeeRange{
@MetaProperty()
private Integer min;
@MetaProperty()
private Integer max;
}
}
@Data
private static class Deposit{
@MetaProperty()
private Double appraiseFee;
@MetaProperty()
private Double packageFee;
@MetaProperty()
private Double storageManagementFee;
}
@Data
private static class PreSale{
@MetaProperty()
private Double appraiseFee;
@MetaProperty()
private Double packageFee;
private GoodsServiceFeeRange goodsServiceFeeRange;
@Data
private static class GoodsServiceFeeRange{
@MetaProperty()
private Integer min;
@MetaProperty()
private Integer max;
}
}
@Data
private static class Flaw{
@MetaProperty()
private Double appraiseFee;
@MetaProperty()
private Double packageFee;
}
@Data
private static class SecondHand{
@MetaProperty()
private Double appraiseFee;
@MetaProperty()
private Double packageFee;
}
@Data
private static class HkInStock{
@MetaProperty()
private Double appraiseFee;
@MetaProperty()
private Double packageFee;
private GoodsServiceFeeRange goodsServiceFeeRange;
@Data
private static class GoodsServiceFeeRange{
@MetaProperty()
private Integer min;
@MetaProperty()
private Integer max;
}
}
@Data
private static class QuickDeliver{
@MetaProperty()
private Double appraiseFee;
@MetaProperty()
private Double packageFee;
}
@Data
private static class FastDelivery{
@MetaProperty()
private Double appraiseFee;
@MetaProperty()
private Double packageFee;
private GoodsServiceFeeRange goodsServiceFeeRange;
@Data
private static class GoodsServiceFeeRange{
@MetaProperty()
private Integer min;
@MetaProperty()
private Integer max;
}
}
}
... ...
package com.yoho.order.metaconfig;
import com.yoho.order.annotation.MetaProperty;
import lombok.Data;
import org.springframework.stereotype.Component;
/**
* @Author: 杨长江
* @Date: 2019-11-30 10:24
* @Description: 说明
*/
@Data
@Component("seller_goods_platform_fee")
public class SellerGoodsPlatformFee {
private InStock inStock;
private PreSale preSale;
private Flaw flaw;
private SecondHand secondHand;
private HkInStock hk_in_stock;
private QuickDeliver quickDeliver;
private FastDelivery fastDelivery;
@Data
private static class InStock{
@MetaProperty()
private Double goodsPaymentRate;
@MetaProperty()
private Double earnestMoneyRate;
@MetaProperty()
private Double payChannelRate;
}
@Data
private static class PreSale{
@MetaProperty()
private Double goodsPaymentRate;
@MetaProperty()
private Double earnestMoneyRate;
@MetaProperty()
private Double payChannelRate;
}
@Data
private static class Flaw{
@MetaProperty()
private Double goodsPaymentRate;
@MetaProperty()
private Double earnestMoneyRate;
@MetaProperty()
private Double payChannelRate;
}
@Data
private static class SecondHand{
@MetaProperty()
private Double goodsPaymentRate;
@MetaProperty()
private Double earnestMoneyRate;
@MetaProperty()
private Double payChannelRate;
}
@Data
private static class HkInStock{
@MetaProperty()
private Double goodsPaymentRate;
@MetaProperty()
private Double earnestMoneyRate;
@MetaProperty()
private Double payChannelRate;
}
@Data
private static class QuickDeliver{
@MetaProperty()
private Double goodsPaymentRate;
@MetaProperty()
private Double earnestMoneyRate;
@MetaProperty()
private Double payChannelRate;
}
@Data
private static class FastDelivery{
@MetaProperty()
private Double goodsPaymentRate;
@MetaProperty()
private Double earnestMoneyRate;
@MetaProperty()
private Double payChannelRate;
}
}
... ...
package com.yoho.order.metaconfig;
import com.yoho.order.annotation.MetaProperty;
import lombok.Data;
import org.springframework.stereotype.Component;
/**
* @Author: 杨长江
* @Date: 2019-11-30 10:24
* @Description: 卖家出售价限制
*/
@Data
@Component("seller_goods_price_limit")
public class SellerGoodsPriceLimit {
private InStock inStock;
@Data
private static class InStock{
@MetaProperty()
private Double leastRate;
}
}
... ...
package com.yoho.order.metaconfig;
import com.yoho.order.annotation.MetaProperty;
import lombok.Data;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @Author: 杨长江
* @Date: 2019-11-30 10:24
* @Description: 卖家毁约处罚细则
*/
@Data
@Component("seller_penalty")
public class SellerPenalty {
private StockCaseMap stockCaseMap;
@Data
private static class StockCaseMap{
private AdvanceSale advanceSale;
@Data
private static class AdvanceSale{
@MetaProperty()
private String stockTypeName;
private TriggerCaseMap triggerCaseMap;
@Data
private static class TriggerCaseMap{
private BeforeSellerDeliver beforeSellerDeliver;
@Data
private static class BeforeSellerDeliver{
@MetaProperty()
private String name;
private List<StagedCollection> stagedCollection;
@Data
private static class StagedCollection{
@MetaProperty()
private Integer index;
@MetaProperty()
private Double rate;
private TimeRange timeRage;
private MoneyRange moneyRange;
@Data
private static class TimeRange{
@MetaProperty()
private Integer max;
@MetaProperty()
private Integer min;
}
@Data
private static class MoneyRange{
@MetaProperty()
private Integer max;
@MetaProperty()
private Integer min;
}
}
}
}
}
}
}
... ...
package com.yoho.order.metaconfig;
/**
* @Author: 杨长江
* @Date: 2019-11-30 10:24
* @Description: 说明
*/
public class pullWool {
}
... ...
package com.yoho.order.model;
import lombok.Data;
import java.util.List;
/**
* @Author: 杨长江
* @Date: 2019-11-29 14:29
* @Description: 订单基础服务条款配置
*/
@Data
public class MetaConfig {
/**
* 主键
*/
private int id;
/**
* code
*/
private String code;
/**
* 名称
*/
private String title;
/**
* 创建时间
*/
private Integer createTime;
/**
* json格式的配置内容
*/
private String value;
/**
* 描述
*/
private String desc;
/**
* 属性集合
*/
private List<PropertyItem> propertyItem;
}
... ...
package com.yoho.order.model;
import com.yoho.ufo.service.model.PageRequestBO;
import lombok.Data;
/**
* @Author: 杨长江
* @Date: 2019-11-29 18:10
* @Description: 说明
*/
@Data
public class MetaConfigReq extends PageRequestBO {
/**
* code
*/
private String code;
/**
* 标题
*/
private String title;
}
... ...
package com.yoho.order.model;
import lombok.Builder;
import lombok.Data;
/**
* @Author: 杨长江
* @Date: 2019-11-30 13:01
* @Description: 说明
*/
@Data
@Builder
public class PropertyItem {
/**
* 属性名称
*/
private String pName;
/**
* 属性值
*/
private String pValue;
/**
* 属性描述
*/
private String pDesc;
/**
* 属性父类分组
*/
private String pRootGroup;
/**
* 属性子类分组
*/
private String pChildGroup;
/**
* 是否只读
*/
private boolean pReadOnly;
}
... ...
<?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.yoho.order.dal.MetaConfigMapper">
<resultMap id="BaseResultMap" type="com.yoho.order.model.MetaConfig">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="code" jdbcType="VARCHAR" property="code" />
<result column="title" jdbcType="VARCHAR" property="title" />
<result column="create_time" jdbcType="INTEGER" property="createTime" />
<result column="desc" jdbcType="VARCHAR" property="desc" />
<result column="value" property="value" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List">
id, code, title, create_time
</sql>
<select id="selectByPrimaryKey" parameterType="int" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>,`value`
from meta_config
where id = #{id}
limit 1
</select>
<select id="countByCondition" parameterType="com.yoho.order.model.MetaConfigReq" resultType="int">
select count(1)
from meta_config
<where>
<if test="code != null and code != ''">
code = #{code,jdbcType=VARCHAR}
</if>
<if test="code != null and code != ''">
title = #{title,jdbcType=VARCHAR}
</if>
</where>
</select>
<select id="listByCondition" resultMap="BaseResultMap" parameterType="com.yoho.order.model.MetaConfigReq">
select
<include refid="Base_Column_List"/>
from meta_config
<where>
<if test="code != null and code != ''">
code = #{code,jdbcType=VARCHAR}
</if>
<if test="code != null and code != ''">
title = #{title,jdbcType=VARCHAR}
</if>
</where>
order by id asc
limit #{start},#{size}
</select>
<select id="selectByCode" parameterType="string" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>,`value`
from meta_config
where code = #{code,jdbcType=VARCHAR}
limit 1
</select>
<update id="updateByPrimaryKey" parameterType="com.yoho.order.model.MetaConfig">
update meta_config
<set>
<if test="code != null and code != ''">
code = #{code,jdbcType=VARCHAR},
</if>
<if test="code != null and code != ''">
title = #{title,jdbcType=VARCHAR},
</if>
<if test="code != null and code != ''">
`desc` = #{desc,jdbcType=VARCHAR},
</if>
<if test="code != null and code != ''">
`value` = #{value,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
package com.yoho.ufo.order.controller;
import com.yoho.order.model.MetaConfig;
import com.yoho.order.model.MetaConfigReq;
import com.yoho.service.model.order.response.PageResponse;
import com.yoho.ufo.order.service.IMetaConfigService;
import com.yoho.ufo.service.model.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author: 杨长江
* @Date: 2019-11-29 18:03
* @Description: 点单基础服务配置项controller
*/
@RestController
@RequestMapping(value = "/metaConfig")
public class MetaConfigController {
@Autowired
private IMetaConfigService metaConfigService;
@RequestMapping(value = "/list")
public ApiResponse list(MetaConfigReq metaConfigReq){
PageResponse<MetaConfig> pageResponse = this.metaConfigService.list(metaConfigReq);
return new ApiResponse.ApiResponseBuilder().code(200).data(pageResponse).build();
}
@RequestMapping(value = "/detail")
public ApiResponse getOne(String code){
MetaConfig config = metaConfigService.selectByCode(code);
System.out.println(config);
return new ApiResponse.ApiResponseBuilder().code(200).data(config).build();
}
@RequestMapping(value = "/update")
public ApiResponse update(MetaConfig metaConfig){
System.out.println(metaConfig.getValue());
return new ApiResponse.ApiResponseBuilder().code(200).build();
}
}
... ...
package com.yoho.ufo.order.service;
import com.yoho.order.model.MetaConfig;
import com.yoho.order.model.MetaConfigReq;
import com.yoho.service.model.order.response.PageResponse;
/**
* @Author: 杨长江
* @Date: 2019-11-29 14:17
* @Description: 订单基础服务条款配置
*/
public interface IMetaConfigService {
/**
* 根据主键查询
* @param id
* @return
*/
MetaConfig selectByPrimaryKey(int id);
/**
* 根据给定的code查询
* @param code
* @return
*/
MetaConfig selectByCode(String code);
/**
* 根据主键更新配置项
* @param config
* @return
*/
int updateByPrimaryKey(MetaConfig config);
/**
* 分页查询
* @param metaConfigReq
* @return
*/
PageResponse<MetaConfig> list(MetaConfigReq metaConfigReq);
}
... ...
package com.yoho.ufo.order.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yoho.order.annotation.MetaProperty;
import com.yoho.order.dal.MetaConfigMapper;
import com.yoho.order.model.MetaConfig;
import com.yoho.order.model.MetaConfigReq;
import com.yoho.order.model.PropertyItem;
import com.yoho.service.model.order.response.PageResponse;
import com.yoho.ufo.order.service.IMetaConfigService;
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.Service;
import java.lang.reflect.Field;
import java.util.*;
/**
* @Author: 杨长江
* @Date: 2019-11-29 14:18
* @Description: 订单服务基础服务条款服务类
*/
@Service
public class MetaConfigServiceImpl implements IMetaConfigService, ApplicationContextAware {
@Autowired
private MetaConfigMapper metaConfigMapper;
private ApplicationContext applicationContext;
/**
* 保存集合的名称,当前遍历到第几个了(xxx[n]格式)
*/
private StringBuffer collectionName;
@Override
public MetaConfig selectByPrimaryKey(int id) {
return this.metaConfigMapper.selectByPrimaryKey(id);
}
@Override
public MetaConfig selectByCode(String code) {
MetaConfig config = this.metaConfigMapper.selectByCode(code);
if(Objects.isNull(config)){
return null;
}
String configCode = config.getCode();
// 根据code获取bean对应的class
Class clazz = applicationContext.getBean(configCode).getClass();
// 把json格式的字符串解析成对象
Object object = JSONObject.parseObject(config.getValue(),clazz);
try {
List<PropertyItem> list = new ArrayList<>(32);
// 将所有属性展开成一维列表
transformData(object, list);
this.collectionName = null;
config.setPropertyItem(list);
}catch (IllegalAccessException e){
e.printStackTrace();
}
return config;
}
@Override
public int updateByPrimaryKey(MetaConfig config) {
return this.metaConfigMapper.updateByPrimaryKey(config);
}
@Override
public PageResponse<MetaConfig> list(MetaConfigReq metaConfigReq) {
int count = this.metaConfigMapper.countByCondition(metaConfigReq);
List<MetaConfig> list = null;
if(count >0){
list = this.metaConfigMapper.listByCondition(metaConfigReq);
}
PageResponse<MetaConfig> pageResponse = new PageResponse();
pageResponse.setList(list);
pageResponse.setPageNo(metaConfigReq.getPage());
pageResponse.setPageSize(metaConfigReq.getSize());
pageResponse.setTotalCount(count);
return pageResponse;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
/**
* 将对象转化为list
* @param o metaConfig对象
* @param list 属性容器
* @throws IllegalAccessException
*/
private void transformData(Object o, List<PropertyItem> list) throws IllegalAccessException{
Class clazz = o.getClass();
Field[] fields = clazz.getDeclaredFields();
// 遍历所有属性
for(Field field : fields){
field.setAccessible(true);
//如果这个字段从json转过来是null,就不加入列表了,直接处理下一个属性
if(Objects.isNull(field.get(o))){
continue;
}
// 如果属性上有MetaProperty注解,说明是基本的元数据,
// 获取注解属性,构造一个基础属性对象,存到list中
MetaProperty metaProperty = field.getAnnotation(MetaProperty.class);
if(metaProperty != null){
String desc = metaProperty.desc();
String rootGroup = metaProperty.rootGroup();
String childGroup = metaProperty.childGroup();
boolean readOnly = metaProperty.readOnly();
// 获取该类的全限定名
String clazzName = field.getDeclaringClass().getName();
// 拆分为类名数组(包含多个内部类嵌套)
String[] clazzNames = clazzName.split("\\$");
StringBuffer prefix = new StringBuffer();
// 拼接该属性的完整限定名
Arrays.asList(clazzNames).stream().skip(1).forEach((s) ->
prefix.append(Character.toLowerCase(s.charAt(0)))
.append(s.substring(1))
.append("."));
String pName = prefix.toString() + field.getName();
// 如果该属性完整的限定名包含CollectionName,那么则替换
if(collectionName != null){
String toReplaceName = collectionName.toString().split("\\[")[0];
if(pName.contains(toReplaceName)) {
pName = pName.replace(toReplaceName, collectionName.toString());
}
}
PropertyItem propertyItem = PropertyItem.builder()
.pDesc(desc)
.pName(pName)
.pRootGroup(rootGroup)
.pChildGroup(childGroup)
.pValue(field.get(o).toString())
.pReadOnly(readOnly)
.build();
list.add(propertyItem);
}
//集合循环处理
if(field.getGenericType().getTypeName().contains("java.util.List")){
List<Object> obj = (List)field.get(o);
for(int i =0; i< obj.size(); i++){
// 处理集合,用collectionName表示这是集合中的第几个元素
collectionName = new StringBuffer();
collectionName.append(field.getName())
.append("[")
.append(i)
.append("]");
transformData(obj.get(i), list);
}
}
// 如果这个字段上没有注解,又不是基础类型或String类型,说明这个是一个类,递归处理
if(!"java.lang.String".equals(field.getGenericType().getTypeName())
&& !"java.lang.Integer".equals(field.getGenericType().getTypeName())
&& !"java.lang.Double".equals(field.getGenericType().getTypeName())
&& !field.getGenericType().getTypeName().contains("java.util.List")){
transformData(field.get(o), list);
}
}
}
}
... ...
... ... @@ -70,6 +70,7 @@ datasources:
- com.yoho.order.dal.OrdersPayRefundMapper
- com.yoho.order.dal.BuyerOrderStatusFlowMapper
- com.yoho.order.dal.BlackUserMapper
- com.yoho.order.dal.MetaConfigMapper
ufo_resource:
servers:
... ...
... ... @@ -71,6 +71,7 @@ datasources:
- com.yoho.order.dal.OrdersPayRefundMapper
- com.yoho.order.dal.BuyerOrderStatusFlowMapper
- com.yoho.order.dal.BlackUserMapper
- com.yoho.order.dal.MetaConfigMapper
ufo_resource:
servers:
... ...
<!DOCTYPE html>
<div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll">
<form name="metaConfigEditForm" id="metaConfigEditForm" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" id="id"/>
<div style="margin-top: 20px;margin-left: 30px">
<table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab">
<tr style="height: 60px" id="ttt">
<td width="20%">编码<span class="requriedInput">*</span></td>
<td width="60%">
<input id="code" name="code" readonly="readonly" class="easyui-textbox" data-options="validType:'length[1,50]'" style="width: 380px;"/></td>
</tr>
<tr style="height: 60px">
<td width="20%">名称<span class="requriedInput">*</span></td>
<td width="60%">
<input id="title" name="title" class="easyui-textbox" data-options="validType:'length[1,400]'" style="width: 380px;"/></td>
</tr>
<tr style="height: 60px" id="descDiv">
<td width="20%">备注</td>
<td width="60%">
<input id="desc" name="desc" class="easyui-textbox" style="width: 380px;"/>
</td>
</tr>
<input type="hidden" name="value" id="value" />
</table>
</div>
</form>
</div>
<script>
$(function () {
// 隐藏域赋值
$('#metaConfigEditForm #id').val(code);
if (code !=null && code != '') {
$.post(contextPath + "/metaConfig/detail", {
'code': code
}, function (data) {
$("#metaConfigEditForm").form("load", data.data);
var items = data.data.propertyItem;
var map = {};
for(var i=0; i< items.length; i++){
var item = items[i];
if(item.pRootGroup != null && item.pRootGroup != ''){
map[item.pRootGroup] = map[item.pRootGroup] || [];
map[item.pRootGroup].push(item);
}
keyValueMap[item.pName] = item.pRootGroup + item.pChildGroup + item.pDesc ;
}
var list = [];
for(var key in map){
if(map[key] instanceof Array){
var rootMap = {};
var childMap = {};
for(var i=0; i < map[key].length; i++){
var item = map[key][i];
if(item.pChildGroup == null || item.pChildGroup == ''){
rootMap[item.pRootGroup] = rootMap[item.pRootGroup] || [];
rootMap[item.pRootGroup].push(item);
}
if(item.pChildGroup != null && item.pChildGroup != ''){
childMap[item.pChildGroup] = childMap[item.pChildGroup] || [];
childMap[item.pChildGroup].push(item);
}
}
list.push(rootMap);
list.push(childMap);
}
}
var htmlStr = "";
for(var i=0; i<list.length; i++){
var item = list[i];
for(key in item){
var itemValue = item[key];
htmlStr += "<tr style='height: 60px'>";
if(itemValue[0].pChildGroup == ""){
htmlStr += "<td colspan='2'><p style='font-size: 16px;font-weight: bold'>"+ key +"</p></td>";
}else {
htmlStr += "<td colspan='2'> <p style='font-size: 16px;font-weight: bold;margin-left: 35px'>"+ key +"</p></td>";
}
htmlStr += "</td></tr>";
for(var j =0; j<itemValue.length; j++){
if(!itemValue[j].pReadOnly){
htmlStr += "<tr style='height: 60px'>";
htmlStr += "<td width='20%'>" +itemValue[j].pDesc+ "<span class='requriedInput'>*</span></td>";
htmlStr += "<td width='60%'>";
}
if(itemValue[j].pReadOnly){
htmlStr += "<input id='"+ itemValue[j].pName +"' name='"+itemValue[j].pName+"' type='hidden' value='"+itemValue[j].pValue+"' class='easyui-textbox' style='width: 380px' />"
}else {
htmlStr += "<input id='"+ itemValue[j].pName +"' name='"+itemValue[j].pName+"' value='"+itemValue[j].pValue+"' class='easyui-textbox' style='width: 380px' />"
htmlStr += "</td></tr>";
}
}
}
}
var targetObj = $(htmlStr).insertAfter("#descDiv");
$.parser.parse(targetObj);
});
}
});
</script>
\ No newline at end of file
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Yoho!Buy运营平台</title>
<script src="/ufoPlatform/js/include.js"></script>
<style>
.selected{background: #5bc0de; color:#fff; }
</style>
<style type="text/css">
.nav li {float:left; list-style:none;}
.nav li a{float:left;text-decoration:none;padding:0.2em 1.6em;border-right:1px solid white;color:black; font-size:14px;}
</style>
</head>
<body class="easyui-layout">
<div region="north" style="height:240px;">
<script>
document.write(addHead('订单管理', '配置管理'));
</script>
<br>
<div style="margin-left: 10px;margin-top: 30px">
<hr style="border:1px solid #ddd;"><br>
<div style="border:1px solid #ddd;border-radius:5px 5px 5px 5px;">
<div style="margin-left: 10px;margin-top: 20px;margin-bottom: 20px">
<label>订单编号:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
<input id="code" type="text" class="easyui-textbox" style="width:150px">
<label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;标题:</label>
<input id="title" type="text" class="easyui-textbox" style="width:150px"/>
<a id="searchBtn" class="btn-info">查询</a>
<a id="allBtn" class="btn-success">全部</a>
</div>
</div>
</div>
</div>
<div id="orderList" region="center" style="margin-left: 10px;border:1px solid #ddd;border-radius:5px 5px 5px 5px;">
<table id="configListTable"></table>
</div>
<script>
var code;
var keyValueMap = {};
$(function() {
$("#searchBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
$("#configListTable").datagrid("load", {
code : $("#code").val(),
uid : $("#title").val(),
});
}
});
//全部按钮
$("#allBtn").linkbutton({
iconCls: "icon-import",
onClick: function () {
$("#code").textbox('setValue','');
$("#uid").textbox('setValue','');
$("#configListTable").datagrid("load", {
});
}
});
getOrderList();
});
function getOrderList(){
$("#configListTable").myDatagrid({
fit: true,
fitColumns: true,
striped: true,
url: contextPath + "/metaConfig/list",
method: 'POST',
queryParams: {
},
loadFilter: function (data) {
var temp = defaultLoadFilter(data);
temp=null==temp?[]:temp;
temp.rows = temp.list;
return temp;
},
columns: [[{
title: "编号",
field: "code",
width: 40
}, {
title: "标题",
field: "title",
align: "center",
width: 40
}, {
title: "修改时间",
field: "uid",
align: "center",
width: 40
}, {
title: "创建时间",
field: "productName",
align: "center",
width: 40
}, {
title: "操作",
field: "operations",
align: "center",
width: 40,
formatter: function (value, rowData) {
var str = "<a role='detail' dataId='"+ rowData.code + "' style='margin-left:10px;background-color: #5cb85c !important;'>编辑</a>";
return str;
}}
]],
cache: false,
pagination: true,
pageSize: 10,
idField: "id",
singleSelect: true,
onLoadSuccess: function () {
var me = $(this);
me.datagrid("getPanel").find("a[role='detail']").linkbutton({
onClick: function () {
code = $(this).attr("dataId");
editRow()
}
});
}
});
}
function editRow() {
var div = $("<div>").appendTo($(document.body));
var title = "编辑";
var message = "确认修改吗?";
$(div).myDialog({
width: "780px",
height: "550px",
title: title,
href: contextPath + "/html/orderManage/editConfig.html?time_version=" + new Date().getTime(),
modal: true,
collapsible: true,
cache: false,
buttons: [{
id: "saveBtn",
text: "保存",
handler: function () {
$.messager.confirm("确认", message, function (flag) {
if (flag) {
var a = toJSON();
delete a.id;
delete a.code;
delete a.title;
delete a.desc;
delete a.value;
//$('#value').val(JSON.stringify(a));
var url = contextPath + "/metaConfig/update";
var code = $('#metaConfigEditForm #code').val();
if (code == '' || code == null || code == undefined) {
$.messager.alert("提示", '编码不能为空!', "error");
return false;
}
var title = $('#metaConfigEditForm #title').val();
if (title == '' || title == null || title == undefined) {
$.messager.alert("提示", '标题不能为空!', "error");
return false;
}
for(key in keyValueMap){
var val = $("#metaConfigEditForm [name = '"+key+"']").val();
if (val == '' || val == null || val == undefined) {
$.messager.alert("提示", keyValueMap[key] + '不能为空!', "error");
return false;
}
}
$("#metaConfigEditForm").form("submit", {
url: url,
onSubmit: function () {
if (!$("#metaConfigEditForm").form("validate")) {
return false;
}
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后..."
});
return true;
},
success: function (data) {
$.messager.progress("close");
data = JSON.parse(data);
if (data.code == 200) {
$(div).dialog("close");
$("#noticeListTable").myDatagrid("reload");
$.messager.show({
title: "提示",
msg: title + "成功!",
height: 120
});
} else {
$.messager.alert("失败", data.message, "error");
}
}
});
/*var name = $('#metaConfigEditForm #name').val();
if (name == '' || name == null || name == undefined) {
$.messager.alert("提示", '公告名称不能为空!', "error");
return false;
}
var url = $('#metaConfigEditForm #url').val();
if (url == '' || url == null || url == undefined) {
$.messager.alert("提示", '跳转页面不能为空!', "error");
return false;
}
var orderBy = $('#metaConfigEditForm #orderBy').val();
if (orderBy == '' || orderBy == null || orderBy == undefined) {
$.messager.alert("提示", '排序不能为空!', "error");
return false;
}
var showFront = $('input[name="showFront"]:checked').val();
if (showFront == '' || showFront == null || showFront == undefined) {
$.messager.alert("提示", '请选择是否开启滚动通知!', "error");
return false;
}
var url = contextPath + "/usersNotice/saveOrUpdateNotice";
$("#metaConfigEditForm").form("submit", {
url: url,
onSubmit: function () {
if (!$("#metaConfigEditForm").form("validate")) {
return false;
}
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后..."
});
return true;
},
success: function (data) {
$.messager.progress("close");
data = JSON.parse(data);
if (data.code == 200) {
$(div).dialog("close");
$("#noticeListTable").myDatagrid("reload");
$.messager.show({
title: "提示",
msg: title + "成功!",
height: 120
});
} else {
$.messager.alert("失败", data.message, "error");
}
}
});*/
}
});
}
}, {
text: "关闭",
iconCls: "icon-cancel",
handler: function () {
$(div).dialog("close");
}
}]
});
}
/**
* form表单转JSON格式
*/
function toJSON() {
var keyValues = $('#metaConfigEditForm').serializeArray();
var pattern=/\[(\d+)\]/;
var filter_keys = [],
normal_keys = keyValues.filter(function (v, i) {
if (~v.name.indexOf('.')||~pattern.test(v.name)) {
filter_keys.push(v);
return false
}
return true;
})
var resultJson = {};
filter_keys.forEach(function (v, i, ary) {
var v_ary = v.name.split('.'),
v_last = v_ary.length - 1;
var deal = function (obj, j, array) {
var me = arguments.callee,
islast = j === v_last ? true : false;
if (islast&&!pattern.test(array[j])) {
if(typeof obj =='array'){
return obj.push(v.value);
}else{
if(obj[array[j]]){
obj[array[j]]+=','+v.value||'';
}else{
obj[array[j]] = v.value || '';
}
return;
}
}else if(islast&&pattern.test(array[j])){
var name = array[j].substr(0, array[j].indexOf('['));
var index = array[j].match(pattern)[1];
if (!obj[name]) {
obj[name] = [];
}
if (obj[name].length<= index) {
return obj[name].push(v.value||'');
}
}
var nextObj;
if (pattern.test(array[j])) {
var name = array[j].substr(0, array[j].indexOf('['));
var index = array[j].match(pattern)[1];
if (!obj[name]) {
obj[name] = [];
}
if (obj[name].length<= index) {
nextObj={};
obj[name].push(nextObj);
}else{
nextObj=obj[name][index];
}
} else {
if (!obj[array[j]]) {
obj[array[j]] = {};
}
nextObj=obj[array[j]];
}
return me(nextObj, j + 1, array);
}
deal(resultJson, 0, v_ary);
});
normal_keys.forEach(function (v) {
resultJson[v.name] = v.value;
});
return resultJson;
}
</script>
</body>
</html>
\ No newline at end of file
... ...