Browse Source

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@770 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d

administrator 11 years ago
parent
commit
f3736193a8

+ 5 - 2
src/main/java/com/uas/platform/b2b/controller/EnterpriseController.java

@@ -1,5 +1,7 @@
 package com.uas.platform.b2b.controller;
 
+import java.util.List;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -7,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import com.uas.platform.b2b.model.Enterprise;
+import com.uas.platform.b2b.model.GrowthProcess;
 import com.uas.platform.b2b.service.EnterpriseService;
 import com.uas.platform.b2b.service.GrowthService;
 import com.uas.platform.b2b.service.UserService;
@@ -51,8 +54,8 @@ public class EnterpriseController {
 	 */
 	@RequestMapping(value = "/growth", method = RequestMethod.GET)
 	@ResponseBody
-	public void getGrowth() {
-
+	public List<GrowthProcess> getGrowth() {
+		return growthService.findAllProcess();
 	}
 
 }

+ 2 - 0
src/main/java/com/uas/platform/b2b/dao/CommonDao.java

@@ -45,5 +45,7 @@ public class CommonDao {
 	public <T> List<T> query(String sql, Class<T> elementType, Object... args) {
 		return this.jdbcTemplate.query(sql, new BeanPropertyRowMapper<T>(elementType), args);
 	}
+	
+	
 
 }

+ 5 - 1
src/main/java/com/uas/platform/b2b/dao/GrowthProcessDao.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.jpa.repository.query.Procedure;
 import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 
@@ -18,7 +19,10 @@ public interface GrowthProcessDao extends JpaRepository<GrowthProcess, Long> {
 	 * @param enUU
 	 * @return
 	 */
-	@Query("from GrowthProcess g where g.enUU = :enUU order by g.date desc")
+	@Query("from GrowthProcess g where g.enUU = :enUU order by g.date")
 	public List<GrowthProcess> findByEnUU(@Param("enUU") long enUU);
 
+	@Procedure(procedureName = "log_growth")
+	public void updateProcess(@Param("enUU") long enUU);
+
 }

+ 35 - 3
src/main/java/com/uas/platform/b2b/model/Growth.java

@@ -40,9 +40,41 @@ public class Growth {
 	private Short hasOrder;
 
 	/**
-	 * 销售总额
+	 * 销售等级
 	 */
-	@Column(name = "grow_total")
-	private Double saleTotal;
+	@Column(name = "grow_level")
+	private Short level;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Long getEnUU() {
+		return enUU;
+	}
+
+	public void setEnUU(Long enUU) {
+		this.enUU = enUU;
+	}
+
+	public Short getHasOrder() {
+		return hasOrder;
+	}
+
+	public void setHasOrder(Short hasOrder) {
+		this.hasOrder = hasOrder;
+	}
+
+	public Short getLevel() {
+		return level;
+	}
+
+	public void setLevel(Short level) {
+		this.level = level;
+	}
 
 }

+ 6 - 121
src/main/java/com/uas/platform/b2b/service/impl/GrowthServiceImpl.java

@@ -1,149 +1,34 @@
 package com.uas.platform.b2b.service.impl;
 
-import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
-import com.uas.platform.b2b.dao.GrowthDao;
+import com.uas.platform.b2b.dao.CommonDao;
 import com.uas.platform.b2b.dao.GrowthProcessDao;
-import com.uas.platform.b2b.dao.PurchaseOrderDao;
-import com.uas.platform.b2b.dao.SaleSendDao;
-import com.uas.platform.b2b.model.Enterprise;
-import com.uas.platform.b2b.model.Growth;
 import com.uas.platform.b2b.model.GrowthProcess;
-import com.uas.platform.b2b.model.PurchaseOrder;
 import com.uas.platform.b2b.service.GrowthService;
 import com.uas.platform.b2b.support.SystemSession;
 
 @Service
 public class GrowthServiceImpl implements GrowthService {
 
-	@Autowired
-	private GrowthDao growthDao;
-
 	@Autowired
 	private GrowthProcessDao growthProcessDao;
 
 	@Autowired
-	private SaleSendDao saleSendDao;
-
-	@Autowired
-	private PurchaseOrderDao purchaseOrderDao;
-
-	@Autowired
-	private com.uas.platform.b2b.history.dao.PurchaseOrderDao purchaseOrderHisDao;
-
-	/**
-	 * 销售额度成长阶
-	 */
-	private static final double SALE_STEP_1 = 10000000D;
-	private static final double SALE_STEP_2 = 100000000D;
-	private static final double SALE_STEP_3 = 1000000000D;
-	private static final double SALE_STEP_4 = 10000000000D;
-	private static final double SALE_STEP_5 = 100000000000D;
-	private static final double SALE_STEP_6 = 1000000000000D;
-	private static final double SALE_STEP_7 = 10000000000000D;
+	private CommonDao commonDao;
 
 	@Override
 	public List<GrowthProcess> findAllProcess() {
 		long enUU = SystemSession.getUser().getEnterprise().getUu();
-		Growth growth = growthDao.findByEnUU(enUU);
-		if (growth == null) {
-			growth = new Growth();
-			List<GrowthProcess> processes = new ArrayList<GrowthProcess>();
-			processes.add(getSignupProcess());
-			GrowthProcess orderProcess = getFirstOrderProcess();
-			if (orderProcess != null) {
-				processes.add(orderProcess);
-				
-			}
-		}
-		return growthProcessDao.findAll();
-	}
-
-	/**
-	 * 企业注册
-	 * 
-	 * @return
-	 */
-	private GrowthProcess getSignupProcess() {
-		Enterprise enterprise = SystemSession.getUser().getEnterprise();
-		GrowthProcess signupProcess = new GrowthProcess();
-		signupProcess.setDate(enterprise.getEnDate());
-		signupProcess.setEnUU(enterprise.getUu());
-		signupProcess.setTitle("注册加入到优软商务平台");
-		signupProcess.setType("user");
-		return signupProcess;
-	}
-
-	/**
-	 * 收到的第一份采购合同
-	 * 
-	 * @return
-	 */
-	private GrowthProcess getFirstOrderProcess() {
-		GrowthProcess orderProcess = null;
-//		long enUU = SystemSession.getUser().getEnterprise().getUu();
-//		com.uas.platform.b2b.history.model.PurchaseOrder orderHis = purchaseOrderHisDao.findFirst(enUU);
-//		if (orderHis != null) {
-//			orderProcess = new GrowthProcess();
-//			orderProcess.setDate(orderHis.getDate());
-//			orderProcess.setEnUU(enUU);
-//			orderProcess.setTitle("收到了第一份客户采购单<a href=\"#/sale/order/" + orderHis.getId() + "\" target=\"_blank\">" + orderHis.getCode()
-//					+ "</a>");
-//			orderProcess.setDescription("客户:" + orderHis.getEnterprise().getEnName() + ",币别:" + orderHis.getCurrency() + ",付款方式:"
-//					+ orderHis.getPayments());
-//			orderProcess.setDetail("#/sale/order/" + orderHis.getId());
-//			orderProcess.setType("order");
-//		} else {
-//			PurchaseOrder order = purchaseOrderDao.findFirst(enUU);
-//			if (order != null) {
-//				orderProcess = new GrowthProcess();
-//				orderProcess.setDate(order.getDate());
-//				orderProcess.setEnUU(enUU);
-//				orderProcess.setTitle("收到了第一份客户采购单<a href=\"#/sale/order/" + order.getId() + "\" target=\"_blank\">" + order.getCode()
-//						+ "</a>");
-//				orderProcess.setDescription("客户:" + order.getEnterprise().getEnName() + ",币别:" + order.getCurrency() + ",付款方式:"
-//						+ order.getPayments());
-//				orderProcess.setDetail("#/sale/order/" + order.getId());
-//				orderProcess.setType("order");
-//			}
-//		}
-		return orderProcess;
-	}
-	
-	/**
-	 * 出货历程
-	 * @return
-	 */
-	private List<GrowthProcess> getSaleProcesses() {
-		List<GrowthProcess> processes = null;
-		Double total = getSaleTotal();
-		if(total != null && total >= SALE_STEP_1) {
-			GrowthProcess process1 = new GrowthProcess();
-			
+		List<GrowthProcess> processes = growthProcessDao.findByEnUU(enUU);
+		if (CollectionUtils.isEmpty(processes)) {
+			growthProcessDao.updateProcess(enUU);
 		}
 		return processes;
 	}
-	
-	private GrowthProcess getSaleStepProcess(double actual, double step) {
-		GrowthProcess process = null;
-		if(actual >= step) {
-			process = new GrowthProcess();
-		}
-		return process;
-	}
-
-	/**
-	 * 计算出货总额
-	 * 
-	 * @return
-	 */
-	private Double getSaleTotal() {
-		return saleSendDao.summaryByPriceAndQty(SystemSession.getUser().getEnterprise().getUu());
-	}
 
 }

+ 3 - 3
src/main/resources/spring/context.xml

@@ -2,9 +2,9 @@
 	xmlns:context="http://www.springframework.org/schema/context"
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
 	xmlns:cache="http://www.springframework.org/schema/cache"
-	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd   
-	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
-	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd   
+	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
+	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
 	http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd">
 
 	<context:property-placeholder location="classpath*:*.properties" />

+ 17 - 2
src/main/webapp/resources/js/index/app.js

@@ -1,6 +1,6 @@
-define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'service/Account', 'ui.router', 'ui.bootstrap' , 'file-upload'], function() {
+define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'service/Account', 'ui.router', 'ui.bootstrap' , 'file-upload', 'ngSanitize'], function() {
 	'use strict';
-	var app = angular.module('myApp', [ 'toaster', 'angularCharts', 'ngTable', 'ui.router', 'common.services', 'PurcServices', 'AccountServices', 'ui.bootstrap', 'angularFileUpload']);
+	var app = angular.module('myApp', [ 'toaster', 'angularCharts', 'ngTable', 'ui.router', 'common.services', 'PurcServices', 'AccountServices', 'ui.bootstrap', 'angularFileUpload', 'ngSanitize']);
 	app.init = function() {
 		angular.bootstrap(document, [ 'myApp' ]);
 	};
@@ -1881,6 +1881,21 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'ser
 		AccountEnterprise.get({}, function(data){
 			$scope.enterprise = data;
 		});
+		AccountEnterprise.growth({}, function(data){
+			if(data != null && data.length > 0) {
+				var growth = [], years = [];
+				angular.forEach(data, function(d){
+					var date = new Date(d.date), year = date.getFullYear();
+					d.date = (date.getMonth() + 1) + '月' + (date.getDate()) + '日';
+					if(years.indexOf(year) == -1) {
+						years.push(year);
+						growth.push({year: year});
+					}
+					growth.push(d);
+				});
+				$scope.growth = growth;
+			}
+		});
 	});
 	
 	app.controller('UserCtrl', function($scope, $rootScope, $filter, AuthenticationService, AccountUser, BaseService, ngTableParams, toaster, $modal, $http){

+ 3 - 1
src/main/webapp/resources/js/index/main.js

@@ -14,7 +14,8 @@ require.config({
 		'file-upload' : 'lib/angular/angular-file-upload.min',
 		'file-upload-shim' : 'lib/angular/angular-file-upload-shim.min',
 		'ngTable' : 'lib/angular/ng-table',
-		'ngResource' : 'lib/angular/angular-resource.min'
+		'ngResource' : 'lib/angular/angular-resource.min',
+		'ngSanitize': 'lib/angular/angular-sanitize.min'
 	},
 	shim : {
 		'angular' : {
@@ -22,6 +23,7 @@ require.config({
 		},
 		'ngAnimate' : ['angular'],
 		'ngResource' : ['angular'],
+		'ngSanitize' : ['angular'],
 		'toaster' : ['angular', 'ngAnimate'],
 		'charts' : ['angular', 'd3'],
 		'ui.router' : ['angular'],

+ 6 - 1
src/main/webapp/resources/js/index/services/Account.js

@@ -1,6 +1,11 @@
 define([ 'ngResource' ], function() {
 	angular.module('AccountServices', [ 'ngResource' ]).factory('AccountEnterprise', function($resource) {
-		return $resource('account/enterprise', {});
+		return $resource('account/enterprise', {}, {
+			growth: {
+				url: 'account/enterprise/growth',
+				isArray: true
+			}
+		});
 	}).factory('AccountUser', function($resource) {
 		return $resource('account/user', {}, {
 			getAll: {

+ 17 - 66
src/main/webapp/resources/tpl/index/account/enterprise.html

@@ -101,76 +101,27 @@
 	</div>
 	<div class="pane-body">
 		<dl class="events">
-			<dd>
-				<div class="year">
-					2014<span class="character">年</span>
-				</div>
-				<div class="icon year-icon"></div>
-			</dd>
-			<dd>
-				<div class="date">8月11日</div>
-				<div class="icon">
-					<i class="fa fa-user"></i>
-				</div>
-				<div class="event">
-					<div class="event_tit-wrapper">
-						<div class="event_tit">注册加入到优软商务平台</div>
-					</div>
-				</div>
-			</dd>
-			<dd>
-				<div class="date">8月15日</div>
-				<div class="icon">
-					<i class="fa fa-shopping-cart"></i>
-				</div>
-				<div class="event">
-					<div class="event_tit-wrapper">
-						<div class="event_tit">
-							收到了第一份客户采购单<a href="#" target="_blank">MP14080001</a>
-						</div>
-					</div>
-					<div class="event_cnt">
-						采购单<a href="#" target="_blank">MP14080001</a>,客户:天派电子(深圳)有限公司,币别:RMB,付款方式:货到付款<a
-							href="#" target="_blank" class="pull-right">详细&gt;&gt;</a>
+			<dd ng-repeat="grow in growth">
+				<div ng-if="grow.year">
+					<div class="year">
+						<span ng-bind="::grow.year"></span><span class="character">年</span>
 					</div>
+					<div class="icon year-icon"></div>
 				</div>
-			</dd>
-			<dd>
-				<div class="date">9月11日</div>
-				<div class="icon">
-					<i class="fa fa-line-chart"></i>
-				</div>
-				<div class="event">
-					<div class="event_tit-wrapper">
-						<div class="event_tit">
-							销售额突破<span class="text-inverse">1,000</span>万元
-						</div>
-						<div class="event_cnt">
-							截止2014年9月11日,统计平台的发货单金额累计达到1,200万元<a href="#" target="_blank"
-								class="pull-right">详细&gt;&gt;</a>
-						</div>
+				<div ng-if="grow.title">
+					<div class="date" ng-bind="::grow.date"></div>
+					<div class="icon">
+						<i class="fa"
+							ng-class="{'fa-user':grow.type=='about-user','fa-shopping-cart':grow.type=='about-order','fa-line-chart':grow.type=='about-sale'}"></i>
 					</div>
-				</div>
-			</dd>
-			<dd>
-				<div class="year">
-					2015<span class="character">年</span>
-				</div>
-				<div class="icon year-icon"></div>
-			</dd>
-			<dd>
-				<div class="date">5月11日</div>
-				<div class="icon">
-					<i class="fa fa-line-chart"></i>
-				</div>
-				<div class="event">
-					<div class="event_tit-wrapper">
-						<div class="event_tit">
-							销售额突破<span class="text-inverse">10,000</span>万元
+					<div class="event">
+						<div class="event_tit-wrapper">
+							<div class="event_tit" ng-bind-html="::grow.title"></div>
 						</div>
-						<div class="event_cnt">
-							截止2015年9月11日,统计平台的发货单金额累计达到10,800万元<a href="#" target="_blank"
-								class="pull-right">详细&gt;&gt;</a>
+						<div class="event_cnt" ng-if="grow.description">
+							<span ng-bind-html="::grow.description"></span> <a
+								href="#{{::grow.detail}}" target="_blank" class="pull-right"
+								ng-if="grow.detail">详细&gt;&gt;</a>
 						</div>
 					</div>
 				</div>