Authored by chenjian

品友行为数据上报

... ... @@ -11,3 +11,4 @@ web/catalina.home_IS_UNDEFINED/logs/2016-06-08/active_dingdang.log
*.log
web/catalina.home_IS_UNDEFINED/logs/2016-06-13/add_dingdang.log
channel/target/
channel/.settings/
... ...
... ... @@ -32,8 +32,8 @@ public class ChannelGroupRest {
@Autowired
private IChannelGroupService channelGroupService;
@Autowired
private HttpSession session;
// @Autowired
// private HttpSession session;
@RequestMapping("/queryChannelGroupList")
... ... @@ -123,10 +123,10 @@ public class ChannelGroupRest {
public ApiResponse addGroup(@RequestBody ChannelUserRequest request) {
// 设置系统管理员 ID
UserInfoBO userInfo = (UserInfoBO) session.getAttribute("userSession");
checkNotNull(userInfo, "获取当前用户信息失败,请刷新当前页面");
// UserInfoBO userInfo = (UserInfoBO) session.getAttribute("userSession");
// checkNotNull(userInfo, "获取当前用户信息失败,请刷新当前页面");
channelGroupService.saveGroup(request, userInfo);
// channelGroupService.saveGroup(request, userInfo);
return new ApiResponse.ApiResponseBuilder().build();
}
... ...
package com.yoho.unions.common.utils;
import java.util.Date;
public class TimeUtils {
public static int SECONDS_PER_DAY = 86400;
public static int getTimeStamp3MonthAgo() {
return (int)(new Date().getTime()/1000) - SECONDS_PER_DAY * 90;
}
}
... ...
package com.yoho.unions.dal;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yoho.unions.dal.model.OrdersGoods;
/**
* OrdersGoodsMapper
*/
public interface IOrdersGoodsMapper {
List<OrdersGoods> selectOrderGoodsByOrder(@Param("uid") Integer uid, @Param("orderCode") Long orderCode);
}
\ No newline at end of file
... ...
package com.yoho.unions.dal;
import org.apache.ibatis.annotations.Param;
import com.yoho.unions.dal.model.Orders;
public interface IOrdersMapper {
Orders selectByUidAndOrderCode(@Param("uid") int uid, @Param("orderCode") long orderCode);
/**
* 查询某用户一段时间以来的已交寄订单
* @param uid
* @param createTime
* @return
*/
int selectCountShipStatusOrderSince(@Param("uid") Integer uid, @Param("createTime") Integer createTime);
}
\ No newline at end of file
... ...
package com.yoho.unions.dal.model;
import java.math.BigDecimal;
import java.util.List;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
/**
* Orders
* 类描述
*
* @author zhangyonghui
* @date 2015/11/3
*/
public class Orders {
/**
*
*/
private static final long serialVersionUID = 187012492719939638L;
/**
* 新订单
*/
public static final Byte STATUS_NEW = 0;
/**
* 已支付
*/
public static final Byte STATUS_PAID = 1;
/**
* 已交寄
*/
public static final Byte STATUS_MAILED = 4;
/**
* 已完成
*/
public static final Byte STATUS_DONE = 6;
/**
* 订单状态-正常
*/
public static final Byte ATTRIBUTE_NORMAL = 1;
/**
* 订单状态-虚拟
*/
public static final Byte ATTRIBUTE_VIRTUAL = 3;
/**
* 订单状态-预售
*/
public static final Byte ATTRIBUTE_ADVANCE = 5;
/**
* 订单状态-特殊
*/
public static final Byte ATTRIBUTE_SPECIAL = 7;
/**
* 订单状态-定金预售
*/
public static final Byte ATTRIBUTE_DEPOSIT = 9;
/**
* 订单状态-已删除
*/
public static final Byte ORDERS_STATUS_DELETE = 0;
/**
* 支付状态-已付款
*/
public static final String PAYMENT_STATUS_YES = "Y";
/**
* 支付状态-未付款
*/
public static final String PAYMENT_STATUS_NO = "N";
/**
* 支付方式-在线支付
*/
public static final Byte PAYMENT_TYPE_ONLINE = 1;
/**
* 支付方式-货到付款
*/
public static final Byte PAYMENT_TYPE_COD = 2;
/**
* 支付方式-现金支付
*/
public static final Byte PAYMENT_TYPE_CASH = 3;
/**
* 支付方式-抵消支付
*/
public static final Byte PAYMENT_TYPE_OFFSET = 4;
/**
* 取消方式-用户
*/
public static final Byte CANCEL_TYPE_USER = 2;
/**
* 取消方式-客服取消
*/
public static final Byte CANCEL_TYPE_CS = 11;
/**
* 取消方式-备货中
*/
public static final Byte CANCEL_TYPE_PREPARING = 12;
/**
* 取消方式-配货中
*/
public static final Byte CANCEL_TYPE_DISTRIBUTION = 13;
/**
* 取消方式-发货后
*/
public static final Byte CANCEL_TYPE_POST_SHIP = 14;
/**
* 取消方式-运输中
*/
public static final Byte CANCEL_TYPE_IN_TRANSIT = 15;
/**
* 取消方式-系统自动取消
*/
public static final Byte CANCEL_TYPE_SYSTEM_AUTO = 16;
public static final int USER_NAME_MAX_LENGTH = 10;
/**
* 退款中
*/
public static final Byte REFUND_STATUS_REFUNDING = 6;
/**
* 退款完成
*/
public static final Byte REFUND_STATUS_FINISHED = 7;
/**
* @deprecated 使用uid、order_code 替换
*/
private Integer id;
/**
* 订单号
*/
private Long orderCode;
/**
* 用户ID
*/
private Integer uid;
/**
* 快递单号
*/
private String expressNumber;
/**
* 订单类型(渠道)
*/
private Byte orderType;
private String isInvoice;
/**
* 发票类型
*/
private String invoicesType;
/**
* 发票类型 ,引入电子发票后
*/
private Integer invoiceTypes;
/**
* 发票抬头
*/
private String invoicesPayable;
/**
* 使用有货币量
*/
private Integer yohoCoinNum;
/**
* 支付类型
*/
private Byte paymentType;
/**
* 支付方式
*/
private Byte payment;
/**
*
*/
private String paymentAmount;
/**
* 银行编码
*/
private String bankCode;
/**
* 支付状态
*/
private String paymentStatus;
/**
*
*/
private Byte shippingTypeId;
/**
* 运费金额
*/
private BigDecimal shippingCost;
/**
* 快递公司ID
*/
private Byte expressId;
/**
*
*/
private String userName;
/**
* 收货人电话
*/
private String phone;
/**
* 手机号码
*/
private String mobile;
/**
* 地区编码
*/
private Integer areaCode;
/**
* 具体的地区
*/
private String Area;
/**
* 地质
*/
private String address;
/**
* 邮编
*/
private Integer zipCode;
/**
* 注释
*/
private String remark;
/**
* 到货时间
*/
private Integer receivingTime;
/**
* 收货时间(周六方便收货)
*/
private String receiptTime;
private Byte exceptionStatus;
/**
*
*/
private String isLock;
/**
*
*/
private String isArrive;
/**
* 订单状态
*/
private Byte status;
/**
* 是否取消
*/
private String isCancel;
/**
* 是否可以评论
*/
private String isComment;
private Byte cancelType;
private Byte exchangeStatus;
private Byte refundStatus;
private Integer arriveTime;
private Integer shipmentTime;
private Integer createTime;
private BigDecimal amount;
private String isPrintPrice;
private String isPreContact;
private String isNeedRapid;
private Integer updateTime;
private Byte attribute;
private String isPayed;
private Short activitiesId;
private Long parentOrderCode;
/**
* 订单状态
*/
private Byte ordersStatus;
private String canCommont;
private String expressCompany;
private String statusStr;
private BigDecimal goodsTotalAmount;
private BigDecimal couponsAmount;
private BigDecimal promotionAmount;
private boolean isSupportRefund;
private boolean isSupportExchange;
//用户是否支付,从order_pay表查询,支付回调不同步
private String user_confirm_paid = "N";
//是否使用限购码
private String use_limit_code = "N";
private String isJit = "N";
private String isJitAlreadySplit = "N";
//收货地址省份
private String province;
//收货地址城市
private String city;
//收货地址街区
private String district;
//收货人email
private String email;
//用户等级
private int userLevel;
//是否包含多个包裹 Y:分仓调拨,N:单个包裹
private String isMultiPackage;
/**
* 赠送的有货币数
*/
private int deliverYohoCoin;
//预售
private String isAdvance = "N";
/**
* 是否展示倒计时计数器
*/
private String counter_flag;
/**
* 取消订单倒计时时间,单位:秒
*/
private int pay_lefttime;
/**
* 支付完成时间
*/
private String pay_finish_time;
/**
* 确认收货时间
*/
private String confirm_time;
/**
* 虚拟种类,兼容以后的虚拟商品,3为门票
*/
private String virtualType;
/**
* BLK参数 Y:N
*/
private String isBlk="N";
/**
* student Y:N
*/
private String isStudent="N";
//支付逾期时间
private String payExpire;
//订单定金金额
private String order_deposit_amount;
//订单尾款金额:订单金额-订单定金
private String order_tail_pay_amount;
private List<String> links;
private int ordersProcessStatus;
private String payment_stage;
private String canUpdateDeliveryAddress = "N";
private String canChangeProvince = "N";
public String getPayment_stage() {
return payment_stage;
}
public void setPayment_stage(String payment_stage) {
this.payment_stage = payment_stage;
}
public int getOrdersProcessStatus() {
return ordersProcessStatus;
}
public void setOrdersProcessStatus(int ordersProcessStatus) {
this.ordersProcessStatus = ordersProcessStatus;
}
public List<String> getLinks() {
return links;
}
public void setLinks(List<String> links) {
this.links = links;
}
public String getIsStudent() {
return isStudent;
}
public void setIsStudent(String isStudent) {
this.isStudent = isStudent;
}
public String getIsBlk() {
return isBlk;
}
public void setIsBlk(String isBlk) {
this.isBlk = isBlk;
}
public String getPay_finish_time() {
return pay_finish_time;
}
public void setPay_finish_time(String pay_finish_time) {
this.pay_finish_time = pay_finish_time;
}
public String getConfirm_time() {
return confirm_time;
}
public void setConfirm_time(String confirm_time) {
this.confirm_time = confirm_time;
}
public String getCounter_flag() {
return counter_flag;
}
public void setCounter_flag(String counter_flag) {
this.counter_flag = counter_flag;
}
public int getPay_lefttime() {
return pay_lefttime;
}
public void setPay_lefttime(int pay_lefttime) {
this.pay_lefttime = pay_lefttime;
}
public void setPayExpire(String payExpire) {
this.payExpire = payExpire;
}
public String getPayExpire() {
return payExpire;
}
public boolean isSupportRefund() {
return isSupportRefund;
}
public void setSupportRefund(boolean isSupportRefund) {
this.isSupportRefund = isSupportRefund;
}
public boolean isSupportExchange() {
return isSupportExchange;
}
public void setSupportExchange(boolean isSupportExchange) {
this.isSupportExchange = isSupportExchange;
}
public BigDecimal getPromotionAmount() {
return promotionAmount;
}
public void setPromotionAmount(BigDecimal promotionAmount) {
this.promotionAmount = promotionAmount;
}
public BigDecimal getCouponsAmount() {
return couponsAmount;
}
public void setCouponsAmount(BigDecimal couponsAmount) {
this.couponsAmount = couponsAmount;
}
public BigDecimal getGoodsTotalAmount() {
return goodsTotalAmount;
}
public void setGoodsTotalAmount(BigDecimal goodsTotalAmount) {
this.goodsTotalAmount = goodsTotalAmount;
}
public String getStatusStr() {
return statusStr;
}
public void setStatusStr(String statusStr) {
this.statusStr = statusStr;
}
public String getExpressCompany() {
return expressCompany;
}
public void setExpressCompany(String expressCompany) {
this.expressCompany = expressCompany;
}
public String getArea() {
return Area;
}
public void setArea(String area) {
Area = area;
}
public String getPaymentAmount() {
return paymentAmount;
}
public void setPaymentAmount(String paymentAmount) {
this.paymentAmount = paymentAmount;
}
private List<OrdersGoods> ordersGoodsList;
public String getCanCommont() {
return canCommont;
}
public void setCanCommont(String canCommont) {
this.canCommont = canCommont;
}
public List<OrdersGoods> getOrdersGoodsList() {
return ordersGoodsList;
}
public void setOrdersGoodsList(List<OrdersGoods> ordersGoodsList) {
this.ordersGoodsList = ordersGoodsList;
}
/**
* @deprecated 使用uid、order_code 替换
*/
public Integer getId() {
return id;
}
/**
* @deprecated 使用uid、order_code 替换
*/
public void setId(Integer id) {
this.id = id;
}
public Long getOrderCode() {
return orderCode;
}
public void setOrderCode(Long orderCode) {
this.orderCode = orderCode;
}
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public String getExpressNumber() {
return expressNumber;
}
public void setExpressNumber(String expressNumber) {
this.expressNumber = expressNumber == null ? null : expressNumber.trim();
}
public Byte getOrderType() {
return orderType;
}
public void setOrderType(Byte orderType) {
this.orderType = orderType;
}
public String getIsInvoice() {
return isInvoice;
}
public void setIsInvoice(String isInvoice) {
this.isInvoice = isInvoice == null ? null : isInvoice.trim();
}
public String getInvoicesType() {
return invoicesType;
}
public void setInvoicesType(String invoicesType) {
this.invoicesType = invoicesType == null ? null : invoicesType.trim();
}
public String getInvoicesPayable() {
return invoicesPayable;
}
public void setInvoicesPayable(String invoicesPayable) {
this.invoicesPayable = invoicesPayable == null ? null : invoicesPayable.trim();
}
public Integer getYohoCoinNum() {
return yohoCoinNum;
}
public void setYohoCoinNum(Integer yohoCoinNum) {
this.yohoCoinNum = yohoCoinNum;
}
public Byte getPaymentType() {
return paymentType;
}
public void setPaymentType(Byte paymentType) {
this.paymentType = paymentType;
}
public Byte getPayment() {
return payment;
}
public void setPayment(Byte payment) {
this.payment = payment;
}
public String getBankCode() {
return bankCode;
}
public void setBankCode(String bankCode) {
this.bankCode = bankCode == null ? null : bankCode.trim();
}
public String getPaymentStatus() {
return paymentStatus;
}
public void setPaymentStatus(String paymentStatus) {
this.paymentStatus = paymentStatus == null ? null : paymentStatus.trim();
}
public Byte getShippingTypeId() {
return shippingTypeId;
}
public void setShippingTypeId(Byte shippingTypeId) {
this.shippingTypeId = shippingTypeId;
}
public BigDecimal getShippingCost() {
return shippingCost;
}
public void setShippingCost(BigDecimal shippingCost) {
this.shippingCost = shippingCost;
}
public Byte getExpressId() {
return expressId;
}
public void setExpressId(Byte expressId) {
this.expressId = expressId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName == null ? null : userName.trim();
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone == null ? null : phone.trim();
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile == null ? null : mobile.trim();
}
public Integer getAreaCode() {
return areaCode;
}
public void setAreaCode(Integer areaCode) {
this.areaCode = areaCode;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address == null ? null : address.trim();
}
public Integer getZipCode() {
return zipCode;
}
public void setZipCode(Integer zipCode) {
this.zipCode = zipCode;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark == null ? null : remark.trim();
}
public Integer getReceivingTime() {
return receivingTime;
}
public void setReceivingTime(Integer receivingTime) {
this.receivingTime = receivingTime;
}
public String getReceiptTime() {
return receiptTime;
}
public void setReceiptTime(String receiptTime) {
this.receiptTime = receiptTime == null ? null : receiptTime.trim();
}
public Byte getExceptionStatus() {
return exceptionStatus;
}
public void setExceptionStatus(Byte exceptionStatus) {
this.exceptionStatus = exceptionStatus;
}
public String getIsLock() {
return isLock;
}
public void setIsLock(String isLock) {
this.isLock = isLock == null ? null : isLock.trim();
}
public String getIsArrive() {
return isArrive;
}
public void setIsArrive(String isArrive) {
this.isArrive = isArrive == null ? null : isArrive.trim();
}
public Byte getStatus() {
return status;
}
public void setStatus(Byte status) {
this.status = status;
}
public String getIsCancel() {
return isCancel;
}
public void setIsCancel(String isCancel) {
this.isCancel = isCancel == null ? null : isCancel.trim();
}
public Byte getCancelType() {
return cancelType;
}
public void setCancelType(Byte cancelType) {
this.cancelType = cancelType;
}
public Byte getExchangeStatus() {
return exchangeStatus;
}
public void setExchangeStatus(Byte exchangeStatus) {
this.exchangeStatus = exchangeStatus;
}
public Byte getRefundStatus() {
return refundStatus;
}
public void setRefundStatus(Byte refundStatus) {
this.refundStatus = refundStatus;
}
public Integer getArriveTime() {
return arriveTime;
}
public void setArriveTime(Integer arriveTime) {
this.arriveTime = arriveTime;
}
public Integer getShipmentTime() {
return shipmentTime;
}
public void setShipmentTime(Integer shipmentTime) {
this.shipmentTime = shipmentTime;
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public String getIsPrintPrice() {
return isPrintPrice;
}
public void setIsPrintPrice(String isPrintPrice) {
this.isPrintPrice = isPrintPrice == null ? null : isPrintPrice.trim();
}
public String getIsPreContact() {
return isPreContact;
}
public void setIsPreContact(String isPreContact) {
this.isPreContact = isPreContact == null ? null : isPreContact.trim();
}
public String getIsComment() {
return isComment;
}
public void setIsComment(String isComment) {
this.isComment = isComment;
}
public String getIsNeedRapid() {
return isNeedRapid;
}
public void setIsNeedRapid(String isNeedRapid) {
this.isNeedRapid = isNeedRapid == null ? null : isNeedRapid.trim();
}
public Integer getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
public Byte getAttribute() {
return attribute;
}
public void setAttribute(Byte attribute) {
this.attribute = attribute;
}
public String getIsPayed() {
return isPayed;
}
public void setIsPayed(String isPayed) {
this.isPayed = isPayed == null ? null : isPayed.trim();
}
public Short getActivitiesId() {
return activitiesId;
}
public void setActivitiesId(Short activitiesId) {
this.activitiesId = activitiesId;
}
public Long getParentOrderCode() {
return parentOrderCode;
}
public void setParentOrderCode(Long parentOrderCode) {
this.parentOrderCode = parentOrderCode;
}
public Byte getOrdersStatus() {
return ordersStatus;
}
public void setOrdersStatus(Byte ordersStatus) {
this.ordersStatus = ordersStatus;
}
public String getUser_confirm_paid() {
return user_confirm_paid;
}
public void setUser_confirm_paid(String user_confirm_paid) {
this.user_confirm_paid = user_confirm_paid;
}
public String getUse_limit_code() {
if ("N".equals(use_limit_code)) {
//虚拟订单也不能再次购物
return this.attribute == ATTRIBUTE_VIRTUAL ? "Y" : use_limit_code;
}
return use_limit_code;
}
public void setUse_limit_code(String use_limit_code) {
this.use_limit_code = use_limit_code;
}
public String getIsJit() {
return isJit;
}
public void setIsJit(String isJit) {
this.isJit = isJit;
}
public String getIsJitAlreadySplit() {
return isJitAlreadySplit;
}
public void setIsJitAlreadySplit(String isJitAlreadySplit) {
this.isJitAlreadySplit = isJitAlreadySplit;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public int getUserLevel() {
return userLevel;
}
public void setUserLevel(int userLevel) {
this.userLevel = userLevel;
}
public String getIsAdvance() {
return isAdvance;
}
public void setIsAdvance(String isAdvance) {
this.isAdvance = isAdvance;
}
public int getDeliverYohoCoin() {
return deliverYohoCoin;
}
public void setDeliverYohoCoin(int deliverYohoCoin) {
this.deliverYohoCoin = deliverYohoCoin;
}
public String getIsMultiPackage() {
return isMultiPackage;
}
public void setIsMultiPackage(String isMultiPackage) {
this.isMultiPackage = isMultiPackage;
}
public void setIsJitBySupplierId(Integer supplierId) {
this.setIsJit("N");
if (supplierId != null && supplierId > 0) {
if (supplierId > 0) {
this.setIsJit("Y");
}
}
}
public Integer getInvoiceTypes() {
return invoiceTypes;
}
public void setInvoiceTypes(Integer invoiceTypes) {
this.invoiceTypes = invoiceTypes;
}
public String getVirtualType() {
return virtualType;
}
public void setVirtualType(String virtualType) {
this.virtualType = virtualType;
}
public String getOrder_deposit_amount() {
return order_deposit_amount;
}
public void setOrder_deposit_amount(String order_deposit_amount) {
this.order_deposit_amount = order_deposit_amount;
}
public String getOrder_tail_pay_amount() {
return order_tail_pay_amount;
}
public void setOrder_tail_pay_amount(String order_tail_pay_amount) {
this.order_tail_pay_amount = order_tail_pay_amount;
}
public String getCanUpdateDeliveryAddress() {
return canUpdateDeliveryAddress;
}
public void setCanUpdateDeliveryAddress(String canUpdateDeliveryAddress) {
this.canUpdateDeliveryAddress = canUpdateDeliveryAddress;
}
public String getCanChangeProvince() {
return canChangeProvince;
}
public void setCanChangeProvince(String canChangeProvince) {
this.canChangeProvince = canChangeProvince;
}
@Override
public String toString() {
return ReflectionToStringBuilder.toString(this);
}
}
\ No newline at end of file
... ...
package com.yoho.unions.dal.model;
import java.math.BigDecimal;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
/**
* OrdersGoods
* 订单商品类
*
* @author zhangyonghui
* @date 2015/11/3
*/
public class OrdersGoods {
public final static int BUY_TYPE_OFFLINE = 1;
public final static int BUY_TYPE_ONLINE = 2;
private Integer id;
private Integer uid;
private Long orderCode;
private Integer productId;
private Integer brandId;
private Integer goodsId;
/**
* '1为正常商品,2为商品的赠品,3为加价购,4为outlet,5为free 6为预售 7为电子票。
*/
private Byte goodsType;
private Integer erpSkuId;
/**
* 商品价格
*/
private BigDecimal goodsPrice;
private BigDecimal goodsAmount;
// 购物数量
private Integer num;
private Integer sizeId;
/**
* 尺码
*/
private String sizeName;
private Integer colorId;
/**
* 颜色名称
*/
private String colorName;
/**
* @deprecated 使用uid、order_code 替换
*/
private Integer orderId;
private Integer productSkn;
private Long salesPrice;
//------------------BO-----------------------
private Integer productSku;
private String goodsImage;
//判断商品品类是否显示身高体重
private boolean shouldShowWeighInfo;
/**
* 商品名称
*/
private String goodsName;
private String productName;
private String goodsStatus;
private String expectArrivalTime;
private String cnAlphabet;
private String productUrl;
private String goodsTypeDESC;
// 退货数量
private Integer refundNum;
//促销活动减免金额
private BigDecimal promotionCutAmount = BigDecimal.valueOf(0);
//优惠券抵扣金额
private BigDecimal couponsCutAmount = BigDecimal.valueOf(0);
//优惠码抵扣金额
private BigDecimal promoCodeCutAmount = BigDecimal.valueOf(0);
//红包抵扣金额
private BigDecimal redenvelopeCutAmount = BigDecimal.valueOf(0);
//有货币抵扣数量
private int yohoCoinCutNum;
//vip价格
private BigDecimal realVipPrice = BigDecimal.valueOf(0);
//vip折扣率
private BigDecimal vipDiscountRate = BigDecimal.valueOf(0);
//vip折扣金额
private BigDecimal vipCutAmount = BigDecimal.valueOf(0);
//jit商品
private String isJit;
//店铺id
private int shopId;
//供应商id
private int supplierId;
//商品返回的有货币数量
private int getYohoCoin;
private Integer productSkc;
/**
* 学生折扣
*/
private String discountTag;
//1门店商品 2线上商品
private int buy_type;
private String delay_notice;
/**
* 厂家颜色
*/
private String factoryGoodsName;
public String getFactoryGoodsName() {
return factoryGoodsName;
}
public void setFactoryGoodsName(String factoryGoodsName) {
this.factoryGoodsName = factoryGoodsName;
}
public String getDelay_notice() {
return delay_notice;
}
public void setDelay_notice(String delay_notice) {
this.delay_notice = delay_notice;
}
/**
* @return the buy_type
*/
public int getBuy_type() {
return buy_type;
}
/**
* @param buy_type the buy_type to set
*/
public void setBuy_type(int buy_type) {
this.buy_type = buy_type;
}
public Integer getRefundNum() {
return refundNum;
}
public void setRefundNum(Integer refundNum) {
this.refundNum = refundNum;
}
public boolean isShouldShowWeighInfo() {
return shouldShowWeighInfo;
}
public void setShouldShowWeighInfo(boolean shouldShowWeighInfo) {
this.shouldShowWeighInfo = shouldShowWeighInfo;
}
public String getExpectArrivalTime() {
return expectArrivalTime;
}
public void setExpectArrivalTime(String expectArrivalTime) {
this.expectArrivalTime = expectArrivalTime;
}
public String getGoodsStatus() {
return goodsStatus;
}
;
public void setGoodsStatus(String goodsStatus) {
this.goodsStatus = goodsStatus;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public Integer getProductId() {
return productId;
}
public void setProductId(Integer productId) {
this.productId = productId;
}
public Integer getBrandId() {
return brandId;
}
public void setBrandId(Integer brandId) {
this.brandId = brandId;
}
public Integer getGoodsId() {
return goodsId;
}
public void setGoodsId(Integer goodsId) {
this.goodsId = goodsId;
}
public Byte getGoodsType() {
return goodsType;
}
public void setGoodsType(Byte goodsType) {
this.goodsType = goodsType;
}
public Integer getErpSkuId() {
return erpSkuId;
}
public void setErpSkuId(Integer erpSkuId) {
this.erpSkuId = erpSkuId;
}
public BigDecimal getGoodsPrice() {
return goodsPrice;
}
public void setGoodsPrice(BigDecimal goodsPrice) {
this.goodsPrice = goodsPrice;
}
public BigDecimal getGoodsAmount() {
return goodsAmount;
}
public void setGoodsAmount(BigDecimal goodsAmount) {
this.goodsAmount = goodsAmount;
}
public String getSizeName() {
return sizeName;
}
public void setSizeName(String sizeName) {
this.sizeName = sizeName == null ? null : sizeName.trim();
}
public Integer getColorId() {
return colorId;
}
public void setColorId(Integer colorId) {
this.colorId = colorId;
}
public String getColorName() {
return colorName;
}
public void setColorName(String colorName) {
this.colorName = colorName == null ? null : colorName.trim();
}
/**
* @deprecated 使用uid、order_code 替换
*/
public Integer getOrderId() {
return orderId;
}
/**
* @deprecated 使用uid、order_code 替换
*/
public void setOrderId(Integer orderId) {
this.orderId = orderId;
}
public Integer getProductSkn() {
return productSkn;
}
public void setProductSkn(Integer productSkn) {
this.productSkn = productSkn;
}
public Long getSalesPrice() {
return salesPrice;
}
public void setSalesPrice(Long salesPrice) {
this.salesPrice = salesPrice;
}
public Integer getProductSku() {
return productSku;
}
public void setProductSku(Integer productSku) {
this.productSku = productSku;
}
public Integer getNum() {
return num;
}
public void setNum(Integer num) {
this.num = num;
}
public Integer getSizeId() {
return sizeId;
}
public void setSizeId(Integer sizeId) {
this.sizeId = sizeId;
}
public String getCnAlphabet() {
return cnAlphabet;
}
public void setCnAlphabet(String cnAlphabet) {
this.cnAlphabet = cnAlphabet;
}
public String getGoodsImage() {
return goodsImage;
}
public void setGoodsImage(String goodsImage) {
this.goodsImage = goodsImage;
}
public String getGoodsTypeDESC() {
return goodsTypeDESC;
}
public void setGoodsTypeDESC(String goodsTypeDESC) {
this.goodsTypeDESC = goodsTypeDESC;
}
public Long getOrderCode() {
return orderCode;
}
public void setOrderCode(Long orderCode) {
this.orderCode = orderCode;
}
public String getProductUrl() {
return productUrl;
}
public void setProductUrl(String productUrl) {
this.productUrl = productUrl;
}
public BigDecimal getCouponsCutAmount() {
return couponsCutAmount;
}
public void setCouponsCutAmount(BigDecimal couponsCutAmount) {
this.couponsCutAmount = couponsCutAmount;
}
public BigDecimal getPromoCodeCutAmount() {
return promoCodeCutAmount;
}
public void setPromoCodeCutAmount(BigDecimal promoCodeCutAmount) {
this.promoCodeCutAmount = promoCodeCutAmount;
}
public BigDecimal getRedenvelopeCutAmount() {
return redenvelopeCutAmount;
}
public void setRedenvelopeCutAmount(BigDecimal redenvelopeCutAmount) {
this.redenvelopeCutAmount = redenvelopeCutAmount;
}
public int getYohoCoinCutNum() {
return yohoCoinCutNum;
}
public void setYohoCoinCutNum(int yohoCoinCutNum) {
this.yohoCoinCutNum = yohoCoinCutNum;
}
public BigDecimal getRealVipPrice() {
return realVipPrice;
}
public void setRealVipPrice(BigDecimal realVipPrice) {
this.realVipPrice = realVipPrice;
}
public BigDecimal getVipDiscountRate() {
return vipDiscountRate;
}
public void setVipDiscountRate(BigDecimal vipDiscountRate) {
this.vipDiscountRate = vipDiscountRate;
}
public String getIsJit() {
return isJit;
}
public void setIsJit(String isJit) {
this.isJit = isJit;
}
public int getShopId() {
return shopId;
}
public void setShopId(int shopId) {
this.shopId = shopId;
}
public int getSupplierId() {
return supplierId;
}
public void setSupplierId(int supplierId) {
this.supplierId = supplierId;
}
public int getGetYohoCoin() {
return getYohoCoin;
}
public void setGetYohoCoin(int getYohoCoin) {
this.getYohoCoin = getYohoCoin;
}
public BigDecimal getPromotionCutAmount() {
return promotionCutAmount;
}
public void setPromotionCutAmount(BigDecimal promotionCutAmount) {
this.promotionCutAmount = promotionCutAmount;
}
public BigDecimal getVipCutAmount() {
return vipCutAmount;
}
public void setVipCutAmount(BigDecimal vipCutAmount) {
this.vipCutAmount = vipCutAmount;
}
public Integer getProductSkc() {
return productSkc;
}
public void setProductSkc(Integer productSkc) {
this.productSkc = productSkc;
}
public String getDiscountTag() {
return discountTag;
}
public void setDiscountTag(String discountTag) {
this.discountTag = discountTag;
}
@Override
public String toString() {
return ReflectionToStringBuilder.toString(this);
}
}
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.unions.dal.IOrdersGoodsMapper">
<resultMap id="BaseResultMap" type="com.yoho.unions.dal.OrdersGoods">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="uid" property="uid" jdbcType="INTEGER"/>
<result column="order_code" property="orderCode" jdbcType="BIGINT"/>
<result column="product_id" property="productId" jdbcType="INTEGER"/>
<result column="brand_id" property="brandId" jdbcType="INTEGER"/>
<result column="goods_id" property="goodsId" jdbcType="INTEGER"/>
<result column="goods_type" property="goodsType" jdbcType="TINYINT"/>
<result column="erp_sku_id" property="erpSkuId" jdbcType="INTEGER"/>
<result column="goods_price" property="goodsPrice" jdbcType="DECIMAL"/>
<result column="goods_amount" property="goodsAmount" jdbcType="DECIMAL"/>
<result column="num" property="num" jdbcType="SMALLINT"/>
<result column="size_id" property="sizeId" jdbcType="SMALLINT"/>
<result column="size_name" property="sizeName" jdbcType="VARCHAR"/>
<result column="color_id" property="colorId" jdbcType="SMALLINT"/>
<result column="color_name" property="colorName" jdbcType="VARCHAR"/>
<result column="order_id" property="orderId" jdbcType="INTEGER"/>
<result column="product_skn" property="productSkn" jdbcType="INTEGER"/>
<result column="sales_price" property="salesPrice" jdbcType="DECIMAL"/>
<result column="get_yoho_coin" property="getYohoCoin" jdbcType="INTEGER"/>
<result column="vip_cut_amount" property="vipCutAmount" jdbcType="DECIMAL"/>
<result column="promotion_cut_amount" property="promotionCutAmount" jdbcType="DECIMAL"/>
<result column="coupons_cut_amount" property="couponsCutAmount" jdbcType="DECIMAL"/>
<result column="promo_code_cut_amount" property="promoCodeCutAmount" jdbcType="DECIMAL"/>
<result column="red_envelope_cut_amount" property="redenvelopeCutAmount" jdbcType="DECIMAL"/>
<result column="yoho_coin_cut_num" property="yohoCoinCutNum" jdbcType="DECIMAL"/>
<result column="vip_discount_rate" property="vipDiscountRate" jdbcType="DECIMAL"/>
<result column="is_jit" property="isJit" jdbcType="VARCHAR"/>
<result column="shop_id" property="shopId" jdbcType="INTEGER"/>
<result column="supplier_id" property="supplierId" jdbcType="INTEGER"/>
<result column="product_name" property="productName" jdbcType="VARCHAR"/>
<result column="product_skc" property="productSkc" jdbcType="INTEGER"/>
<result column="discount_tag" property="discountTag" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id, uid, order_code, product_id, brand_id, goods_id, goods_type, erp_sku_id, goods_price, goods_amount,
num, size_id, size_name, color_id, color_name, order_id, product_skn, sales_price,
coupons_cut_amount,promo_code_cut_amount,red_envelope_cut_amount,yoho_coin_cut_num,is_jit,
shop_id,supplier_id,promotion_cut_amount,vip_discount_rate,vip_cut_amount,get_yoho_coin,product_name,product_skc,discount_tag
</sql>
<select id="selectOrderGoodsByOrder" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from orders_goods
where
order_code = #{orderCode} and uid = #{uid}
</select>
</mapper>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.unions.dal.IOrdersMapper">
<resultMap id="BaseResultMap" type="com.yoho.service.model.order.response.Orders">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="order_code" property="orderCode" jdbcType="BIGINT"/>
<result column="uid" property="uid" jdbcType="INTEGER"/>
<result column="express_number" property="expressNumber" jdbcType="VARCHAR"/>
<result column="order_type" property="orderType" jdbcType="TINYINT"/>
<result column="is_invoice" property="isInvoice" jdbcType="CHAR"/>
<result column="invoices_type" property="invoicesType" jdbcType="VARCHAR"/>
<result column="invoices_payable" property="invoicesPayable" jdbcType="VARCHAR"/>
<result column="yoho_coin_num" property="yohoCoinNum" jdbcType="SMALLINT"/>
<result column="payment_type" property="paymentType" jdbcType="TINYINT"/>
<result column="payment" property="payment" jdbcType="TINYINT"/>
<result column="bank_code" property="bankCode" jdbcType="VARCHAR"/>
<result column="payment_status" property="paymentStatus" jdbcType="CHAR"/>
<result column="shipping_type_id" property="shippingTypeId" jdbcType="TINYINT"/>
<result column="shipping_cost" property="shippingCost" jdbcType="DECIMAL"/>
<result column="express_id" property="expressId" jdbcType="TINYINT"/>
<result column="user_name" property="userName" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="mobile" property="mobile" jdbcType="VARCHAR"/>
<result column="area_code" property="areaCode" jdbcType="INTEGER"/>
<result column="address" property="address" jdbcType="VARCHAR"/>
<result column="zip_code" property="zipCode" jdbcType="INTEGER"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="receiving_time" property="receivingTime" jdbcType="INTEGER"/>
<result column="receipt_time" property="receiptTime" jdbcType="VARCHAR"/>
<result column="exception_status" property="exceptionStatus" jdbcType="TINYINT"/>
<result column="is_lock" property="isLock" jdbcType="CHAR"/>
<result column="is_arrive" property="isArrive" jdbcType="CHAR"/>
<result column="status" property="status" jdbcType="TINYINT"/>
<result column="is_cancel" property="isCancel" jdbcType="CHAR"/>
<result column="cancel_type" property="cancelType" jdbcType="TINYINT"/>
<result column="exchange_status" property="exchangeStatus" jdbcType="TINYINT"/>
<result column="refund_status" property="refundStatus" jdbcType="TINYINT"/>
<result column="arrive_time" property="arriveTime" jdbcType="INTEGER"/>
<result column="shipment_time" property="shipmentTime" jdbcType="INTEGER"/>
<result column="create_time" property="createTime" jdbcType="INTEGER"/>
<result column="amount" property="amount" jdbcType="DECIMAL"/>
<result column="is_print_price" property="isPrintPrice" jdbcType="CHAR"/>
<result column="is_pre_contact" property="isPreContact" jdbcType="CHAR"/>
<result column="is_need_rapid" property="isNeedRapid" jdbcType="CHAR"/>
<result column="update_time" property="updateTime" jdbcType="INTEGER"/>
<result column="attribute" property="attribute" jdbcType="TINYINT"/>
<result column="is_payed" property="isPayed" jdbcType="CHAR"/>
<result column="activities_id" property="activitiesId" jdbcType="SMALLINT"/>
<result column="parent_order_code" property="parentOrderCode" jdbcType="BIGINT"/>
<result column="orders_status" property="ordersStatus" jdbcType="TINYINT"/>
<result column="province" property="province" jdbcType="VARCHAR"/>
<result column="user_level" property="userLevel" jdbcType="TINYINT"/>
<result column="is_jit" property="isJit" jdbcType="CHAR"/>
<result column="email" property="email" jdbcType="VARCHAR"/>
<result column="city" property="city" jdbcType="VARCHAR"/>
<result column="district" property="district" jdbcType="VARCHAR"/>
<result column="is_multi_package" property="isMultiPackage" jdbcType="CHAR"/>
<result column="is_advance" property="isAdvance" jdbcType="CHAR"/>
<result column="deliver_yoho_coin" property="deliverYohoCoin" jdbcType="INTEGER"/>
<result column="is_jit_already_split" property="isJitAlreadySplit" jdbcType="CHAR"/>
<result column="is_blk" property="isBlk" jdbcType="CHAR"/>
</resultMap>
<sql id="Base_Column_List">
id, order_code, uid, express_number, order_type, is_invoice, invoices_type, invoices_payable,
yoho_coin_num, payment_type, payment, bank_code, payment_status, shipping_type_id,
shipping_cost, express_id, user_name, phone, mobile, area_code, address, zip_code,
remark, receiving_time, receipt_time, exception_status, is_lock, is_arrive, status,
is_cancel, cancel_type, exchange_status, refund_status, arrive_time, shipment_time,
create_time, amount, is_print_price, is_pre_contact, is_need_rapid, update_time,
attribute, is_payed, activities_id, parent_order_code, orders_status,province, user_level,
is_jit, email, city, district, is_multi_package, is_advance, deliver_yoho_coin, is_jit_already_split,is_blk
</sql>
<select id="selectByUidAndOrderCode" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from orders
where order_code = #{orderCode,jdbcType=BIGINT} and uid = #{uid,jdbcType=INTEGER}
</select>
<select id="selectCountShipStatusOrderSince" resultType="java.lang.Integer">
select count(1)
from orders
where uid = #{uid,jdbcType=INTEGER}
and status >= 4
and create_time > #{createTime,jdbcType=INTEGER}
</select>
</mapper>
\ No newline at end of file
... ...
package com.yoho.unions.kafka.consumer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.yoho.unions.kafka.consumer.handler.ClickEventHandIntf;
@Service
public class ClickActionDispatcher {
private static final Logger logger = LoggerFactory.getLogger(ClickActionDispatcher.class);
/**
* 只有bean初始化时修改,后续只作读取,线程安全
*/
private Map<String, List<ClickEventHandIntf>> handlerMap = new HashMap<>();
/**
* handler注册
* @param eventKey
* @param handler
*/
synchronized public void register(String eventKey, ClickEventHandIntf handler) {
if(eventKey == null || handler == null) {
logger.warn("invalid click event handler, key: {}, handler:{}", eventKey, handler);
return;
}
List<ClickEventHandIntf> handlerList = handlerMap.get(eventKey);
if(handlerList == null) {
handlerList = new ArrayList<>();
handlerMap.put(eventKey, handlerList);
}
handlerList.add(handler);
logger.info("register handler, event: {}, handler: {}", eventKey, handler);
}
/**
* 点击事件分发处理
* @param eventJson
*/
public void dispatch(JSONObject eventJson) {
if(eventJson == null)
return;
String op = eventJson.getString("op");
if(op == null)
return;
List<ClickEventHandIntf> handlerList = handlerMap.get(op.toUpperCase());
if(CollectionUtils.isEmpty(handlerList))
return;
for(ClickEventHandIntf handler : handlerList) {
handler.process(eventJson);
}
}
}
... ...
package com.yoho.unions.kafka.consumer;
public class ClickEventConstants {
//主界面-首页-搜索功能使用
public final static String YB_MAIN_S = "YB_MAIN_S";
//商品详情页,页面展示的时候上报事件
public final static String YB_GDS_DT_INFO = "YB_GDS_DT_INFO";
//商品详情页-选择SKCSKN后加入购物车
public final static String YB_GDS_DT_SEL = "YB_GDS_DT_SEL";
//购物车-生成订单
public final static String YB_SC_ORD = "YB_SC_ORD";
}
... ...
package com.yoho.unions.kafka.consumer;
import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.listener.MessageListener;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
public class ClickStreamConsumer implements MessageListener<String, String> {
private static final Logger logger = LoggerFactory.getLogger(ClickStreamConsumer.class);
@Autowired
private ClickActionDispatcher dispatcher;
@Override
public void onMessage(ConsumerRecord<String, String> data) {
if (null == data || StringUtils.isEmpty(data.value())) {
logger.warn("kafka onMessage no data");
return;
}
JSONObject eventJson = JSON.parseObject(data.value());
dispatcher.dispatch(eventJson);
}
}
... ...
package com.yoho.unions.kafka.consumer.handler;
import com.alibaba.fastjson.JSONObject;
public interface ClickEventHandIntf {
void process(JSONObject actionData);
}
... ...
package com.yoho.unions.kafka.consumer.handler;
import java.math.BigDecimal;
import java.util.List;
import javax.annotation.PostConstruct;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.yoho.service.model.union.request.TransPinYouRequestBO;
import com.yoho.service.model.union.request.ViewPinYouRequestBO;
import com.yoho.unions.common.utils.TimeUtils;
import com.yoho.unions.dal.IOrdersGoodsMapper;
import com.yoho.unions.dal.IOrdersMapper;
import com.yoho.unions.dal.model.Orders;
import com.yoho.unions.dal.model.OrdersGoods;
import com.yoho.unions.kafka.consumer.ClickActionDispatcher;
import com.yoho.unions.kafka.consumer.ClickEventConstants;
import com.yoho.unions.server.service.IPinYouService;
/**
* 品友行为上报
* @author yoho
*
*/
@Service
public class PinyouReportHandler implements ClickEventHandIntf {
private static final Logger logger = LoggerFactory.getLogger(PinyouReportHandler.class);
@Autowired
private ClickActionDispatcher dispatcher;
@Autowired
IPinYouService pinYouService;
@Autowired
private IOrdersMapper ordersMapper;
@Autowired
private IOrdersGoodsMapper ordersGoodsMapper;
@PostConstruct
public void init() {
dispatcher.register(ClickEventConstants.YB_MAIN_S, this);
dispatcher.register(ClickEventConstants.YB_GDS_DT_INFO, this);
dispatcher.register(ClickEventConstants.YB_GDS_DT_SEL, this);
dispatcher.register(ClickEventConstants.YB_SC_ORD, this);
}
@Override
public void process(JSONObject actionData) {
logger.info("click event: {}", actionData.toJSONString());
String uid = actionData.getString("uid");
if(StringUtils.isEmpty(uid)) {
logger.info("none uid data ignore");
return;
}
//3个月内存在已交寄订单,则不上报数据
int orderNums = statShipOrdersNumLast3Months(Integer.valueOf(uid));
if(orderNums > 0) {
logger.info("click event ignore, uid: {}, orderNums: {}", uid, orderNums);
return;
}
String opr = actionData.getString("op") == null ? "" : actionData.getString("op").toUpperCase();
switch(opr) {
case ClickEventConstants.YB_MAIN_S:
case ClickEventConstants.YB_GDS_DT_INFO:
case ClickEventConstants.YB_GDS_DT_SEL:
ViewPinYouRequestBO viewBO = getPinyouViewData(opr, actionData);
pinYouService.sendView(viewBO);
break;
case ClickEventConstants.YB_SC_ORD:
TransPinYouRequestBO transBO = getPinyouTransData(opr, actionData);
pinYouService.sendTrans(transBO);
break;
}
}
/**
* 解析品友行为数据
* @param opr
* @param actionData
* @return
*/
private ViewPinYouRequestBO getPinyouViewData(String opr, JSONObject actionData) {
JSONObject paramData = actionData.getJSONObject("param");
String eventName = null;
String eventValue = null;
switch(opr) {
case ClickEventConstants.YB_MAIN_S:
eventName = "viewSearch";
eventValue = paramData == null ? "" : paramData.getString("KW");
break;
case ClickEventConstants.YB_GDS_DT_INFO:
eventName = "viewItem";
eventValue = paramData == null ? "" : paramData.getString("PRD_ID");
break;
case ClickEventConstants.YB_GDS_DT_SEL:
eventName = "addCart";
eventValue = paramData == null ? "" : paramData.getString("PRD_SKC");
break;
}
if(eventName == null || eventValue == null)
return null;
ViewPinYouRequestBO viewRequest = new ViewPinYouRequestBO();
viewRequest.setEvent(eventName);
viewRequest.setEvent_value(eventValue);
viewRequest.setUser_id(actionData.getString("uid"));
viewRequest.setOs(actionData.getString("os"));
viewRequest.setIp(actionData.getString("ip"));
viewRequest.setIdfa(actionData.getString("idfa"));
viewRequest.setImei(actionData.getString("imei"));
viewRequest.setTs(actionData.getString("ts"));
return viewRequest;
}
/**
* 解析品友转化数据
* @param actionData
* @return
*/
private TransPinYouRequestBO getPinyouTransData(String opr, JSONObject actionData) {
if(!StringUtils.equalsIgnoreCase(ClickEventConstants.YB_SC_ORD, opr)) {
return null;
}
TransPinYouRequestBO transRequest = new TransPinYouRequestBO();
String orderCode = actionData.getJSONObject("param") == null ? null : actionData.getJSONObject("param").getString("ORD_NUM");
String uid = actionData.getString("uid");
if(orderCode == null || uid == null) {
return null;
}
Orders orders = ordersMapper.selectByUidAndOrderCode(Integer.valueOf(uid), Long.valueOf(orderCode));
List<OrdersGoods> orderGoodsList = ordersGoodsMapper.selectOrderGoodsByOrder(Integer.valueOf(uid), Long.valueOf(orderCode));
if(orders == null || orderGoodsList == null) {
return null;
}
StringBuilder plistBuf = new StringBuilder();
int count = 0;
for(OrdersGoods ordersGoods : orderGoodsList) {
if(count > 0)
plistBuf.append(":");
plistBuf.append(ordersGoods.getProductSkn()).append(",").append(ordersGoods.getNum());
count++;
}
transRequest.setEvent("createOrder");
transRequest.setEvent_value(orderCode);
transRequest.setUser_id(actionData.getString("uid"));
transRequest.setOs(actionData.getString("os"));
transRequest.setIp(actionData.getString("ip"));
transRequest.setIdfa(actionData.getString("idfa"));
transRequest.setImei(actionData.getString("imei"));
transRequest.setTs(actionData.getString("ts"));
transRequest.setOrder(orderCode);
transRequest.setMoney(orders.getAmount().setScale(2, BigDecimal.ROUND_HALF_EVEN).toString());
transRequest.setPlist(plistBuf.toString());
transRequest.setOrderStatus("Y".equals(orders.getPaymentStatus()) ? "1" : "0");
return transRequest;
}
private int statShipOrdersNumLast3Months(int uid) {
//缓存
return ordersMapper.selectCountShipStatusOrderSince(uid, TimeUtils.getTimeStamp3MonthAgo());
}
}
... ...
... ... @@ -92,6 +92,9 @@ public class PinYouServiceImpl implements IPinYouService {
*/
@Override
public UnionResponse sendView(ViewPinYouRequestBO requestBO) {
if(null == requestBO)
return new UnionResponse();
//广告主信息
String advertiser = "MC.LF";
//操作系统信息
... ... @@ -161,6 +164,9 @@ public class PinYouServiceImpl implements IPinYouService {
}
public UnionResponse sendTrans(TransPinYouRequestBO requestBO) {
if(null == requestBO)
return new UnionResponse();
//广告主信息
String advertiser = "MC.LF";
//操作系统信息
... ...
... ... @@ -22,8 +22,11 @@ import java.util.List;
/**
* 定时从大数据的redis中捞取数据,然后推送给品友
* Created by yoho on 2016/11/15.
*
* Modify on 2017/04/18
* 修改:去掉此定时任务,改为监听kafka实时上报品友
*/
@Component
//@Component
public class PinYouTask {
static Logger log = LoggerFactory.getLogger(PinYouTask.class);
... ... @@ -42,7 +45,7 @@ public class PinYouTask {
/**
* 每天早上6点执行
*/
@Scheduled(cron = "0 0/2 6,7 * * ?")
//@Scheduled(cron = "0 0/2 6,7 * * ?")
public void run(){
log.info("begin run pinyoutask");
DynamicStringProperty taskHostPro = DynamicPropertyFactory.getInstance().getStringProperty("union.host", "172.31.16.99");
... ...
... ... @@ -124,70 +124,4 @@
<entry key="channelUserServiceImpl" value-ref="channelUserServiceImpl"/>
</util:map>
<!-- kafka consumer -->
<!-- 定义consumer的参数 -->
<bean id="consumerProperties" class="java.util.HashMap">
<constructor-arg>
<map>
<entry key="bootstrap.servers" value="${bootstrap-consumer.servers}" />
<entry key="group.id" value="union_rec" />
<entry key="enable.auto.commit" value="false"/>
<entry key="key.deserializer" value="org.apache.kafka.common.serialization.StringDeserializer" />
<entry key="value.deserializer" value="org.apache.kafka.common.serialization.StringDeserializer" />
</map>
</constructor-arg>
</bean>
<!-- 创建consumerFactory bean -->
<bean id="kafkaConsumerFactory" class="org.springframework.kafka.core.DefaultKafkaConsumerFactory">
<constructor-arg>
<ref bean="consumerProperties" />
</constructor-arg>
</bean>
<bean id="kafkaConsumer" class="com.yoho.unions.server.mqconsumer.KafkaConsumer">
</bean>
<!-- 消费者容器配置信息 -->
<bean id="containerProperties" class="org.springframework.kafka.listener.config.ContainerProperties">
<constructor-arg name="topics" value="yoho_log_mobile" /> <!-- yoho_log_mobile/test -->
<property name="messageListener" ref="kafkaConsumer" />
</bean>
<bean id="messageListenerContainer" class="org.springframework.kafka.listener.KafkaMessageListenerContainer"
init-method="doStart">
<constructor-arg ref="kafkaConsumerFactory" />
<constructor-arg ref="containerProperties" />
</bean>
<!-- kafka consumer -->
<!-- 定义producer的参数 -->
<bean id="producerProperties" class="java.util.HashMap">
<constructor-arg>
<map>
<entry key="bootstrap.servers" value="${bootstrap-producer.servers}" />
<entry key="group.id" value="union_rec" />
<entry key="key.serializer" value="org.apache.kafka.common.serialization.StringSerializer" />
<entry key="value.serializer" value="org.apache.kafka.common.serialization.StringSerializer" />
</map>
</constructor-arg>
</bean>
<!-- 创建kafkatemplate需要使用的producerfactory bean -->
<bean id="producerFactory" class="org.springframework.kafka.core.DefaultKafkaProducerFactory">
<constructor-arg>
<ref bean="producerProperties" />
</constructor-arg>
</bean>
<!-- 创建kafkatemplate bean,使用的时候,只需要注入这个bean,即可使用template的send消息方法 -->
<bean id="KafkaTemplate" class="org.springframework.kafka.core.KafkaTemplate">
<constructor-arg ref="producerFactory" />
<constructor-arg name="autoFlush" value="true" />
<property name="defaultTopic" value="yoho_log_mobile" /> <!-- yoho_log_mobile/test -->
</bean>
<!--kafak product-->
</beans>
... ...
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- kafka consumer -->
<!-- 定义consumer的参数 -->
<bean id="consumerProperties" class="java.util.HashMap">
<constructor-arg>
<map>
<entry key="bootstrap.servers" value="${bootstrap-consumer.servers}" />
<entry key="group.id" value="union_rec" />
<entry key="enable.auto.commit" value="false"/>
<entry key="key.deserializer" value="org.apache.kafka.common.serialization.StringDeserializer" />
<entry key="value.deserializer" value="org.apache.kafka.common.serialization.StringDeserializer" />
</map>
</constructor-arg>
</bean>
<!-- 创建consumerFactory bean -->
<bean id="kafkaConsumerFactory" class="org.springframework.kafka.core.DefaultKafkaConsumerFactory">
<constructor-arg>
<ref bean="consumerProperties" />
</constructor-arg>
</bean>
<bean id="kafkaConsumer" class="com.yoho.unions.kafka.consumer.ClickStreamConsumer" />
<!-- 消费者容器配置信息 -->
<bean id="containerProperties" class="org.springframework.kafka.listener.config.ContainerProperties">
<constructor-arg name="topics" value="rec_unions_topic" />
<property name="messageListener" ref="kafkaConsumer" />
</bean>
<bean id="messageListenerContainer" class="org.springframework.kafka.listener.KafkaMessageListenerContainer"
init-method="doStart">
<constructor-arg ref="kafkaConsumerFactory" />
<constructor-arg ref="containerProperties" />
</bean>
<!-- kafka consumer -->
<!-- 定义producer的参数 -->
<bean id="producerProperties" class="java.util.HashMap">
<constructor-arg>
<map>
<entry key="bootstrap.servers" value="${bootstrap-producer.servers}" />
<entry key="key.serializer" value="org.apache.kafka.common.serialization.StringSerializer" />
<entry key="value.serializer" value="org.apache.kafka.common.serialization.StringSerializer" />
</map>
</constructor-arg>
</bean>
<!-- 创建kafkatemplate需要使用的producerfactory bean -->
<bean id="producerFactory" class="org.springframework.kafka.core.DefaultKafkaProducerFactory">
<constructor-arg>
<ref bean="producerProperties" />
</constructor-arg>
</bean>
<!-- 创建kafkatemplate bean,使用的时候,只需要注入这个bean,即可使用template的send消息方法 -->
<bean id="KafkaTemplate" class="org.springframework.kafka.core.KafkaTemplate">
<constructor-arg ref="producerFactory" />
<constructor-arg name="autoFlush" value="true" />
<property name="defaultTopic" value="rec_unions_topic" />
</bean>
<!--kafak product-->
</beans>
\ No newline at end of file
... ...
... ... @@ -67,5 +67,27 @@ datasources:
- com.yoho.unions.dal.IChannelUserDAO
- com.yoho.unions.dal.AppAdSourceMonitorAnaMapper
yh_orders_split:
servers:
- 127.0.0.1:8066
- 127.0.0.1:8066
username: yh_test
password: 9nm0icOwt6bMHjMusIfMLw==
cobar: true
maxConnections: 80
minIdle: 20
maxIdle: 40
daos:
- com.yoho.yhorder.dal.IShoppingCartDAO
- com.yoho.yhorder.dal.IShoppingCartItemsDAO
- com.yoho.yhorder.dal.IOrdersMapper
- com.yoho.yhorder.dal.IOrdersGoodsMapper
- com.yoho.yhorder.dal.OrdersCouponsMapper
- com.yoho.yhorder.dal.OrderPromotionInfoMapper
- com.yoho.yhorder.dal.IOrderExtAttributeDAO
- com.yoho.yhorder.dal.IOrdersMetaDAO
- com.yoho.yhorder.dal.CrfPayLogMapper
- com.yoho.yhorder.dal.CmbNetpayBindMapper
readOnlyInSlave: true
\ No newline at end of file
... ...
... ... @@ -75,4 +75,28 @@ datasources:
daos:
- com.yoho.unions.dal.IMobilePanChannelDAO
yh_orders_split:
servers:
- ${jdbc.mysql.yhorderssplit.master}
- ${jdbc.mysql.yhorderssplit.slave}
- ${jdbc.mysql.yhorderssplit.slave2}
- ${jdbc.mysql.yhorderssplit.slave3}
username: ${jdbc.mysql.yhorderssplit.username}
password: ${jdbc.mysql.yhorderssplit.password}
cobar: true
maxConnections: 80
minIdle: 20
maxIdle: 40
daos:
- com.yoho.yhorder.dal.IShoppingCartDAO
- com.yoho.yhorder.dal.IShoppingCartItemsDAO
- com.yoho.yhorder.dal.IOrdersMapper
- com.yoho.yhorder.dal.IOrdersGoodsMapper
- com.yoho.yhorder.dal.OrdersCouponsMapper
- com.yoho.yhorder.dal.OrderPromotionInfoMapper
- com.yoho.yhorder.dal.IOrderExtAttributeDAO
- com.yoho.yhorder.dal.IOrdersMetaDAO
- com.yoho.yhorder.dal.CrfPayLogMapper
- com.yoho.yhorder.dal.CmbNetpayBindMapper
readOnlyInSlave: true
\ No newline at end of file
... ...
... ... @@ -18,7 +18,10 @@ public class KafakTest {
private KafkaTemplate<Integer, String> kafkaTemplate;
@Test
public void kafakTest(){
kafkaTemplate.sendDefault("test");
public void kafakTest() throws Exception {
System.out.println("++++======");
kafkaTemplate.sendDefault("{\"uid\":\"5241677\",\"ts\":\"1492490377300\",\"param\":{\"C_ID\":\"2\",\"AB_TYPE\":\"A\",\"PRD_ID\":\"647554\"},\"os\":\"iOS\",\"op\":\"YB_GDS_DT_INFO\",\"imei\":\"b52d90b970a7a59\",\"udid\":\"b52d90b970a7a59e5a91f9f924e6b5ead11cfbec\",\"ip\":\"223.104.94.245\",\"idfa\":\"9F5E72D9-FECC-49DD-915F-680417D2B25F\"}");
Thread.sleep(3000);
}
}
... ...