|
|
@@ -0,0 +1,149 @@
|
|
|
+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 com.uas.platform.b2b.dao.GrowthDao;
|
|
|
+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;
|
|
|
+
|
|
|
+ @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();
|
|
|
+
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+
|
|
|
+}
|