Commit f6f65d75 by Huang Linyu

排行榜数据更新查询

parent b60e547d
......@@ -21,8 +21,8 @@ public class ActiveCustomerDao extends GenericHibernateDao<ActiveCustomer, Integ
public Integer insertOne(ActiveCustomerBean bean) {
StringBuilder sql = new StringBuilder("INSERT INTO active_customer (saleMobile,customerName,customerMobile,picUrl,sex,createTime,updateTime)")
.append("VALUES('"+bean.getSaleMobile()+"','"+bean.getCustomerName()+"','"+bean.getCustomerMobile()+"','"+bean.getPicUrl()+"','"+bean.getSex()+"',NOW(),NOW());")
StringBuilder sql = new StringBuilder("INSERT INTO active_customer (productName,saleMobile,customerName,customerMobile,picUrl,sex,createTime,updateTime)")
.append("VALUES('"+bean.getProductName()+"','"+bean.getSaleMobile()+"','"+bean.getCustomerName()+"','"+bean.getCustomerMobile()+"','"+bean.getPicUrl()+"','"+bean.getSex()+"',NOW(),NOW());")
;
Query query = getSession().createSQLQuery(sql.toString());
return query.executeUpdate();
......
......@@ -1250,12 +1250,23 @@ public class UserExtDao extends GenericHibernateDao<UserExt, Integer> {
public List<RecommendRankBean> getRanking980() {
StringBuffer sql = new StringBuffer("");
sql.append("SELECT b.recommendUid inviterUid,c.UserName inviterUserName,COUNT(CASE WHEN a.amount=980 THEN a.orderId END) AS myNum1,");
sql.append(" COUNT(CASE WHEN a.amount=360 THEN a.orderId END) AS myNum2");
sql.append(" FROM ord_order a LEFT JOIN ord_communeitem b ON a.orderId = b.orderId ");
sql.append(" LEFT JOIN bsc_userext c ON b.recommendUid = c.uid");
sql.append(" SELECT DISTINCT q.uid inviterUid,q.username inviterUserName,");
sql.append(" COUNT(CASE WHEN p.productName='980.00' THEN p.customerMobile END) AS myNum1, ");
sql.append(" COUNT(CASE WHEN p.productName='360.00' THEN p.customerMobile END) AS myNum2");
sql.append(" FROM(");
sql.append(" SELECT a.saleMobile,a.customerMobile ,CONCAT(a.productName,'.00') AS productName");
sql.append(" FROM active_customer a");
sql.append(" UNION ");
sql.append(" SELECT d.bindedMobilePhone AS customerMobile,c.bindedMobilePhone AS saleMobile,CONCAT(a.amount) AS productName");
sql.append(" FROM ord_order a LEFT JOIN ord_communeitem b ON a.orderId = b.orderId");
sql.append(" LEFT JOIN bsc_userext c ON a.uid = c.uid");
sql.append(" LEFT JOIN bsc_userext d ON b.recommendUid = d.uid");
sql.append(" WHERE a.orderDate >'2018-10-10 23:59:59' AND OrderCategory = 13 AND ProcessStatus & 16=16 AND platform = 'MP'");
sql.append(" GROUP BY b.recommendUid ORDER BY myNum1 DESC");
sql.append(" ) p ");
sql.append(" LEFT JOIN bsc_userext q ON p.saleMobile = q.bindedMobilePhone");
sql.append(" GROUP BY p.saleMobile");
sql.append(" ORDER BY myNum1 DESC");
sql.append(" ");
Query query = getSession().createSQLQuery(sql.toString())
......
......@@ -26,6 +26,7 @@ public class ActiveCustomer implements java.io.Serializable{
private Integer id ;
private String productName;
private String saleMobile;
private String customerName;
private String customerMobile;
......@@ -45,7 +46,14 @@ public class ActiveCustomer implements java.io.Serializable{
this.id = id;
}
@Column(name = "saleMobile", length = 20)
@Column(name = "productName", length = 100)
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
@Column(name = "saleMobile", length = 20)
public String getSaleMobile() {
return saleMobile;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment