Merge branch 'master' of ssh://193.112.35.168:29418/tejia
27个文件已删除
20个文件已修改
11个文件已添加
| | |
| | | name: lijin-provider |
| | | registry: |
| | | protocol: zookeeper |
| | | address: zookeeper://118.195.138.153:2181 # 134.175.68.214 134.175.68.214:2181 |
| | | address: zookeeper://193.112.35.168:2181 |
| | | # address: zookeeper://118.195.138.153:2181 |
| | | client: curator |
| | | protocol: |
| | | name: dubbo |
| | |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>com.ks</groupId> |
| | | <artifactId>facade-vip</artifactId> |
| | | <version>0.0.1-SNAPSHOT</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.ks</groupId> |
| | | <artifactId>lib-common</artifactId> |
| | |
| | | |
| | | <dependency> |
| | | <groupId>com.ks</groupId> |
| | | <artifactId>facade-goods</artifactId> |
| | | <version>0.0.1-SNAPSHOT</version> |
| | | <scope>system</scope> |
| | | <systemPath>${project.basedir}/src/main/libs/facade-goods.jar</systemPath> |
| | | </dependency> |
| | | |
| | | |
| | | <dependency> |
| | | <groupId>com.ks</groupId> |
| | | <artifactId>lib-common</artifactId> |
| | | <version>0.0.1-SNAPSHOT</version> |
| | | <scope>system</scope> |
| | |
| | | import com.ks.lib.common.exception.BaseException; |
| | | |
| | | public class LiJinException extends BaseException { |
| | | |
| | | // 淘礼金账户暂未创建 |
| | | public static final int CODE_TLJ_UN_PAID = 100; |
| | | // 商品支持创建红包 |
| | | //商品不支持创建淘礼金 |
| | | public static final int CODE_TLJ_FORBIDDEN = 101; |
| | | // 官方账户余额不足 |
| | | public static final int CODE_TLJ_NO_MONEY = 102; |
New file |
| | |
| | | package com.ks.lijin.exception; |
| | | |
| | | import com.ks.lib.common.exception.BaseException; |
| | | |
| | | /** |
| | | * 商品下架额异常 |
| | | */ |
| | | public class TaoBaoGoodsDownException extends BaseException { |
| | | |
| | | public TaoBaoGoodsDownException(int code, String msg) { |
| | | super(code, msg); |
| | | } |
| | | |
| | | public TaoBaoGoodsDownException() { |
| | | super(); |
| | | } |
| | | |
| | | |
| | | //屏蔽堆栈信息 |
| | | @Override |
| | | public synchronized Throwable fillInStackTrace() { |
| | | return this; |
| | | } |
| | | } |
| | |
| | | |
| | | String appkey; |
| | | String appsecret; |
| | | |
| | | private String pid; |
| | | |
| | | // 用户id |
| | | private String uid; |
| | | // 商品id |
| | | private Long goodsId; |
| | | // 礼金标题 |
| | | private String title; |
| | | // 礼金数量 |
| | | private int num; |
| | | // 单个金额 |
| | | private BigDecimal money; |
| | | // 数量 |
| | | private Integer num; |
| | | |
| | | private Date sendStartTime; |
| | | private Date sendEndTime; |
| | | private Date useStartTime; |
| | | private Date useEndTime; |
| | | |
| | | |
| | | public Integer getNum() { |
| | | return num; |
| | | } |
| | | |
| | | public void setNum(Integer num) { |
| | | this.num = num; |
| | | } |
| | | |
| | | public String getAppkey() { |
| | | return appkey; |
| | |
| | | |
| | | public void setAppsecret(String appsecret) { |
| | | this.appsecret = appsecret; |
| | | } |
| | | |
| | | public String getUid() { |
| | | return uid; |
| | | } |
| | | |
| | | public void setUid(String uid) { |
| | | this.uid = uid; |
| | | } |
| | | |
| | | public int getNum() { |
| | | return num; |
| | | } |
| | | |
| | | public void setNum(int num) { |
| | | this.num = num; |
| | | } |
| | | |
| | | public Date getSendStartTime() { |
| | |
| | | this.pid = pid; |
| | | } |
| | | |
| | | public Long getGoodsId() { |
| | | return goodsId; |
| | | } |
| | | |
| | | public void setGoodsId(Long goodsId) { |
| | | this.goodsId = goodsId; |
| | | } |
| | | |
| | | public String getTitle() { |
| | | return title; |
| | | } |
| | |
| | | this.title = title; |
| | | } |
| | | |
| | | public BigDecimal getMoney() { |
| | | return money; |
| | | } |
| | | |
| | | public void setMoney(BigDecimal money) { |
| | | this.money = money; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ks.lijin.pojo.DTO.taobao; |
| | | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Set; |
| | | |
| | | public class SearchFilter { |
| | | |
| | | private BigDecimal startPrice; |
| | | private BigDecimal endPrice; |
| | | private Set<String> params; |
| | | private String key; |
| | | private int page; |
| | | private int pageSize; |
| | | |
| | | // 排序字段 |
| | | // 销量(total_sales)淘客佣金比率(tk_rate)累计推广量(tk_total_sales)总支出佣金(tk_total_commi) |
| | | private int sort; |
| | | |
| | | private String cateIds; |
| | | // 官方的物料Id |
| | | private String materialId; |
| | | |
| | | private boolean tmall; |
| | | |
| | | private int hongbao; |
| | | |
| | | private int type; |
| | | |
| | | private String shopTag; |
| | | // 1-包邮 0-不包邮 |
| | | private boolean baoYou; |
| | | |
| | | private boolean tmFlagship; |
| | | |
| | | private int provinceId; |
| | | // 淘客佣金比率上限,如:1234表示12.34% |
| | | private int endTkRate; |
| | | // 淘客佣金比率下限,如:1234表示12.34% |
| | | private int startTkRate; |
| | | |
| | | // KA媒体淘客佣金比率上限,如:1234表示12.34% |
| | | private int endKaTkRate; |
| | | // KA媒体淘客佣金比率下限,如:1234表示12.34% |
| | | private int startKaTkRate; |
| | | |
| | | |
| | | // 1-有券 0-无券 |
| | | private int quan; |
| | | |
| | | |
| | | // 店铺dsr评分,筛选高于等于当前设置的店铺dsr评分的商品0-50000之间 |
| | | private int startDsr; |
| | | // 是否海外商品,设置为true表示该商品是属于海外商品,设置为false或不设置表示不判断这个属性 |
| | | private boolean overseas; |
| | | // 是否加入消费者保障,true表示加入,空或false表示不限 |
| | | private boolean needPrepay; |
| | | // 成交转化是否高于行业均值 |
| | | private boolean includePayRate30; |
| | | // 好评率是否高于行业均值 |
| | | private boolean includeGoodRate; |
| | | // 退款率是否低于行业均值 |
| | | private boolean includeRfdRate; |
| | | // 牛皮癣程度,取值:1:不限,2:无,3:轻微 |
| | | private int npxLevel; |
| | | |
| | | // 月销量 |
| | | private String startBiz30day; |
| | | |
| | | // 销售量小值 |
| | | private int minSales; |
| | | // 销售量大值 |
| | | private int maxSales; |
| | | // 标签 |
| | | private String lableNames; |
| | | |
| | | // ip地址 |
| | | private String ip; |
| | | |
| | | public SearchFilter() { |
| | | shopTag = ""; |
| | | } |
| | | |
| | | public boolean isTmFlagship() { |
| | | return tmFlagship; |
| | | } |
| | | |
| | | public int getPageSize() { |
| | | return pageSize; |
| | | } |
| | | |
| | | public void setPageSize(int pageSize) { |
| | | this.pageSize = pageSize; |
| | | } |
| | | |
| | | public void setTmFlagship(boolean tmFlagship) { |
| | | this.tmFlagship = tmFlagship; |
| | | } |
| | | |
| | | public String getShopTag() { |
| | | return shopTag; |
| | | } |
| | | |
| | | public void setShopTag(String shopTag) { |
| | | this.shopTag = shopTag; |
| | | } |
| | | |
| | | public Set<String> getParams() { |
| | | return params; |
| | | } |
| | | |
| | | public boolean isBaoYou() { |
| | | return baoYou; |
| | | } |
| | | |
| | | public void setBaoYou(boolean baoYou) { |
| | | this.baoYou = baoYou; |
| | | } |
| | | |
| | | public void setParams(Set<String> params) { |
| | | this.params = params; |
| | | } |
| | | |
| | | public int getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(int type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public int getHongbao() { |
| | | return hongbao; |
| | | } |
| | | |
| | | public void setHongbao(int hongbao) { |
| | | this.hongbao = hongbao; |
| | | } |
| | | |
| | | public int getQuan() { |
| | | return quan; |
| | | } |
| | | |
| | | public void setQuan(int quan) { |
| | | this.quan = quan; |
| | | } |
| | | |
| | | public boolean isTmall() { |
| | | return tmall; |
| | | } |
| | | |
| | | public void setTmall(boolean tmall) { |
| | | this.tmall = tmall; |
| | | } |
| | | |
| | | public String getCateIds() { |
| | | return cateIds; |
| | | } |
| | | |
| | | public void setCateIds(String cateIds) { |
| | | this.cateIds = cateIds; |
| | | } |
| | | |
| | | public String getKey() { |
| | | return key; |
| | | } |
| | | |
| | | public void setKey(String key) { |
| | | this.key = key; |
| | | } |
| | | |
| | | public int getPage() { |
| | | return page; |
| | | } |
| | | |
| | | public void setPage(int page) { |
| | | this.page = page; |
| | | } |
| | | |
| | | public int getSort() { |
| | | return sort; |
| | | } |
| | | |
| | | public void setSort(int sort) { |
| | | this.sort = sort; |
| | | } |
| | | |
| | | public int getProvinceId() { |
| | | return provinceId; |
| | | } |
| | | |
| | | public void setProvinceId(int provinceId) { |
| | | this.provinceId = provinceId; |
| | | } |
| | | |
| | | public int getEndTkRate() { |
| | | return endTkRate; |
| | | } |
| | | |
| | | public void setEndTkRate(int endTkRate) { |
| | | this.endTkRate = endTkRate; |
| | | } |
| | | |
| | | public int getStartTkRate() { |
| | | return startTkRate; |
| | | } |
| | | |
| | | public void setStartTkRate(int startTkRate) { |
| | | this.startTkRate = startTkRate; |
| | | } |
| | | |
| | | public int getStartDsr() { |
| | | return startDsr; |
| | | } |
| | | |
| | | public void setStartDsr(int startDsr) { |
| | | this.startDsr = startDsr; |
| | | } |
| | | |
| | | public boolean isOverseas() { |
| | | return overseas; |
| | | } |
| | | |
| | | public void setOverseas(boolean overseas) { |
| | | this.overseas = overseas; |
| | | } |
| | | |
| | | public boolean isNeedPrepay() { |
| | | return needPrepay; |
| | | } |
| | | |
| | | public void setNeedPrepay(boolean needPrepay) { |
| | | this.needPrepay = needPrepay; |
| | | } |
| | | |
| | | public boolean isIncludePayRate30() { |
| | | return includePayRate30; |
| | | } |
| | | |
| | | public void setIncludePayRate30(boolean includePayRate30) { |
| | | this.includePayRate30 = includePayRate30; |
| | | } |
| | | |
| | | public boolean isIncludeGoodRate() { |
| | | return includeGoodRate; |
| | | } |
| | | |
| | | public void setIncludeGoodRate(boolean includeGoodRate) { |
| | | this.includeGoodRate = includeGoodRate; |
| | | } |
| | | |
| | | public boolean isIncludeRfdRate() { |
| | | return includeRfdRate; |
| | | } |
| | | |
| | | public void setIncludeRfdRate(boolean includeRfdRate) { |
| | | this.includeRfdRate = includeRfdRate; |
| | | } |
| | | |
| | | public int getNpxLevel() { |
| | | return npxLevel; |
| | | } |
| | | |
| | | public void setNpxLevel(int npxLevel) { |
| | | this.npxLevel = npxLevel; |
| | | } |
| | | |
| | | public String getStartBiz30day() { |
| | | return startBiz30day; |
| | | } |
| | | |
| | | public void setStartBiz30day(String startBiz30day) { |
| | | this.startBiz30day = startBiz30day; |
| | | } |
| | | |
| | | public BigDecimal getStartPrice() { |
| | | return startPrice; |
| | | } |
| | | |
| | | public void setStartPrice(BigDecimal startPrice) { |
| | | this.startPrice = startPrice; |
| | | } |
| | | |
| | | public BigDecimal getEndPrice() { |
| | | return endPrice; |
| | | } |
| | | |
| | | public void setEndPrice(BigDecimal endPrice) { |
| | | this.endPrice = endPrice; |
| | | } |
| | | |
| | | public int getMinSales() { |
| | | return minSales; |
| | | } |
| | | |
| | | public void setMinSales(int minSales) { |
| | | this.minSales = minSales; |
| | | } |
| | | |
| | | public int getMaxSales() { |
| | | return maxSales; |
| | | } |
| | | |
| | | public void setMaxSales(int maxSales) { |
| | | this.maxSales = maxSales; |
| | | } |
| | | |
| | | public String getLableNames() { |
| | | return lableNames; |
| | | } |
| | | |
| | | public void setLableNames(String lableNames) { |
| | | this.lableNames = lableNames; |
| | | } |
| | | |
| | | public String getIp() { |
| | | return ip; |
| | | } |
| | | |
| | | public void setIp(String ip) { |
| | | this.ip = ip; |
| | | } |
| | | |
| | | public String getMaterialId() { |
| | | return materialId; |
| | | } |
| | | |
| | | public void setMaterialId(String materialId) { |
| | | this.materialId = materialId; |
| | | } |
| | | |
| | | public int getEndKaTkRate() { |
| | | return endKaTkRate; |
| | | } |
| | | |
| | | public void setEndKaTkRate(int endKaTkRate) { |
| | | this.endKaTkRate = endKaTkRate; |
| | | } |
| | | |
| | | public int getStartKaTkRate() { |
| | | return startKaTkRate; |
| | | } |
| | | |
| | | public void setStartKaTkRate(int startKaTkRate) { |
| | | this.startKaTkRate = startKaTkRate; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.lijin.pojo.DTO.taobao; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | |
| | | /** |
| | | * 淘宝搜索分类实体 |
| | | * |
| | | * @author Administrator |
| | | * |
| | | */ |
| | | public class TaoBaoSearchNav { |
| | | private int count; |
| | | private String flag; |
| | | @Expose |
| | | private long id; |
| | | private int level; |
| | | @Expose |
| | | private String name; |
| | | @Expose |
| | | private String type; |
| | | @Expose |
| | | private List<TaoBaoSearchNav> subIds; |
| | | @Expose |
| | | private int selector; //0单选 1多选 |
| | | |
| | | public TaoBaoSearchNav(int count, String flag, long id, int level, String name, String type) { |
| | | this.count = count; |
| | | this.flag = flag; |
| | | this.id = id; |
| | | this.level = level; |
| | | this.name = name; |
| | | this.type = type; |
| | | } |
| | | |
| | | public TaoBaoSearchNav() { |
| | | |
| | | } |
| | | |
| | | public int getSelector() { |
| | | return selector; |
| | | } |
| | | |
| | | public void setSelector(int selector) { |
| | | this.selector = selector; |
| | | } |
| | | |
| | | public int getCount() { |
| | | return count; |
| | | } |
| | | |
| | | public void setCount(int count) { |
| | | this.count = count; |
| | | } |
| | | |
| | | public String getFlag() { |
| | | return flag; |
| | | } |
| | | |
| | | public void setFlag(String flag) { |
| | | this.flag = flag; |
| | | } |
| | | |
| | | public long getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(long id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public int getLevel() { |
| | | return level; |
| | | } |
| | | |
| | | public void setLevel(int level) { |
| | | this.level = level; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(String type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public List<TaoBaoSearchNav> getSubIds() { |
| | | return subIds; |
| | | } |
| | | |
| | | public void setSubIds(List<TaoBaoSearchNav> subIds) { |
| | | this.subIds = subIds; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.lijin.pojo.DTO.taobao; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.ks.lijin.pojo.PageEntity; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoHead; |
| | | |
| | | public class TaoBaoSearchResult { |
| | | private String key; |
| | | private List<TaoBaoGoodsBrief> taoBaoGoodsBriefs; |
| | | private List<TaoBaoSearchNav> navList; |
| | | private TaoBaoHead taoBaoHead; |
| | | private PageEntity pageEntity; |
| | | |
| | | public PageEntity getPageEntity() { |
| | | return pageEntity; |
| | | } |
| | | |
| | | public void setPageEntity(PageEntity pageEntity) { |
| | | this.pageEntity = pageEntity; |
| | | } |
| | | |
| | | public String getKey() { |
| | | return key; |
| | | } |
| | | |
| | | public void setKey(String key) { |
| | | this.key = key; |
| | | } |
| | | |
| | | public List<TaoBaoGoodsBrief> getTaoBaoGoodsBriefs() { |
| | | return taoBaoGoodsBriefs; |
| | | } |
| | | |
| | | public void setTaoBaoGoodsBriefs(List<TaoBaoGoodsBrief> taoBaoGoodsBriefs) { |
| | | this.taoBaoGoodsBriefs = taoBaoGoodsBriefs; |
| | | } |
| | | |
| | | public List<TaoBaoSearchNav> getNavList() { |
| | | return navList; |
| | | } |
| | | |
| | | public void setNavList(List<TaoBaoSearchNav> navList) { |
| | | this.navList = navList; |
| | | } |
| | | |
| | | public TaoBaoHead getTaoBaoHead() { |
| | | return taoBaoHead; |
| | | } |
| | | |
| | | public void setTaoBaoHead(TaoBaoHead taoBaoHead) { |
| | | this.taoBaoHead = taoBaoHead; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.lijin.pojo; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Map; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | |
| | | public class PageEntity implements Serializable{ |
| | | /** |
| | | * |
| | | */ |
| | | private static final long serialVersionUID = 1L; |
| | | private String url; // |
| | | @Expose |
| | | private int pageIndex;// |
| | | @Expose |
| | | private int pageSize; // |
| | | @Expose |
| | | private long totalCount;// |
| | | @Expose |
| | | private int totalPage; |
| | | |
| | | public PageEntity(int pageIndex, int pageSize, long totalCount, int totalPage) { |
| | | super(); |
| | | this.pageIndex = pageIndex; |
| | | this.pageSize = pageSize; |
| | | this.totalCount = totalCount; |
| | | this.totalPage = totalPage; |
| | | } |
| | | public PageEntity() { |
| | | super(); |
| | | } |
| | | |
| | | public PageEntity(int pageIndex, int pageSize, int totalCount) { |
| | | super(); |
| | | this.pageIndex = pageIndex; |
| | | this.pageSize = pageSize; |
| | | this.totalCount = totalCount; |
| | | } |
| | | |
| | | private Map<String, String> params;// |
| | | |
| | | public int getTotalPage() { |
| | | return totalPage; |
| | | } |
| | | |
| | | public void setTotalPage(int totalPage) { |
| | | this.totalPage = totalPage; |
| | | } |
| | | |
| | | public String getUrl() { |
| | | return url; |
| | | } |
| | | |
| | | public void setUrl(String url) { |
| | | this.url = url; |
| | | } |
| | | |
| | | public int getPageIndex() { |
| | | return pageIndex; |
| | | } |
| | | |
| | | public void setPageIndex(int pageIndex) { |
| | | this.pageIndex = pageIndex; |
| | | } |
| | | |
| | | public int getPageSize() { |
| | | return pageSize; |
| | | } |
| | | |
| | | public void setPageSize(int pageSize) { |
| | | this.pageSize = pageSize; |
| | | } |
| | | |
| | | public long getTotalCount() { |
| | | return totalCount; |
| | | } |
| | | |
| | | public void setTotalCount(long totalCount) { |
| | | this.totalCount = totalCount; |
| | | } |
| | | |
| | | public Map<String, String> getParams() { |
| | | return params; |
| | | } |
| | | |
| | | public void setParams(Map<String, String> params) { |
| | | this.params = params; |
| | | } |
| | | } |
| | |
| | | |
| | | import com.ks.lijin.exception.LiJinExpendRecordException; |
| | | import com.ks.lijin.pojo.DO.LiJinExpendRecord; |
| | | import com.ks.lijin.pojo.DTO.taobao.TaoBaoGoodsBrief; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | |
| | | public void save(LiJinExpendRecord t); |
| | | |
| | | public void delete(Long id); |
| | | |
| | | public LiJinExpendRecord createLiJin(String uid, BigDecimal money, TaoBaoGoodsBrief goods) |
| | | throws LiJinExpendRecordException; |
| | | |
| | | /** |
| | | * 统计今日已使用次数 |
| | |
| | | package com.ks.lijin.service; |
| | | |
| | | import com.ks.lijin.exception.LiJinAmountException; |
| | | import com.ks.lijin.exception.LiJinException; |
| | | import com.ks.lijin.exception.LiJinGoodsException; |
| | | import com.ks.lijin.exception.LiJinUserException; |
| | | import com.ks.lijin.pojo.DO.LiJinExpendRecord; |
| | | import com.ks.lijin.pojo.DTO.LiJinCreateParam; |
| | | import com.ks.vip.pojo.Enums.VIPEnum; |
| | | |
| | | import java.math.BigDecimal; |
| | |
| | | * @param uid 用户ID |
| | | * @return 礼金创建的面额 |
| | | */ |
| | | public BigDecimal getTBLijinAmount(Long actionId, String uid) throws LiJinGoodsException, LiJinUserException; |
| | | public BigDecimal getTBLijinAmount(Long actionId, String uid) |
| | | throws LiJinGoodsException, LiJinUserException, LiJinAmountException; |
| | | |
| | | /** |
| | | * 获取商品可创建的淘礼金面额,若不能创建需要抛出相关的异常(1.商品不支持礼金创建) |
| | |
| | | * @return 礼金创建的面额 |
| | | * @throws LiJinGoodsException |
| | | */ |
| | | public BigDecimal getTBLijinAmount(Long actionId, VIPEnum vipRank) throws LiJinGoodsException; |
| | | |
| | | |
| | | /** |
| | | * 淘礼金创建 |
| | | * |
| | | * @param uid |
| | | * @param money |
| | | * @param auctionId |
| | | * @return |
| | | * @throws LiJinGoodsException |
| | | * @throws LiJinUserException |
| | | * @throws LiJinAmountException |
| | | */ |
| | | public LiJinExpendRecord createTBLijin(String uid, BigDecimal money, Long auctionId) throws LiJinGoodsException, LiJinUserException, LiJinAmountException; |
| | | public BigDecimal getTBLijinAmount(Long actionId, VIPEnum vipRank) throws LiJinGoodsException, LiJinAmountException; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | public boolean userCanCreateTBLijin(String uid) throws LiJinUserException; |
| | | |
| | | /** |
| | | * 用户是否还可以创建礼金 |
| | | * |
| | | * @param uid |
| | | * @param money 本次需要创建的金额 |
| | | * @return |
| | | * @throws LiJinUserException |
| | | */ |
| | | public boolean userCanCreateTBLijin(String uid, BigDecimal money) throws LiJinUserException; |
| | | |
| | | /** |
| | | * 淘礼金创建 |
| | | * |
| | | * @param uid |
| | | * @param auctionId |
| | | * @return |
| | | * @throws LiJinGoodsException |
| | | * @throws LiJinUserException |
| | | * @throws LiJinAmountException |
| | | */ |
| | | public LiJinExpendRecord createTBLijin(String uid,Long auctionId) |
| | | throws LiJinException, LiJinGoodsException, LiJinUserException, LiJinAmountException; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.lijin.utils.taobao; |
| | | |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | |
| | | public class TaoBaoCouponUtil { |
| | | |
| | | |
| | | /** |
| | | * 获取券后价--(无券可用返回的是在售价) |
| | | * @param goodsBrief |
| | | * @return |
| | | */ |
| | | public static BigDecimal getCouplePrice(TaoBaoGoodsBrief goodsBrief) { |
| | | if (StringUtil.isNullOrEmpty(goodsBrief.getCouponInfo()) || "无".equals(goodsBrief.getCouponInfo())) { |
| | | return goodsBrief.getZkPrice(); |
| | | } else { |
| | | List<BigDecimal> list = getCouponInfo(goodsBrief.getCouponInfo()); |
| | | BigDecimal startFee = list.get(0); |
| | | BigDecimal couponAccount = list.get(1); |
| | | if (startFee.compareTo(goodsBrief.getZkPrice()) <= 0 |
| | | && goodsBrief.getZkPrice().compareTo(couponAccount) > 0) { |
| | | BigDecimal finalPrice = goodsBrief.getZkPrice().subtract(couponAccount); |
| | | return finalPrice; |
| | | } else {// 不能用券 |
| | | return goodsBrief.getZkPrice(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public static List<BigDecimal> getCouponInfo(String info) { |
| | | Pattern p = Pattern.compile("满\\d+(\\.\\d+)?元减\\d+(\\.\\d+)?元"); |
| | | Matcher matcher = p.matcher(info); |
| | | Pattern p2 = Pattern.compile("\\d+元无条件券"); |
| | | Matcher matcher2 = p2.matcher(info); |
| | | List<BigDecimal> list = new ArrayList<BigDecimal>(); |
| | | if (matcher.matches()) { |
| | | String[] sts = info.split("元减"); |
| | | list.add(new BigDecimal(sts[0].replace("满", "").trim())); |
| | | list.add(new BigDecimal(sts[1].replace("元", "").trim())); |
| | | } else if (matcher2.matches()) { |
| | | String[] split = info.split("元无条件券"); |
| | | list.add(new BigDecimal(0)); |
| | | list.add(new BigDecimal(split[0])); |
| | | } else { |
| | | list.add(new BigDecimal(0)); |
| | | list.add(new BigDecimal(0)); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.lijin.utils.taobao; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.net.URLEncoder; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.commons.httpclient.HttpClient; |
| | | import org.apache.commons.httpclient.HttpException; |
| | | import org.apache.commons.httpclient.methods.GetMethod; |
| | | import org.apache.commons.httpclient.params.HttpConnectionManagerParams; |
| | | |
| | | |
| | | public class TaoBaoHttpUtil { |
| | | |
| | | |
| | | public static String proxyGet(String url, String cookie) { |
| | | HttpClient client = new HttpClient(); |
| | | try { |
| | | GetMethod method = new GetMethod(url); |
| | | if (cookie != null) { |
| | | method.addRequestHeader("cookie", cookie); |
| | | } |
| | | client.executeMethod(method); |
| | | return method.getResponseBodyAsString(); |
| | | } catch (HttpException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | public static String proxyGet(String url, Map<String, String> headers) { |
| | | HttpClient client = new HttpClient(); |
| | | try { |
| | | GetMethod method = new GetMethod(url); |
| | | if (headers != null) { |
| | | Iterator<String> keys = headers.keySet().iterator(); |
| | | while (keys.hasNext()) { |
| | | String key = keys.next(); |
| | | method.addRequestHeader(key, headers.get(key)); |
| | | } |
| | | } |
| | | client.executeMethod(method); |
| | | return method.getResponseBodyAsString(); |
| | | } catch (HttpException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | |
| | | public static String get(String url, Map<String, String> params, boolean proxy) { |
| | | HttpClient client = new HttpClient(); |
| | | // client.getHostConfiguration().setProxy("192.168.1.122", 8888); |
| | | try { |
| | | Iterator<String> keys = params.keySet().iterator(); |
| | | url += "?"; |
| | | while (keys.hasNext()) { |
| | | String key = keys.next(); |
| | | url += String.format("%s=%s&", key, URLEncoder.encode(params.get(key), "UTF-8")); |
| | | } |
| | | |
| | | // System.out.println("url"+url); |
| | | GetMethod method = new GetMethod(url); |
| | | // 3S的响应超时 |
| | | HttpConnectionManagerParams hparams = new HttpConnectionManagerParams(); |
| | | hparams.setConnectionTimeout(3000); |
| | | client.getHttpConnectionManager().setParams(hparams); |
| | | |
| | | /* |
| | | * if(proxy){ Address address = ProxyUtil.getAddressProxy(); |
| | | * if(address != null){ HttpConnectionManagerParams hparams = new |
| | | * HttpConnectionManagerParams(); |
| | | * hparams.setConnectionTimeout(3500); |
| | | * client.getHttpConnectionManager().setParams(hparams); |
| | | * client.getHostConfiguration().setProxy(address.getIp(),address. |
| | | * getPort()); } } |
| | | */ |
| | | // client.getHostConfiguration().setProxy("192.168.1.122",8888); |
| | | client.executeMethod(method); |
| | | String result = method.getResponseBodyAsString(); |
| | | return result; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | public static String get(String url, Map<String, String> params, Map<String, String> headers, boolean proxy) { |
| | | HttpClient client = new HttpClient(); |
| | | try { |
| | | Iterator<String> keys = params.keySet().iterator(); |
| | | url += "?"; |
| | | while (keys.hasNext()) { |
| | | String key = keys.next(); |
| | | url += String.format("%s=%s&", key, URLEncoder.encode(params.get(key), "UTF-8")); |
| | | } |
| | | |
| | | System.out.println(url); |
| | | |
| | | GetMethod method = new GetMethod(url); |
| | | if (headers != null) { |
| | | keys = headers.keySet().iterator(); |
| | | while (keys.hasNext()) { |
| | | String key = keys.next(); |
| | | headers.get(key); |
| | | method.setRequestHeader(key, headers.get(key)); |
| | | } |
| | | } |
| | | |
| | | /* |
| | | * if(proxy){ Address address = ProxyUtil.getAddressProxy(); |
| | | * if(address != null){ HttpConnectionManagerParams hparams = new |
| | | * HttpConnectionManagerParams(); |
| | | * hparams.setConnectionTimeout(3500); |
| | | * client.getHttpConnectionManager().setParams(hparams); |
| | | * client.getHostConfiguration().setProxy(address.getIp(),address. |
| | | * getPort()); } } |
| | | */ |
| | | // client.getHostConfiguration().setProxy("120.92.118.64", 10000); |
| | | |
| | | client.executeMethod(method); |
| | | String result = method.getResponseBodyAsString(); |
| | | return result; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | public static String taoKeGet(Map<String, String> params) { |
| | | String result = get("https://eco.taobao.com/router/rest", params, false); |
| | | return result; |
| | | } |
| | | |
| | | public static String get(String url, Map<String, String> params) { |
| | | return get(url, params, false); |
| | | } |
| | | |
| | | public static InputStream getAsInputStream(String url) { |
| | | HttpClient client = new HttpClient(); |
| | | GetMethod method = new GetMethod(url); |
| | | try { |
| | | client.executeMethod(method); |
| | | return method.getResponseBodyAsStream(); |
| | | } catch (HttpException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | private static String convertInputStreamToString(InputStream inputStream) { |
| | | BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); |
| | | StringBuffer stringBuffer = new StringBuffer(); |
| | | String str = ""; |
| | | try { |
| | | while ((str = br.readLine()) != null) { |
| | | stringBuffer.append(str); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return stringBuffer.toString(); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ks.lijin.utils.taobao; |
| | | |
| | | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.*; |
| | | |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | |
| | | import com.yeshi.goods.facade.entity.taobao.dataoke.DaTaoKeDetailV2; |
| | | |
| | | |
| | | @Component |
| | | public class TaoBaoUtil { |
| | | |
| | | |
| | | public final static int SORT_PRICE_HIGH_TO_LOW = 3;// 价格从高到低 |
| | | public final static int SORT_PRICE_LOW_TO_HIGH = 4;// 价格从低到高 |
| | | |
| | | public static final int SORT_TKRATE_LOW_TO_HIGH = 1;// 淘客佣金比率低到高 |
| | | public static final int SORT_TKRATE_HIGH_TO_LOW = 2;// 淘客佣金比率高到低 |
| | | |
| | | public static final int SORT_TOTAL_COMMI_LOW_TO_HIGH = 5;// 总支出佣金低到高 |
| | | public static final int SORT_TOTAL_COMMI_HIGH_TO_LOW = 6;// 总支出佣金高到低 |
| | | |
| | | public static final int SORT_TOTAL_SALES_LOW_TO_HIGH = 10;// 累计推广量低到高 |
| | | public static final int SORT_TOTAL_SALES_HIGH_TO_LOW = 11;// 累计推广量高到低 |
| | | |
| | | public static final int SORT_SALE_COMMISSION = 7;// 月支出佣金从高到低 |
| | | |
| | | public final static int SORT_SALE_LOW_TO_HIGH = 8;// 销量从低到高 |
| | | |
| | | public final static int SORT_SALE_HIGH_TO_LOW = 9;// 销量从高到低 |
| | | public final static int SORT_DEFAULT = 0;// 销量从高到低 |
| | | |
| | | public final static int SORT_FILTER_FROM_ALL = 0;// 淘宝天猫 |
| | | public final static int SORT_FILTER_FROM_TMALL = 1;// 天猫 |
| | | |
| | | private final static int PAGESIZE = 20; |
| | | |
| | | public final static String SEARCH_URL = "http://pub.alimama.com/items/search.json"; |
| | | private static final String NZJH_URL = "http://pub.alimama.com/items/channel/nzjh.json"; |
| | | private static final String MUYING_URL = "http://pub.alimama.com/items/channel/muying.json"; |
| | | private static final String QQHD_URL = "http://pub.alimama.com/items/channel/qqhd.json"; |
| | | private static final String IFS_URL = "http://pub.alimama.com/items/channel/ifs.json"; |
| | | private static final String QBB_URL = "http://pub.alimama.com/items/channel/qbb.json"; |
| | | private static final String HCH_URL = "http://pub.alimama.com/items/channel/hch.json"; |
| | | private static final String CDJ_URL = "http://pub.alimama.com/items/channel/cdj.json"; |
| | | private static final String JYJ_URL = "http://pub.alimama.com/items/channel/jyj.json"; |
| | | private static final String KDC_URL = "http://pub.alimama.com/items/channel/kdc.json"; |
| | | private static final String DIY_URL = "http://pub.alimama.com/items/channel/diy.json"; |
| | | private static final String K9_URL = "http://pub.alimama.com/items/channel/9k9.json"; |
| | | private static final String K20_URL = "http://pub.alimama.com/items/channel/20k.json"; |
| | | private static final String TEHUI_URL = "http://pub.alimama.com/items/channel/tehui.json"; |
| | | |
| | | private static final String TB_ITEM_URL = "http://gw.api.taobao.com/router/rest"; |
| | | |
| | | public static final String TB_URL = "http://item.taobao.com/item.htm?id=%s"; |
| | | public static final String TM_PHONE_URL = "https://detail.m.tmall.com/item.htm?id=%s"; |
| | | public static final String TB_H5_URL = "http://h5.m.taobao.com/awp/core/detail.htm?id=%s"; |
| | | |
| | | |
| | | /** |
| | | * 获取商品的用户分成比例 |
| | | * |
| | | * @param goodsBrief 商品详情 |
| | | * @param rate 用户再次分成比例(0-100) |
| | | * @return |
| | | */ |
| | | public static String getGoodsHongBaoInfo(TaoBaoGoodsBrief goodsBrief, BigDecimal rate, boolean share) { |
| | | // if (goodsBrief != null && goodsBrief.getMaterialLibType() != null && |
| | | // goodsBrief.getMaterialLibType() == 0) |
| | | // return "¥0.00"; |
| | | // else |
| | | return "¥" + getGoodsHongBaoMoney(goodsBrief, rate, share).toString(); |
| | | } |
| | | |
| | | /** |
| | | * 获取淘宝商品该获得多少佣金 |
| | | * |
| | | * @param goodsBrief |
| | | * @param rate |
| | | * @return |
| | | */ |
| | | public static BigDecimal getGoodsHongBaoMoney(TaoBaoGoodsBrief goodsBrief, BigDecimal rate, boolean share) { |
| | | BigDecimal commissionRate = null; |
| | | if (goodsBrief.getMinTkRate() != null && !share) |
| | | commissionRate = goodsBrief.getMinTkRate(); |
| | | else |
| | | commissionRate = goodsBrief.getTkRate(); |
| | | |
| | | BigDecimal money = null; |
| | | if (StringUtil.isNullOrEmpty(goodsBrief.getCouponInfo()) |
| | | || goodsBrief.getCouponInfo().trim().equalsIgnoreCase("无")) { |
| | | money = MoneyBigDecimalUtil.mul( |
| | | MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(goodsBrief.getZkPrice(), commissionRate), |
| | | new BigDecimal("0.01")), |
| | | MoneyBigDecimalUtil.div(rate, new BigDecimal(100))); |
| | | } else// 有券 |
| | | { |
| | | List<BigDecimal> list = TaoBaoCouponUtil.getCouponInfo(goodsBrief.getCouponInfo()); |
| | | BigDecimal startFee = list.get(0); |
| | | BigDecimal couponAccount = list.get(1); |
| | | if (startFee.compareTo(goodsBrief.getZkPrice()) <= 0 |
| | | && goodsBrief.getZkPrice().compareTo(couponAccount) > 0) { |
| | | BigDecimal finalPrice = goodsBrief.getZkPrice().subtract(couponAccount); |
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil |
| | | .mul(MoneyBigDecimalUtil.mul(finalPrice, commissionRate), new BigDecimal("0.01")), |
| | | MoneyBigDecimalUtil.div(rate, new BigDecimal(100))); |
| | | |
| | | } else {// 不能用券 |
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul( |
| | | MoneyBigDecimalUtil.mul(goodsBrief.getZkPrice(), commissionRate), |
| | | new BigDecimal("0.01")), MoneyBigDecimalUtil.div(rate, new BigDecimal(100))); |
| | | } |
| | | } |
| | | |
| | | if (share) |
| | | money = TaoBaoUtil.getCanShareMoney(new Date(), money); |
| | | |
| | | |
| | | return BigDecimalUtil.getWithNoZera(money); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取分享赚的金额 |
| | | * |
| | | * @param goodsBrief |
| | | * @param rate |
| | | * @return |
| | | */ |
| | | |
| | | public static BigDecimal getShareGoodsHongBaoInfo(TaoBaoGoodsBrief goodsBrief, BigDecimal rate) { |
| | | return getGoodsHongBaoMoney(goodsBrief, rate, true); |
| | | } |
| | | |
| | | /** |
| | | * 计算商品券后价,没有券则返回原价 |
| | | * |
| | | * @param goodsBrief |
| | | * @return |
| | | */ |
| | | public static BigDecimal getAfterUseCouplePrice(TaoBaoGoodsBrief goodsBrief) { |
| | | |
| | | if (StringUtil.isNullOrEmpty(goodsBrief.getCouponInfo()) || "无".equals(goodsBrief.getCouponInfo())) { |
| | | return goodsBrief.getZkPrice(); |
| | | } else { |
| | | List<BigDecimal> list = TaoBaoCouponUtil.getCouponInfo(goodsBrief.getCouponInfo()); |
| | | BigDecimal startFee = list.get(0); |
| | | BigDecimal couponAccount = list.get(1); |
| | | if (startFee.compareTo(goodsBrief.getZkPrice()) <= 0 |
| | | && goodsBrief.getZkPrice().compareTo(couponAccount) > 0) { |
| | | BigDecimal finalPrice = goodsBrief.getZkPrice().subtract(couponAccount); |
| | | return finalPrice; |
| | | } else {// 不能用券 |
| | | return goodsBrief.getZkPrice(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public static String getSaleCount(int count) { |
| | | if (count >= 10000) { |
| | | double sales = count; |
| | | String salesCountMidea = String.format("%.1f", sales / 10000); |
| | | return salesCountMidea + "万"; |
| | | } else |
| | | return count + ""; |
| | | } |
| | | |
| | | |
| | | public static TaoBaoGoodsBrief convert(DaTaoKeDetailV2 detail) { |
| | | TaoBaoGoodsBrief taoBaoGoods = new TaoBaoGoodsBrief(); |
| | | taoBaoGoods.setAuctionId(detail.getGoodsId()); |
| | | taoBaoGoods.setBiz30day(detail.getMonthSales()); |
| | | // 券相关转换 |
| | | taoBaoGoods.setCouponAmount(detail.getCouponPrice()); |
| | | taoBaoGoods.setCouponInfo(String.format("满%s元减%s元", detail.getOriginalPrice(), |
| | | MoneyBigDecimalUtil.getWithNoZera(detail.getCouponPrice()))); |
| | | if (detail.getCouponTotalNum() != null && detail.getCouponReceiveNum() != null) |
| | | taoBaoGoods.setCouponLeftCount(detail.getCouponTotalNum() - detail.getCouponReceiveNum()); |
| | | else |
| | | taoBaoGoods.setCouponLeftCount(0); |
| | | taoBaoGoods.setCouponStartFee(detail.getOriginalPrice()); |
| | | try { |
| | | taoBaoGoods.setCouponStartFee(detail.getOriginalPrice()); |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | taoBaoGoods.setCouponTotalCount(detail.getCouponTotalNum()); |
| | | taoBaoGoods.setCouponLink(detail.getCouponLink()); |
| | | taoBaoGoods.setCouponEffectiveStartTime(TimeUtil.getGernalTime( |
| | | TimeUtil.convertToTimeTemp(detail.getCouponStartTime(), "yyyy-MM-dd HH:mm:ss"), "yyyy-MM-dd")); |
| | | taoBaoGoods.setCouponEffectiveEndTime(TimeUtil.getGernalTime( |
| | | TimeUtil.convertToTimeTemp(detail.getCouponEndTime(), "yyyy-MM-dd HH:mm:ss"), "yyyy-MM-dd")); |
| | | |
| | | taoBaoGoods.setPictUrl(detail.getMainPic()); |
| | | taoBaoGoods.setPictUrlWhite(detail.getMainPic()); |
| | | if (taoBaoGoods.getPictUrl() != null && !taoBaoGoods.getPictUrl().startsWith("http")) |
| | | taoBaoGoods.setPictUrl("https:" + taoBaoGoods.getPictUrl()); |
| | | |
| | | if (taoBaoGoods.getPictUrlWhite() != null && !taoBaoGoods.getPictUrlWhite().startsWith("http")) |
| | | taoBaoGoods.setPictUrlWhite("https:" + taoBaoGoods.getPictUrlWhite()); |
| | | |
| | | |
| | | String imgs = detail.getImgs(); |
| | | if (!StringUtil.isNullOrEmpty(imgs)) { |
| | | String[] array = imgs.split(","); |
| | | if (array != null && array.length > 0) { |
| | | List<String> imgList = new ArrayList<>(); |
| | | for (int i = 0; i < array.length; i++) { |
| | | imgList.add(array[i]); |
| | | } |
| | | taoBaoGoods.setImgList(imgList); |
| | | } |
| | | } |
| | | |
| | | |
| | | taoBaoGoods.setSellerId(detail.getSellerId()); |
| | | taoBaoGoods.setShopTitle(detail.getShopName()); |
| | | taoBaoGoods.setTitle(detail.getDtitle()); |
| | | taoBaoGoods.setUserType(detail.getShopType()); |
| | | taoBaoGoods.setZkPrice(detail.getOriginalPrice()); |
| | | taoBaoGoods.setTkRate(detail.getCommissionRate()); |
| | | taoBaoGoods.setTkCommFee(new BigDecimal("0")); |
| | | taoBaoGoods.setState(0); |
| | | return taoBaoGoods; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 提取自有格式的淘口令 |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static String parseSystemTaoToken(String str) { |
| | | String pattern = "(\\({1}[A-Za-z0-9]+\\){1})"; |
| | | Pattern r = Pattern.compile(pattern); |
| | | Matcher m = r.matcher(str); |
| | | while (m.find()) { |
| | | String group = m.group(0); |
| | | if (!StringUtil.isNullOrEmpty(group) && group.length() >= 10) |
| | | return group; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static boolean isSpecialGoods(Integer materialLibType) { |
| | | if (materialLibType != null && materialLibType == 1) |
| | | return true; |
| | | else |
| | | return false; |
| | | } |
| | | |
| | | private final static String[] taoTokenSymbols = new String[]{"₳-₳", "¥-¥", "¥-¥", "€-€", "\\$-\\$", "₴-₴", "¢-¢", |
| | | "₤-₤"}; |
| | | |
| | | /** |
| | | * 从文本中提取淘口令 @Title: getTokenListFromText @Description: @param str @return |
| | | * List<String> 返回类型 @throws |
| | | */ |
| | | public static List<String> getTokenListFromText(String str) { |
| | | String[] marks = taoTokenSymbols; |
| | | List<String> list = new ArrayList<>(); |
| | | for (String m : marks) { |
| | | for (String m1 : marks) { |
| | | list.add(m.split("-")[0] + "-" + m1.split("-")[1]); |
| | | } |
| | | } |
| | | |
| | | return getTokenListFromText(str, list); |
| | | } |
| | | |
| | | /** |
| | | * 从文本中提取淘口令(括号的口令也算) |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static List<String> getTokenListFromTextWithKuoHao(String str) { |
| | | String[] marks = taoTokenSymbols; |
| | | List<String> list = new ArrayList<>(); |
| | | for (String m : marks) { |
| | | for (String m1 : marks) { |
| | | list.add(m.split("-")[0] + "-" + m1.split("-")[1]); |
| | | } |
| | | } |
| | | |
| | | list.add("\\(-\\)"); |
| | | list.add("(-)"); |
| | | return getTokenListFromText(str, list); |
| | | } |
| | | |
| | | public static List<String> getTokenListFromText(String str, List<String> markList) { |
| | | List<String> expressList = new ArrayList<>(); |
| | | for (String st : markList) { |
| | | expressList.add(String.format("(%s{1}[A-Za-z0-9]{11,13}+%s{1})", st.split("-")[0], st.split("-")[1])); |
| | | } |
| | | String pattern = StringUtil.concat(expressList, "|"); |
| | | Pattern r = Pattern.compile(pattern); |
| | | Matcher m = r.matcher(str); |
| | | List<String> urlList = new ArrayList<>(); |
| | | while (m.find()) { |
| | | urlList.add(m.group()); |
| | | } |
| | | return urlList; |
| | | } |
| | | |
| | | /** |
| | | * 获取能够分的钱 |
| | | * |
| | | * @param estimate |
| | | * @return BigDecimal 返回类型 |
| | | * @throws |
| | | * @Title: getCanShareMoney |
| | | * @Description: |
| | | */ |
| | | public static BigDecimal getCanShareMoney(Date createTime, BigDecimal estimate) { |
| | | if (estimate == null) |
| | | return null; |
| | | if (createTime.getTime() < TimeUtil.convertToTimeTemp("2020-06-01 12:30:00", "yyyy-MM-dd HH:mm:ss")) { |
| | | return estimate; |
| | | } |
| | | BigDecimal rate = new BigDecimal("0.9101"); |
| | | return MoneyBigDecimalUtil.mul(estimate, rate); |
| | | } |
| | | |
| | | /** |
| | | * 拼接渠道ID |
| | | * |
| | | * @param url |
| | | * @param relationId |
| | | * @return |
| | | */ |
| | | public static String concatRelationId(String url, String relationId) { |
| | | if (StringUtil.isNullOrEmpty(relationId)) |
| | | return url; |
| | | return url + "&relationId=" + relationId; |
| | | } |
| | | |
| | | |
| | | //从券链接获取券ID |
| | | |
| | | /** |
| | | * 从券链接中获取券ID |
| | | * |
| | | * @param couponLink |
| | | * @return |
| | | */ |
| | | public static String getActivityIdFromCouponLink(String couponLink) { |
| | | Map<String, String> params = HttpUtil.getPramsFromUrl(couponLink); |
| | | if (params != null && params.containsKey("activityId")) |
| | | return params.get("activityId"); |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | import com.ks.lijin.exception.LiJinException; |
| | | import com.ks.lijin.exception.LiJinGoodsException; |
| | | import com.ks.lijin.exception.TaoBaoGoodsDownException; |
| | | import com.ks.lijin.exception.TaoKeApiException; |
| | | import com.ks.lijin.pojo.DTO.taobao.TaoKeAppInfo; |
| | | import com.ks.lijin.pojo.DTO.taobao.TaoLiJinDTO; |
| | | import com.ks.lijin.pojo.DTO.taobao.*; |
| | | import com.ks.lijin.pojo.PageEntity; |
| | | import com.taobao.api.internal.util.StringUtils; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoHead; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.apache.commons.httpclient.HttpClient; |
| | | import org.apache.commons.httpclient.methods.GetMethod; |
| | | import org.apache.commons.httpclient.params.HttpConnectionManagerParams; |
| | | import org.yeshi.utils.*; |
| | | import org.yeshi.utils.taobao.TbImgUtil; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | |
| | | // 淘礼金创建 |
| | | public static TaoLiJinDTO createTaoLiJin(Long auctionId, String name, BigDecimal perface, int totalNum, |
| | | Date sendStartTime, Date sendEndTime, Date useStartTime, Date useEndTime, TaoKeAppInfo app) |
| | | throws LiJinException, TaoKeApiException { |
| | | |
| | | throws LiJinException, LiJinGoodsException { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.dg.vegas.tlj.create"); |
| | | map.put("adzone_id", app.getPid().split("_")[3]); |
| | |
| | | // TLJLogHelper.info(auctionId, root.toString());// 淘礼金异常信息记录 TODO |
| | | switch (msgCode) { |
| | | case "FAIL_BIZ_ITEM_FORBIDDEN": |
| | | throw new LiJinException(LiJinException.CODE_TLJ_FORBIDDEN, "该商品不支持创建淘礼金红包"); |
| | | throw new LiJinGoodsException(LiJinGoodsException.CODE_GOODS_NOT_SUPPORT, "该商品不支持创建淘礼金红包"); |
| | | case "FAIL_BIZ_ACCOUNT_UN_PAID": |
| | | throw new LiJinException(LiJinException.CODE_TLJ_UN_PAID, "您的淘礼金账户暂未创建,请前往资金管理页面充值"); |
| | | case "PRE_FREEZE_ASSET_ACCOUNT_ERROR": |
| | | throw new LiJinException(LiJinException.CODE_TLJ_NO_MONEY, "官方玩法钱包余额不足"); |
| | | case "ASSET_ACCOUNT_BALANCE_NOT_ENOUGH": |
| | | throw new LiJinException(LiJinException.CODE_TLJ_NO_MONEY, "账户预算不足"); |
| | | case "FAIL_CHECK_ITEM_DAILY_SEND_NUM_CHECK_ERROR": |
| | | throw new LiJinGoodsException(LiJinGoodsException.CODE_GOODS_CREATED_NUM_FULL, "今日该商品淘礼金创建数已超上限,请您明日再试"); |
| | | default: |
| | | throw new TaoKeApiException(Integer.parseInt(msgCode), root.toString()); |
| | | throw new LiJinException(Integer.parseInt(msgCode), root.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | |
| | | public static TaoBaoGoodsBrief searchGoodsDetail(Long id) throws TaoBaoGoodsDownException { |
| | | return searchGoodsDetail(id, null, null); |
| | | } |
| | | |
| | | /** |
| | | * 搜索商品详情-详细 |
| | | * |
| | | * @param id |
| | | * @return |
| | | * @throws |
| | | */ |
| | | public static TaoBaoGoodsBrief searchGoodsDetail(Long id, String specialId, String relationId) throws TaoBaoGoodsDownException { |
| | | TaoBaoGoodsBrief goods = getSimpleGoodsInfo(id); |
| | | if (goods == null) |
| | | return null; |
| | | SearchFilter filter = new SearchFilter(); |
| | | filter.setKey(goods.getTitle()); |
| | | filter.setPage(1); |
| | | filter.setPageSize(50); |
| | | TaoBaoSearchResult result = searchWuLiaoForDetail(goods.getTitle(), goods.getZkPrice(), goods.getProvcity(), |
| | | goods.getUserType(), specialId, relationId); |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) |
| | | for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) { |
| | | System.out.println(goods.getAuctionId() + ":" + g.getAuctionId()); |
| | | if (goods.getAuctionId().longValue() == g.getAuctionId()) { |
| | | g.setId(goods.getAuctionId()); |
| | | g.setCreatetime(new Date()); |
| | | g.setMaterialLibType(goods.getMaterialLibType()); |
| | | g.setProvcity(goods.getProvcity()); |
| | | return g; |
| | | } |
| | | } |
| | | goods.setCouponAmount(new BigDecimal("0")); |
| | | goods.setTkMktStatus("1"); |
| | | goods.setTkRate(new BigDecimal("0")); |
| | | goods.setReservePrice(new BigDecimal(0)); |
| | | goods.setTkCommFee(new BigDecimal(0)); |
| | | return goods; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取商品详情,简版 |
| | | * |
| | | * @param id -商品AuctionId |
| | | * @return |
| | | */ |
| | | public static TaoBaoGoodsBrief getSimpleGoodsInfo(Long id) throws TaoBaoGoodsDownException { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.item.info.get"); |
| | | map.put("num_iids", id + ""); |
| | | String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); |
| | | System.out.println(resultStr); |
| | | JSONObject data = JSONObject.fromObject(resultStr); |
| | | // 商品下架 |
| | | if (data.optJSONObject("error_response") != null && data.optJSONObject("error_response").optInt("code") == 15 |
| | | && data.optJSONObject("error_response").optInt("sub_code") == 50001) { |
| | | throw new TaoBaoGoodsDownException(data.optJSONObject("error_response").optInt("code"), "商品下架"); |
| | | } |
| | | |
| | | if (data.optJSONObject("tbk_item_info_get_response") == null) |
| | | return null; |
| | | JSONArray array = data.optJSONObject("tbk_item_info_get_response").optJSONObject("results") |
| | | .optJSONArray("n_tbk_item"); |
| | | if (array != null && array.size() > 0) { |
| | | JSONObject item = array.optJSONObject(0); |
| | | return parseSimpleGoodsInfo(item); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | private static TaoBaoGoodsBrief parseSimpleGoodsInfo(JSONObject item) { |
| | | TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief(); |
| | | goods.setAuctionId(item.optLong("num_iid")); |
| | | goods.setAuctionUrl(item.optString("item_url")); |
| | | goods.setBiz30day(item.optInt("volume")); |
| | | if (item.optJSONObject("small_images") != null) { |
| | | JSONArray imgArray = item.optJSONObject("small_images").optJSONArray("string"); |
| | | if (imgArray != null) { |
| | | List<String> imgList = new ArrayList<>(); |
| | | for (int n = 0; n < imgArray.size(); n++) { |
| | | imgList.add(imgArray.optString(n)); |
| | | } |
| | | goods.setImgList(imgList); |
| | | } |
| | | } |
| | | goods.setTitle(item.optString("title")); |
| | | goods.setUserType(item.optInt("user_type")); |
| | | goods.setZkPrice(new BigDecimal(item.optString("zk_final_price"))); |
| | | goods.setReservePrice(new BigDecimal(item.optString("zk_final_price"))); |
| | | goods.setAuctionUrl(item.optString("item_url")); |
| | | goods.setProvcity(item.optString("provcity")); |
| | | goods.setPictUrl(item.optString("pict_url")); |
| | | goods.setShopTitle(item.optString("nick")); |
| | | goods.setSellerId(item.optLong("seller_id")); |
| | | goods.setRootCategoryName(item.optString("cat_name")); |
| | | goods.setLeafName(item.optString("cat_leaf_name")); |
| | | |
| | | String optString = item.optString("shop_dsr"); |
| | | if (!StringUtil.isNullOrEmpty(optString)) { |
| | | goods.setShopDsr(new Integer(optString)); |
| | | } |
| | | |
| | | String ratesum = item.optString("ratesum"); |
| | | if (!StringUtil.isNullOrEmpty(ratesum)) { |
| | | goods.setRatesum(new Integer(ratesum)); |
| | | } |
| | | |
| | | if (item.optBoolean("is_prepay")) |
| | | goods.setIsPrepay(1); |
| | | |
| | | if (item.optBoolean("i_rfd_rate")) |
| | | goods.setRfdRate(1); |
| | | |
| | | if (item.optBoolean("h_good_rate")) |
| | | goods.setGoodRate(1); |
| | | |
| | | if (item.optBoolean("h_pay_rate30")) |
| | | goods.setPayRate30(1); |
| | | |
| | | if (item.optBoolean("free_shipment")) |
| | | goods.setFreeShipment(1); |
| | | |
| | | if (!StringUtil.isNullOrEmpty(item.optString("material_lib_type"))) { |
| | | try { |
| | | String materialLibType = item.optString("material_lib_type"); |
| | | goods.setMaterialLibType(Integer.parseInt(materialLibType.split(",")[0])); |
| | | } catch (Exception e) { |
| | | goods.setMaterialLibType(0); |
| | | } |
| | | |
| | | } else |
| | | goods.setMaterialLibType(0); |
| | | |
| | | goods.setRootCategoryName(item.optString("cat_name")); |
| | | goods.setLeafName(item.optString("cat_leaf_name")); |
| | | |
| | | goods = loadYuShouInfo(goods, item); |
| | | return goods; |
| | | } |
| | | |
| | | private static TaoBaoGoodsBrief loadYuShouInfo(TaoBaoGoodsBrief goods, JSONObject item) { |
| | | if (goods != null && item != null) { |
| | | // 预售相关解析 |
| | | goods.setYsylClickUrl(item.optString("ysyl_click_url")); |
| | | if (!StringUtil.isNullOrEmpty(item.optString("ysyl_commission_rate"))) |
| | | goods.setYsylCommissionRate(new BigDecimal(item.optString("ysyl_commission_rate"))); |
| | | goods.setYsylTljFace(item.optString("ysyl_tlj_face")); |
| | | goods.setYsylTljSendTime(item.optString("ysyl_tlj_send_time")); |
| | | goods.setYsylTljUseEndTime(item.optString("ysyl_tlj_use_end_time")); |
| | | goods.setYsylTljUseStartTime(item.optString("ysyl_tlj_use_start_time")); |
| | | |
| | | goods.setPresaleDeposit(item.optString("presale_deposit")); |
| | | goods.setPresaleDiscountFeeText(item.optString("presale_discount_fee_text")); |
| | | goods.setPresaleEndTime(item.optString("presale_end_time")); |
| | | goods.setPresaleStartTime(item.optString("presale_start_time")); |
| | | goods.setPresaleTailEndTime(item.optString("presale_tail_end_time")); |
| | | goods.setPresaleTailStartTime(item.optString("presale_tail_start_time")); |
| | | |
| | | return goods; |
| | | } |
| | | return goods; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 商品物料搜索 |
| | | * |
| | | * @param title |
| | | * @param zkPrice |
| | | * @param provcity |
| | | * @param userType |
| | | * @param specialId |
| | | * @param relationId |
| | | * @return |
| | | */ |
| | | public static TaoBaoSearchResult searchWuLiaoForDetail(String title, BigDecimal zkPrice, String provcity, |
| | | int userType, String specialId, String relationId) { |
| | | if (provcity.trim().contains(" ")) |
| | | provcity = provcity.split(" ")[provcity.split(" ").length - 1]; |
| | | TaoBaoSearchResult taoBaoSearchResult = new TaoBaoSearchResult(); |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.dg.material.optional"); |
| | | map.put("page_size", 50 + ""); |
| | | map.put("page_no", 1 + ""); |
| | | map.put("start_price", (int) zkPrice.subtract(new BigDecimal(1)).doubleValue() + ""); |
| | | map.put("end_price", (int) zkPrice.add(new BigDecimal(1)).doubleValue() + ""); |
| | | map.put("is_tmall", (userType == 1) + ""); |
| | | map.put("q", title); |
| | | map.put("itemloc", provcity); |
| | | |
| | | if (!StringUtil.isNullOrEmpty(specialId) && !StringUtil.isNullOrEmpty(relationId)) { |
| | | map.put("special_id", specialId); |
| | | } else if (!StringUtil.isNullOrEmpty(specialId)) { |
| | | map.put("special_id", specialId); |
| | | } else if (!StringUtil.isNullOrEmpty(relationId)) { |
| | | map.put("relation_id", relationId); |
| | | } |
| | | |
| | | String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); |
| | | System.out.println(resultStr); |
| | | JSONObject data = JSONObject.fromObject(resultStr); |
| | | if (data.optJSONObject("tbk_dg_material_optional_response") != null |
| | | && data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") != null) { |
| | | JSONArray array = data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") |
| | | .optJSONArray("map_data"); |
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); |
| | | if (array != null) { |
| | | for (int i = 0; i < array.size(); i++) { |
| | | TaoBaoGoodsBrief goods = parseWuLiaoItem(array.optJSONObject(i)); |
| | | if (goods != null) |
| | | goodsList.add(goods); |
| | | } |
| | | } |
| | | taoBaoSearchResult.setTaoBaoGoodsBriefs(goodsList); |
| | | } |
| | | |
| | | List<TaoBaoSearchNav> navList = new ArrayList<>(); |
| | | |
| | | TaoBaoHead taoBaoHead = new TaoBaoHead(); |
| | | taoBaoHead.setDocsfound(1000); |
| | | taoBaoSearchResult.setTaoBaoHead(taoBaoHead); |
| | | taoBaoSearchResult.setPageEntity(new PageEntity()); |
| | | |
| | | taoBaoSearchResult.setNavList(navList); |
| | | |
| | | return taoBaoSearchResult; |
| | | } |
| | | |
| | | |
| | | // 解析物料 |
| | | private static TaoBaoGoodsBrief parseWuLiaoItem(JSONObject item) { |
| | | TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief(); |
| | | goods.setPictUrl(item.optString("pict_url")); |
| | | |
| | | if (!StringUtil.isNullOrEmpty(item.optString("white_image"))) { |
| | | goods.setPictUrlWhite(item.optString("white_image")); |
| | | } |
| | | |
| | | goods.setAuctionId(item.optLong("num_iid")); |
| | | goods.setAuctionUrl("https:" + item.optString("url")); |
| | | goods.setBiz30day(item.optInt("volume")); |
| | | goods.setCouponInfo(item.optString("coupon_info")); |
| | | |
| | | if (goods.getCouponInfo() != null) |
| | | goods.setCouponInfo(goods.getCouponInfo().replace(".00", "")); |
| | | |
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponInfo())) { |
| | | List<BigDecimal> quanInfo = TaoBaoCouponUtil.getCouponInfo(goods.getCouponInfo()); |
| | | goods.setCouponAmount(quanInfo.get(1)); |
| | | goods.setCouponEffectiveEndTime(item.optString("coupon_end_time")); |
| | | goods.setCouponEffectiveStartTime(item.optString("coupon_start_time")); |
| | | goods.setCouponStartFee(new BigDecimal(item.optString("coupon_start_fee"))); |
| | | goods.setCouponLeftCount(item.optInt("coupon_remain_count")); |
| | | goods.setCouponLink("https:" + item.optString("coupon_share_url")); |
| | | goods.setCouponTotalCount(item.optInt("coupon_total_count")); |
| | | goods.setCouponActivityId(item.optString("coupon_id")); |
| | | } else { |
| | | goods.setCouponAmount(new BigDecimal(0)); |
| | | } |
| | | |
| | | goods.setDayLeft(-1); |
| | | if (item.optJSONObject("small_images") != null) { |
| | | JSONArray imgArray = item.optJSONObject("small_images").optJSONArray("string"); |
| | | if (imgArray != null) { |
| | | List<String> imgList = new ArrayList<>(); |
| | | for (int n = 0; n < imgArray.size(); n++) { |
| | | imgList.add(imgArray.optString(n)); |
| | | } |
| | | goods.setImgList(imgList); |
| | | } |
| | | } |
| | | |
| | | if (item.optBoolean("include_mkt")) |
| | | goods.setTkMktStatus("1"); |
| | | else |
| | | goods.setTkMktStatus("0"); |
| | | |
| | | if (item.optBoolean("include_dxjh")) |
| | | goods.setIncludeDxjh(1); |
| | | |
| | | goods.setSellerId(item.optLong("seller_id")); |
| | | goods.setShopTitle(item.optString("shop_title")); |
| | | goods.setTitle(item.optString("title")); |
| | | goods.setProvcity(item.optString("provcity")); |
| | | |
| | | if (!StringUtil.isNullOrEmpty(item.optString("level_one_category_id"))) { |
| | | goods.setRootCatId(item.optInt("level_one_category_id")); |
| | | } |
| | | goods.setRootCategoryName(item.optString("level_one_category_name")); |
| | | |
| | | if (!StringUtil.isNullOrEmpty(item.optString("category_id"))) { |
| | | goods.setLeafCatId(item.optInt("category_id")); |
| | | } |
| | | goods.setLeafName(item.optString("category_name")); |
| | | |
| | | goods.setTkRate(new BigDecimal(item.optString("commission_rate")).divide(new BigDecimal(100))); |
| | | goods.setTotalNum(1000); |
| | | goods.setUserType(item.optInt("user_type")); |
| | | goods.setUserTypeName(""); |
| | | goods.setZkPrice(new BigDecimal(item.optString("zk_final_price"))); |
| | | |
| | | if (item.optBoolean("include_dxjh")) { |
| | | goods.setDxjhInfo(item.optString("info_dxjh")); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(goods.getCouponInfo())) {// 无券 |
| | | goods.setTkCommFee(goods.getZkPrice().multiply(goods.getTkRate()).divide(new BigDecimal(100))); |
| | | } else if (goods.getZkPrice().compareTo(goods.getCouponStartFee()) >= 0// 有券 |
| | | && goods.getZkPrice().compareTo(goods.getCouponAmount()) >= 0) { |
| | | BigDecimal finalPrice = goods.getZkPrice().subtract(goods.getCouponAmount()); |
| | | goods.setTkCommFee(finalPrice.multiply(goods.getTkRate()).divide(new BigDecimal(100))); |
| | | } else { |
| | | goods.setTkCommFee(new BigDecimal(0)); |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(item.optString("reserve_price"))) |
| | | goods.setReservePrice(new BigDecimal(item.optString("reserve_price"))); |
| | | goods.setTotalFee(new BigDecimal("0")); |
| | | // 推荐语 |
| | | goods.setDescription(item.optString("item_description")); |
| | | |
| | | goods = loadYuShouInfo(goods, item); |
| | | return goods; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
New file |
| | |
| | | package com.ks.lijin.utils.taobao; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | import com.ks.lijin.exception.TaoKeApiException; |
| | | import com.ks.lijin.pojo.DTO.taobao.TaoKeAppInfo; |
| | | import com.taobao.api.internal.util.StringUtils; |
| | | import org.yeshi.utils.StringUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | import org.yeshi.utils.HttpUtil; |
| | | |
| | | import net.sf.json.JSONObject; |
| | | |
| | | public class TaoKeBaseUtil { |
| | | |
| | | private static TaoKeAppInfo taoKeAppInfo = null; |
| | | private static long lastTime = 0; |
| | | |
| | | public static JSONObject baseRequest(Map<String, String> param, boolean needAdzoneId) throws TaoKeApiException { |
| | | // 复制params |
| | | Map<String, String> params = new HashMap<>(); |
| | | if (param != null) { |
| | | Iterator<String> its = param.keySet().iterator(); |
| | | while (its.hasNext()) { |
| | | String key = its.next(); |
| | | params.put(key, param.get(key)); |
| | | } |
| | | } |
| | | |
| | | // 获取有效的APPKey |
| | | TaoKeAppInfo app = getAvailableTaoKeAppInfo(); |
| | | if (app == null) |
| | | throw new TaoKeApiException(TaoKeApiException.CODE_NO_USE, "无appkey可用"); |
| | | // 签名 |
| | | params.put("app_key", app.getAppKey()); |
| | | params.put("sign_method", "md5"); |
| | | params.put("v", "2.0"); |
| | | params.put("timestamp", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); |
| | | params.put("format", "json"); |
| | | if (needAdzoneId) |
| | | params.put("adzone_id", app.getAdzoneId()); |
| | | params.put("sign", getSign(params, "md5", app).toUpperCase()); |
| | | String result = TaoBaoHttpUtil.taoKeGet(params); |
| | | JSONObject data = JSONObject.fromObject(result); |
| | | if (data != null) { |
| | | if (data.optJSONObject("error_response") != null && data.optJSONObject("error_response").optInt("code") == 7 |
| | | && "accesscontrol.limited-by-app-access-count" |
| | | .equalsIgnoreCase(data.optJSONObject("error_response").optString("sub_code"))) { |
| | | reportAppInvalid(app.getAppKey()); |
| | | throw new TaoKeApiException(TaoKeApiException.CODE_APPKEY_LIMIT, "淘宝请求限制:" + result, params); |
| | | } else if (data.optJSONObject("error_response") != null) { |
| | | throw new TaoKeApiException(TaoKeApiException.CODE_API_ERROR, result, params); |
| | | } |
| | | } else |
| | | throw new TaoKeApiException(TaoKeApiException.CODE_OTHER, ":" + result, params); |
| | | reValid(app.getAppKey()); |
| | | return data; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 重复3次请求,降低出错概率 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | public static String baseRequestForThreeTimes(Map<String, String> params, boolean needAdzoneId) { |
| | | JSONObject data = null; |
| | | int count = 0; |
| | | String result = null; |
| | | while (data == null && count < 2) { |
| | | count++; |
| | | try { |
| | | data = baseRequest(params, needAdzoneId); |
| | | } catch (TaoKeApiException e) { |
| | | if (e.getCode() == TaoKeApiException.CODE_API_ERROR) { |
| | | result = e.getMsg(); |
| | | } |
| | | } |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(result)) { |
| | | try { |
| | | data = JSONObject.fromObject(result); |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | } |
| | | |
| | | if (data != null) |
| | | return data.toString(); |
| | | else |
| | | return new JSONObject().toString(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取签名参数 |
| | | * |
| | | * @param params |
| | | * @param signMethod |
| | | * @param app |
| | | * @return |
| | | */ |
| | | public static String getSign(Map<String, String> params, String signMethod, TaoKeAppInfo app) { |
| | | // 第一步:检查参数是否已经排序 |
| | | String[] keys = params.keySet().toArray(new String[0]); |
| | | Arrays.sort(keys); |
| | | |
| | | // 第二步:把所有参数名和参数值串在一起 |
| | | StringBuilder query = new StringBuilder(); |
| | | if ("md5".equals(signMethod)) { |
| | | query.append(app.getAppSecret()); |
| | | } |
| | | for (String key : keys) { |
| | | String value = params.get(key); |
| | | if (StringUtils.areNotEmpty(key, value)) { |
| | | query.append(key).append(value); |
| | | } |
| | | } |
| | | |
| | | query.append(app.getAppSecret()); |
| | | return StringUtil.Md5(query.toString()); |
| | | } |
| | | |
| | | static TaoKeAppInfo getAvailableTaoKeAppInfo() { |
| | | if (System.currentTimeMillis() - lastTime > 1000 * 20L) |
| | | taoKeAppInfo = null; |
| | | if (taoKeAppInfo == null) { |
| | | System.out.println("请求。。。。。"); |
| | | String result = null; |
| | | try { |
| | | result = HttpUtil.get("http://193.112.35.168:8091/tb/taoke/getcanuseapp"); |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | // 接口请求失败,默认设置成影视大全IOS的媒体信息 |
| | | if (StringUtil.isNullOrEmpty(result)) { |
| | | taoKeAppInfo = new TaoKeAppInfo(); |
| | | taoKeAppInfo.setAdzoneId("381938426"); |
| | | taoKeAppInfo.setAppKey("24838852"); |
| | | taoKeAppInfo.setAppSecret("bc8265e2bf8d8115329d652f9d3d4cd8"); |
| | | taoKeAppInfo.setPid("mm_124933865_43788020_381938426"); |
| | | lastTime = System.currentTimeMillis(); |
| | | return taoKeAppInfo; |
| | | } |
| | | |
| | | JSONObject data = JSONObject.fromObject(result); |
| | | if (data.optInt("code") == 0) { |
| | | TaoKeAppInfo info = new TaoKeAppInfo(); |
| | | info.setAppKey(data.optJSONObject("data").optString("appkey")); |
| | | info.setAppSecret(data.optJSONObject("data").optString("appsecret")); |
| | | info.setPid(data.optJSONObject("data").optString("pid")); |
| | | String[] sts = info.getPid().split("_"); |
| | | info.setAdzoneId(sts[sts.length - 1]); |
| | | taoKeAppInfo = info; |
| | | lastTime = System.currentTimeMillis(); |
| | | } else {// 防止所有的失效 |
| | | taoKeAppInfo = new TaoKeAppInfo(); |
| | | taoKeAppInfo.setAdzoneId("381938426"); |
| | | taoKeAppInfo.setAppKey("24838852"); |
| | | taoKeAppInfo.setAppSecret("bc8265e2bf8d8115329d652f9d3d4cd8"); |
| | | taoKeAppInfo.setPid("mm_124933865_43788020_381938426"); |
| | | return taoKeAppInfo; |
| | | } |
| | | } |
| | | return taoKeAppInfo; |
| | | } |
| | | |
| | | static void filterTaoKeResponse(String result, TaoKeAppInfo app) { |
| | | if (!StringUtil.isNullOrEmpty(result)) { |
| | | try { |
| | | JSONObject data = JSONObject.fromObject(result); |
| | | if (data != null) { |
| | | if (data.optJSONObject("error_response") != null |
| | | && data.optJSONObject("error_response").optInt("code") == 7) { |
| | | reportAppInvalid(app.getAppKey()); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | static Map<String, Integer> invalidMap = new HashMap<>(); |
| | | |
| | | /** |
| | | * 报告该APPKey不能用 |
| | | * |
| | | * @param appkey |
| | | */ |
| | | static void reportAppInvalid(String appkey) { |
| | | if (invalidMap == null) |
| | | return; |
| | | // 错误三次后再真正上报 |
| | | if (invalidMap.get(appkey) == null) |
| | | invalidMap.put(appkey, 1); |
| | | else |
| | | invalidMap.put(appkey, invalidMap.get(appkey) + 1); |
| | | |
| | | if (invalidMap.get(appkey) < 4) |
| | | return; |
| | | invalidMap.put(appkey, 0); |
| | | HttpUtil.get("http://193.112.35.168:8091/tb/taoke/reportappcannotuse?appkey=" + appkey); |
| | | lastTime = 0; |
| | | } |
| | | |
| | | /** |
| | | * APPKey恢复可用 |
| | | * |
| | | * @param appKey |
| | | */ |
| | | static void reValid(String appKey) { |
| | | if (invalidMap == null) |
| | | return; |
| | | Integer count = invalidMap.get(appKey); |
| | | if (count != null && count > 0) |
| | | invalidMap.put(appKey, count - 1); |
| | | } |
| | | |
| | | public static void setAppValid() { |
| | | HttpUtil.get("http://193.112.35.168:8091/tb/taoke/setappcanuse"); |
| | | } |
| | | |
| | | } |
| | |
| | | private BigDecimal taolijinPercent; |
| | | |
| | | @Column(name = "pc_taolijin_max_number") |
| | | private String taolijinMaxNumber; |
| | | private Integer taolijinMaxNumber; |
| | | |
| | | @Column(name = "pc_taolijin_max_money") |
| | | private BigDecimal taolijinMaxMoney; |
| | |
| | | this.taolijinPercent = taolijinPercent; |
| | | } |
| | | |
| | | public String getTaolijinMaxNumber() { |
| | | public Integer getTaolijinMaxNumber() { |
| | | return taolijinMaxNumber; |
| | | } |
| | | |
| | | public void setTaolijinMaxNumber(String taolijinMaxNumber) { |
| | | public void setTaolijinMaxNumber(Integer taolijinMaxNumber) { |
| | | this.taolijinMaxNumber = taolijinMaxNumber; |
| | | } |
| | | |
| | |
| | | */ |
| | | public enum VIPEnum { |
| | | |
| | | bronze("青铜"), |
| | | silver("白银"), |
| | | platinum("铂金"); |
| | | |
| | |
| | | import com.ks.vip.pojo.DO.VipCombo; |
| | | import com.ks.vip.pojo.DO.VipGrade; |
| | | import com.ks.vip.pojo.DO.VipGradePotence; |
| | | import com.ks.vip.pojo.Enums.VIPEnum; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * 获取会员等级 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public VipGrade getVipGrade(String uid); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 验证会员状态 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public boolean verifyVIP(String uid); |
| | | |
| | | /** |
| | | * 添加会员权益 |
| | | * @param uid |
| | | * @param gradeId |
| | |
| | | |
| | | |
| | | /** |
| | | * 获取会员权益 |
| | | * 获取当前用户会员权益 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public VipGradePotence getVipPotence(String uid); |
| | | |
| | | /** |
| | | * 获取当前用户会员等级信息 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public VipGrade getVipGrade(String uid); |
| | | |
| | | |
| | | /** |
| | | * 获取当前用户会员等级枚举 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public VIPEnum getVIPEnumByUid(String uid); |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | import com.ks.vip.pojo.DO.VipGradePotence; |
| | | import com.ks.vip.pojo.Enums.VIPEnum; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | public VipGradePotence selectByPrimaryKey(Long id); |
| | | |
| | | public void delete(Long id); |
| | | |
| | | /** |
| | | * 根据等级Id查询权益 |
| | | * @param gradeId |
| | | * @return |
| | | */ |
| | | public VipGradePotence getPotenceByGradeId(Long gradeId); |
| | | |
| | | |
| | | /** |
| | | * 获取默认权益 |
| | | * @return |
| | | */ |
| | | public VipGradePotence getDefaultGradePotence(); |
| | | |
| | | |
| | | /** |
| | | * 根据枚举类型查询权益 |
| | | * @param vipEnum |
| | | * @return |
| | | */ |
| | | public VipGradePotence getPotenceByVipEnum(VIPEnum vipEnum); |
| | | } |
| | |
| | | |
| | | |
| | | import com.ks.vip.pojo.DO.VipGrade; |
| | | import com.ks.vip.pojo.Enums.VIPEnum; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | public List<VipGrade> getValidList(); |
| | | |
| | | public VipGrade getByIdentity(String identity); |
| | | |
| | | public VipGrade selectByPrimaryKey(Long id); |
| | | |
| | | /** |
| | | * 查询默认等级(白银) |
| | | * @return |
| | | */ |
| | | public VipGrade getDefaultGrade(); |
| | | |
| | | /** |
| | | * 根据等级类型查询等级 |
| | | * @param vipEnum |
| | | * @return |
| | | */ |
| | | public VipGrade getByVipEnum(VIPEnum vipEnum); |
| | | } |
| | |
| | | import com.ks.lijin.pojo.DO.LiJinProviderAccount; |
| | | import com.ks.lijin.pojo.DO.LiJinProviderNotice; |
| | | import com.ks.lijin.pojo.DTO.LiJinCreateParam; |
| | | import com.ks.lijin.pojo.DTO.taobao.TaoBaoGoodsBrief; |
| | | import com.ks.lijin.pojo.DTO.taobao.TaoKeAppInfo; |
| | | import com.ks.lijin.pojo.DTO.taobao.TaoLiJinDTO; |
| | | import com.ks.lijin.pojo.Enums.NoticeTypeEnum; |
| | |
| | | liJinExpendRecordMapper.deleteByPrimaryKey(id); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public LiJinExpendRecord createLiJin(String uid, BigDecimal money, TaoBaoGoodsBrief goods) |
| | | throws LiJinExpendRecordException { |
| | | |
| | | // TODO 验证次数 |
| | | int expendNum = countTodayNumByExpend(uid); |
| | | // TODO 验证金额 |
| | | BigDecimal bigDecimal = countTodayMoneyByExpend(uid); |
| | | |
| | | |
| | | Date date = new Date(); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat formatStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String date_str = format.format(date); |
| | | String sendEndTime_str = date_str + " 22:00:00"; |
| | | String useEndTime_str = date_str + " 23:59:59"; |
| | | |
| | | /* 创建淘礼金 */ |
| | | String name = "自购淘礼金红包"; |
| | | // 发放开始时间 |
| | | Date sendStartTime = date; |
| | | // 发放截止时间 - 分享当日22:00 |
| | | Date sendEndTime = null; |
| | | // 使用结束日期 - 分享当日 23:59 |
| | | Date useEndTime = null; |
| | | |
| | | try { |
| | | sendEndTime = formatStr.parse(sendEndTime_str); |
| | | useEndTime = formatStr.parse(useEndTime_str); |
| | | } catch (ParseException e2) { |
| | | e2.printStackTrace(); |
| | | } |
| | | |
| | | LiJinCreateParam params = new LiJinCreateParam(); |
| | | params.setTitle("自购淘礼金红包"); |
| | | params.setUid(uid + ""); |
| | | params.setGoodsId(goods.getAuctionId()); |
| | | params.setUseEndTime(useEndTime); |
| | | params.setSendStartTime(sendStartTime); |
| | | params.setSendEndTime(sendEndTime); |
| | | params.setNum(1); |
| | | params.setMoney(money); |
| | | |
| | | // params.setPid(); // pid缺少 TODO |
| | | // params.setAppkey(); |
| | | // params.setAppsecret(); |
| | | |
| | | return createTaoLiJin(params); |
| | | } |
| | | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public LiJinExpendRecord createTaoLiJin(LiJinCreateParam params) throws LiJinExpendRecordException { |
| | | String appkey =params.getAppkey(); |
| | | String appsecret = params.getAppsecret(); |
| | | |
| | | // 创建淘礼金红包 |
| | | TaoLiJinDTO taoLiJinDTO = null; |
| | | try { |
| | | taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(params.getGoodsId(), params.getTitle(), params.getMoney(), |
| | | params.getNum(), params.getSendStartTime(), params.getSendEndTime(), |
| | | params.getUseStartTime(), params.getUseEndTime(), new TaoKeAppInfo(appkey, appsecret, params.getPid())); |
| | | } catch (LiJinException e) { |
| | | // 通知相应供应商 TODO |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | LiJinProviderAccount account = liJinProviderAccountService.getByAppInfo(appkey, appsecret); |
| | | if (account == null) { |
| | | return; |
| | | } |
| | | |
| | | LiJinProviderNotice notice = new LiJinProviderNotice(); |
| | | notice.setRead(false); |
| | | notice.setProviderId(account.getProviderId()); |
| | | |
| | | if (e.getCode() == LiJinException.CODE_TLJ_FORBIDDEN) { |
| | | // 该商品不支持创建淘礼金红包 |
| | | } else if (e.getCode() == LiJinException.CODE_TLJ_NO_MONEY) { |
| | | // 官方玩法钱包余额不足 |
| | | notice.setTitle("玩法钱包余额不足"); |
| | | notice.setContent("账号:"+ appkey +"官方玩法钱包余额不足"); |
| | | notice.setType(NoticeTypeEnum.noMoney.name()); |
| | | liJinProviderNoticeService.save(notice); |
| | | } else if (e.getCode() == LiJinException.CODE_TLJ_UN_PAID) { |
| | | // 未创建账户 |
| | | } |
| | | } |
| | | }); |
| | | } catch (TaoKeApiException e1) { |
| | | // TODO |
| | | } |
| | | |
| | | if (taoLiJinDTO == null) { |
| | | throw new LiJinExpendRecordException(101, "淘宝API推广红包创建失败"); |
| | | } |
| | | |
| | | // 保存记录 |
| | | LiJinExpendRecord record = new LiJinExpendRecord(); |
| | | record.setUid(params.getUid()); |
| | | record.setGoodsId(params.getGoodsId() + ""); |
| | | record.setTitle(params.getTitle()); |
| | | record.setNum(params.getNum()); |
| | | record.setMoney(params.getMoney()); |
| | | record.setRightsId(taoLiJinDTO.getRightsId()); |
| | | record.setSendUrl(taoLiJinDTO.getSendUrl()); |
| | | record.setCreateTime(new Date()); |
| | | liJinExpendRecordMapper.insertSelective(record); |
| | | |
| | | return record; |
| | | } |
| | | |
| | | @Override |
| | | public int countTodayNumByExpend(String uid) { |
New file |
| | |
| | | package com.ks.lijin.service.remote; |
| | | |
| | | import com.ks.lijin.exception.*; |
| | | import com.ks.lijin.mapper.LiJinExpendRecordMapper; |
| | | import com.ks.lijin.pojo.DO.LiJinExpendRecord; |
| | | import com.ks.lijin.pojo.DO.LiJinProviderAccount; |
| | | import com.ks.lijin.pojo.DO.LiJinProviderNotice; |
| | | import com.ks.lijin.pojo.DTO.LiJinCreateParam; |
| | | import com.ks.lijin.pojo.DTO.taobao.TaoKeAppInfo; |
| | | import com.ks.lijin.pojo.DTO.taobao.TaoLiJinDTO; |
| | | import com.ks.lijin.pojo.Enums.NoticeTypeEnum; |
| | | import com.ks.lijin.service.LiJinExpendRecordService; |
| | | import com.ks.lijin.service.LiJinProviderAccountService; |
| | | import com.ks.lijin.service.LiJinProviderNoticeService; |
| | | import com.ks.lijin.service.LijinCreateService; |
| | | import com.ks.lijin.utils.taobao.TaoBaoUtil; |
| | | import com.ks.lijin.utils.taobao.TaoKeApiUtil; |
| | | import com.ks.vip.pojo.DO.VipGradePotence; |
| | | import com.ks.vip.pojo.Enums.VIPEnum; |
| | | import com.ks.vip.service.VipCenterService; |
| | | import com.ks.vip.service.VipGradePotenceService; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | import org.springframework.core.task.TaskExecutor; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.yeshi.utils.MoneyBigDecimalUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | |
| | | @Service(version = "1.0") |
| | | public class LijinCreateServiceImpl implements LijinCreateService { |
| | | |
| | | @Resource(name = "taskExecutor") |
| | | private TaskExecutor executor; |
| | | |
| | | @Resource |
| | | private LiJinExpendRecordMapper liJinExpendRecordMapper; |
| | | |
| | | @Resource |
| | | private LiJinProviderNoticeService liJinProviderNoticeService; |
| | | |
| | | @Resource |
| | | private LiJinProviderAccountService liJinProviderAccountService; |
| | | |
| | | @Resource |
| | | private VipCenterService vipCenterService; |
| | | |
| | | @Resource |
| | | private VipGradePotenceService vipGradePotenceService; |
| | | |
| | | @Resource |
| | | private LiJinExpendRecordService liJinExpendRecordService; |
| | | |
| | | |
| | | @Override |
| | | public BigDecimal getTBLijinAmount(Long actionId, String uid) throws LiJinGoodsException, LiJinUserException, LiJinAmountException { |
| | | // 获取用户等级 |
| | | VIPEnum vipRank = vipCenterService.getVIPEnumByUid(uid); |
| | | if (vipRank == null) { |
| | | throw new LiJinUserException(LiJinUserException.CODE_USER_CREATE_NUM_LIMIT, "用户创建淘礼金的次数超限"); |
| | | } |
| | | |
| | | // 1、判断商品 并计算金额 |
| | | BigDecimal money = getTBLijinAmount(actionId, vipRank); |
| | | |
| | | // 2、判断用户 |
| | | boolean result = userCanCreateTBLijin(uid, money); |
| | | if (result) { |
| | | return money; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public BigDecimal getTBLijinAmount(Long actionId, VIPEnum vipRank) throws LiJinGoodsException,LiJinAmountException { |
| | | //获取商品可创建的淘礼金面额,若不能创建需要抛出相关的异常(1.商品不支持礼金创建) |
| | | BigDecimal money = null; |
| | | // 1、判断商品 |
| | | try{ |
| | | TaoBaoGoodsBrief goods = TaoKeApiUtil.searchGoodsDetail(actionId); |
| | | if (goods == null) { |
| | | throw new LiJinGoodsException(LiJinGoodsException.CODE_GOODS_OFFLINE, "商品下线"); |
| | | } |
| | | |
| | | Integer materialLibType = goods.getMaterialLibType(); |
| | | if (materialLibType == null || materialLibType.intValue() <= 0) { |
| | | throw new LiJinGoodsException(LiJinGoodsException.CODE_GOODS_NOT_SUPPORT, "商品不支持创建淘礼金"); |
| | | } |
| | | |
| | | //券后价 * 商品佣金比例 * 返利比例 |
| | | VipGradePotence potence = vipGradePotenceService.getPotenceByVipEnum(vipRank); |
| | | if (potence != null && potence.getRebatePercent()!= null) { |
| | | money = TaoBaoUtil.getGoodsHongBaoMoney(goods,potence.getRebatePercent(),false); |
| | | } |
| | | } catch (TaoBaoGoodsDownException e){ |
| | | throw new LiJinGoodsException(LiJinGoodsException.CODE_GOODS_OFFLINE, "商品下线"); |
| | | } |
| | | |
| | | // 金额为空 或者小于零 则抛出异常 |
| | | if (money == null || money.compareTo(BigDecimal.valueOf(0)) <= 0) { |
| | | throw new LiJinAmountException(LiJinAmountException.CODE_LIJIN_AMOUNT_OUTOFRANGE,"礼金创建的金额超出规定范围"); |
| | | } |
| | | |
| | | return money; |
| | | } |
| | | |
| | | @Override |
| | | public boolean userCanCreateTBLijin(String uid) throws LiJinUserException { |
| | | VipGradePotence potence = vipCenterService.getVipPotence(uid); |
| | | if (potence == null) { |
| | | return false; |
| | | } |
| | | |
| | | // 每日最大次数判断 |
| | | Integer numMax = potence.getTaolijinMaxNumber(); |
| | | if(numMax == null || numMax.intValue() <= 0) { |
| | | throw new LiJinUserException(LiJinUserException.CODE_USER_CREATE_NUM_LIMIT, "用户创建淘礼金的次数超限"); |
| | | } |
| | | |
| | | // 每日最大金额判断 |
| | | BigDecimal moneyMax = potence.getTaolijinMaxMoney(); |
| | | if (moneyMax == null || moneyMax.compareTo(BigDecimal.valueOf(0)) <= 0) { |
| | | throw new LiJinUserException(LiJinUserException.CODE_USER_CREATE_MONEY_LIMIT, "用户创建淘礼金的金额超限"); |
| | | } |
| | | |
| | | // 使用次数已经超过最大次数 |
| | | int numExpend = liJinExpendRecordService.countTodayNumByExpend(uid); |
| | | if (numMax.intValue() < numExpend){ |
| | | throw new LiJinUserException(LiJinUserException.CODE_USER_CREATE_NUM_LIMIT, "用户创建淘礼金的次数超限"); |
| | | } |
| | | |
| | | // 统计已使用金额 |
| | | BigDecimal moneyExpend = liJinExpendRecordService.countTodayMoneyByExpend(uid); |
| | | if(moneyExpend != null) { |
| | | moneyExpend = BigDecimal.valueOf(0); |
| | | } |
| | | // 消耗金额已经超过最大金额 |
| | | if (moneyMax.compareTo(BigDecimal.valueOf(0)) <= 0) { |
| | | throw new LiJinUserException(LiJinUserException.CODE_USER_CREATE_MONEY_LIMIT, "用户创建淘礼金的金额超限"); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public boolean userCanCreateTBLijin(String uid, BigDecimal money) throws LiJinUserException { |
| | | VipGradePotence potence = vipCenterService.getVipPotence(uid); |
| | | if (potence == null) { |
| | | return false; |
| | | } |
| | | |
| | | // 每日最大次数判断 |
| | | Integer numMax = potence.getTaolijinMaxNumber(); |
| | | if(numMax == null || numMax.intValue() <= 0) { |
| | | throw new LiJinUserException(LiJinUserException.CODE_USER_CREATE_NUM_LIMIT, "用户创建淘礼金的次数超限"); |
| | | } |
| | | |
| | | // 每日最大金额判断 |
| | | BigDecimal moneyMax = potence.getTaolijinMaxMoney(); |
| | | if (moneyMax == null || moneyMax.compareTo(BigDecimal.valueOf(0)) <= 0 || moneyMax.compareTo(money) <= 0 ) { |
| | | throw new LiJinUserException(LiJinUserException.CODE_USER_CREATE_MONEY_LIMIT, "用户创建淘礼金的金额超限"); |
| | | } |
| | | |
| | | // 使用次数已经超过最大次数 |
| | | int numExpend = liJinExpendRecordService.countTodayNumByExpend(uid); |
| | | if (numMax.intValue() < numExpend){ |
| | | throw new LiJinUserException(LiJinUserException.CODE_USER_CREATE_NUM_LIMIT, "用户创建淘礼金的次数超限"); |
| | | } |
| | | |
| | | // 统计已使用金额 |
| | | BigDecimal moneyExpend = liJinExpendRecordService.countTodayMoneyByExpend(uid); |
| | | if(moneyExpend != null) { |
| | | moneyExpend = BigDecimal.valueOf(0); |
| | | } |
| | | // 加上本次需要使用金额 |
| | | moneyExpend = MoneyBigDecimalUtil.add(moneyExpend, money); |
| | | |
| | | // 消耗金额已经超过最大金额 |
| | | if (moneyMax.compareTo(BigDecimal.valueOf(0)) <= 0) { |
| | | throw new LiJinUserException(LiJinUserException.CODE_USER_CREATE_MONEY_LIMIT, "用户创建淘礼金的金额超限"); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public LiJinExpendRecord createTBLijin(String uid, Long goodsId) throws LiJinException, LiJinGoodsException, LiJinUserException, LiJinAmountException { |
| | | // 获取用户等级 |
| | | VIPEnum vipRank = vipCenterService.getVIPEnumByUid(uid); |
| | | if (vipRank == null) { |
| | | throw new LiJinUserException(LiJinUserException.CODE_USER_CREATE_NUM_LIMIT, "用户创建淘礼金的次数超限"); |
| | | } |
| | | |
| | | //淘礼金创建 |
| | | TaoBaoGoodsBrief goods = null; |
| | | try{ |
| | | goods = TaoKeApiUtil.searchGoodsDetail(goodsId); |
| | | } catch (TaoBaoGoodsDownException e){ |
| | | throw new LiJinGoodsException(LiJinGoodsException.CODE_GOODS_OFFLINE, "商品下线"); |
| | | } |
| | | if (goods == null) { |
| | | throw new LiJinGoodsException(LiJinGoodsException.CODE_GOODS_OFFLINE, "商品下线"); |
| | | } |
| | | |
| | | // 创建的淘礼金-金额 |
| | | BigDecimal lijinAmount = getTBLijinAmount(goods, vipRank); |
| | | |
| | | // 执行创建淘礼金 |
| | | LiJinCreateParam params = getLiJinCreateParam(); |
| | | |
| | | // TODO |
| | | // params.setAppkey(); |
| | | // params.setAppsecret(); |
| | | |
| | | |
| | | TaoLiJinDTO taoLiJinDTO = executeTaoLiJinAPI(uid, goodsId, lijinAmount, params); |
| | | if (taoLiJinDTO == null) { |
| | | throw new LiJinException(1, "淘宝API推广红包创建失败"); |
| | | } |
| | | |
| | | |
| | | // 保存记录 |
| | | LiJinExpendRecord record = new LiJinExpendRecord(); |
| | | record.setUid(uid); |
| | | record.setGoodsId(goodsId + ""); |
| | | record.setTitle(params.getTitle()); |
| | | record.setNum(params.getNum()); |
| | | record.setMoney(lijinAmount); |
| | | record.setRightsId(taoLiJinDTO.getRightsId()); |
| | | record.setSendUrl(taoLiJinDTO.getSendUrl()); |
| | | record.setCreateTime(new Date()); |
| | | liJinExpendRecordMapper.insertSelective(record); |
| | | return record; |
| | | } |
| | | |
| | | |
| | | // 创建淘礼金 |
| | | private TaoLiJinDTO executeTaoLiJinAPI(String uid, Long goodsId, BigDecimal lijinAmount, LiJinCreateParam params) throws LiJinGoodsException { |
| | | String appkey =params.getAppkey(); |
| | | String appsecret = params.getAppsecret(); |
| | | |
| | | // 创建淘礼金红包 |
| | | TaoLiJinDTO taoLiJinDTO = null; |
| | | try { |
| | | taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(goodsId, params.getTitle(), lijinAmount, |
| | | params.getNum(), params.getSendStartTime(), params.getSendEndTime(), |
| | | params.getUseStartTime(), params.getUseEndTime(), new TaoKeAppInfo(appkey, appsecret, params.getPid())); |
| | | } catch (LiJinException e) { |
| | | // 通知相应供应商 TODO |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | LiJinProviderAccount account = liJinProviderAccountService.getByAppInfo(appkey, appsecret); |
| | | if (account == null) { |
| | | return; |
| | | } |
| | | LiJinProviderNotice notice = new LiJinProviderNotice(); |
| | | notice.setRead(false); |
| | | notice.setProviderId(account.getProviderId()); |
| | | |
| | | if (e.getCode() == LiJinException.CODE_TLJ_FORBIDDEN) { |
| | | // 该商品不支持创建淘礼金红包 |
| | | } else if (e.getCode() == LiJinException.CODE_TLJ_NO_MONEY) { |
| | | // 官方玩法钱包余额不足 |
| | | notice.setTitle("玩法钱包余额不足"); |
| | | notice.setContent("账号:"+ appkey +"官方玩法钱包余额不足"); |
| | | notice.setType(NoticeTypeEnum.noMoney.name()); |
| | | liJinProviderNoticeService.save(notice); |
| | | } else if (e.getCode() == LiJinException.CODE_TLJ_UN_PAID) { |
| | | // 未创建账户 |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | return taoLiJinDTO; |
| | | } |
| | | |
| | | |
| | | private BigDecimal getTBLijinAmount(TaoBaoGoodsBrief goods, VIPEnum vipRank) throws LiJinGoodsException,LiJinAmountException { |
| | | //获取商品可创建的淘礼金面额,若不能创建需要抛出相关的异常(1.商品不支持礼金创建) |
| | | BigDecimal money = null; |
| | | |
| | | Integer materialLibType = goods.getMaterialLibType(); |
| | | if (materialLibType == null || materialLibType.intValue() <= 0) { |
| | | throw new LiJinGoodsException(LiJinGoodsException.CODE_GOODS_NOT_SUPPORT, "商品不支持创建淘礼金"); |
| | | } |
| | | |
| | | //券后价 * 商品佣金比例 * 返利比例 |
| | | VipGradePotence potence = vipGradePotenceService.getPotenceByVipEnum(vipRank); |
| | | if (potence != null && potence.getRebatePercent()!= null) { |
| | | money = TaoBaoUtil.getGoodsHongBaoMoney(goods,potence.getRebatePercent(),false); |
| | | } |
| | | |
| | | // 金额为空 或者小于零 则抛出异常 |
| | | if (money == null || money.compareTo(BigDecimal.valueOf(0)) <= 0) { |
| | | throw new LiJinAmountException(LiJinAmountException.CODE_LIJIN_AMOUNT_OUTOFRANGE,"礼金创建的金额超出规定范围"); |
| | | } |
| | | return money; |
| | | } |
| | | |
| | | /** |
| | | * 创建淘礼金基本参数 |
| | | * @return |
| | | */ |
| | | private LiJinCreateParam getLiJinCreateParam() { |
| | | Date date = new Date(); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat formatStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String date_str = format.format(date); |
| | | String sendEndTime_str = date_str + " 23:59:59"; |
| | | String useEndTime_str = date_str + " 23:59:59"; |
| | | |
| | | /* 创建淘礼金 */ |
| | | String name = "自购淘礼金红包"; |
| | | // 发放开始时间 |
| | | Date sendStartTime = date; |
| | | // 发放截止时间 - 当日23:59 |
| | | Date sendEndTime = null; |
| | | // 使用结束日期 - 当日 23:59 |
| | | Date useEndTime = null; |
| | | |
| | | try { |
| | | sendEndTime = formatStr.parse(sendEndTime_str); |
| | | useEndTime = formatStr.parse(useEndTime_str); |
| | | } catch (ParseException e2) { |
| | | e2.printStackTrace(); |
| | | } |
| | | |
| | | LiJinCreateParam params = new LiJinCreateParam(); |
| | | params.setTitle("淘礼金红包"); |
| | | params.setUseEndTime(useEndTime); |
| | | params.setSendStartTime(sendStartTime); |
| | | params.setSendEndTime(sendEndTime); |
| | | params.setNum(1); |
| | | return params; |
| | | } |
| | | |
| | | } |
| | |
| | | name: lijin-provider |
| | | registry: |
| | | protocol: zookeeper |
| | | address: zookeeper://118.195.138.153:2181 # 134.175.68.214 134.175.68.214:2181 |
| | | address: zookeeper://193.112.35.168:2181 |
| | | # address: zookeeper://118.195.138.153:2181 |
| | | client: curator |
| | | protocol: |
| | | name: dubbo |
| | |
| | | List<VipGradePotence> listByPage(@Param("query") VipGradePotenceQuery query); |
| | | |
| | | long count(@Param("query")VipGradePotenceQuery query); |
| | | |
| | | |
| | | VipGradePotence getByGradeId(@Param("gradeId")Long gradeId); |
| | | } |
| | |
| | | import com.ks.vip.mapper.VipCenterMapper; |
| | | import com.ks.vip.mapper.VipComboMapper; |
| | | import com.ks.vip.pojo.DO.*; |
| | | import com.ks.vip.pojo.Enums.VIPEnum; |
| | | import com.ks.vip.query.VipCenterQuery; |
| | | import com.ks.vip.query.VipComboQuery; |
| | | import com.ks.vip.service.*; |
| | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean verifyVIP(String uid) { |
| | | VipCenter vipCenter = vipCenterMapper.getByUid(uid); |
| | | if (vipCenter == null) { |
| | | return false; |
| | | } |
| | | // 验证会员是否有效 |
| | | long nowTime = java.lang.System.currentTimeMillis(); |
| | | if (vipCenter.getStartTime().getTime() <= nowTime && vipCenter.getEndTime().getTime() >= nowTime) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public VipGradePotence getVipPotence(String uid) { |
| | | VipGradePotence potence = null; |
| | | VipCenter vipCenter = vipCenterMapper.getByUid(uid); |
| | | if (vipCenter == null || vipCenter.getGradeId() == null) { |
| | | return null; |
| | | if (vipCenter != null || vipCenter.getGradeId() != null) { |
| | | long nowTime = java.lang.System.currentTimeMillis(); |
| | | if (vipCenter.getStartTime().getTime() <= nowTime && vipCenter.getEndTime().getTime() >= nowTime) { |
| | | potence = vipGradePotenceService.getPotenceByGradeId(vipCenter.getGradeId()); |
| | | } |
| | | } |
| | | |
| | | long nowTime = java.lang.System.currentTimeMillis(); |
| | | if (vipCenter.getStartTime().getTime() <= nowTime && vipCenter.getEndTime().getTime() >= nowTime) { |
| | | return vipGradePotenceService.selectByPrimaryKey(vipCenter.getGradeId()); |
| | | if (potence == null) { |
| | | potence = vipGradePotenceService.getDefaultGradePotence(); |
| | | } |
| | | return null; |
| | | return potence; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public VipGrade getVipGrade(String uid) { |
| | | VipGrade vipGrade = null; |
| | | VipCenter vipCenter = vipCenterMapper.getByUid(uid); |
| | | if (vipCenter == null || vipCenter.getGradeId() == null) { |
| | | return null; |
| | | if (vipCenter != null || vipCenter.getGradeId() != null) { |
| | | long nowTime = java.lang.System.currentTimeMillis(); |
| | | if (vipCenter.getStartTime().getTime() <= nowTime && vipCenter.getEndTime().getTime() >= nowTime) { |
| | | vipGrade = vipGradeService.selectByPrimaryKey(vipCenter.getGradeId()); |
| | | } |
| | | } |
| | | return vipGradeService.selectByPrimaryKey(vipCenter.getGradeId()); |
| | | if (vipGrade == null) { |
| | | vipGradeService.getDefaultGrade(); |
| | | } |
| | | return vipGrade; |
| | | } |
| | | |
| | | } |
| | | @Override |
| | | public VIPEnum getVIPEnumByUid(String uid) { |
| | | VipGrade vipGrade = getVipGrade(uid); |
| | | return vipGrade.getIdentity(); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.ks.vip.mapper.VipGradePotenceMapper; |
| | | import com.ks.vip.mapper.VipGradePotenceMapper; |
| | | import com.ks.vip.pojo.DO.VipGrade; |
| | | import com.ks.vip.pojo.DO.VipGradePotence; |
| | | import com.ks.vip.pojo.Enums.VIPEnum; |
| | | import com.ks.vip.query.VipGradePotenceQuery; |
| | | import com.ks.vip.service.VipGradePotenceService; |
| | | import com.ks.vip.service.VipGradePotenceService; |
| | | import com.ks.vip.service.VipGradeService; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | |
| | | @Resource |
| | | private VipGradePotenceMapper vipGradePotenceMapper; |
| | | |
| | | @Resource |
| | | private VipGradeService vipGradeService; |
| | | |
| | | |
| | | @Override |
| | |
| | | return vipGradePotenceMapper.listByPage(query); |
| | | } |
| | | |
| | | @Override |
| | | public VipGradePotence getPotenceByGradeId(Long gradeId) { |
| | | return vipGradePotenceMapper.getByGradeId(gradeId); |
| | | } |
| | | |
| | | @Override |
| | | public VipGradePotence getDefaultGradePotence() { |
| | | VipGrade grade = vipGradeService.getDefaultGrade(); |
| | | if (grade == null) { |
| | | return null; |
| | | } |
| | | return vipGradePotenceMapper.getByGradeId(grade.getId()); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public VipGradePotence getPotenceByVipEnum(VIPEnum vipEnum) { |
| | | VipGrade grade = vipGradeService.getByVipEnum(vipEnum); |
| | | if (grade == null) { |
| | | return null; |
| | | } |
| | | return vipGradePotenceMapper.getByGradeId(grade.getId()); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.ks.vip.mapper.VipGradeMapper; |
| | | import com.ks.vip.pojo.DO.VipCombo; |
| | | import com.ks.vip.pojo.DO.VipGrade; |
| | | import com.ks.vip.pojo.Enums.VIPEnum; |
| | | import com.ks.vip.query.VipComboQuery; |
| | | import com.ks.vip.query.VipGradeQuery; |
| | | import com.ks.vip.service.VipComboService; |
| | |
| | | return listByPage(0, Integer.MAX_VALUE, t); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public VipGrade getByIdentity(String identity){ |
| | | return vipGradeMapper.getByIdentity(identity); |
| | | } |
| | | |
| | | @Override |
| | | public VipGrade selectByPrimaryKey(Long id){ |
| | | return vipGradeMapper.selectByPrimaryKey(id); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public VipGrade getDefaultGrade(){ |
| | | return vipGradeMapper.getByIdentity(VIPEnum.silver.name()); |
| | | } |
| | | |
| | | @Override |
| | | public VipGrade getByVipEnum(VIPEnum vipEnum){ |
| | | return vipGradeMapper.getByIdentity(vipEnum.name()); |
| | | } |
| | | |
| | | } |
| | |
| | | name: lijin-provider |
| | | registry: |
| | | protocol: zookeeper |
| | | address: zookeeper://118.195.138.153:2181 # 134.175.68.214 134.175.68.214:2181 |
| | | address: zookeeper://193.112.35.168:2181 |
| | | # address: zookeeper://118.195.138.153:2181 |
| | | client: curator |
| | | protocol: |
| | | name: dubbo |
| | |
| | | <result column="pc_grade_id" property="gradeId" jdbcType="BIGINT"/> |
| | | <result column="pc_rebate_percent" property="rebatePercent" jdbcType="DECIMAL"/> |
| | | <result column="pc_taolijin_percent" property="taolijinPercent" jdbcType="DECIMAL"/> |
| | | <result column="pc_taolijin_max_number" property="taolijinMaxNumber" jdbcType="VARCHAR"/> |
| | | <result column="pc_taolijin_max_number" property="taolijinMaxNumber" jdbcType="INTEGER"/> |
| | | <result column="pc_taolijin_max_money" property="taolijinMaxMoney" jdbcType="DECIMAL"/> |
| | | <result column="pc_creator_id" property="creatorId" jdbcType="BIGINT"/> |
| | | <result column="pc_create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | |
| | | <include refid="Base_Column_List"/>from vip_grade_potence where pc_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from vip_grade_potence where pc_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.ks.vip.pojo.DO.VipGradePotence" useGeneratedKeys="true" keyProperty="id">insert into vip_grade_potence (pc_id,pc_grade_id,pc_rebate_percent,pc_taolijin_percent,pc_taolijin_max_number,pc_taolijin_max_money,pc_creator_id,pc_create_time,pc_updator_id,pc_update_time) values (#{id,jdbcType=BIGINT},#{gradeId,jdbcType=BIGINT},#{rebatePercent,jdbcType=DECIMAL},#{taolijinPercent,jdbcType=DECIMAL},#{taolijinMaxNumber,jdbcType=VARCHAR},#{taolijinMaxMoney,jdbcType=DECIMAL},#{creatorId,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP},#{updatorId,jdbcType=BIGINT},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insert" parameterType="com.ks.vip.pojo.DO.VipGradePotence" useGeneratedKeys="true" keyProperty="id">insert into vip_grade_potence (pc_id,pc_grade_id,pc_rebate_percent,pc_taolijin_percent,pc_taolijin_max_number,pc_taolijin_max_money,pc_creator_id,pc_create_time,pc_updator_id,pc_update_time) values (#{id,jdbcType=BIGINT},#{gradeId,jdbcType=BIGINT},#{rebatePercent,jdbcType=DECIMAL},#{taolijinPercent,jdbcType=DECIMAL},#{taolijinMaxNumber,jdbcType=INTEGER},#{taolijinMaxMoney,jdbcType=DECIMAL},#{creatorId,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP},#{updatorId,jdbcType=BIGINT},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.ks.vip.pojo.DO.VipGradePotence" useGeneratedKeys="true" keyProperty="id">insert into vip_grade_potence |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">pc_id,</if> |
| | |
| | | <if test="gradeId != null">#{gradeId,jdbcType=BIGINT},</if> |
| | | <if test="rebatePercent != null">#{rebatePercent,jdbcType=DECIMAL},</if> |
| | | <if test="taolijinPercent != null">#{taolijinPercent,jdbcType=DECIMAL},</if> |
| | | <if test="taolijinMaxNumber != null">#{taolijinMaxNumber,jdbcType=VARCHAR},</if> |
| | | <if test="taolijinMaxNumber != null">#{taolijinMaxNumber,jdbcType=INTEGER},</if> |
| | | <if test="taolijinMaxMoney != null">#{taolijinMaxMoney,jdbcType=DECIMAL},</if> |
| | | <if test="creatorId != null">#{creatorId,jdbcType=BIGINT},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.ks.vip.pojo.DO.VipGradePotence">update vip_grade_potence set pc_grade_id = #{gradeId,jdbcType=BIGINT},pc_rebate_percent = #{rebatePercent,jdbcType=DECIMAL},pc_taolijin_percent = #{taolijinPercent,jdbcType=DECIMAL},pc_taolijin_max_number = #{taolijinMaxNumber,jdbcType=VARCHAR},pc_taolijin_max_money = #{taolijinMaxMoney,jdbcType=DECIMAL},pc_creator_id = #{creatorId,jdbcType=BIGINT},pc_create_time = #{createTime,jdbcType=TIMESTAMP},pc_updator_id = #{updatorId,jdbcType=BIGINT},pc_update_time = #{updateTime,jdbcType=TIMESTAMP} where pc_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKey" parameterType="com.ks.vip.pojo.DO.VipGradePotence">update vip_grade_potence set pc_grade_id = #{gradeId,jdbcType=BIGINT},pc_rebate_percent = #{rebatePercent,jdbcType=DECIMAL},pc_taolijin_percent = #{taolijinPercent,jdbcType=DECIMAL},pc_taolijin_max_number = #{taolijinMaxNumber,jdbcType=INTEGER},pc_taolijin_max_money = #{taolijinMaxMoney,jdbcType=DECIMAL},pc_creator_id = #{creatorId,jdbcType=BIGINT},pc_create_time = #{createTime,jdbcType=TIMESTAMP},pc_updator_id = #{updatorId,jdbcType=BIGINT},pc_update_time = #{updateTime,jdbcType=TIMESTAMP} where pc_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.ks.vip.pojo.DO.VipGradePotence">update vip_grade_potence |
| | | <set> |
| | | <if test="gradeId != null">pc_grade_id=#{gradeId,jdbcType=BIGINT},</if> |
| | | <if test="rebatePercent != null">pc_rebate_percent=#{rebatePercent,jdbcType=DECIMAL},</if> |
| | | <if test="taolijinPercent != null">pc_taolijin_percent=#{taolijinPercent,jdbcType=DECIMAL},</if> |
| | | <if test="taolijinMaxNumber != null">pc_taolijin_max_number=#{taolijinMaxNumber,jdbcType=VARCHAR},</if> |
| | | <if test="taolijinMaxNumber != null">pc_taolijin_max_number=#{taolijinMaxNumber,jdbcType=INTEGER},</if> |
| | | <if test="taolijinMaxMoney != null">pc_taolijin_max_money=#{taolijinMaxMoney,jdbcType=DECIMAL},</if> |
| | | <if test="creatorId != null">pc_creator_id=#{creatorId,jdbcType=BIGINT},</if> |
| | | <if test="createTime != null">pc_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | |
| | | <include refid="listWhere"/> |
| | | </select> |
| | | |
| | | <select id="getByGradeId" resultMap="BaseResultMap"> |
| | | select <include refid="Base_Column_List"/> from vip_grade_potence |
| | | where pc_grade_id = #{gradeId} |
| | | limit 1 |
| | | </select> |
| | | |
| | | |
| | | </mapper> |