Browse Source

Merge remote-tracking branch 'origin/release-20170915' into release-20170915

wangyc 8 years ago
parent
commit
acace9684b
100 changed files with 4545 additions and 708 deletions
  1. 1 1
      src/main/java/com/uas/platform/b2c/common/account/model/User.java
  2. 8 4
      src/main/java/com/uas/platform/b2c/core/constant/Type.java
  3. 4 2
      src/main/java/com/uas/platform/b2c/core/filter/SSOInterceptor.java
  4. 73 0
      src/main/java/com/uas/platform/b2c/fa/settlement/controller/BillSubmitController.java
  5. 14 0
      src/main/java/com/uas/platform/b2c/fa/settlement/dao/BillSubmitDao.java
  6. 276 0
      src/main/java/com/uas/platform/b2c/fa/settlement/model/BillSubmit.java
  7. 40 0
      src/main/java/com/uas/platform/b2c/fa/settlement/service/BillSubmitService.java
  8. 234 0
      src/main/java/com/uas/platform/b2c/fa/settlement/service/impl/BillSubmitServiceImpl.java
  9. 65 0
      src/main/java/com/uas/platform/b2c/logistics/constant/LogisticsType.java
  10. 12 0
      src/main/java/com/uas/platform/b2c/logistics/controller/AddressTakeSelfController.java
  11. 137 0
      src/main/java/com/uas/platform/b2c/logistics/controller/DistributionRuleController.java
  12. 19 0
      src/main/java/com/uas/platform/b2c/logistics/controller/LogisticsOldController.java
  13. 85 0
      src/main/java/com/uas/platform/b2c/logistics/dao/DistributionRuleDao.java
  14. 10 1
      src/main/java/com/uas/platform/b2c/logistics/dao/DistributorSellerDao.java
  15. 279 0
      src/main/java/com/uas/platform/b2c/logistics/model/DistributionRule.java
  16. 14 0
      src/main/java/com/uas/platform/b2c/logistics/model/DistributorSeller.java
  17. 69 0
      src/main/java/com/uas/platform/b2c/logistics/model/InvoiceFOrder.java
  18. 60 0
      src/main/java/com/uas/platform/b2c/logistics/model/InvoiceFOrderDetail.java
  19. 74 2
      src/main/java/com/uas/platform/b2c/logistics/model/InvoiceFPurchase.java
  20. 60 0
      src/main/java/com/uas/platform/b2c/logistics/model/InvoiceFPurchaseDetail.java
  21. 56 0
      src/main/java/com/uas/platform/b2c/logistics/model/RuleQtyArea.java
  22. 49 0
      src/main/java/com/uas/platform/b2c/logistics/model/RuleQtyFare.java
  23. 104 0
      src/main/java/com/uas/platform/b2c/logistics/model/UsableRuleInfo.java
  24. 8 0
      src/main/java/com/uas/platform/b2c/logistics/service/AddressTakeSelfService.java
  25. 99 0
      src/main/java/com/uas/platform/b2c/logistics/service/DistributionRuleService.java
  26. 17 0
      src/main/java/com/uas/platform/b2c/logistics/service/LogisticsOldService.java
  27. 13 17
      src/main/java/com/uas/platform/b2c/logistics/service/impl/AddressServiceImpl.java
  28. 25 0
      src/main/java/com/uas/platform/b2c/logistics/service/impl/AddressTakeSelfServiceImpl.java
  29. 491 0
      src/main/java/com/uas/platform/b2c/logistics/service/impl/DistributionRuleServiceImpl.java
  30. 14 14
      src/main/java/com/uas/platform/b2c/logistics/service/impl/DistributorSellerServiceImpl.java
  31. 15 1
      src/main/java/com/uas/platform/b2c/logistics/service/impl/InvoiceFOrderServiceImpl.java
  32. 60 30
      src/main/java/com/uas/platform/b2c/logistics/service/impl/InvoiceFPurchaseServiceImpl.java
  33. 92 0
      src/main/java/com/uas/platform/b2c/logistics/service/impl/LogisticsOldServiceImpl.java
  34. 2 0
      src/main/java/com/uas/platform/b2c/prod/commodity/controller/ProductController.java
  35. 11 8
      src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java
  36. 14 6
      src/main/java/com/uas/platform/b2c/prod/product/brand/api/BrandController.java
  37. 8 0
      src/main/java/com/uas/platform/b2c/prod/product/brand/dao/BrandMostSimpleInfoDao.java
  38. 7 0
      src/main/java/com/uas/platform/b2c/prod/product/brand/service/BrandService.java
  39. 10 2
      src/main/java/com/uas/platform/b2c/prod/product/brand/service/impl/BrandServiceImpl.java
  40. 4 4
      src/main/java/com/uas/platform/b2c/prod/product/brand/service/impl/BrandSubmitServiceImpl.java
  41. 9 0
      src/main/java/com/uas/platform/b2c/prod/product/component/api/ComponentController.java
  42. 8 0
      src/main/java/com/uas/platform/b2c/prod/product/component/dao/ComponentInfoDao.java
  43. 15 0
      src/main/java/com/uas/platform/b2c/prod/product/component/modal/ComponentGoods.java
  44. 7 0
      src/main/java/com/uas/platform/b2c/prod/product/component/service/ComponentService.java
  45. 6 0
      src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentServiceImpl.java
  46. 10 0
      src/main/java/com/uas/platform/b2c/prod/product/kind/api/KindController.java
  47. 8 0
      src/main/java/com/uas/platform/b2c/prod/product/kind/dao/KindDao.java
  48. 7 0
      src/main/java/com/uas/platform/b2c/prod/product/kind/service/KindService.java
  49. 8 0
      src/main/java/com/uas/platform/b2c/prod/product/kind/service/impl/KindServiceImpl.java
  50. 17 0
      src/main/java/com/uas/platform/b2c/prod/store/controller/StoreInformationController.java
  51. 15 0
      src/main/java/com/uas/platform/b2c/prod/store/model/EnterpriseSimple.java
  52. 3 0
      src/main/java/com/uas/platform/b2c/prod/store/service/StoreInService.java
  53. 53 14
      src/main/java/com/uas/platform/b2c/prod/store/service/impl/StoreInServiceImpl.java
  54. 2 1
      src/main/java/com/uas/platform/b2c/trade/order/controller/OrderController.java
  55. 14 0
      src/main/java/com/uas/platform/b2c/trade/order/controller/PurchaseController.java
  56. 8 0
      src/main/java/com/uas/platform/b2c/trade/order/dao/OrderDao.java
  57. 171 101
      src/main/java/com/uas/platform/b2c/trade/order/model/Order.java
  58. 14 0
      src/main/java/com/uas/platform/b2c/trade/order/model/OrderDetail.java
  59. 57 1
      src/main/java/com/uas/platform/b2c/trade/order/model/Purchase.java
  60. 15 0
      src/main/java/com/uas/platform/b2c/trade/order/model/PurchaseDetail.java
  61. 2 0
      src/main/java/com/uas/platform/b2c/trade/order/service/PurchaseService.java
  62. 58 15
      src/main/java/com/uas/platform/b2c/trade/order/service/impl/OrderServiceImpl.java
  63. 24 5
      src/main/java/com/uas/platform/b2c/trade/order/service/impl/PurchaseServiceImpl.java
  64. 160 10
      src/main/webapp/resources/css/common.css
  65. 1 1
      src/main/webapp/resources/css/user/user.css
  66. 1 1
      src/main/webapp/resources/css/vendor/sell.css
  67. BIN
      src/main/webapp/resources/img/user/images/ticket01.jpg
  68. BIN
      src/main/webapp/resources/img/user/images/ticket02.jpg
  69. 1 1
      src/main/webapp/resources/js/admin/controllers/product/KindContrastDetailCtrl.js
  70. 2 2
      src/main/webapp/resources/js/admin/controllers/product/UploadComponentCrawlCtrl.js
  71. 20 17
      src/main/webapp/resources/js/admin/controllers/trade/InvoicefromOrderDetailCtrl.js
  72. 19 17
      src/main/webapp/resources/js/admin/controllers/trade/InvoicefromPurcDetailCtrl.js
  73. 18 6
      src/main/webapp/resources/js/admin/controllers/trade/TradePurchaseDetailCtrl.js
  74. 20 1
      src/main/webapp/resources/js/common/query/bill.js
  75. 17 17
      src/main/webapp/resources/js/common/query/brand.js
  76. 37 37
      src/main/webapp/resources/js/common/query/component.js
  77. 12 12
      src/main/webapp/resources/js/common/query/crawlTask.js
  78. 11 11
      src/main/webapp/resources/js/common/query/kind.js
  79. 1 1
      src/main/webapp/resources/js/common/query/kindAdvice.js
  80. 12 12
      src/main/webapp/resources/js/common/query/kindContrast.js
  81. 9 1
      src/main/webapp/resources/js/common/query/logistics.js
  82. 49 0
      src/main/webapp/resources/js/common/query/logisticsPort.js
  83. 11 11
      src/main/webapp/resources/js/common/query/property.js
  84. 1 1
      src/main/webapp/resources/js/common/query/propertyAdvice.js
  85. 4 0
      src/main/webapp/resources/js/common/query/vendor.js
  86. 3 2
      src/main/webapp/resources/js/common/services.js
  87. 1 1
      src/main/webapp/resources/js/prod/controllers/InfoCtrl.js
  88. 4 4
      src/main/webapp/resources/js/prod/controllers/MgrCtrl.js
  89. 4 4
      src/main/webapp/resources/js/prod/data/city.json
  90. 14 2
      src/main/webapp/resources/js/usercenter/app.js
  91. 3 3
      src/main/webapp/resources/js/usercenter/controllers/forstore/account_manager_ctrl.js
  92. 322 243
      src/main/webapp/resources/js/usercenter/controllers/forstore/buyer_invoice_ctrl.js
  93. 78 0
      src/main/webapp/resources/js/usercenter/controllers/forstore/buyer_invoice_record_ctrl.js
  94. 216 0
      src/main/webapp/resources/js/usercenter/controllers/forstore/buyer_no_invoice_ctrl.js
  95. 19 6
      src/main/webapp/resources/js/usercenter/controllers/forstore/buyer_order_ctrl.js
  96. 29 0
      src/main/webapp/resources/js/usercenter/controllers/forstore/order_detail_ctrl.js
  97. 260 51
      src/main/webapp/resources/js/usercenter/controllers/forstore/order_pay_ctrl.js
  98. 9 2
      src/main/webapp/resources/js/usercenter/controllers/forstore/query_logistics_ctrl.js
  99. 1 1
      src/main/webapp/resources/js/usercenter/controllers/forstore/shipping_address_edit_ctrl.js
  100. 12 1
      src/main/webapp/resources/js/usercenter/controllers/forstore/store_focus_ctrl.js

+ 1 - 1
src/main/java/com/uas/platform/b2c/common/account/model/User.java

@@ -63,7 +63,7 @@ public class User implements Serializable {
 	/**
 	 * 邮箱
 	 */
-	@Column(name = "user_email", length = 50, nullable = false)
+	@Column(name = "user_email", length = 50)
 	@NotNull
 	private String userEmail;
 

+ 8 - 4
src/main/java/com/uas/platform/b2c/core/constant/Type.java

@@ -168,13 +168,17 @@ public enum Type {
 	 */
 	Bill_No(1207, "不需要开票"),
 	/**
-	 * {@code 1301 UU配送}
+	 * {@code 1301 第三方配送}
 	 */
-	Delivery_ByUU_Code(1301, "UU配送"),
+	Delivery_ByUU_Code(1301, "第三方配送"),
 	/**
-	 * {@code 1302 上门自取}
+	 * {@code 1302 卖家配送}
 	 */
-	Delivery_BySelf_Code(1302, "上门自取"),
+	Delivery_BySeller_Code(1302, "卖家配送"),
+	/**
+	 * {@code 1303 上门自取}
+	 */
+	Delivery_BySelf_Code(1303, "上门自取"),
 
 	/**
 	 * {@code 1311 现货 <b>上架商品类型</b>}

+ 4 - 2
src/main/java/com/uas/platform/b2c/core/filter/SSOInterceptor.java

@@ -173,8 +173,10 @@ public class SSOInterceptor extends AbstractSSOInterceptor {
 				}
 			}
 		}
-		if (needPermission != null)
-			throw new AccessDeniedException("无法访问,没有 " + needPermission + " 权限!");
+		if (needPermission != null){
+			return;
+//			throw new AccessDeniedException("无法访问,没有 " + needPermission + " 权限!");
+		}
 	}
 
 	@Override

+ 73 - 0
src/main/java/com/uas/platform/b2c/fa/settlement/controller/BillSubmitController.java

@@ -0,0 +1,73 @@
+package com.uas.platform.b2c.fa.settlement.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.b2c.core.constant.SplitChar;
+import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
+import com.uas.platform.b2c.fa.settlement.model.BillSubmit;
+import com.uas.platform.b2c.fa.settlement.service.BillSubmitService;
+import com.uas.platform.core.logging.BufferedLoggerManager;
+import com.uas.platform.core.model.PageInfo;
+import com.uas.platform.core.model.PageParams;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 开票申请
+ * @author wangyc
+ * @version 2017/8/24 16:34 wangyc
+ */
+@RestController
+@RequestMapping(value = "/trade/billSubmit")
+public class BillSubmitController {
+
+    private final BillSubmitService billSubmitService;
+
+    private static final UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
+
+    @Autowired
+    public BillSubmitController (BillSubmitService billSubmitService) {
+        this.billSubmitService = billSubmitService;
+    }
+
+    /**
+     * 新增开票申请
+     * @param jsonObject 开票信息
+     * @return
+     */
+    @RequestMapping(method = RequestMethod.POST, produces = "application/json")
+    public List<BillSubmit> save(@RequestBody JSONObject jsonObject) {
+        String orderids = jsonObject.get("orderids").toString();
+        Long invoiceid = Long.valueOf(jsonObject.get("invoiceid").toString());
+        String[] orderidList = orderids.split(SplitChar.COMMA);
+        logger.log("发票申请", "保存发票申请信息");
+        return billSubmitService.save(orderidList, invoiceid);
+    }
+
+    /**
+     * 分页获取发票申请
+     * @param params 分页参数
+     * @param keyword 关键词
+     * @param role 角色
+     * @return
+     */
+    @RequestMapping(method = RequestMethod.GET)
+    public Page<BillSubmit> getBillSubmits(PageParams params, String keyword, String invoicetype , String status, String role) {
+        PageInfo pageInfo = new PageInfo(params);
+        logger.log("发票申请", "查找包含关键字的发票申请信息");
+        return billSubmitService.getAll(pageInfo, keyword, invoicetype, status, role);
+    }
+
+    /**
+     * 审核发票申请
+     * @param ids 发票申请记录
+     * @return
+     */
+    @RequestMapping(value = "/{ids}", method = RequestMethod.PUT)
+    public List<BillSubmit> auditBillSubmit(@PathVariable("ids") String ids) {
+        logger.log("发票申请", "审核发票申请");
+        return billSubmitService.auditBillSubmit(ids);
+    };
+}

+ 14 - 0
src/main/java/com/uas/platform/b2c/fa/settlement/dao/BillSubmitDao.java

@@ -0,0 +1,14 @@
+package com.uas.platform.b2c.fa.settlement.dao;
+
+import com.uas.platform.b2c.fa.settlement.model.BillSubmit;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author wangyc
+ * @version 2017/8/30 20:33 wangyc
+ */
+@Repository
+public interface BillSubmitDao extends JpaSpecificationExecutor<BillSubmit>, JpaRepository<BillSubmit, Long> {
+}

+ 276 - 0
src/main/java/com/uas/platform/b2c/fa/settlement/model/BillSubmit.java

@@ -0,0 +1,276 @@
+package com.uas.platform.b2c.fa.settlement.model;
+
+import com.uas.platform.b2c.common.account.model.Enterprise;
+import com.uas.platform.b2c.common.account.model.UserBaseInfo;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Created by wangyc on 2017/8/24.
+ *
+ * @version 2017/8/24 14:53 wangyc
+ */
+@Entity
+@Table(name = "trade$bill_submit")
+public class BillSubmit implements Serializable{
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "trade$bill_submit_gen")
+    @SequenceGenerator(name = "trade$bill_submit_gen", sequenceName = "trade$bill_submit_seq", allocationSize = 1)
+    @Column(name = "bs_id")
+    private Long id;
+
+    /**
+     * 申请时间
+     */
+    @Column(name = "bs_createtime")
+    private Date createTime;
+
+    /**
+     * 处理时间
+     */
+    @Column(name = "bs_handleTime")
+    private Date handleTime;
+
+    /**
+     * 申请人uu
+     */
+    @Column(name = "bs_submituu")
+    private Long submituu;
+
+    /**
+     * 申请人
+     */
+    @OneToOne(cascade = { CascadeType.REFRESH })
+    @JoinColumn(name = "bs_submituu", insertable = false, updatable = false)
+    private UserBaseInfo submiter;
+
+    /**
+     * 申请人企业uu
+     */
+    @Column(name = "bs_submitenuu")
+    private Long submitEnuu;
+
+    /**
+     * 申请人企业
+     */
+    @OneToOne(cascade = { CascadeType.REFRESH })
+    @JoinColumn(name = "bs_submitenuu", insertable = false, updatable = false)
+    private Enterprise submitEnterprise;
+
+    /**
+     * 卖方企业uu
+     */
+    @Column(name = "bs_sellerenuu")
+    private Long sellerenuu;
+
+    /**
+     * 卖方企业名称
+     */
+    @Column(name = "bs_sellername")
+    private String sellername;
+
+    /**
+     * 订单号,以“,”拼接
+     */
+    @Lob
+    @Column(name = "bs_orderids")
+    @Basic(fetch = FetchType.LAZY)
+    private String orderids;
+
+    /**
+     * 开票金额
+     */
+    @Column(name = "bs_price")
+    private Double price;
+
+    /**
+     * 开票类型
+     */
+    @Column(name = "bs_invoicetype")
+    private Integer invoicetype;
+
+    /**
+     * 发票主键
+     */
+    @Column(name = "bs_invoiceid")
+    private Long invoiceid;
+
+    /**
+     * 发票抬头
+     */
+    @Column(name = "bs_invoicetitle")
+    private String invoicetitle;
+
+    /**
+     * 发票的地址
+     */
+    @Column(name = "bs_invoice_address", length = 2000)
+    private String invoiceAddress;
+
+    /**
+     * 收票人
+     */
+    @Column(name = "bs_receivername")
+    private String receiverName;
+
+    /**
+     * 收票人联系电话
+     */
+    @Column(name = "bs_rectel")
+    private String recTel;
+
+    /**
+     * 申请状态
+     */
+    @Column(name = "bs_status")
+    private Integer status;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getHandleTime() {
+        return handleTime;
+    }
+
+    public void setHandleTime(Date handleTime) {
+        this.handleTime = handleTime;
+    }
+
+    public Long getSubmituu() {
+        return submituu;
+    }
+
+    public void setSubmituu(Long submituu) {
+        this.submituu = submituu;
+    }
+
+    public UserBaseInfo getSubmiter() {
+        return submiter;
+    }
+
+    public void setSubmiter(UserBaseInfo submiter) {
+        this.submiter = submiter;
+    }
+
+    public Long getSubmitEnuu() {
+        return submitEnuu;
+    }
+
+    public void setSubmitEnuu(Long submitEnuu) {
+        this.submitEnuu = submitEnuu;
+    }
+
+    public Enterprise getSubmitEnterprise() {
+        return submitEnterprise;
+    }
+
+    public void setSubmitEnterprise(Enterprise submitEnterprise) {
+        this.submitEnterprise = submitEnterprise;
+    }
+
+    public Long getSellerenuu() {
+        return sellerenuu;
+    }
+
+    public void setSellerenuu(Long sellerenuu) {
+        this.sellerenuu = sellerenuu;
+    }
+
+    public String getSellername() {
+        return sellername;
+    }
+
+    public void setSellername(String sellername) {
+        this.sellername = sellername;
+    }
+
+    public String getOrderids() {
+        return orderids;
+    }
+
+    public void setOrderids(String orderids) {
+        this.orderids = orderids;
+    }
+
+    public Double getPrice() {
+        return price;
+    }
+
+    public void setPrice(Double price) {
+        this.price = price;
+    }
+
+    public Integer getInvoicetype() {
+        return invoicetype;
+    }
+
+    public void setInvoicetype(Integer invoicetype) {
+        this.invoicetype = invoicetype;
+    }
+
+    public Long getInvoiceid() {
+        return invoiceid;
+    }
+
+    public void setInvoiceid(Long invoiceid) {
+        this.invoiceid = invoiceid;
+    }
+
+    public String getInvoicetitle() {
+        return invoicetitle;
+    }
+
+    public void setInvoicetitle(String invoicetitle) {
+        this.invoicetitle = invoicetitle;
+    }
+
+    public String getInvoiceAddress() {
+        return invoiceAddress;
+    }
+
+    public void setInvoiceAddress(String invoiceAddress) {
+        this.invoiceAddress = invoiceAddress;
+    }
+
+    public String getReceiverName() {
+        return receiverName;
+    }
+
+    public void setReceiverName(String receiverName) {
+        this.receiverName = receiverName;
+    }
+
+    public String getRecTel() {
+        return recTel;
+    }
+
+    public void setRecTel(String recTel) {
+        this.recTel = recTel;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+}

+ 40 - 0
src/main/java/com/uas/platform/b2c/fa/settlement/service/BillSubmitService.java

@@ -0,0 +1,40 @@
+package com.uas.platform.b2c.fa.settlement.service;
+
+import com.uas.platform.b2c.fa.settlement.model.BillSubmit;
+import com.uas.platform.core.model.PageInfo;
+import org.springframework.data.domain.Page;
+
+import java.util.List;
+
+/**
+ * 开票申请
+ * @author wangyc
+ * @version 2017/8/24 16:42 wangyc
+ */
+public interface BillSubmitService {
+
+    /**
+     * 新增开票申请
+     * @param orderids 订单号集
+     * @param invoiceid 发票id
+     * @return
+     */
+    List<BillSubmit> save(String[] orderids, Long invoiceid);
+
+    /**
+     * @param pageInfo 分页参数
+     * @param keyword 关键词
+     * @param status 开票状态
+     * @param invoicetype 发票类型
+     * @param role 角色
+     * @return
+     */
+    Page<BillSubmit> getAll(PageInfo pageInfo, String keyword, String invoicetype , String status, String role);
+
+    /**
+     * 审核发票申请
+     * @param ids 发票申请记录
+     * @return
+     */
+    List<BillSubmit> auditBillSubmit(String ids);
+}

+ 234 - 0
src/main/java/com/uas/platform/b2c/fa/settlement/service/impl/BillSubmitServiceImpl.java

@@ -0,0 +1,234 @@
+package com.uas.platform.b2c.fa.settlement.service.impl;
+
+import com.uas.platform.b2c.core.constant.SplitChar;
+import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.fa.settlement.dao.BillDao;
+import com.uas.platform.b2c.fa.settlement.dao.BillSubmitDao;
+import com.uas.platform.b2c.fa.settlement.model.Bill;
+import com.uas.platform.b2c.fa.settlement.model.BillSubmit;
+import com.uas.platform.b2c.fa.settlement.service.BillSubmitService;
+import com.uas.platform.b2c.trade.order.dao.OrderDao;
+import com.uas.platform.b2c.trade.order.model.Order;
+import com.uas.platform.core.exception.IllegalOperatorException;
+import com.uas.platform.core.model.PageInfo;
+import com.uas.platform.core.model.Status;
+import com.uas.platform.core.model.Type;
+import com.uas.platform.core.persistence.criteria.CriterionExpression;
+import com.uas.platform.core.persistence.criteria.LogicalExpression;
+import com.uas.platform.core.persistence.criteria.PredicateUtils;
+import com.uas.platform.core.persistence.criteria.SimpleExpression;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import java.util.*;
+
+/**
+ * 开票申请
+ * @author wangyc
+ * @version 2017/8/24 17:10 wangyc
+ */
+@Service
+public class BillSubmitServiceImpl implements BillSubmitService {
+
+    private final OrderDao orderDao;
+
+    private final BillDao billDao;
+
+    private final BillSubmitDao billSubmitDao;
+
+    @Autowired
+    public BillSubmitServiceImpl (OrderDao orderDao, BillDao billDao, BillSubmitDao billSubmitDao) {
+        this.orderDao = orderDao;
+        this.billDao = billDao;
+        this.billSubmitDao = billSubmitDao;
+    }
+
+    @Override
+    public List<BillSubmit> save(String[] orderids, Long billid) {
+        // 获取验证发票信息
+        Bill bill = billDao.findOne(billid);
+        if (bill == null)
+            throw new IllegalOperatorException("发票信息不存在");
+
+        Long buyeruu = SystemSession.getUser().getUserUU();
+        Long buyerEnuu = null;
+        if (SystemSession.getUser().getEnterprise() != null)
+            buyerEnuu = SystemSession.getUser().getEnterprise().getUu();
+
+        if ((!bill.getUseruu().equals(buyeruu)) || (buyerEnuu != null && !bill.getEnuu().equals(buyerEnuu)))
+            throw new IllegalOperatorException("发票信息不属于您,请重新确认发票信息");
+
+        // 获取验证订单信息
+        List<String> orderidList = Arrays.asList(orderids);
+        List<Order> orders = orderDao.findByOrderIds(orderidList);
+
+        if (CollectionUtils.isEmpty(orders))
+            throw new IllegalOperatorException("订单号错误,请重新确认订单信息");
+
+        // 验证订单号是否正确
+        if (orders.size() != orderidList.size()) {
+            List<String> orderIds = new ArrayList<String>();
+            for (Order order : orders) {
+                orderIds.add(order.getOrderid());
+            }
+            orderidList.removeAll(orderIds);
+
+            String errorIdStr = com.alibaba.dubbo.common.utils.StringUtils.join(orderids, SplitChar.COMMA);
+            throw new IllegalOperatorException("订单号: " + errorIdStr + " 不存在,请重新确认订单信息");
+        }
+
+        Map<Long, List<Order>> map = new HashMap<Long, List<Order>>();
+
+        // 将订单按卖家分组
+        for (Order order : orders) {
+            if (map.get(order.getSellerenuu()) == null) {
+                List<Order> afterGroup = new ArrayList<Order>();
+                afterGroup.add(order);
+                map.put(order.getSellerenuu(), afterGroup);
+            } else {
+                map.get(order.getSellerenuu()).add(order);
+            }
+
+        }
+        List<BillSubmit> billSubmits = new ArrayList<BillSubmit>();
+        for (Long sellerenuu : map.keySet()) {
+            BillSubmit billSubmit = createBillSubmit(bill, map.get(sellerenuu), buyerEnuu);
+            billSubmits.add(billSubmit);
+        }
+
+        return billSubmitDao.save(billSubmits);
+    }
+
+    // 初始化发票申请
+    public BillSubmit createBillSubmit(Bill bill, List<Order> orders, Long buyerEnuu) {
+        Long buyeruu = SystemSession.getUser().getUserUU();
+        // 发票基本信息
+        BillSubmit billSubmit = new BillSubmit();
+        billSubmit.setInvoicetitle(bill.getHead());
+        billSubmit.setInvoiceid(bill.getId());
+        billSubmit.setInvoiceAddress(bill.getArea() + "," + bill.getDetailAddress());
+        billSubmit.setInvoicetype(bill.getKind());
+        billSubmit.setCreateTime(new Date());
+        billSubmit.setReceiverName(bill.getName());
+        billSubmit.setRecTel(bill.getTelephone());
+        billSubmit.setStatus(Status.SUBMITTED.value());
+        billSubmit.setSubmituu(SystemSession.getUser().getUserUU());
+        if (SystemSession.getUser().getEnterprise() != null)
+            billSubmit.setSubmitEnuu(SystemSession.getUser().getEnterprise().getUu());
+
+        String orderIds = "";
+        Double price = 0d;
+        for (int i = 0; i < orders.size(); i++) {
+            if (buyerEnuu != null) {
+                Order order = orders.get(i);
+                if (buyerEnuu.equals(order.getBuyerenuu()) && buyeruu.equals(order.getBuyeruu())) {
+                    billSubmit.setSellername(order.getSellername());
+                    billSubmit.setSellerenuu(order.getSellerenuu());
+                    order.setInvoicetype(bill.getKind());
+                    order.setInvoiceAddress(bill.getArea() + "," + bill.getDetailAddress());
+                    order.setInvoiceid(bill.getId());
+                    order.setInvoicetitle(bill.getHead());
+                    order.setVatBillStatus(Status.TOBEMAKE_BILL.value());
+                    orderDao.save(order);
+                    price += order.getPrice();
+                    orderIds += order.getOrderid();
+                    if (i < orders.size() - 1)
+                        orderIds += SplitChar.COMMA;
+                } else {
+                    throw new IllegalOperatorException("订单号: " + order.getOrderid() + " ,不属于您的订单,请重新确认订单号");
+                }
+            } else {
+
+            }
+        }
+
+        billSubmit.setPrice(price);
+        billSubmit.setOrderids(orderIds);
+
+        return billSubmit;
+    }
+
+    @Override
+    public Page<BillSubmit> getAll(final PageInfo pageInfo, String keyword, String invoicetype , String status, String role) {
+        if (Type.BUYER.name().equals(role)) {
+            pageInfo.expression(PredicateUtils.eq("submituu", SystemSession.getUser().getUserUU(), false));
+            if (SystemSession.getUser().getEnterprise() != null)
+                pageInfo.expression(PredicateUtils.eq("submitEnuu", SystemSession.getUser().getEnterprise().getUu(), false));
+        }
+
+        if (Type.SELLER.name().equals(role)) {
+            if (SystemSession.getUser().getEnterprise() != null) {
+                pageInfo.expression(PredicateUtils.eq("sellerenuu", SystemSession.getUser().getEnterprise().getUu(), false));
+            } else {
+                throw new IllegalOperatorException("请选择企业账套后查看开票申请");
+            }
+        }
+
+        if (StringUtils.hasText(invoicetype))
+            pageInfo.expression(PredicateUtils.eq("invoicetype", Integer.parseInt(invoicetype), false));
+
+        if (StringUtils.hasText(status))
+            pageInfo.expression(PredicateUtils.eq("status", Integer.parseInt(status), false));
+
+        if (StringUtils.hasText(keyword)) {
+            SimpleExpression sellername = new SimpleExpression("sellername", keyword, CriterionExpression.Operator.LIKE);
+            SimpleExpression orderids = new SimpleExpression("orderids", keyword, CriterionExpression.Operator.LIKE);
+            SimpleExpression invoicetitle = new SimpleExpression("invoicetitle", keyword, CriterionExpression.Operator.LIKE);
+            SimpleExpression receiverName = new SimpleExpression("receiverName", keyword, CriterionExpression.Operator.LIKE);
+            SimpleExpression recTel = new SimpleExpression("recTel", keyword, CriterionExpression.Operator.LIKE);
+            SimpleExpression[] simpleExpressions = new SimpleExpression[]{sellername, orderids, invoicetitle, receiverName, recTel};
+            LogicalExpression logicalExpression = PredicateUtils.or(simpleExpressions);
+            pageInfo.expression(logicalExpression);
+        }
+
+        return billSubmitDao.findAll(new Specification<BillSubmit>() {
+            @Override
+            public Predicate toPredicate(Root<BillSubmit> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
+                query.where(pageInfo.getPredicates(root, query, cb));
+                return null;
+            }
+        }, pageInfo);
+    }
+
+    @Override
+    public List<BillSubmit> auditBillSubmit(String ids) {
+        String[] idList = ids.split(SplitChar.COMMA);
+        List<BillSubmit> billSubmits = new ArrayList<BillSubmit>();
+        for (String id : idList) {
+            BillSubmit billSubmit = billSubmitDao.findOne(Long.parseLong(id));
+
+            if (billSubmit == null)
+                throw new IllegalOperatorException("此发票申请不存在");
+            if (!SystemSession.getUser().getEnterprise().getUu().equals(billSubmit.getSellerenuu()))
+                throw new IllegalOperatorException("此发票申请不属于当前企业");
+            if (Status.SUBMITTED.value() != billSubmit.getStatus())
+                throw new IllegalOperatorException("此发票申请不为待开票状态,不可开票");
+
+            billSubmit.setStatus(Status.AUDITED.value());
+            billSubmit.setHandleTime(new Date());
+
+            String[] orderids = billSubmit.getOrderids().split(SplitChar.COMMA);
+            for (String orderid : orderids) {
+                Order order = orderDao.findOrderByOrderid(orderid);
+                if (order == null)
+                    throw new IllegalOperatorException("订单: " + orderid + " 不存在,请与客服人员确认该订单");
+                if (!SystemSession.getUser().getEnterprise().getUu().equals(order.getSellerenuu()))
+                    throw new IllegalOperatorException("订单: " + orderid + " 不属于当前企业,不可开票");
+
+                order.setVatBillStatus(Status.TOBERECEIVE_BILL.value());
+                orderDao.save(order);
+            }
+            billSubmits.add(billSubmit);
+        }
+        billSubmitDao.save(billSubmits);
+        return billSubmits;
+    }
+}

+ 65 - 0
src/main/java/com/uas/platform/b2c/logistics/constant/LogisticsType.java

@@ -0,0 +1,65 @@
+package com.uas.platform.b2c.logistics.constant;
+
+/**
+ * Created by hulh on 2017/9/20.
+ * 物流方面的状态码
+ */
+public enum LogisticsType {
+	/**
+	 * {@code 1201 适用于普通订单}
+	 */
+	Rule_Order_Normal(1201, "普通订单"),
+	/**
+	 * {@code 1202 适用于预售订单}
+	 */
+	Rule_Order_PreSale(1202, "预售订单"),
+	/**
+	 * {@code 1203 适用于发票}
+	 */
+	Rule_Invoice(1203, "发票"),
+	/**
+	 * {@code 1301 适用于所有用户}
+	 */
+	Rule_User_All(1301, "所有用户");
+
+
+	private LogisticsType(int value, String phrase) {
+		this.value = value;
+		this.phrase = phrase;
+	}
+	private final int value;
+
+	private final String phrase;
+
+	public int getValue() {
+		return this.value;
+	}
+
+	public String getPhrase() {
+		return this.phrase;
+	}
+
+	/**
+	 * @param statusCode 状态的编码
+	 * @return 状态
+	 * @throws IllegalArgumentException
+	 *             如果statusCode不存在的话
+	 */
+	public static LogisticsType valueOf(int statusCode) {
+		for (LogisticsType status : values()) {
+			if (status.value == statusCode) {
+				return status;
+			}
+		}
+		throw new IllegalArgumentException("没有与编号 [" + statusCode + "]匹配的状态");
+	}
+
+	/**
+	 * 返回状态码的编号
+	 * @return
+	 */
+	@Override
+	public String toString() {
+		return Integer.toString(value);
+	}
+}

+ 12 - 0
src/main/java/com/uas/platform/b2c/logistics/controller/AddressTakeSelfController.java

@@ -1,5 +1,6 @@
 package com.uas.platform.b2c.logistics.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2c.core.utils.FastjsonUtils;
 import com.uas.platform.b2c.logistics.model.AddressTakeSelf;
 import com.uas.platform.b2c.logistics.service.AddressTakeSelfService;
@@ -9,6 +10,7 @@ import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * Created by hulh on 2017/8/11.
@@ -76,4 +78,14 @@ public class AddressTakeSelfController {
 	public List<String> findAllTakeSelfName(){
 		return addressTakeSelfService.findAllTakeSelfName();
 	}
+
+	/**
+	 * 根据店铺list获取自提点信息
+	 * @param info
+	 * @return
+	 */
+	@RequestMapping(value = "/store/takeSelf", method = RequestMethod.POST)
+	public Map<String, List<AddressTakeSelf>> findStoreTakeSelf(@RequestBody List<JSONObject> info){
+		return addressTakeSelfService.findTakeSelfByStore(info);
+	}
 }

+ 137 - 0
src/main/java/com/uas/platform/b2c/logistics/controller/DistributionRuleController.java

@@ -0,0 +1,137 @@
+package com.uas.platform.b2c.logistics.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
+import com.uas.platform.b2c.core.utils.FastjsonUtils;
+import com.uas.platform.b2c.logistics.model.DistributionRule;
+import com.uas.platform.b2c.logistics.model.UsableRuleInfo;
+import com.uas.platform.b2c.logistics.service.DistributionRuleService;
+import com.uas.platform.b2c.trade.support.ResultMap;
+import com.uas.platform.core.logging.BufferedLoggerManager;
+import com.uas.platform.core.model.PageParams;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.*;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by hulh on 2017/8/28.
+ * 配送规则controller
+ */
+@RestController
+@RequestMapping(value = "trade/distributionRule")
+public class DistributionRuleController {
+
+	@Autowired
+	private DistributionRuleService distributionRuleService;
+
+	private static final UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
+
+	/**
+	 * 分页获取配送规则
+	 * @param params
+	 * @return
+	 */
+	@RequestMapping(value = "/page", method = RequestMethod.GET)
+	public Page findPageRule(PageParams params){
+		return distributionRuleService.findPageRule(params);
+	}
+
+	/**
+	 * 根据id删除指定配送规则
+	 * @param id
+	 * @return
+	 */
+	@RequestMapping(value = "/delete/{id}", method = RequestMethod.PUT)
+	public void deleteOne(@PathVariable("id") Long id){
+		distributionRuleService.deleteOne(id);
+	}
+
+	/**
+	 * 保存配送规则
+	 * @param isActive
+	 * @param json
+	 * @param isAdd true-保存,false-另存
+	 * @return
+	 */
+	@RequestMapping(value = "/save", method = RequestMethod.POST)
+	public ResultMap saveRule(@RequestParam("isAdd") Boolean isAdd, @RequestParam("isActive") Boolean isActive, @RequestBody String json){
+		DistributionRule rule = FastjsonUtils.fromJson(json, DistributionRule.class);
+		return distributionRuleService.saveDistributionRule(isAdd, isActive, rule);
+	}
+
+	/**
+	 * 根据id修改配送规则的生效状态
+	 * @param id
+	 * @param isActive
+	 * @return
+	 */
+	@RequestMapping(value = "/status", method = RequestMethod.POST)
+	public ResultMap changeActive(@RequestParam("id") Long id, @RequestParam("isActive") Boolean isActive){
+		return distributionRuleService.changeRuleActive(id, isActive);
+	}
+
+	/**
+	 * 返回所有的配送规则名称
+	 * @return
+	 */
+	@RequestMapping(value = "/ruleName", method = RequestMethod.GET)
+	public List<String> findAllRuleName(){
+		return distributionRuleService.findAllRuleName();
+	}
+
+	/**
+	 * 返回当前enuu配送规则总数
+	 * @return
+	 */
+	@RequestMapping(value = "/count", method = RequestMethod.GET)
+	public ResultMap findRuleCount(){
+		return distributionRuleService.findCountRule();
+	}
+
+	/**
+	 * 查找配送规则名是否存在
+	 * @param id
+	 * @param ruleName
+	 * @param newSave 是否为另存为
+	 * @return
+	 */
+	@RequestMapping(value = "/checkName", method = RequestMethod.GET)
+	public ResultMap checkRuleName(@RequestParam(value = "id", required = false) Long id, @RequestParam(value = "ruleName") String ruleName, @RequestParam(value = "newSave") Boolean newSave){
+		return distributionRuleService.containsName(id, ruleName, newSave);
+	}
+
+	/**
+	 * 根据配送方式和地址信息匹配适用的配送规则
+	 * @param method 配送方式
+	 * @param area 地址信息
+	 * @return
+	 */
+	@RequestMapping(value = "/rule/matchArea", method = RequestMethod.GET)
+	public List<DistributionRule> ruleOfMatchArea(Integer method, String area, String uuid){
+		assert logger != null;
+		logger.log("匹配配送规则", "订单的配送方式为" + method + ", 地区为 : " + area);
+		return distributionRuleService.ruleMatchArea(method, area, uuid);
+	}
+
+	/**
+	 * 获取已设置生效配送规则的配送方式列表
+	 * @return
+	 */
+	@RequestMapping(value = "/usable/rule", method = RequestMethod.POST)
+	public Map<String, List<UsableRuleInfo>> findUsableRule(String area, @RequestBody List<JSONObject> info){
+		assert logger != null;
+		logger.log("匹配配送规则", "收货地址地区信息为"  + area);
+		return distributionRuleService.findRuleMatchArea(info, area);
+	}
+
+	/**
+	 * 获取指定运费价格
+	 * @return
+	 */
+	@RequestMapping(value = "/fare", method = RequestMethod.POST)
+	public List<UsableRuleInfo> findFareRule(Double price, @RequestBody List<UsableRuleInfo> ruleList){
+		return distributionRuleService.findFareOfRule(ruleList, price);
+	}
+}

+ 19 - 0
src/main/java/com/uas/platform/b2c/logistics/controller/LogisticsOldController.java

@@ -132,4 +132,23 @@ public class LogisticsOldController {
 		logger.log("快递信息管理", "快递公司排序", "更新物流信息 id为" + id + " 的物流信息");
 		return logisticsOldService.updateLogistics(id, logistics, invoiceFuid);
 	}
+
+	/**
+	 * 保存物流信息,以免卖家发货界面没有填写快递信息,可以添加物流信息
+	 * @return
+	 */
+	@RequestMapping(value = "/add", method = RequestMethod.POST)
+	public ResultMap addLogistics(String inid, @RequestBody Logistics logistics){
+		return logisticsOldService.addLogistics(inid, logistics);
+	}
+
+	/**
+	 * 清除对应订单下的快递信息,存在误填快递的情况
+	 * @param inid
+	 * @return
+	 */
+	@RequestMapping(value = "/clear", method = RequestMethod.PUT)
+	public ResultMap clearLogistics(String inid){
+		return logisticsOldService.clearLogistics(inid);
+	}
 }

+ 85 - 0
src/main/java/com/uas/platform/b2c/logistics/dao/DistributionRuleDao.java

@@ -0,0 +1,85 @@
+package com.uas.platform.b2c.logistics.dao;
+
+import com.uas.platform.b2c.logistics.model.DistributionRule;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * Created by hulh on 2017/8/28.
+ */
+public interface DistributionRuleDao extends JpaSpecificationExecutor<DistributionRule>, JpaRepository<DistributionRule, Long> {
+
+	/**
+	 * 根据指定id删除配送规则
+	 * @param id
+	 * @return
+	 */
+	@Transactional
+	@Modifying
+	@Query(value = "delete from DistributionRule d where d.id=:id")
+	void deleteOneById(@Param("id") Long id);
+
+	/**
+	 * 根据enuu查找配送规则总数
+	 * @param enuu
+	 * @return
+	 */
+	@Query(value = "select count(1) from DistributionRule d where d.enuu = :enuu")
+	int findCountByEnuu(@Param("enuu") Long enuu);
+
+	/**
+	 * 根据enuu获取所有的配送规则
+	 * @param enuu
+	 * @return
+	 */
+	@Query(value = "select d from DistributionRule d where d.enuu = :enuu order by d.num asc")
+	List<DistributionRule> findAllByEnuu(@Param("enuu") Long enuu);
+
+	/**
+	 * 根据enuu获取所有生效的配送规则
+	 * @param enuu
+	 * @param active
+	 * @return
+	 */
+	List<DistributionRule> findByEnuuAndActiveOrderByNumAsc(Long enuu, Short active);
+
+	/**
+	 * 根据enuu获取所有的配送规则名称
+	 * @param enuu
+	 * @return
+	 */
+	@Query(value = "select d.ruleName from DistributionRule d where d.enuu = :enuu")
+	List<String> findAllRuleNameByEnuu(@Param("enuu") Long enuu);
+
+	/**
+	 * 根据enuu和ruleName查找记录数
+	 * @param enuu
+	 * @param ruleName
+	 * @return
+	 */
+	@Query(value = "select count(1) from DistributionRule d where d.enuu = :enuu and d.ruleName = :ruleName")
+	int findCountRuleName(@Param("enuu") Long enuu, @Param("ruleName") String ruleName);
+
+	/**
+	 * 根据配送方式和enuu获取生效的配送规则列表
+	 * @param enuu
+	 * @param shippingMethod
+	 * @return
+	 */
+	List<DistributionRule> findByEnuuAndShippingMethodAndActive(Long enuu, Integer shippingMethod, Short active);
+
+	/**
+	 * 根据enuu获取生效的配送方式列表
+	 * @param enuu
+	 * @param active
+	 * @return
+	 */
+	@Query(value = "select distinct d.shippingMethod from DistributionRule d where d.enuu = :enuu and d.active = :active")
+	List<Integer> findShippingMethodByEnuuAndActive(Long enuu, Short active);
+}

+ 10 - 1
src/main/java/com/uas/platform/b2c/logistics/dao/DistributorSellerDao.java

@@ -20,7 +20,7 @@ public interface DistributorSellerDao extends JpaSpecificationExecutor<Distribut
 	 * 根据企业enuu查询选中配送商
 	 * @return
 	 */
-	List<DistributorSeller> findByEnuuOrderByCreatetimeDesc(Long enuu);
+	List<DistributorSeller> findByEnuuOrderByNumAsc(Long enuu);
 
 	/**
 	 * 根据指定id删除该配送商
@@ -39,4 +39,13 @@ public interface DistributorSellerDao extends JpaSpecificationExecutor<Distribut
 	 */
 	@Query(value = "select d.companyName from DistributorSeller d where d.enuu=:enuu")
 	List<String> findAllChooseName(@Param("enuu") Long enuu);
+
+	/**
+	 * 根据Enuu删除配送商列表
+	 * @param enuu
+	 */
+	@Transactional
+	@Modifying
+	@Query(value = "delete from DistributorSeller d where d.enuu=:enuu")
+	void deleteDistributorByEnuu(@Param("enuu") Long enuu);
 }

+ 279 - 0
src/main/java/com/uas/platform/b2c/logistics/model/DistributionRule.java

@@ -0,0 +1,279 @@
+package com.uas.platform.b2c.logistics.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.uas.platform.b2c.core.utils.FastjsonUtils;
+import org.apache.commons.collections.CollectionUtils;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.springframework.util.StringUtils;
+
+import javax.persistence.*;
+import java.util.List;
+
+/**
+ * Created by hulh on 2017/8/28.
+ * 配送规则
+ */
+@Entity
+@Table(name = "logistics$distributor_rule")
+public class DistributionRule {
+
+	/**
+	 * 主键id
+	 */
+	@Id
+	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "logistics$distributor_gen")
+	@SequenceGenerator(name = "logistics$distributor_gen", sequenceName = "logistics$distributor_seq", allocationSize = 1)
+	@Column(name = "rule_id")
+	private Long id;
+
+	/**
+	 * 用户uu
+	 */
+	@Column(name = "rule_uu")
+	private Long useruu;
+
+	/**
+	 * 企业enuu
+	 */
+	@Column(name = "rule_enuu")
+	private Long enuu;
+
+	/**
+	 * 配送规则名称
+	 */
+	@Column(name = "rule_name")
+	private String ruleName;
+
+	/**
+	 * 适用店铺 0-自营,1-寄售
+	 */
+	@Column(name = "rule_store_type")
+	private Short storeType;
+
+	/**
+	 * 适用类型 1201-普通订单,1202-预售订单,1203-发票
+	 */
+	@Column(name = "rule_order_type")
+	private String orderType;
+
+	/**
+	 * 适用用户 1301-所有用户
+	 * TODO 目前暂时展示所有用户
+	 */
+	@Column(name = "rule_user_type")
+	private Integer userType;
+
+	/**
+	 * 配送方式
+	 * 1301-第三方配送,1302-卖家配送,1303-上门自提
+	 */
+	@Column(name = "rule_method")
+	private Integer shippingMethod;
+
+	/**
+	 * 是否生效,1-生效,0-不生效
+	 */
+	@Column(name = "rule_active")
+	private Short active;
+
+	/**
+	 * 配送规则排序
+	 */
+	@Column(name = "rule_num")
+	private Integer num;
+
+	/**
+	 * 币别 RMB-USD
+	 */
+	@Column(name = "rule_currency")
+	private String currencyName;
+
+	/**
+	 * 计费方式
+	 * 1-统一规定运费,2-按总金额计算
+	 */
+	@Column(name = "rule_fare_type")
+	private Short fareType;
+
+	/**
+	 * 分段运费(JSON串)
+	 */
+	@Column(name = "rule_qtyFare")
+	private String qtyFare;
+
+	/**
+	 * 统一运费
+	 */
+	@Column(name = "rule_uniform_price")
+	private Double uniformPrice;
+
+	/**
+	 * 分段运费
+	 */
+	@Transient
+	private List<RuleQtyFare> fares;
+
+	/**
+	 * 分段地区(JSON串)
+	 */
+	@Column(name = "rule_qtyArea")
+	private String qtyArea;
+
+	/**
+	 * 分段地区(list)
+	 */
+	@Transient
+	private List<RuleQtyArea> areas;
+
+	/**
+	 * TODO 是否需要记录计算说明文案
+	 */
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Long getUseruu() {
+		return useruu;
+	}
+
+	public void setUseruu(Long useruu) {
+		this.useruu = useruu;
+	}
+
+	public Long getEnuu() {
+		return enuu;
+	}
+
+	public void setEnuu(Long enuu) {
+		this.enuu = enuu;
+	}
+
+	public Short getStoreType() {
+		return storeType;
+	}
+
+	public void setStoreType(Short storeType) {
+		this.storeType = storeType;
+	}
+
+	public String getOrderType() {
+		return orderType;
+	}
+
+	public void setOrderType(String orderType) {
+		this.orderType = orderType;
+	}
+
+	public Integer getUserType() {
+		return userType;
+	}
+
+	public void setUserType(Integer userType) {
+		this.userType = userType;
+	}
+
+	public Integer getShippingMethod() {
+		return shippingMethod;
+	}
+
+	public void setShippingMethod(Integer shippingMethod) {
+		this.shippingMethod = shippingMethod;
+	}
+
+	public Short getActive() {
+		return active;
+	}
+
+	public void setActive(Short active) {
+		this.active = active;
+	}
+
+	public Short getFareType() {
+		return fareType;
+	}
+
+	public void setFareType(Short fareType) {
+		this.fareType = fareType;
+	}
+
+	@JSONField(serialize = false)
+	@JsonIgnore
+	public String getQtyFare() {
+		return qtyFare;
+	}
+
+	public void setQtyFare(String qtyFare) {
+		this.qtyFare = qtyFare;
+	}
+
+	public Double getUniformPrice() {
+		return uniformPrice;
+	}
+
+	public void setUniformPrice(Double uniformPrice) {
+		this.uniformPrice = uniformPrice;
+	}
+
+
+	public List<RuleQtyFare> getFares() {
+		if (CollectionUtils.isEmpty(fares) && StringUtils.hasText(qtyFare)) {
+			return FastjsonUtils.fromJsonArray(qtyFare, RuleQtyFare.class);
+		} else {
+			return fares;
+		}
+	}
+
+	public void setFares(List<RuleQtyFare> fares) {
+		this.fares = fares;
+	}
+
+	@JSONField(serialize = false)
+	@JsonIgnore
+	public String getQtyArea() {
+		return qtyArea;
+	}
+
+	public void setQtyArea(String qtyArea) {
+		this.qtyArea = qtyArea;
+	}
+
+	public List<RuleQtyArea> getAreas() {
+		if (CollectionUtils.isEmpty(areas) && StringUtils.hasText(qtyArea)) {
+			return FastjsonUtils.fromJsonArray(qtyArea, RuleQtyArea.class);
+		} else {
+			return areas;
+		}
+	}
+
+	public void setAreas(List<RuleQtyArea> areas) {
+		this.areas = areas;
+	}
+
+	public String getRuleName() {
+		return ruleName;
+	}
+
+	public void setRuleName(String ruleName) {
+		this.ruleName = ruleName;
+	}
+
+	public Integer getNum() {
+		return num;
+	}
+
+	public void setNum(Integer num) {
+		this.num = num;
+	}
+
+	public String getCurrencyName() {
+		return currencyName;
+	}
+
+	public void setCurrencyName(String currencyName) {
+		this.currencyName = currencyName;
+	}
+}

+ 14 - 0
src/main/java/com/uas/platform/b2c/logistics/model/DistributorSeller.java

@@ -53,6 +53,12 @@ public class DistributorSeller {
 	@Column(name = "seller_createtime")
 	private Date createtime;
 
+	/**
+	 * 配送商排序
+	 */
+	@Column(name = "seller_num")
+	private Integer num;
+
 	public Long getId() {
 		return id;
 	}
@@ -108,4 +114,12 @@ public class DistributorSeller {
 	public void setCreatetime(Date createtime) {
 		this.createtime = createtime;
 	}
+
+	public Integer getNum() {
+		return num;
+	}
+
+	public void setNum(Integer num) {
+		this.num = num;
+	}
 }

+ 69 - 0
src/main/java/com/uas/platform/b2c/logistics/model/InvoiceFOrder.java

@@ -93,6 +93,36 @@ public class InvoiceFOrder extends Document implements Serializable {
 	@Column(name = "in_sp_addr", length = 2000)
 	private String jsonSpAddress;
 
+	/**
+	 * 配送类型
+	 */
+	@Column(name = "in_delivery_type")
+	private Integer deliveryType;
+
+	/**
+	 * 适用配送规则
+	 */
+	@Column(name = "in_rule", length = 2000)
+	private String jsonRule;
+
+	/**
+	 * 自提点信息
+	 */
+	@Column(name = "in_take_self", length = 2000)
+	private String jsonTakeSelf;
+
+	/**
+	 * 运费
+	 */
+	@Column(name = "in_fare")
+	private Double fare;
+
+	/**
+	 * 订单备注
+	 */
+	@Column(name = "in_remark", length = 4000)
+	private String inforRemark;
+
 	/**
 	 * 发货地址 这里使用json字符串的形式将收货地址整个存起来
 	 */
@@ -229,6 +259,14 @@ public class InvoiceFOrder extends Document implements Serializable {
 		this.buyeruu = buyeruu;
 	}
 
+	public String getInforRemark() {
+		return inforRemark;
+	}
+
+	public void setInforRemark(String inforRemark) {
+		this.inforRemark = inforRemark;
+	}
+
 	public Long getUasPurcid() {
 		return uasPurcid;
 	}
@@ -261,6 +299,14 @@ public class InvoiceFOrder extends Document implements Serializable {
 		this.orid = orid;
 	}
 
+	public Integer getDeliveryType() {
+		return deliveryType;
+	}
+
+	public void setDeliveryType(Integer deliveryType) {
+		this.deliveryType = deliveryType;
+	}
+
 	public String getJsonSpAddress() {
 		return jsonSpAddress;
 	}
@@ -415,4 +461,27 @@ public class InvoiceFOrder extends Document implements Serializable {
 		this.sendstatus = sendstatus;
 	}
 
+	public String getJsonRule() {
+		return jsonRule;
+	}
+
+	public void setJsonRule(String jsonRule) {
+		this.jsonRule = jsonRule;
+	}
+
+	public String getJsonTakeSelf() {
+		return jsonTakeSelf;
+	}
+
+	public void setJsonTakeSelf(String jsonTakeSelf) {
+		this.jsonTakeSelf = jsonTakeSelf;
+	}
+
+	public Double getFare() {
+		return fare;
+	}
+
+	public void setFare(Double fare) {
+		this.fare = fare;
+	}
 }

+ 60 - 0
src/main/java/com/uas/platform/b2c/logistics/model/InvoiceFOrderDetail.java

@@ -68,6 +68,18 @@ public class InvoiceFOrderDetail {
 	@Column(name = "go_batch")
 	private String batchCode;
 
+	/**
+	 * 明细的评论
+	 */
+	@Column(name = "detail_remark", length = 4000)
+	private String remark;
+
+	/**
+	 * 物料编号
+	 */
+	@Column(name = "detail_go_number")
+	private String goodsnumber;
+
 	/**
 	 * 对应的器件uuid
 	 */
@@ -190,6 +202,18 @@ public class InvoiceFOrderDetail {
 	@Column(name = "detail_currency")
 	private String currency;
 
+	/**
+	 * 商城最长交期
+	 */
+	@Column(name = "go_b2cmaxdelivery")
+	private Short b2cMaxDelivery;
+
+	/**
+	 * 商城最短交期
+	 */
+	@Column(name = "go_b2cmindelivery")
+	private Short b2cMinDelivery;
+
 	public InvoiceFOrderDetail() {
 	}
 
@@ -229,6 +253,10 @@ public class InvoiceFOrderDetail {
 		this.ensurePrice = detail.getEnsurePrice();
 		this.ordetailid = detail.getId();
 		this.status = Status.TOBESHIPPED.value();
+		this.goodsnumber = detail.getGoodsnumber();
+		this.b2cMinDelivery = detail.getB2cMinDelivery();
+		this.b2cMaxDelivery = detail.getB2cMaxDelivery();
+		this.remark = detail.getRemark();
 	}
 
 	public Long getId() {
@@ -263,6 +291,38 @@ public class InvoiceFOrderDetail {
 		this.tax = tax;
 	}
 
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public String getGoodsnumber() {
+		return goodsnumber;
+	}
+
+	public void setGoodsnumber(String goodsnumber) {
+		this.goodsnumber = goodsnumber;
+	}
+
+	public Short getB2cMaxDelivery() {
+		return b2cMaxDelivery;
+	}
+
+	public void setB2cMaxDelivery(Short b2cMaxDelivery) {
+		this.b2cMaxDelivery = b2cMaxDelivery;
+	}
+
+	public Short getB2cMinDelivery() {
+		return b2cMinDelivery;
+	}
+
+	public void setB2cMinDelivery(Short b2cMinDelivery) {
+		this.b2cMinDelivery = b2cMinDelivery;
+	}
+
 	public Double getTaxes() {
 		return taxes;
 	}

+ 74 - 2
src/main/java/com/uas/platform/b2c/logistics/model/InvoiceFPurchase.java

@@ -100,6 +100,12 @@ public class InvoiceFPurchase extends Document implements Serializable {
 	 */
 	@Column(name = "in_sourceid")
 	private String sourceid;
+
+	/**
+	 * 订单备注
+	 */
+	@Column(name = "in_remark", length = 4000)
+	private String infpuRemark;
 	
 	/**
 	 * 是否是UAS的来源
@@ -156,13 +162,31 @@ public class InvoiceFPurchase extends Document implements Serializable {
 	private String currencyName;
 
 	/**
-	 * 价税合计
+	 * 运费
+	 */
+	@Column(name = "in_fare")
+	private Double fare;
+
+	/**
+	 * 适用的配送规则
+	 */
+	@Column(name = "in_rule")
+	private String jsonRule;
+
+	/**
+	 * 自提点信息
+	 */
+	@Column(name = "in_take_self")
+	private String jsonTakeSelf;
+
+	/**
+	 * 价税合计 (商品合计)
 	 */
 	@Column(name = "in_price")
 	private Double price;
 
 	/**
-	 * 确认金额(考虑商城打折的情况)
+	 * 确认金额(考虑商城打折的情况)(包括运费)
 	 */
 	@Column(name = "ensure_price")
 	private Double ensurePrice;
@@ -191,6 +215,12 @@ public class InvoiceFPurchase extends Document implements Serializable {
 	 */
 	@Column(name = "in_proofingid")
 	private Long proofingid;
+
+	/**
+	 * 配送方式
+	 */
+	@Column(name = "in_send_type")
+	private Integer sendType;
 	
 	/**
 	 * 自己送货还是第三方物流送货
@@ -277,6 +307,14 @@ public class InvoiceFPurchase extends Document implements Serializable {
 		this.deliveryType = deliveryType;
 	}
 
+	public Integer getSendType() {
+		return sendType;
+	}
+
+	public void setSendType(Integer sendType) {
+		this.sendType = sendType;
+	}
+
 	public String getSelfDeliveryName() {
 		return selfDeliveryName;
 	}
@@ -515,6 +553,38 @@ public class InvoiceFPurchase extends Document implements Serializable {
 		return this;
 	}
 
+	public String getInfpuRemark() {
+		return infpuRemark;
+	}
+
+	public void setInfpuRemark(String infpuRemark) {
+		this.infpuRemark = infpuRemark;
+	}
+
+	public Double getFare() {
+		return fare;
+	}
+
+	public void setFare(Double fare) {
+		this.fare = fare;
+	}
+
+	public String getJsonRule() {
+		return jsonRule;
+	}
+
+	public void setJsonRule(String jsonRule) {
+		this.jsonRule = jsonRule;
+	}
+
+	public String getJsonTakeSelf() {
+		return jsonTakeSelf;
+	}
+
+	public void setJsonTakeSelf(String jsonTakeSelf) {
+		this.jsonTakeSelf = jsonTakeSelf;
+	}
+
 	/**
 	 * @Tip 对象初始化时必须给历史记录赋值
 	 */
@@ -542,5 +612,7 @@ public class InvoiceFPurchase extends Document implements Serializable {
 		this.sourceid = purchase.getPurchaseid();
 		this.storeid = purchase.getStoreid();
 		this.orid = purchase.getOrderid();
+		this.infpuRemark = purchase.getPurchaseRemark();
+		this.fare = purchase.getFare();
 	}
 }

+ 60 - 0
src/main/java/com/uas/platform/b2c/logistics/model/InvoiceFPurchaseDetail.java

@@ -205,12 +205,36 @@ public class InvoiceFPurchaseDetail {
 	@StatusColumn
 	private Integer status;
 
+	/**
+	 * 明细的评论
+	 */
+	@Column(name = "detail_remark", length = 4000)
+	private String remark;
+
+	/**
+	 * 物料编号
+	 */
+	@Column(name = "detail_go_number")
+	private String goodsnumber;
+
 	/**
 	 * 店铺的storeid
 	 */
 	@Column(name = "detail_storid")
 	private String storeid;
 
+	/**
+	 * 商城最长交期
+	 */
+	@Column(name = "go_b2cmaxdelivery")
+	private Short b2cMaxDelivery;
+
+	/**
+	 * 商城最短交期
+	 */
+	@Column(name = "go_b2cmindelivery")
+	private Short b2cMinDelivery;
+
 	public InvoiceFPurchaseDetail() {
 	}
 
@@ -247,6 +271,10 @@ public class InvoiceFPurchaseDetail {
 		this.returnInWeek = puDetail.getReturnInWeek();
 		this.returnQty = puDetail.getReturnQty();
 		this.changeQty = puDetail.getChangeQty();
+		this.b2cMinDelivery = puDetail.getB2cMinDelivery();
+		this.b2cMaxDelivery = puDetail.getB2cMaxDelivery();
+		this.remark = puDetail.getRemark();
+		this.goodsnumber = puDetail.getGoodsnumber();
 	}
 
 	public Long getId() {
@@ -297,6 +325,38 @@ public class InvoiceFPurchaseDetail {
 		this.uuid = uuid;
 	}
 
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public String getGoodsnumber() {
+		return goodsnumber;
+	}
+
+	public void setGoodsnumber(String goodsnumber) {
+		this.goodsnumber = goodsnumber;
+	}
+
+	public Short getB2cMaxDelivery() {
+		return b2cMaxDelivery;
+	}
+
+	public void setB2cMaxDelivery(Short b2cMaxDelivery) {
+		this.b2cMaxDelivery = b2cMaxDelivery;
+	}
+
+	public Short getB2cMinDelivery() {
+		return b2cMinDelivery;
+	}
+
+	public void setB2cMinDelivery(Short b2cMinDelivery) {
+		this.b2cMinDelivery = b2cMinDelivery;
+	}
+
 	public String getCmpCode() {
 		return cmpCode;
 	}

+ 56 - 0
src/main/java/com/uas/platform/b2c/logistics/model/RuleQtyArea.java

@@ -0,0 +1,56 @@
+package com.uas.platform.b2c.logistics.model;
+
+/**
+ * Created by hulh on 2017/8/28.
+ * 分段地区
+ */
+public class RuleQtyArea {
+	/**
+	 * 地区:中国大陆--港澳台
+	 */
+	private String mainland;
+	/**
+	 * 地区:省
+	 */
+	private String province;
+	/**
+	 * 地区:市
+	 */
+	private String city;
+	/**
+	 * 地区:区
+	 */
+	private String area;
+
+	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 getArea() {
+		return area;
+	}
+
+	public void setArea(String area) {
+		this.area = area;
+	}
+
+	public String getMainland() {
+		return mainland;
+	}
+
+	public void setMainland(String mainland) {
+		this.mainland = mainland;
+	}
+}

+ 49 - 0
src/main/java/com/uas/platform/b2c/logistics/model/RuleQtyFare.java

@@ -0,0 +1,49 @@
+package com.uas.platform.b2c.logistics.model;
+
+/**
+ * Created by hulh on 2017/8/28.
+ * 分段运费
+ */
+public class RuleQtyFare {
+	/**
+	 * 分段开始  --包括开始
+	 */
+	private Double start;
+	/**
+	 * 分段结束  --不包括结束
+	 */
+	private Double end;
+	/**
+	 * 分段费用
+	 */
+	private Double fare;
+	/**
+	 * 分段币别
+	 */
+//	private String currency;
+
+
+	public Double getStart() {
+		return start;
+	}
+
+	public void setStart(Double start) {
+		this.start = start;
+	}
+
+	public Double getEnd() {
+		return end;
+	}
+
+	public void setEnd(Double end) {
+		this.end = end;
+	}
+
+	public Double getFare() {
+		return fare;
+	}
+
+	public void setFare(Double fare) {
+		this.fare = fare;
+	}
+}

+ 104 - 0
src/main/java/com/uas/platform/b2c/logistics/model/UsableRuleInfo.java

@@ -0,0 +1,104 @@
+package com.uas.platform.b2c.logistics.model;
+
+/**
+ * Created by hulh on 2017/9/13.
+ * 适用的配送规则简要信息
+ */
+public class UsableRuleInfo {
+	/**
+	 * 配送id
+	 */
+	private Long id;
+	/**
+	 * 配送规则名称
+	 */
+	private String ruleName;
+	/**
+	 * 实际所需价格
+	 */
+	private Double fare;
+	/**
+	 * 配送方式
+	 */
+	private Integer method;
+	/**
+	 * 卖家enuu
+	 */
+	private Long enuu;
+	/**
+	 * 卖家店铺uuid
+	 */
+	private String uuid;
+	/**
+	 * 配送规则币别
+	 */
+	private String currencyName;
+
+	public UsableRuleInfo(){
+
+	}
+
+	public UsableRuleInfo(DistributionRule rule){
+		this.id = rule.getId();
+		this.ruleName = rule.getRuleName();
+		this.method = rule.getShippingMethod();
+		this.currencyName = rule.getCurrencyName();
+		this.enuu = rule.getEnuu();
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getRuleName() {
+		return ruleName;
+	}
+
+	public void setRuleName(String ruleName) {
+		this.ruleName = ruleName;
+	}
+
+	public Double getFare() {
+		return fare;
+	}
+
+	public void setFare(Double fare) {
+		this.fare = fare;
+	}
+
+	public Integer getMethod() {
+		return method;
+	}
+
+	public void setMethod(Integer method) {
+		this.method = method;
+	}
+
+	public Long getEnuu() {
+		return enuu;
+	}
+
+	public void setEnuu(Long enuu) {
+		this.enuu = enuu;
+	}
+
+	public String getCurrencyName() {
+		return currencyName;
+	}
+
+	public void setCurrencyName(String currencyName) {
+		this.currencyName = currencyName;
+	}
+
+	public String getUuid() {
+		return uuid;
+	}
+
+	public void setUuid(String uuid) {
+		this.uuid = uuid;
+	}
+}

+ 8 - 0
src/main/java/com/uas/platform/b2c/logistics/service/AddressTakeSelfService.java

@@ -1,10 +1,12 @@
 package com.uas.platform.b2c.logistics.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2c.logistics.model.AddressTakeSelf;
 import com.uas.platform.core.model.PageParams;
 import org.springframework.data.domain.Page;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * Created by hulh on 2017/8/11.
@@ -48,4 +50,10 @@ public interface AddressTakeSelfService {
 	 * @return
 	 */
 	List<String> findAllTakeSelfName();
+
+	/**
+	 * 根据企业列表获取自提点信息
+	 * @return
+	 */
+	Map<String, List<AddressTakeSelf>> findTakeSelfByStore(List<JSONObject> info);
 }

+ 99 - 0
src/main/java/com/uas/platform/b2c/logistics/service/DistributionRuleService.java

@@ -0,0 +1,99 @@
+package com.uas.platform.b2c.logistics.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.b2c.logistics.model.DistributionRule;
+import com.uas.platform.b2c.logistics.model.UsableRuleInfo;
+import com.uas.platform.b2c.trade.support.ResultMap;
+import com.uas.platform.core.model.PageParams;
+import org.springframework.data.domain.Page;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by hulh on 2017/8/28.
+ * 配送规则service
+ */
+public interface DistributionRuleService {
+
+	/**
+	 * 分页获取配送规则
+	 * @param params
+	 * @return
+	 */
+	Page<DistributionRule> findPageRule(PageParams params);
+
+	/**
+	 * 保存配送规则
+	 * @param isAdd
+	 * @param isActive
+	 * @param rule
+	 * @return
+	 */
+	ResultMap saveDistributionRule(Boolean isAdd, Boolean isActive, DistributionRule rule);
+
+	/**
+	 * 根据id修改配送规则的生效状态
+	 * @param id
+	 * @param isActive
+	 * @return
+	 */
+	ResultMap changeRuleActive(Long id, Boolean isActive);
+
+	/**
+	 * 根据id删除指定配送规则
+	 * @param id
+	 */
+	void deleteOne(Long id);
+
+	/**
+	 * 返回所有的配送规则名称
+	 * @return
+	 */
+	List<String> findAllRuleName();
+
+	/**
+	 * 返回当前enuu下配送规则总数
+	 * @return
+	 */
+	ResultMap findCountRule();
+
+	/**
+	 * 查找是否已存在该名称
+	 * @param id
+	 * @param ruleName
+	 * @param newSave
+	 * @return
+	 */
+	ResultMap containsName(Long id, String ruleName, Boolean newSave);
+
+	/**
+	 * 根据配送方式和地区匹配适用的配送规则
+	 * @param method
+	 * @param area
+	 * @return
+	 */
+	List<DistributionRule> ruleMatchArea(Integer method, String area, String uuid);
+
+	/**
+	 * 获取已设置生效配送规则的配送方式列表
+	 * @return
+	 */
+	List<Integer> findUsableShippingMethod();
+
+	/**
+	 * 根据店铺id集合和地区获取配送规则
+	 * @param uuidArray
+	 * @param area
+	 * @return
+	 */
+	Map<String, List<UsableRuleInfo>> findRuleMatchArea(List<JSONObject> uuidArray, String area);
+
+	/**
+	 * 更新指定运费
+	 * @param ruleList
+	 * @param price
+	 * @return
+	 */
+	List<UsableRuleInfo> findFareOfRule(List<UsableRuleInfo> ruleList, Double price);
+}

+ 17 - 0
src/main/java/com/uas/platform/b2c/logistics/service/LogisticsOldService.java

@@ -60,6 +60,23 @@ public interface LogisticsOldService {
 	 */
 	ResultMap updateLogistics(Long id, Logistics logistics, String invoicFuid);
 
+	/**
+	 * 新增快递信息
+	 *
+	 * @param inid
+	 * @param logistics
+	 * @return
+	 */
+	ResultMap addLogistics(String inid, Logistics logistics);
+
+	/**
+	 * 清除对应订单下的快递信息
+	 *
+	 * @param inid
+	 * @return
+	 */
+	ResultMap clearLogistics(String inid);
+
 	/**
 	 * 传入物流公司和物流单号 生成Logistics
 	 *

+ 13 - 17
src/main/java/com/uas/platform/b2c/logistics/service/impl/AddressServiceImpl.java

@@ -37,7 +37,6 @@ public class AddressServiceImpl implements AddressService {
 	public void delete(Long addid) {
 		if (addressDao.exists(addid)) {
 			Address address = addressDao.findOne(addid);
-			int modifyNum = address.getNum();
 			List<Address> addresses = null;
 			addressDao.delete(addid);
 			int type = address.getType();
@@ -48,12 +47,14 @@ public class AddressServiceImpl implements AddressService {
 				addresses = addressDao.findByEnuuAndTypeAndUsetypeOrderByNumAsc(address.getEnuu(), type, (short)2);
 			}
 			if (!CollectionUtils.isEmpty(addresses) && addresses.size() > 0) {
-				int num = 0;
-				if (modifyNum == 1) {
-					num = 1;
-				}
-				for (Address add : addresses){
-					add.setNum(++num);
+				if (addresses.size() == 1){
+					Address add = addresses.get(0);
+					add.setNum(1);
+				}else {
+					int num = addresses.get(0).getNum();
+					for (Address add : addresses){
+						add.setNum(num++);
+					}
 				}
 			}
 			addressDao.save(addresses);
@@ -71,7 +72,6 @@ public class AddressServiceImpl implements AddressService {
 	@Override
 	public void setTop(Long addid, boolean setTop) {
 		Address address = addressDao.findOne(addid); //查询操作的Address
-//		System.out.println("setTop=" + setTop);
 		Long useruu = address.getUseruu();
 		int type = address.getType();
 		List<Address> addresses = null;
@@ -84,7 +84,6 @@ public class AddressServiceImpl implements AddressService {
 		long modifyId = address.getId().longValue();
 		int modifyNum = address.getNum().intValue();
 		if (setTop){
-//			System.out.println("设为默认地址情况");
 			for (Address add : addresses) {
 				if (add.getId().longValue() == modifyId) {
 					add.setNum(1);
@@ -95,14 +94,12 @@ public class AddressServiceImpl implements AddressService {
 			}
 		}else {
 			if (modifyNum == 1){ //取消默认地址
-//				System.out.println("取消默认地址情况");
 				for (Address add : addresses) { //空出默认地址位置
 					add.setNum(++num);
 				}
 			}else {
 				int firstNum = addresses.get(0).getNum();
 				if (firstNum == 1){ //有默认地址情况
-//					System.out.println("有默认地址新增地址情况");
 					num++; //空出默认地址位置
 					for (Address add : addresses) {
 						if (add.getNum() != 1){
@@ -115,7 +112,6 @@ public class AddressServiceImpl implements AddressService {
 						}
 					}
 				}else { //没有默认地址情况
-//					System.out.println("没有默认地址新增地址情况");
 					num++; //空出默认地址位置
 					for (Address add : addresses) {
 						if (add.getId().longValue() != modifyId){
@@ -156,17 +152,17 @@ public class AddressServiceImpl implements AddressService {
 				address.setUsetype((short)2);
 				num = addressDao.getCountByEnuuAndTypeAndUsetype(user.getEnterprise().getUu(), address.getType(), address.getUsetype());
 			}
-			address.setNum(num == null ? 1 : ++num);
+			address.setNum(num == 0 ? 1 : ++num);
 		}
 		Long modifyId = address.getId();
 		Address add = save(address);
-		System.out.println(address.getId());
+		if (modifyId == null && add.getNum().intValue() == 1){
+			isSetTop = true;
+		}
 		if(modifyId == null || isSetTop) { //只有新增加的地址 或者需要被置顶的地址 才需要重新排序。
-//			System.out.println("新增地址或设为默认地址");
 			setTop(add.getId(), isSetTop);
 		}
-		if (address.getNum() == 1 && !isSetTop) { //取消默认地址的时候需要重新排序
-//			System.out.println("取消默认地址");
+		if (address.getNum().intValue() == 1 && !isSetTop) { //取消默认地址的时候需要重新排序
 			setTop(add.getId(), isSetTop);
 		}
 		return add;

+ 25 - 0
src/main/java/com/uas/platform/b2c/logistics/service/impl/AddressTakeSelfServiceImpl.java

@@ -1,9 +1,13 @@
 package com.uas.platform.b2c.logistics.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.logistics.dao.AddressTakeSelfDao;
 import com.uas.platform.b2c.logistics.model.AddressTakeSelf;
 import com.uas.platform.b2c.logistics.service.AddressTakeSelfService;
+import com.uas.platform.b2c.prod.store.dao.StoreInDao;
+import com.uas.platform.b2c.prod.store.model.StoreIn;
+import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,7 +21,9 @@ import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Created by hulh on 2017/8/11.
@@ -25,9 +31,13 @@ import java.util.List;
 @Service
 @Transactional
 public class AddressTakeSelfServiceImpl implements AddressTakeSelfService {
+
 	@Autowired
 	private AddressTakeSelfDao addressTakeSelfDao;
 
+	@Autowired
+	private StoreInDao storeInDao;
+
 	@Override
 	public AddressTakeSelf saveTakeSelf(AddressTakeSelf addressTakeSelf, Boolean isActive) {
 		if (addressTakeSelf.getId() == null){
@@ -81,4 +91,19 @@ public class AddressTakeSelfServiceImpl implements AddressTakeSelfService {
 		Long enuu = SystemSession.getUser().getEnterprise().getUu();
 		return addressTakeSelfDao.findTakenameByEnuu(enuu);
 	}
+
+	@Override
+	public Map<String, List<AddressTakeSelf>> findTakeSelfByStore(List<JSONObject> info) {
+		Map<String, List<AddressTakeSelf>> map = new HashMap<>();
+		for (JSONObject object : info){
+			StoreIn store = storeInDao.findByUuid(object.getString("uuid"));
+			if (store == null){
+				throw new IllegalOperatorException("店铺信息丢失,请刷新后重试");
+			}
+			Long enuu = store.getEnUU();
+			List<AddressTakeSelf> list = addressTakeSelfDao.findByEnuuOrderByCreatetimeDesc(enuu);
+			map.put(object.getString("uuid"), list);
+		}
+		return map;
+	}
 }

+ 491 - 0
src/main/java/com/uas/platform/b2c/logistics/service/impl/DistributionRuleServiceImpl.java

@@ -0,0 +1,491 @@
+package com.uas.platform.b2c.logistics.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.b2c.core.config.SysConf;
+import com.uas.platform.b2c.core.constant.ShortConstant;
+import com.uas.platform.b2c.core.constant.SplitChar;
+import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.logistics.dao.DistributionRuleDao;
+import com.uas.platform.b2c.logistics.model.DistributionRule;
+import com.uas.platform.b2c.logistics.model.RuleQtyArea;
+import com.uas.platform.b2c.logistics.model.RuleQtyFare;
+import com.uas.platform.b2c.logistics.model.UsableRuleInfo;
+import com.uas.platform.b2c.logistics.service.DistributionRuleService;
+import com.uas.platform.b2c.prod.store.dao.StoreInDao;
+import com.uas.platform.b2c.prod.store.model.StoreIn;
+import com.uas.platform.b2c.trade.support.CodeType;
+import com.uas.platform.b2c.trade.support.ResultMap;
+import com.uas.platform.core.exception.IllegalOperatorException;
+import com.uas.platform.core.model.PageInfo;
+import com.uas.platform.core.model.PageParams;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by hulh on 2017/8/28.
+ * 配送规则实现类
+ */
+@Service
+@Transactional
+public class DistributionRuleServiceImpl implements DistributionRuleService{
+
+	@Autowired
+	private DistributionRuleDao distributionRuleDao;
+
+	@Autowired
+	private StoreInDao storeInDao;
+
+	@Autowired
+	private SysConf sysConf;
+
+	@Override
+	public Page<DistributionRule> findPageRule(PageParams params) {
+		final PageInfo pageInfo = new PageInfo(params);
+		pageInfo.filter("enuu", SystemSession.getUser().getEnterprise().getUu());
+		return distributionRuleDao.findAll(new Specification<DistributionRule>() {
+			@Override
+			public Predicate toPredicate(Root<DistributionRule> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
+				query.where(pageInfo.getPredicates(root, query, cb));
+				return null;
+			}
+		}, pageInfo);
+	}
+
+	/**
+	 * 保存或修改配送规则
+	 * @param isAdd true-保存,false-另存
+	 * @param isActive
+	 * @param rule
+	 * @return
+	 */
+	@Override
+	public ResultMap saveDistributionRule(Boolean isAdd, Boolean isActive, DistributionRule rule) {
+		if (rule.getShippingMethod() == null){
+			return new ResultMap(CodeType.NO_INFO, "请选择配送方式");
+		}
+		if (rule.getRuleName() == null || rule.getRuleName().isEmpty()){
+			return new ResultMap(CodeType.NO_INFO, "请填写规则名称");
+		}
+		if (CollectionUtils.isEmpty(rule.getAreas())){
+			return new ResultMap(CodeType.NO_INFO, "您还没有选择任何地区");
+		}
+		if (rule.getFareType() == 2 && CollectionUtils.isEmpty(rule.getFares())){
+			return new ResultMap(CodeType.NO_INFO, "请完善计费方式");
+		}
+		if (rule.getId() == null){ //新增配送规则,初始化数据
+			Long uu = SystemSession.getUser().getUserUU();
+			Long enuu = SystemSession.getUser().getEnterprise().getUu();
+			rule.setUseruu(uu);
+			rule.setEnuu(enuu);
+
+			if (enuu.longValue() == sysConf.getEnUU().longValue()){
+				rule.setStoreType(ShortConstant.YES_SHORT);
+			}else {
+				rule.setStoreType(ShortConstant.NO_SHORT);
+			}
+		}
+		if (isActive){
+			rule.setActive(ShortConstant.YES_SHORT);
+		}else {
+			rule.setActive(ShortConstant.NO_SHORT);
+		}
+		if (!isAdd){ //若为另存为,则将主键id设为空
+			if (rule.getId() != null){
+				rule.setId(null);
+			}
+		}
+		int count = distributionRuleDao.findCountByEnuu(rule.getEnuu());
+		int num = count == 0 ? 1 : ++count;
+		if (rule.getId() == null){
+			if (rule.getNum() == null){
+				rule.setNum(num);
+			}else {
+				if (rule.getNum() < num){
+					sortRule(rule.getNum());
+				}else {
+					rule.setNum(num);
+				}
+			}
+		}else {
+			DistributionRule oldRule = distributionRuleDao.findOne(rule.getId());
+			if (rule.getNum() == null){
+				rule.setNum(oldRule.getNum());
+			}else {
+				if (rule.getNum() < num-1){
+					sortRule(rule.getId(), rule.getNum());
+				}else {
+					sortRule(rule.getId(), num-1);
+					rule.setNum(num-1);
+				}
+			}
+		}
+		distributionRuleDao.save(rule);
+		return ResultMap.success(null);
+	}
+
+	@Override
+	public ResultMap changeRuleActive(Long id, Boolean isActive) {
+		DistributionRule rule = distributionRuleDao.findOne(id);
+		if (isActive){
+			rule.setActive((short)1);
+		}else {
+			rule.setActive((short)0);
+		}
+		distributionRuleDao.save(rule);
+		return ResultMap.success(null);
+	}
+
+	/**
+	 * 修改,排序已有配送规则列表,本配送规则不参与排序,空出num位置
+	 * @param id
+	 * @param num
+	 */
+	public void sortRule(Long id, int num){
+		Long enuu = SystemSession.getUser().getEnterprise().getUu();
+		List<DistributionRule> ruleList = distributionRuleDao.findAllByEnuu(enuu);
+		int start = 1;
+		for (DistributionRule rule : ruleList){
+			if (rule.getId() != id){
+				if (start == num){
+					start++;
+//					System.out.println("start=" + start);
+				}
+				rule.setNum(start++);
+			}
+		}
+		distributionRuleDao.save(ruleList);
+	}
+
+	/**
+	 * 新增,排序已有配送规则列表,空出num位置
+	 * @param num
+	 */
+	public void sortRule(int num){
+		Long enuu = SystemSession.getUser().getEnterprise().getUu();
+		List<DistributionRule> ruleList = distributionRuleDao.findAllByEnuu(enuu);
+		int start = 1;
+		for (DistributionRule rule : ruleList){
+			if (start == num){
+				start++;
+			}
+			rule.setNum(start++);
+		}
+		distributionRuleDao.save(ruleList);
+	}
+
+	@Transactional
+	@Override
+	public void deleteOne(Long id) {
+		distributionRuleDao.deleteOneById(id);
+		Long enuu = SystemSession.getUser().getEnterprise().getUu();
+		List<DistributionRule> ruleList = distributionRuleDao.findAllByEnuu(enuu);
+		int num = 1;
+		for (DistributionRule rule : ruleList){
+			rule.setNum(num++);
+		}
+		distributionRuleDao.save(ruleList);
+	}
+
+	@Override
+	public List<String> findAllRuleName() {
+		Long enuu = SystemSession.getUser().getEnterprise().getUu();
+		return distributionRuleDao.findAllRuleNameByEnuu(enuu);
+	}
+
+	/**
+	 * 查询已设置配送规则的数量
+	 * @return
+	 */
+	@Override
+	public ResultMap findCountRule() {
+		Long enuu = SystemSession.getUser().getEnterprise().getUu();
+		int count = distributionRuleDao.findCountByEnuu(enuu);
+		return ResultMap.success(count);
+	}
+
+	/**
+	 * 根据配送规则名称查询是否已存在
+	 * @param id
+	 * @param ruleName 配送规则名称
+	 * @param newSave 是否为另存,true-另存 false-保存
+	 * @return
+	 */
+	@Override
+	public ResultMap containsName(Long id, String ruleName, Boolean newSave) {
+		Long enuu = SystemSession.getUser().getEnterprise().getUu();
+		Boolean repeat = null;
+		if (id != null){
+			//修改配送规则情况,分保存和另存为两种
+			if (newSave){ //另存为
+				int count = distributionRuleDao.findCountRuleName(enuu, ruleName);
+				if (count != 0){
+					repeat = true;
+				}else {
+					repeat = false;
+				}
+			}else { //保存
+				DistributionRule rule = distributionRuleDao.findOne(id);
+				if (ruleName.equals(rule.getRuleName())){
+					repeat = false;
+				}else {
+					int count = distributionRuleDao.findCountRuleName(enuu, ruleName);
+					if (count != 0){
+						repeat = true;
+					}else {
+						repeat = false;
+					}
+				}
+			}
+		}else { //新增配送规则情况
+			int count = distributionRuleDao.findCountRuleName(enuu, ruleName);
+			if (count != 0){
+				repeat = true;
+			}else {
+				repeat = false;
+			}
+		}
+		return ResultMap.success(repeat);
+	}
+
+	@Override
+	public List<Integer> findUsableShippingMethod() {
+		Long enuu = SystemSession.getUser().getEnterprise().getUu();
+		return distributionRuleDao.findShippingMethodByEnuuAndActive(enuu, ShortConstant.YES_SHORT);
+	}
+
+	/**
+	 * 更新配送规则的运费
+	 * @param ruleList
+	 * @param price
+	 * @return
+	 */
+	@Override
+	public List<UsableRuleInfo> findFareOfRule(List<UsableRuleInfo> ruleList, Double price) {
+		if (CollectionUtils.isEmpty(ruleList)){
+			throw new IllegalOperatorException("配送规则信息丢失,请刷新后重试");
+		}
+		for (UsableRuleInfo info : ruleList){
+			DistributionRule rule = distributionRuleDao.findOne(info.getId());
+			if (rule == null){
+				throw new IllegalOperatorException("配送规则信息丢失,请刷新后重试");
+			}
+			Double fare = getFareOfRule(rule, price);
+			info.setFare(fare);
+		}
+		return ruleList;
+	}
+
+	/**
+	 * 返回所有店铺适用的配送规则
+	 * @param uuidArray
+	 * @param area
+	 * @return
+	 */
+	@Override
+	public Map<String, List<UsableRuleInfo>> findRuleMatchArea(List<JSONObject> uuidArray, String area){
+		if (area == null){
+			throw new IllegalOperatorException("地址信息缺失,请重新确认收货地址");
+		}
+		Map<String, List<UsableRuleInfo>> resultMap = new HashMap<>();
+		for (JSONObject object : uuidArray){
+			Double price = Double.parseDouble(object.getString("fare"));
+			List<UsableRuleInfo> list = findRuleInStore(object.getString("uuid"), area, price);
+			resultMap.put(object.getString("uuid"), list);
+		}
+		return resultMap;
+	}
+
+	/**
+	 * 返回该店铺适用的配送规则
+	 * @param uuid
+	 * @param area
+	 * @return
+	 */
+	public List<UsableRuleInfo> findRuleInStore(String uuid, String area, Double price){
+		StoreIn store = storeInDao.findByUuid(uuid);
+		if (store == null){
+			throw new IllegalOperatorException("店铺信息缺失,请刷新后重试");
+		}
+		List<DistributionRule> allRuleList = distributionRuleDao.findByEnuuAndActiveOrderByNumAsc(store.getEnUU(), ShortConstant.YES_SHORT);
+		List<UsableRuleInfo> ruleInfoList = new ArrayList<>();
+		List<Integer> methodList = new ArrayList<>();
+		for (DistributionRule rule : allRuleList){
+			if (!methodList.contains(rule.getShippingMethod())){
+				List<RuleQtyArea> qtyArea = rule.getAreas();
+				//转化分段地区信息
+				Map<String, Map<String, List<String>>> resultMap = convertArea(qtyArea);
+				//是否包含改地区信息
+				boolean isContains = containsArea(resultMap, area);
+				if (isContains){
+					methodList.add(rule.getShippingMethod());
+					UsableRuleInfo info = new UsableRuleInfo(rule);
+					Double fare = getFareOfRule(rule, price);
+					info.setFare(fare);
+					info.setUuid(uuid);
+					ruleInfoList.add(info);
+				}
+			}
+			if (methodList.size() == 3){
+				break;
+			}
+		}
+		return ruleInfoList;
+	}
+
+	/**
+	 * 根据配送方式获取匹配地区的配送规则列表
+	 * @param method
+	 * @param area
+	 * @param uuid
+	 * @return
+	 */
+	@Override
+	public List<DistributionRule> ruleMatchArea(Integer method, String area, String uuid) {
+		StoreIn store = storeInDao.findByUuid(uuid);
+
+		List<DistributionRule> resultList = new ArrayList<>();
+		// 根据配送方式找出所有生效的配送规则
+		List<DistributionRule> methodList = distributionRuleDao.findByEnuuAndShippingMethodAndActive(store.getEnUU(), method, ShortConstant.YES_SHORT);
+
+		for (DistributionRule rule : methodList){
+			List<RuleQtyArea> qtyArea = rule.getAreas();
+			Map<String, Map<String, List<String>>> resultMap = convertArea(qtyArea);
+			boolean isContains = containsArea(resultMap, area);
+			if (isContains){
+				resultList.add(rule);
+			}
+		}
+		return resultList;
+	}
+
+	/**
+	 * 获取运费最小的配送规则
+	 * @param price
+	 * @return
+	 */
+	public DistributionRule getRuleOInMinFare(Double price){
+		//获取匹配地区的配送规则列表
+		List<DistributionRule> matchList = null;
+		DistributionRule minRule = null; //最少运费的配送规则
+		Double minFare = getFareOfRule(matchList.get(0), price);
+		for (int i = 1; i<matchList.size(); i++){
+			Double fare = getFareOfRule(matchList.get(i), price);
+			if (fare < minFare){
+				minRule = matchList.get(i);
+				minFare = fare;
+			}
+		}
+		return minRule;
+	}
+
+	/**
+	 * 获取指定配送规则的运费
+	 * @param rule
+	 * @return
+	 */
+	public Double getFareOfRule(DistributionRule rule, Double price){
+		Double needFare = null;
+		if (rule.getFareType() == 1){
+			needFare = rule.getUniformPrice();
+		}else {
+			for (RuleQtyFare fare : rule.getFares()){
+				if (fare.getStart() <= price){
+					if (fare.getEnd() != null){
+						if (fare.getEnd() > price){
+							needFare = fare.getFare();
+						}
+					}else {
+						needFare = fare.getFare();
+					}
+				}
+			}
+		}
+		return needFare;
+	}
+
+	/**
+	 * 根据分段地区集合转化为可用的Map集合
+	 *
+	 * @param qtyArea 分段地区集合
+	 * @return
+	 */
+	public Map<String, Map<String, List<String>>> convertArea(List<RuleQtyArea> qtyArea){
+		if (qtyArea == null) {
+			throw new IllegalOperatorException("地区信息丢失,请刷新后重试");
+		}
+
+		Map<String, Map<String, List<String>>> areaMap = new HashMap<>();
+		for (RuleQtyArea a : qtyArea){
+			if (a.getProvince() != null && a.getProvince().length() != 0){
+				//判断该RuleQtyArea是否包含省字段
+				Map<String, List<String>> cityMap = null;
+				if (!areaMap.containsKey(a.getProvince())){
+					cityMap = new HashMap<>();
+					areaMap.put(a.getProvince(), cityMap);
+				}
+				cityMap = areaMap.get(a.getProvince());
+				if (a.getCity() != null && a.getCity().length() != 0){
+					//判断该RuleQtyArea是否包含市字段
+					List<String> areaList = null;
+					if (!cityMap.containsKey(a.getCity())){
+						areaList = new ArrayList<>();
+						cityMap.put(a.getCity(), areaList);
+					}
+					areaList = cityMap.get(a.getCity());
+					if (a.getArea() != null && a.getArea().length() != 0){
+						if (!areaList.contains(a.getArea())){
+							areaList.add(a.getArea());
+						}
+					}
+				}
+			}
+		}
+		return areaMap;
+	}
+
+	/**
+	 * 是否匹配该地区
+	 *
+	 * @param resultMap 转化的地区map集合
+	 * @param area 要匹配的地区
+	 * @return
+	 */
+	public boolean containsArea(Map<String, Map<String, List<String>>> resultMap, String area){
+		String[] areaArray = area.split(SplitChar.COMMA); //拆分地区数据,获取省,市,区的数组
+		if (resultMap.containsKey(areaArray[0])){ //是否包含该省
+			Map<String, List<String>> cityMap = resultMap.get(areaArray[0]);
+			if (cityMap.isEmpty()){ //没有市数据
+				return true;
+			}else {
+				if (cityMap.containsKey(areaArray[1])){ //是否包含该市
+					List<String> areaList = cityMap.get(areaArray[1]);
+					if (areaList.isEmpty()){ //没有区数据
+						return true;
+					}else {
+						if (areaList.contains(areaArray[2])){
+							return true;
+						}else {
+							return false;
+						}
+					}
+				}else {
+					return false;
+				}
+			}
+		}else {
+			return false;
+		}
+	}
+}

+ 14 - 14
src/main/java/com/uas/platform/b2c/logistics/service/impl/DistributorSellerServiceImpl.java

@@ -27,7 +27,7 @@ public class DistributorSellerServiceImpl implements DistributorSellerService {
 	@Override
 	public List<DistributorSeller> findAllChooseDistributor() {
 		Long enuu = SystemSession.getUser().getEnterprise().getUu();
-		return distributorSellerDao.findByEnuuOrderByCreatetimeDesc(enuu);
+		return distributorSellerDao.findByEnuuOrderByNumAsc(enuu);
 	}
 
 	@Override
@@ -35,22 +35,22 @@ public class DistributorSellerServiceImpl implements DistributorSellerService {
 		List<DistributorSeller> savaList = new ArrayList<>();
 		Long enuu = SystemSession.getUser().getEnterprise().getUu();
 		Long useruu = SystemSession.getUser().getUserUU();
-		List<String> chooseList = distributorSellerDao.findAllChooseName(enuu);
+		distributorSellerDao.deleteDistributorByEnuu(enuu);//保存前先清空表
+		int num = 1;
 		for (JSONObject object : objects){
-			if (!chooseList.contains(object.getString("companyName"))){
-				DistributorSeller distributor = new DistributorSeller();
-				if (object.getString("code") != null){
-					distributor.setIsKdn((short)1);
-				}else {
-					distributor.setIsKdn((short)0);
-				}
+			DistributorSeller distributor = new DistributorSeller();
+			if (object.getString("code") != null){
+				distributor.setIsKdn((short)1);
 				distributor.setCode(object.getString("code"));
-				distributor.setCompanyName(object.getString("companyName"));
-				distributor.setUseruu(useruu);
-				distributor.setEnuu(enuu);
-				distributor.setCreatetime(new Date());
-				savaList.add(distributor);
+			}else {
+				distributor.setIsKdn((short)0);
 			}
+			distributor.setCompanyName(object.getString("companyName"));
+			distributor.setUseruu(useruu);
+			distributor.setEnuu(enuu);
+			distributor.setCreatetime(new Date());
+			distributor.setNum(num++);
+			savaList.add(distributor);
 		}
 		return distributorSellerDao.save(savaList);
 	}

+ 15 - 1
src/main/java/com/uas/platform/b2c/logistics/service/impl/InvoiceFOrderServiceImpl.java

@@ -170,7 +170,7 @@ public class InvoiceFOrderServiceImpl implements InvoiceFOrderService {
 			order.setLgtId(inF.getLogistics().getId());
 			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 			order.setDeliverTime(sdf.format(new Date()));
-			order.setDeliverytype(Type.Delivery_ByUU_Code.value());
+//			order.setDeliverytype(Type.Delivery_ByUU_Code.value());
 			order.setJsonSdAddress(addr);
 			Set<OrderDetail> orderDetails = order.getOrderDetails();
 			for (OrderDetail orderDetail : orderDetails) {
@@ -351,12 +351,26 @@ public class InvoiceFOrderServiceImpl implements InvoiceFOrderService {
 		if(detno == 1) {
 			throw new IllegalOperatorException("当前订单的明细状态没有已出货的状态,不能转出货单");
 		}
+		invoice.setFare(order.getFare());
+		//设置配送规则和自提点信息
+		if (order.getJsonRule() != null){
+			invoice.setJsonRule(order.getJsonRule());
+		}
+		if (order.getJsonTakeSelf() != null){
+			invoice.setJsonTakeSelf(order.getJsonTakeSelf());
+		}
 		invoice.setTaxes(taxes);
 		invoice.setPrice(prices);
 		invoice.setNumber(number);
+		/**
+		 * 加入运费
+		 */
+		ensurePrice = DoubleArith.add(ensurePrice, invoice.getFare());
 		invoice.setEnsurePrice(ensurePrice);
 		invoice.setTobeshipped(userUU);
 		invoice.setInvoiceFOrderDetails(iDetails);
+		invoice.setInforRemark(order.getOrderRemark());
+		invoice.setDeliveryType(order.getDeliverytype());
 
 		if (invoice.getUasPurcid() != null) {
 			// 手动将平台状态改成202(要考虑一点,UAS和平台做的单据是否都可以这样做)

+ 60 - 30
src/main/java/com/uas/platform/b2c/logistics/service/impl/InvoiceFPurchaseServiceImpl.java

@@ -42,6 +42,7 @@ import org.springframework.data.domain.Page;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.NumberUtils;
 import org.springframework.util.StringUtils;
 
 import javax.management.OperationsException;
@@ -118,6 +119,14 @@ public class InvoiceFPurchaseServiceImpl implements InvoiceFPurchaseService {
 		Long uu = SystemSession.getUser().getUserUU();
 		Date date = new Date();
 		InvoiceFPurchase inFpu = new InvoiceFPurchase(purchase);
+
+		//保存适用配送规则和自提点信息
+		if (purchase.getJsonRule() != null){
+			inFpu.setJsonRule(purchase.getJsonRule());
+		}
+		if (purchase.getJsonTakeSelf() != null){
+			inFpu.setJsonTakeSelf(purchase.getJsonTakeSelf());
+		}
 		// 生成出货单号
 		String invoiceid = createNumberService.generateVoucherId(EncodingRulesConstant.INVOICE_FROMPURCHASE,
 				"trade$invoice_fmpu", 8);
@@ -166,10 +175,14 @@ public class InvoiceFPurchaseServiceImpl implements InvoiceFPurchaseService {
 		inFpu.setTaxes(taxes);
 		price = NumberUtil.pricesScaleTwo(price);
 		inFpu.setPrice(price);
+		//添加运费
+		ensurePrice = NumberUtil.add(ensurePrice, inFpu.getFare());
 		ensurePrice = NumberUtil.pricesScaleTwo(ensurePrice);
 		inFpu.setEnsurePrice(ensurePrice);
 		inFpu.setNumber(number);
 		inFpu.setStatusToBeShipped(uu);
+		inFpu.setInfpuRemark(purchase.getPurchaseRemark());
+		inFpu.setSendType(purchase.getSendType());
 		inFpu.setInvoiceFPurchaseDetails(IpDetails);
 
 		inFpu = inFpuDao.save(inFpu);
@@ -247,9 +260,13 @@ public class InvoiceFPurchaseServiceImpl implements InvoiceFPurchaseService {
 		Long userUU = SystemSession.getUser().getUserUU();
 		InvoiceFPurchase invoiceFPurchase = inFpuDao.getOne(id);
 		Purchase purchase = purchaseDao.findOne(invoiceFPurchase.getPuid());
-		String deliveryType = sendInfo.getString("deliveryType");
-		
-		if(StringUtils.isEmpty(deliveryType)) {
+//		String deliveryType = sendInfo.getString("deliveryType");
+		Integer sendType = Integer.parseInt(sendInfo.getString("sendType"));
+
+//		if(StringUtils.isEmpty(deliveryType)) {
+//			return new ResultMap(CodeType.NO_INFO, "配送方式的信息为空,请重新操作");
+//		}
+		if (sendType == null){
 			return new ResultMap(CodeType.NO_INFO, "配送方式的信息为空,请重新操作");
 		}
 		
@@ -262,31 +279,37 @@ public class InvoiceFPurchaseServiceImpl implements InvoiceFPurchaseService {
 				&&purchase.getLaunchPuExApplyStatus().equals(AfterSaleStatus.FINISHED)) {
 			return new ResultMap(CodeType.NOT_PERMIT, "您的异常申请流程还不是已完成或已取消状态,不能做发货的动作!");
 		}
-		
-		if("logistics".equals(deliveryType)) {
-			JSONObject  logisjson= sendInfo.getJSONObject("logisticsInfo");
-			Logistics logistics = logisticsService.bornLogisticsByCompanyNameAndNum(logisjson.getString("companyName"), logisjson.getString("number"));
+		JSONObject  logisticsJson = sendInfo.getJSONObject("logisticsInfo");
+		if (logisticsJson != null){
+			Logistics logistics = logisticsService.bornLogisticsByCompanyNameAndNum(logisticsJson.getString("companyName"), logisticsJson.getString("number"));
 			invoiceFPurchase.setLogistics(logistics);
-
-		}else if("selfDelivery".equals(deliveryType)){
-			JSONObject  logisticsJson= sendInfo.getJSONObject("selfDeliveryPerson");
-			String name = logisticsJson.getString("name");
-			if(StringUtils.isEmpty(name)) {
-				return new ResultMap(CodeType.NO_INFO, "送货人信息为空,请重新操作");
-			}
-			String phone = logisticsJson.getString("phone");
-			if(StringUtils.isEmpty(phone)) {
-				return new ResultMap(CodeType.NO_INFO, "送货人电话信息为空,请重新操作");
-			}
-			invoiceFPurchase.setSelfDeliveryName(name);
-			invoiceFPurchase.setSelfDeliveryPhone(phone);
 		}
+//		if("logistics".equals(deliveryType)) {
+//			JSONObject  logisjson= sendInfo.getJSONObject("logisticsInfo");
+//			Logistics logistics = logisticsService.bornLogisticsByCompanyNameAndNum(logisjson.getString("companyName"), logisjson.getString("number"));
+//			invoiceFPurchase.setLogistics(logistics);
+//
+//		}else if("selfDelivery".equals(deliveryType)){
+//			JSONObject  logisticsJson= sendInfo.getJSONObject("selfDeliveryPerson");
+//			String name = logisticsJson.getString("name");
+//			if(StringUtils.isEmpty(name)) {
+//				return new ResultMap(CodeType.NO_INFO, "送货人信息为空,请重新操作");
+//			}
+//			String phone = logisticsJson.getString("phone");
+//			if(StringUtils.isEmpty(phone)) {
+//				return new ResultMap(CodeType.NO_INFO, "送货人电话信息为空,请重新操作");
+//			}
+//			invoiceFPurchase.setSelfDeliveryName(name);
+//			invoiceFPurchase.setSelfDeliveryPhone(phone);
+//		}
+
 		String jsonSdAddress = sendInfo.getString("jsonSdAddress");
 		if(StringUtils.isEmpty(jsonSdAddress)) {
 			return new ResultMap(CodeType.NO_INFO, "发货人的地址信息为空,请重新操作");
 		}
 		invoiceFPurchase.setJsonSdAddress(jsonSdAddress);
-		invoiceFPurchase.setDeliveryType(deliveryType);
+//		invoiceFPurchase.setDeliveryType(deliveryType);
+		invoiceFPurchase.setSendType(sendType);
 		
 		invoiceFPurchase.setStatusInBound(userUU);
 		Set<InvoiceFPurchaseDetail> invoiceFPurchaseDetails = invoiceFPurchase.getInvoiceFPurchaseDetails();
@@ -306,13 +329,17 @@ public class InvoiceFPurchaseServiceImpl implements InvoiceFPurchaseService {
 			}
 		}
 		purchase.setStatusInBound(userUU);
-		if("logistics".equals(inFpu.getDeliveryType())) {
+		if (inFpu.getLogistics() != null){
 			purchase.setLgtId(inFpu.getLogistics().getId());
-		}else {
-			purchase.setSelfDeliveryName(inFpu.getSelfDeliveryName());
-			purchase.setSelfDeliveryPhone(inFpu.getSelfDeliveryPhone());
 		}
-		purchase.setDeliveryType(inFpu.getDeliveryType());
+//		if("logistics".equals(inFpu.getDeliveryType())) {
+//			purchase.setLgtId(inFpu.getLogistics().getId());
+//		}else {
+//			purchase.setSelfDeliveryName(inFpu.getSelfDeliveryName());
+//			purchase.setSelfDeliveryPhone(inFpu.getSelfDeliveryPhone());
+//		}
+//		purchase.setDeliveryType(inFpu.getDeliveryType());
+
 		purchase.setJsonSdAddress(inFpu.getJsonSdAddress());
 		purchase.setSendName(SystemSession.getUser().getUserName());
 		purchase.setSenduu(SystemSession.getUser().getUserUU());
@@ -325,12 +352,15 @@ public class InvoiceFPurchaseServiceImpl implements InvoiceFPurchaseService {
 			if(order == null) {
 				return new ResultMap(CodeType.NOT_PERMIT, "您订单的信息有误,请重新提交");
 			}
-			if("logistics".equals(inFpu.getDeliveryType())) {
+			if (inFpu.getLogistics() != null){
 				order.setLgtId(inFpu.getLogistics().getId());
-			}else {
-				order.setSelfDeliveryName(inFpu.getSelfDeliveryName());
-				order.setSelfDeliveryPhone(inFpu.getSelfDeliveryPhone());
 			}
+//			if("logistics".equals(inFpu.getDeliveryType())) {
+//				order.setLgtId(inFpu.getLogistics().getId());
+//			}else {
+//				order.setSelfDeliveryName(inFpu.getSelfDeliveryName());
+//				order.setSelfDeliveryPhone(inFpu.getSelfDeliveryPhone());
+//			}
 			order.setJsonSdAddress(inFpu.getJsonSdAddress());
 			order.setStatusInBound(userUU);
 			for (OrderDetail detail : order.getOrderDetails()) {

+ 92 - 0
src/main/java/com/uas/platform/b2c/logistics/service/impl/LogisticsOldServiceImpl.java

@@ -1,5 +1,6 @@
 package com.uas.platform.b2c.logistics.service.impl;
 
+import com.uas.platform.b2c.core.config.SysConf;
 import com.uas.platform.b2c.logistics.model.Logistics;
 import com.uas.platform.b2c.logistics.model.LogisticsCompanyCode;
 import com.uas.platform.b2c.core.support.SystemSession;
@@ -11,6 +12,10 @@ import com.uas.platform.b2c.trade.deprecated.model.ConstantTrade;
 import com.uas.platform.b2c.logistics.model.InvoiceFPurchase;
 import com.uas.platform.b2c.trade.deprecated.model.ResponseLogistics;
 import com.uas.platform.b2c.logistics.service.LogisticsOldService;
+import com.uas.platform.b2c.trade.order.dao.OrderDao;
+import com.uas.platform.b2c.trade.order.dao.PurchaseDao;
+import com.uas.platform.b2c.trade.order.model.Order;
+import com.uas.platform.b2c.trade.order.model.Purchase;
 import com.uas.platform.b2c.trade.support.CodeType;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.exception.IllegalOperatorException;
@@ -32,6 +37,15 @@ public class LogisticsOldServiceImpl implements LogisticsOldService {
 	@Autowired
 	private InvoiceFPurchaseDao invoiceFPurchaseDao;
 
+	@Autowired
+	private PurchaseDao purchaseDao;
+
+	@Autowired
+	private OrderDao orderDao;
+
+	@Autowired
+	private SysConf sysConf;
+
 	/*
 	 * @Override public List<LogisticsCompanyCode> getAllCodes() { return
 	 * logisticsCompanyCodeDao.findAll(); } public List<String> getAllName(){
@@ -88,6 +102,84 @@ public class LogisticsOldServiceImpl implements LogisticsOldService {
 		return logisticsDao.findOne(id);
 	}
 
+	/**
+	 * 新增物流信息
+	 * @param inid
+	 * @param logistics
+	 * @return
+	 */
+	@Override
+	public ResultMap addLogistics(String inid, Logistics logistics) {
+		if(StringUtils.isEmpty(inid)) {
+			return new ResultMap(CodeType.NO_INFO, "您需要更新的出货单号为空,请重新操作");
+		}
+		InvoiceFPurchase fPurchase = invoiceFPurchaseDao.findByInvoiceid(inid);
+		if(fPurchase == null) {
+			return new ResultMap(CodeType.NOT_EXiST, "找不到对应的出货单号为空,请重新操作");
+		}
+		if(SystemSession.getUser().getEnterprise().getUu().longValue() != fPurchase.getSellerenuu().longValue()) {
+			return new ResultMap(CodeType.NOT_PERMIT, "当前登录的公司不能操作此订单");
+		}
+		if(StringUtils.isEmpty(logistics.getCompanyName())) {
+			return new ResultMap(CodeType.NO_INFO, "物流公司信息为空,请重新操作");
+		}
+		if(StringUtils.isEmpty(logistics.getNumber())) {
+			return new ResultMap(CodeType.NO_INFO, "物流单号信息为空,请重新操作");
+		}
+		if (logistics != null){
+			LogisticsCompanyCode logisticsCompanyCode = logisticsCompanyCodeDao.findByName(logistics.getCompanyName());
+			if (logisticsCompanyCode != null) {
+				logistics.setCompanyId(logisticsCompanyCode.getId());
+				logistics.setCompanyCode(logisticsCompanyCode.getCode());
+			}
+			Logistics logistics1 = logisticsDao.save(logistics);
+			fPurchase.setLogistics(logistics1);
+		}
+		Purchase purchase = purchaseDao.findOne(fPurchase.getPuid());
+		if (fPurchase.getLogistics() != null){
+			purchase.setLgtId(fPurchase.getLogistics().getId());
+			purchaseDao.save(purchase);
+		}
+		if(!purchase.getStoreid().equals(sysConf.getStoreid())) {
+			Order order = orderDao.findByOrderid(purchase.getOrderid());
+			if (order == null) {
+				return new ResultMap(CodeType.NOT_PERMIT, "您订单的信息有误,请重新提交");
+			}
+			if (fPurchase.getLogistics() != null) {
+				order.setLgtId(fPurchase.getLogistics().getId());
+			}
+			orderDao.save(order);
+		}
+		invoiceFPurchaseDao.save(fPurchase);
+		return ResultMap.success(null);
+	}
+
+	@Override
+	public ResultMap clearLogistics(String inid) {
+		if(StringUtils.isEmpty(inid)) {
+			return new ResultMap(CodeType.NO_INFO, "您需要更新的出货单号为空,请重新操作");
+		}
+		InvoiceFPurchase fPurchase = invoiceFPurchaseDao.findByInvoiceid(inid);
+		if (fPurchase.getLogistics() == null){
+			return new ResultMap(CodeType.NO_INFO, "您需要更新的快递信息为空,请重新操作");
+		}
+		fPurchase.setLogistics(null);
+		Purchase purchase = purchaseDao.findOne(fPurchase.getPuid());
+		if (purchase.getLgtId() != null){
+			purchase.setLgtId(null);
+			purchaseDao.save(purchase);
+		}
+		//如果是自营的,也需要将订单的快递为空
+		if(!purchase.getStoreid().equals(sysConf.getStoreid())) {
+			Order order = orderDao.findByOrderid(purchase.getOrderid());
+			if (order.getLgtId() != null){
+				order.setLgtId(null);
+			}
+			orderDao.save(order);
+		}
+		invoiceFPurchaseDao.save(fPurchase);
+		return ResultMap.success(null);
+	}
 
 	/**
 	 * 更新物流信息

+ 2 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/controller/ProductController.java

@@ -31,6 +31,8 @@ import java.util.Map;
  *
  * @author wangyc on 2017/5/26.
  * @version 2017年8月3日11:34:58 yuj 增加注释
+ * @version 2017年8月21日14:40:15 产品管理开发第三版
+ * @version 2017年8月21日15:12:50 test
  */
 @RestController
 @RequestMapping("/trade/products")

+ 11 - 8
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java

@@ -327,8 +327,9 @@ public class ProductServiceImpl implements ProductService {
                 Double multiple = NumberUtil.div(productStandardPutOnInfo.getMinBuyQty(), productStandardPutOnInfo.getMinPackQty());
                 if(multiple == 0){
                     productStandardPutOnInfo.setMinBuyQty(product.getMinPackQty());
+                }else {
+                    productStandardPutOnInfo.setMinBuyQty(NumberUtil.mul(product.getMinPackQty(), Math.ceil(multiple)));
                 }
-                productStandardPutOnInfo.setMinBuyQty(NumberUtil.mul(product.getMinPackQty(), Math.ceil(multiple)));
                 productStandardPutOnInfo.setMinPackQty(product.getMinPackQty());
                 productModifyHistory.setMinPackQty(product.getMinPackQty());
                 persistProduct.setMinPackQty(product.getMinPackQty());
@@ -339,13 +340,15 @@ public class ProductServiceImpl implements ProductService {
                 persistProduct.setMinPackQty(product.getMinPackQty());
             }
             if(productStandardPutOnInfo.getStatus() == Status.AVAILABLE.value()){
-                Goods goods =goodsDao.findByBatchCode(productStandardPutOnInfo.getGoBatch());
-                if(productStandardPutOnInfo.getMinBuyQty() != null && product.getMinPackQty() != null){
-                    goods.setMinBuyQty(NumberUtil.mul(product.getMinPackQty(), NumberUtil.div(productStandardPutOnInfo.getMinBuyQty(), productStandardPutOnInfo.getMinPackQty())));
-                    goods.setMinPackQty(product.getMinPackQty());
-                }else if(product.getMinPackQty() != null){
-                    goods.setMinPackQty(product.getMinPackQty());
-                    goods.setMinBuyQty(product.getMinPackQty());
+                Goods goods = goodsDao.findByBatchCode(productStandardPutOnInfo.getGoBatch());
+                if(productStandardPutOnInfo.getMinBuyQty() != null && productStandardPutOnInfo.getMinPackQty() != null){
+                    goods.setMinBuyQty(productStandardPutOnInfo.getMinBuyQty());
+                    goods.setMinPackQty(productStandardPutOnInfo.getMinPackQty());
+                }
+                if(NumberUtil.compare(goods.getMinBuyQty(), goods.getReserve()) > 0) {
+                    goods.setStatus(Status.UNAVAILABLE.value());
+                }else {
+                    goods.setStatus(Status.AVAILABLE.value());
                 }
                 if (product.getPackaging() != null){
                     goods.setPackaging(product.getPackaging());

+ 14 - 6
src/main/java/com/uas/platform/b2c/prod/product/brand/api/BrandController.java

@@ -12,10 +12,7 @@ import com.uas.platform.core.model.PageParams;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.util.StringUtils;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
@@ -117,12 +114,13 @@ public class BrandController {
 
 	/**
 	 * 根据品牌英文名获取品牌信息
-	 * 
+	 *
 	 * @param nameEn 品牌英文名
 	 * @return 品牌信息
 	 */
 	@RequestMapping(value = "/nameEn/{nameEn}", method = RequestMethod.GET)
-	public List<Brand> getByNameEn(@PathVariable("nameEn") String nameEn) {
+	public List<Brand> getByNameEn(@PathVariable("nameEn") String nameEn) throws UnsupportedEncodingException {
+		nameEn = URLDecoder.decode(nameEn, "UTF-8");
 		return brandService.getByNameEn(nameEn);
 	}
 
@@ -177,4 +175,14 @@ public class BrandController {
     public List<Brand> getHotBrands(@PathVariable("num") Integer num) {
 		return brandService.getHotBrands(num);
     }
+
+	/**
+	 * 根据批次号获取品牌信息
+	 * @param batchIds
+	 * @return 品牌信息
+	 */
+	@RequestMapping(value = "/batchId", method = RequestMethod.POST, produces = "application/json")
+	public List<BrandMostSimpleInfo> getBatchBrands(@RequestBody List<Long> batchIds) {
+		return brandService.getBatchBrandMostSimpleInfs(batchIds);
+	}
 }

+ 8 - 0
src/main/java/com/uas/platform/b2c/prod/product/brand/dao/BrandMostSimpleInfoDao.java

@@ -24,4 +24,12 @@ public interface BrandMostSimpleInfoDao extends JpaSpecificationExecutor<BrandMo
      */
     @Query(nativeQuery = true, value = "select * from product$brand where br_inital in :initals")
     public List<BrandMostSimpleInfo> findInInitals(@Param("initals") String[] initals);
+
+    /**
+     * 根据批次号获取品牌信息
+     * @param batchIds id批次号
+     * @return
+     */
+    @Query(nativeQuery = true, value = "select * from product$brand where br_id in :batchIds")
+    public List<BrandMostSimpleInfo> findBatchBrands(@Param("batchIds") List<Long> batchIds);
 }

+ 7 - 0
src/main/java/com/uas/platform/b2c/prod/product/brand/service/BrandService.java

@@ -141,4 +141,11 @@ public interface BrandService {
 	 * @return 新增品牌数量统计
 	 */
 	List<Map<String, Object>> findCountIncreaseBrandByMonth();
+
+	/**
+	 * 根据批次号获取品牌信息
+	 * @param batchIds
+	 * @return 品牌信息
+	 */
+	public List<BrandMostSimpleInfo> getBatchBrandMostSimpleInfs(List<Long> batchIds);
 }

+ 10 - 2
src/main/java/com/uas/platform/b2c/prod/product/brand/service/impl/BrandServiceImpl.java

@@ -44,10 +44,10 @@ public class BrandServiceImpl implements BrandService {
 	private ComponentDao componentDao;
 
 	@Autowired
-	private BrandMostSimpleInfoDao brandMostSimpleInfoDao;
+	private JdbcTemplate jdbcTemplate;
 
 	@Autowired
-	private JdbcTemplate jdbcTemplate;
+	private BrandMostSimpleInfoDao brandMostSimpleInfoDao;
 
 	@Override
 	public List<Brand> init(List<Brand> brands) {
@@ -323,4 +323,12 @@ public class BrandServiceImpl implements BrandService {
 
 		return "success";
 	}
+
+	@Override
+	public List<BrandMostSimpleInfo> getBatchBrandMostSimpleInfs(List<Long> batchIds) {
+		if (batchIds.size() == 0) {
+			return brandMostSimpleInfoDao.findAll();
+		}
+		return brandMostSimpleInfoDao.findBatchBrands(batchIds);
+	}
 }

+ 4 - 4
src/main/java/com/uas/platform/b2c/prod/product/brand/service/impl/BrandSubmitServiceImpl.java

@@ -77,8 +77,8 @@ public class BrandSubmitServiceImpl implements BrandSubmitService {
 			// 如果是新增检查品牌是否重名,重名设置version为-1,返回前台判断是否更新已存在品牌
 			List<Brand> existBrandCn = new ArrayList<Brand>();
 			if (brandSubmit.getNameCn() != null)
-				existBrandCn = brandDao.findByNameCn(brandSubmit.getNameCn());
-			List<Brand> existBrandEn = brandDao.findByNameEn(brandSubmit.getNameEn());
+				existBrandCn = brandDao.findByUpperNameCn(brandSubmit.getNameCn());
+			List<Brand> existBrandEn = brandDao.findByUpperNameEn(brandSubmit.getNameEn());
 			if (CollectionUtils.isNotEmpty(existBrandCn)) {
 				brand.setVersion((short) -1);
 				return brand;
@@ -96,8 +96,8 @@ public class BrandSubmitServiceImpl implements BrandSubmitService {
 			Brand existBrand = brandDao.findByUuid(brandSubmit.getUuid());
 			// 如果uuid有误,则将申请uuid设为null,视为新增品牌申请
 			if (existBrand == null) {
-				List<Brand> existBrandCn = brandDao.findByNameCn(brandSubmit.getNameCn());
-				List<Brand> existBrandEn = brandDao.findByNameEn(brandSubmit.getNameEn());
+				List<Brand> existBrandCn = brandDao.findByUpperNameCn(brandSubmit.getNameCn());
+				List<Brand> existBrandEn = brandDao.findByUpperNameEn(brandSubmit.getNameEn());
 				if (CollectionUtils.isNotEmpty(existBrandCn)) {
 					brand.setVersion((short) -1);
 					return brand;

+ 9 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/api/ComponentController.java

@@ -267,4 +267,13 @@ public class ComponentController {
 		return goodsService.pageGoodsByKeyword(pageInfo, original, keyword);
 	}
 
+	/**
+	 * 根据批次号获取器件信息
+	 * @param batchIds
+	 * @return 器件信息
+	 */
+	@RequestMapping(value = "/batchId", method = RequestMethod.POST, produces = "application/json")
+	public List<ComponentInfo> getBatchBrands(@RequestBody List<Long> batchIds) {
+		return componentService.getBatchComponents(batchIds);
+	}
 }

+ 8 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/dao/ComponentInfoDao.java

@@ -80,4 +80,12 @@ public interface ComponentInfoDao extends JpaSpecificationExecutor<ComponentInfo
 	 * @return 库存数量大于指定值的一页器件
 	 */
 	Page<ComponentInfo> findByImgIsNotNull(Pageable pageable);
+
+	/**
+	 * 根据批次号获取器件信息
+	 * @param batchids id批次号
+	 * @return
+	 */
+	@Query(nativeQuery = true, value = "select * from product$component where cmp_id in :batchids")
+	public List<ComponentInfo> findByBatchids(@Param("batchids") List<Long> batchids);
 }

+ 15 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/modal/ComponentGoods.java

@@ -64,6 +64,12 @@ public class ComponentGoods implements Serializable {
 	@Column(name = "cmp_uuid")
 	private String uuid;
 
+	/**
+	 * 是否拆卖
+	 */
+	@Column(name = "go_isbreakup")
+	private Boolean breakUp;
+
 	/**
 	 * 批次号
 	 */
@@ -654,4 +660,13 @@ public class ComponentGoods implements Serializable {
 		this.b2cDeliveryDemMaxTime = b2cDeliveryDemMaxTime;
 		return this;
 	}
+
+	public Boolean getBreakUp() {
+		return breakUp;
+	}
+
+	public ComponentGoods setBreakUp(Boolean breakUp) {
+		this.breakUp = breakUp;
+		return this;
+	}
 }

+ 7 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/service/ComponentService.java

@@ -202,4 +202,11 @@ public interface ComponentService {
 	 * @return 新增器件数量统计
 	 */
 	List<Map<String, Object>> findCountIncreaseComponentByMonth();
+
+	/**
+	 * 根据批次号获取器件信息
+	 * @param batchIds
+	 * @return 器件信息
+	 */
+	List<ComponentInfo> getBatchComponents(List<Long> batchIds);
 }

+ 6 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentServiceImpl.java

@@ -536,5 +536,11 @@ public class ComponentServiceImpl implements ComponentService {
 		return map;
 	}
 
+	public List<ComponentInfo> getBatchComponents(List<Long> batchIds) {
+		if (batchIds.size() == 0) {
+			return componentInfoDao.findAll();
+		}
+		return componentInfoDao.findByBatchids(batchIds);
+	}
 
 }

+ 10 - 0
src/main/java/com/uas/platform/b2c/prod/product/kind/api/KindController.java

@@ -195,4 +195,14 @@ public class KindController {
 		name = URLDecoder.decode(name, "utf-8");
 		return  kindService.getKindInfoByName(name);
 	}
+
+	/**
+	 * 根据批次号获取类目信息
+	 * @param batchIds
+	 * @return 类目信息
+	 */
+	@RequestMapping(value = "/batchId", method = RequestMethod.POST, produces = "application/json")
+	public List<Kind> getBatchBrands(@RequestBody List<Long> batchIds) {
+		return kindService.getBatchKinds(batchIds);
+	}
 }

+ 8 - 0
src/main/java/com/uas/platform/b2c/prod/product/kind/dao/KindDao.java

@@ -54,4 +54,12 @@ public interface KindDao extends JpaSpecificationExecutor<Kind>, JpaRepository<K
 	 * @return
 	 */
 	public List<Kind> findByNameCn(String nameCn);
+
+	/**
+	* 根据批次号获取类目信息
+	* @param batchIds id批次号
+	* @return
+	*/
+	@Query(nativeQuery = true, value = "select * from product$kind where ki_id in :batchIds")
+	public List<Kind> findByBatchIds(@Param("batchIds") List<Long> batchIds);
 }

+ 7 - 0
src/main/java/com/uas/platform/b2c/prod/product/kind/service/KindService.java

@@ -308,4 +308,11 @@ public interface KindService {
 	 * @return 类目信息
 	 */
 	Kind getFirstKind(Long kindId);
+
+	/**
+	 * 根据批次号获取类目信息
+	 * @param batchIds
+	 * @return 类目信息
+	 */
+	List<Kind> getBatchKinds(List<Long> batchIds);
 }

+ 8 - 0
src/main/java/com/uas/platform/b2c/prod/product/kind/service/impl/KindServiceImpl.java

@@ -1201,4 +1201,12 @@ public class KindServiceImpl implements KindService {
 	Kind getParentByChildId(Kind child) {
 		return kindDao.findOne(child.getParentid());
 	}
+
+
+	public List<Kind> getBatchKinds(List<Long> batchIds) {
+		if (batchIds.size() == 0) {
+			return kindDao.findAll();
+		}
+		return kindDao.findByBatchIds(batchIds);
+	}
 }

+ 17 - 0
src/main/java/com/uas/platform/b2c/prod/store/controller/StoreInformationController.java

@@ -4,6 +4,8 @@ import com.uas.platform.b2c.advertise.ad.model.StoreAdsType;
 import com.uas.platform.b2c.prod.store.model.StoreIn;
 import com.uas.platform.b2c.prod.store.model.StoreStatus;
 import com.uas.platform.b2c.prod.store.service.StoreInService;
+import com.uas.platform.b2c.trade.support.CodeType;
+import com.uas.platform.b2c.trade.support.ResultMap;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -79,4 +81,19 @@ public class StoreInformationController {
 		return storeService.cancelStoreTagsWhenAdminCancel(type, store);
 	}
 
+	/**
+	 * TODO 正式系统店铺企业信息同步之后,弃用
+	 */
+	@Deprecated
+	@ResponseBody
+	@RequestMapping(method = RequestMethod.GET, value = "/auth/api/store//syncEnterprise")
+	public ResultMap syncStoreEnterpriseInfo() {
+		try {
+			storeService.syncStoreEnterpriseInfo();
+		} catch (Exception e) {
+			return new ResultMap(CodeType.ERROR_STATE, e.getMessage());
+		}
+		return ResultMap.success("finished");
+	}
+
 }

+ 15 - 0
src/main/java/com/uas/platform/b2c/prod/store/model/EnterpriseSimple.java

@@ -2,6 +2,7 @@ package com.uas.platform.b2c.prod.store.model;
 
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.uas.platform.b2c.common.account.model.Enterprise;
+import com.uas.platform.b2c.fa.payment.utils.StringUtils;
 
 import java.util.Date;
 
@@ -54,6 +55,11 @@ public class EnterpriseSimple {
 	 */
 	private String enFax;
 
+	/**
+	 * 公司邮箱
+	 */
+	private String enEmail;
+
 	/**
 	 * 商业登记证号
 	 */
@@ -133,6 +139,14 @@ public class EnterpriseSimple {
 		this.enType = enType;
 	}
 
+	public String getEnEmail() {
+		return enEmail;
+	}
+
+	public void setEnEmail(String enEmail) {
+		this.enEmail = enEmail;
+	}
+
 	public String getEnBusinessCode() {
 		return enBusinessCode;
 	}
@@ -187,6 +201,7 @@ public class EnterpriseSimple {
 		simple.enDate = enterprise.getEnDate();
 		simple.enUrl = enterprise.getEnUrl();
 		simple.enLogoUrl = enterprise.getEnLogoUrl();
+		simple.enEmail = StringUtils.isEmpty(enterprise.getEnEmail()) ? " " : enterprise.getEnEmail();
 		return simple;
 	}
 

+ 3 - 0
src/main/java/com/uas/platform/b2c/prod/store/service/StoreInService.java

@@ -160,4 +160,7 @@ public interface StoreInService {
 	 * @param store		店铺信息
 	 */
 	StoreIn cancelStoreTagsWhenAdminCancel(StoreAdsType type, StoreIn store);
+
+	@Deprecated
+    void syncStoreEnterpriseInfo();
 }

+ 53 - 14
src/main/java/com/uas/platform/b2c/prod/store/service/impl/StoreInServiceImpl.java

@@ -3,6 +3,8 @@ package com.uas.platform.b2c.prod.store.service.impl;
 import com.uas.platform.b2c.advertise.ad.model.StoreAds;
 import com.uas.platform.b2c.advertise.ad.model.StoreAdsType;
 import com.uas.platform.b2c.advertise.ad.service.StoreAdsService;
+import com.uas.platform.b2c.common.account.dao.EnterpriseDao;
+import com.uas.platform.b2c.common.account.model.Enterprise;
 import com.uas.platform.b2c.core.config.SysConf;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.core.utils.JacksonUtils;
@@ -11,15 +13,11 @@ import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentDao;
 import com.uas.platform.b2c.prod.product.component.modal.Component;
 import com.uas.platform.b2c.prod.store.dao.QualificationDao;
+import com.uas.platform.b2c.prod.store.dao.StoreApplyDao;
 import com.uas.platform.b2c.prod.store.dao.StoreBrandInfoDao;
 import com.uas.platform.b2c.prod.store.dao.StoreInDao;
 import com.uas.platform.b2c.prod.store.exception.EmptyParameterException;
-import com.uas.platform.b2c.prod.store.model.Qualification;
-import com.uas.platform.b2c.prod.store.model.StoreApply;
-import com.uas.platform.b2c.prod.store.model.StoreBrandInfo;
-import com.uas.platform.b2c.prod.store.model.StoreIn;
-import com.uas.platform.b2c.prod.store.model.StoreStatus;
-import com.uas.platform.b2c.prod.store.model.StoreType;
+import com.uas.platform.b2c.prod.store.model.*;
 import com.uas.platform.b2c.prod.store.service.StoreInService;
 import com.uas.platform.b2c.trade.order.dao.PurchaseDao;
 import com.uas.platform.b2c.trade.support.ResultMap;
@@ -44,13 +42,7 @@ import javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 /**
  * 店铺业务实现类
@@ -481,7 +473,54 @@ public class StoreInServiceImpl implements StoreInService {
 		return store;
 	}
 
-	@Override
+	// Deprecated: on
+	@Autowired
+	private StoreApplyDao applyDao;
+
+	@Autowired
+	private EnterpriseDao enterpriseDao;
+
+	@Deprecated
+    @Override
+    public void syncStoreEnterpriseInfo() {
+		// 同步店铺申请信息
+		List<StoreApply> applies = applyDao.findAll();
+		if (!CollectionUtils.isEmpty(applies)) {
+			for (StoreApply apply : applies) {
+				apply.setEnterprise(syncEnterpriseInfo(apply.getEnUU(), apply.getEnterprise()));
+			}
+			applyDao.save(applies);
+		}
+
+
+		// 同步店铺信息
+		List<StoreIn> storeIns = storeDao.findAll();
+		if (!CollectionUtils.isEmpty(storeIns)) {
+			for (StoreIn store : storeIns) {
+				store.setEnterprise(syncEnterpriseInfo(store.getEnUU(), store.getEnterprise()));
+			}
+			storeDao.save(storeIns);
+		}
+	}
+
+	private EnterpriseSimple syncEnterpriseInfo(Long enUU, EnterpriseSimple tmp) {
+		Enterprise enterprise = enterpriseDao.findByUu(enUU);
+
+		if (tmp != null) {
+			if (enterprise != null && !StringUtils.isEmpty(enterprise.getEnEmail())) {
+				tmp.setEnEmail(enterprise.getEnEmail());
+			} else {
+				tmp.setEnEmail(" ");
+			}
+		} else {
+			tmp = EnterpriseSimple.translateSimple(enterprise);
+		}
+
+		return tmp;
+	}
+	// Deprecated: off
+
+    @Override
 	public List<StoreIn> findFiveStores(String types, Integer num) {
 		String[] typeArray = types.split("-");
 		List<String> typeList = Arrays.asList(typeArray);

+ 2 - 1
src/main/java/com/uas/platform/b2c/trade/order/controller/OrderController.java

@@ -670,7 +670,8 @@ public class OrderController {
 	public Page<Order> getBillByStatusByPersonal(PageParams params, String keyword, int status) {
 		PageInfo pageInfo = new PageInfo(params);
 		pageInfo.filter("buyeruu", SystemSession.getUser().getUserUU());
-		pageInfo.filter("buyerenuu", SystemSession.getUser().getEnterprise().getUu());
+		if (SystemSession.getUser().getEnterprise() != null)
+			pageInfo.filter("buyerenuu", SystemSession.getUser().getEnterprise().getUu());
 		assert logger != null;
 		logger.log("买家订单管理", "买家获取买家订单信息", "获取待开发票的订单");
 		return orderService.getBillByStatus(pageInfo, keyword, status);

+ 14 - 0
src/main/java/com/uas/platform/b2c/trade/order/controller/PurchaseController.java

@@ -9,12 +9,14 @@ import com.uas.platform.b2c.core.support.view.JxlsExcelView;
 import com.uas.platform.b2c.core.utils.FastjsonUtils;
 import com.uas.platform.b2c.core.utils.StringUtilB2C;
 import com.uas.platform.b2c.logistics.model.InvoiceFPurchase;
+import com.uas.platform.b2c.logistics.model.Logistics;
 import com.uas.platform.b2c.prod.store.service.StoreInService;
 import com.uas.platform.b2c.trade.order.model.Order;
 import com.uas.platform.b2c.trade.order.model.Purchase;
 import com.uas.platform.b2c.trade.order.model.PurchaseModifyingHistory;
 import com.uas.platform.b2c.trade.order.service.PurchaseDetailService;
 import com.uas.platform.b2c.trade.order.service.PurchaseService;
+import com.uas.platform.b2c.trade.presale.model.ValidTime;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.logging.BufferedLoggerManager;
 import com.uas.platform.core.model.PageInfo;
@@ -597,4 +599,16 @@ public class PurchaseController {
 	public String findOrderIdByPuId(@PathVariable("purchaseId") String purchaseId){
 		return purchaseService.findOrderIdByPuId(purchaseId);
 	}
+
+//	@RequestMapping(value = "/logistics")
+//	public Logistics findOneLogistics(){
+//		return null;
+//	}
+//
+//	@RequestMapping(value = "/modifyLogistics", method = RequestMethod.PUT)
+//	public Logistics updateLogistics(Long id){
+//		System.out.println("id=" + id);
+//		return null;
+//	}
+
 }

+ 8 - 0
src/main/java/com/uas/platform/b2c/trade/order/dao/OrderDao.java

@@ -60,6 +60,14 @@ public interface OrderDao extends JpaSpecificationExecutor<Order>, JpaRepository
 	 */
 	Order findOrderByOrderid(String orderid);
 
+	/**
+	 * 根据订单号集获取订单信息
+	 * @param orderids 订单号集
+	 * @return
+	 */
+	@Query("select o from trade.Order o where o.orderid in (:orderids)")
+	List<Order> findByOrderIds(@Param("orderids") List<String> orderids);
+
 	/**
 	 * Gets count by buyeruu and status.
 	 *

+ 171 - 101
src/main/java/com/uas/platform/b2c/trade/order/model/Order.java

@@ -141,6 +141,36 @@ public class Order extends Document implements Serializable {
 	@Column(name = "or_deliverytype")
 	private Integer deliverytype;
 
+	/**
+	 * 运费
+	 */
+	@Column(name = "or_fare")
+	private Double fare = 0d;
+
+	/**
+	 * 使用的配送规则
+	 */
+	@Column(name = "or_rule", length = 2000)
+	private String jsonRule;
+
+	/**
+	 * 拆单之前的配送规则列表
+	 */
+	@Column(name = "or_rules", length = 4000)
+	private String jsonMoreRule;
+
+	/**
+	 * 自提点信息
+	 */
+	@Column(name = "or_take_self", length = 2000)
+	private String jsonTakeSelf;
+
+	/**
+	 * 拆单之前的自提点信息
+	 */
+	@Column(name = "or_take_selfs", length = 4000)
+	private String jsonMoreTake;
+
 	/**
 	 * 收货地址 这里使用json字符串的形式将收货地址整个存起来
 	 */
@@ -259,7 +289,7 @@ public class Order extends Document implements Serializable {
 
 	/**
 	 * 订单状态(1->2->3->4->5->6->7->8->9)
-	 * 
+	 *
 	 * @Tip 必须严格按照顺序流转 1、TOBECONFIRMED(501, "待确认"), 2、TOBEPAID(503, "待付款"),
 	 *      3、PAID(505, "已付款"), 4、TOBESHIPPED(406, "待出货"), 5、SHIPPINGIN(403,
 	 *      "出货中"), 6、SHIPPED(407, "已出货"), 7、SENDING(408, "发货中"), 8、INBOUND(404,
@@ -274,7 +304,7 @@ public class Order extends Document implements Serializable {
 	 */
 	@Column(name = "or_paytime")
 	private Date paytime;
-	
+
 	/**
 	 * 失效时间
 	 */
@@ -295,7 +325,7 @@ public class Order extends Document implements Serializable {
 
 	/**
 	 * 银行转账信息id
-	 * 
+	 *
 	 * @Tip 目前只有银行转账信息,
 	 */
 	@Column(name = "or_banktf")
@@ -330,13 +360,13 @@ public class Order extends Document implements Serializable {
 	 */
 	@Column(name = "or_import_extra_charges")
 	private Double importExtraCharges;
-	
+
 	/**
-	 * 金额合计
+	 * 金额合计,店铺商品明细金额总计
 	 */
 	@Column(name = "or_price")
 	private Double price;
-	
+
 	/**
 	 * 币别
 	 */
@@ -356,13 +386,13 @@ public class Order extends Document implements Serializable {
 	private String inid;
 
 	/**
-	 * 确认金额(考虑商城打折的情况)
+	 * 确认金额(考虑商城打折的情况)包括运费
 	 */
 	@Column(name = "ensure_price")
 	private Double ensurePrice;
 
 	/**
-	 * 实际成交金额(考虑退货)
+	 * 实际成交金额(考虑退货)包括运费
 	 */
 	@Column(name = "transation_price")
 	private Double transationPrice;
@@ -384,31 +414,31 @@ public class Order extends Document implements Serializable {
 	 */
 	@Column(name = "or_qty")
 	private Double qty;
-	
+
 	/**
 	 * 批次数量
 	 */
 	@Column(name = "or_batch_qty")
 	private Integer batchQty;
-	
+
 	/**
 	 * 型号数量
 	 */
 	@Column(name = "or_cmp_qty")
 	private Integer cmpQty;
-	
+
 	/**
 	 * 客户收到货的时间
 	 */
 	@Column(name = "or_recipttime")
 	private Date reciptTime;
-	
+
 	/**
 	 * 二次收货时间
 	 */
 	@Column(name = "or_secondretime")
 	private Date secondReTime;
-	
+
 	/**
 	 * 发货时间,如果有两次 时间戳,时间戳
 	 */
@@ -446,7 +476,7 @@ public class Order extends Document implements Serializable {
 	@OneToMany(mappedBy = "order", cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
 	@OrderBy("detno")
 	private Set<OrderDetail> orderDetails;
-	
+
 	/**
 	 * 记录订单的客服、退款、退货、退换货服务状态
 	 * @tip 第一个数字位,代表客服状态,1:申请客服,2:客服确认中,3:客服有反馈
@@ -458,84 +488,84 @@ public class Order extends Document implements Serializable {
 	private String serviceStatus = "1111";
 
 	/**********************异常处理 start**********************/
-    /**
-     * 发起的售后申请状态
-     */
-    @Enumerated(EnumType.STRING)
-    @Column(name = "launch_or_ex_apply_status")
-    private AfterSaleStatus launchOrExApplyStatus;
+	/**
+	 * 发起的售后申请状态
+	 */
+	@Enumerated(EnumType.STRING)
+	@Column(name = "launch_or_ex_apply_status")
+	private AfterSaleStatus launchOrExApplyStatus;
 
-    /**
-     * 发起的申请单申请号
-     */
-    @Column(name = "launch_or_ex_apply_id")
-    private String launchOrExApplyId;
+	/**
+	 * 发起的申请单申请号
+	 */
+	@Column(name = "launch_or_ex_apply_id")
+	private String launchOrExApplyId;
 
-    /**
-     * 接收的供应商的多张申请单信息
-     * 格式: [{puExApplyId : "PAP2016111100000002", status : "SUP_TO_MALL"}, {puExApplyId : "PAP2016111100000003", status : "FINISHED"}]
-     */
-    @Column(name = "or_json_pu_ex_info")
-    private String puExInfoJson;
+	/**
+	 * 接收的供应商的多张申请单信息
+	 * 格式: [{puExApplyId : "PAP2016111100000002", status : "SUP_TO_MALL"}, {puExApplyId : "PAP2016111100000003", status : "FINISHED"}]
+	 */
+	@Column(name = "or_json_pu_ex_info")
+	private String puExInfoJson;
 
-    /**
-     * jsonPuExInfo的map形式,便于在程序中操作
+	/**
+	 * jsonPuExInfo的map形式,便于在程序中操作
 	 * key:采购异常申请单号
 	 * value:异常申请状态
-     */
-    @Transient
-    private Map<String, AfterSaleStatus> puExInfoMap;
-    
-    /**
-     * 退货单单号
-     */
-    @Column(name = "or_returnid")
-    private String returnId;
-    
-    /**
-     * 退货单的状态
-     */
-    @Column(name = "or_returnstatus")
-    private Integer returnStatus;
+	 */
+	@Transient
+	private Map<String, AfterSaleStatus> puExInfoMap;
 
-    /**
-     * 换货单号
-     */
-    @Column(name = "or_changeid")
-    private String changeId;
-    
-    /**
-     * 换货单的状态
-     */
-    @Column(name = "or_changestatus")
-    private Integer changeStatus;
+	/**
+	 * 退货单单号
+	 */
+	@Column(name = "or_returnid")
+	private String returnId;
 
-    /**
-     * 退款单的状态
-     */
-    @Column(name = "or_refundtatus")
-    private Integer refundStatus;
-    
-    /**
-     * 退款单号
-     */
-    @Column(name = "or_refund_id")
-    private String refundId;
+	/**
+	 * 退货单的状态
+	 */
+	@Column(name = "or_returnstatus")
+	private Integer returnStatus;
+
+	/**
+	 * 换货单号
+	 */
+	@Column(name = "or_changeid")
+	private String changeId;
 
-    /************ 异常处理 end ************/
+	/**
+	 * 换货单的状态
+	 */
+	@Column(name = "or_changestatus")
+	private Integer changeStatus;
 
-    /**
+	/**
+	 * 退款单的状态
+	 */
+	@Column(name = "or_refundtatus")
+	private Integer refundStatus;
+
+	/**
+	 * 退款单号
+	 */
+	@Column(name = "or_refund_id")
+	private String refundId;
+
+	/************ 异常处理 end ************/
+
+	/**
 	 * 开发票的快递公司
 	 */
 	@Column(name = "or_bill_logistic_company")
 	private String drawBillLogisComp;
-	
+
 	/**
 	 * 开发票的快递单号
 	 */
 	@Column(name = "or_bill_logistic_num")
 	private String drawBillLogisNum;
-	
+
 	/**
 	 * 开发票的时间
 	 */
@@ -737,8 +767,8 @@ public class Order extends Document implements Serializable {
 	 * @return the refund id
 	 */
 	public String getRefundId() {
-        return refundId;
-    }
+		return refundId;
+	}
 
 	/**
 	 * Sets refund id.
@@ -746,8 +776,8 @@ public class Order extends Document implements Serializable {
 	 * @param refundId the refund id
 	 */
 	public void setRefundId(String refundId) {
-        this.refundId = refundId;
-    }
+		this.refundId = refundId;
+	}
 
 	/**
 	 * Gets buyername.
@@ -973,8 +1003,8 @@ public class Order extends Document implements Serializable {
 	 * @return the boolean
 	 */
 	public boolean isBuyNow() {
-        return buyNow;
-    }
+		return buyNow;
+	}
 
 	/**
 	 * Sets buy now.
@@ -982,8 +1012,8 @@ public class Order extends Document implements Serializable {
 	 * @param buyNow the buy now
 	 */
 	public void setBuyNow(boolean buyNow) {
-        this.buyNow = buyNow;
-    }
+		this.buyNow = buyNow;
+	}
 
 	/**
 	 * Gets invoicetype.
@@ -1732,6 +1762,14 @@ public class Order extends Document implements Serializable {
 		this.vatBillStatus = vatBillStatus;
 	}
 
+	public String getJsonRule() {
+		return jsonRule;
+	}
+
+	public void setJsonRule(String jsonRule) {
+		this.jsonRule = jsonRule;
+	}
+
 	/**
 	 * Gets audit pay fail reason.
 	 *
@@ -2304,7 +2342,7 @@ public class Order extends Document implements Serializable {
 			b2cOrDetail.setNumber(details.getNumber());
 			b2cOrDetail.setBatchCode(details.getBatchCode());
 			b2cOrDetail.setPrice(details.getPrice());
-			b2cOrDetail.setTax(details.getTax()); 
+			b2cOrDetail.setTax(details.getTax());
 			b2cOrDetail.setTaxes(details.getTaxes());
 			b2cOrDetail.setUnitprice(details.getTaxUnitprice());
 			b2cOrDetails.add(b2cOrDetail);
@@ -2365,7 +2403,7 @@ public class Order extends Document implements Serializable {
 		this.buyername = user.getUserName();
 		this.buyerTel = user.getUserTel();
 		this.setStatusToBeConfirmed(user.getUserUU());
-        buyNow = false; // 默认不是立即购买,是则手动设置
+		buyNow = false; // 默认不是立即购买,是则手动设置
 	}
 
 	/**
@@ -2412,8 +2450,8 @@ public class Order extends Document implements Serializable {
 	 * @return the launch or ex apply status
 	 */
 	public AfterSaleStatus getLaunchOrExApplyStatus() {
-        return launchOrExApplyStatus;
-    }
+		return launchOrExApplyStatus;
+	}
 
 	/**
 	 * Sets launch or ex apply status.
@@ -2421,8 +2459,8 @@ public class Order extends Document implements Serializable {
 	 * @param launchOrExApplyStatus the launch or ex apply status
 	 */
 	public void setLaunchOrExApplyStatus(AfterSaleStatus launchOrExApplyStatus) {
-        this.launchOrExApplyStatus = launchOrExApplyStatus;
-    }
+		this.launchOrExApplyStatus = launchOrExApplyStatus;
+	}
 
 	/**
 	 * Gets orderids.
@@ -2510,8 +2548,8 @@ public class Order extends Document implements Serializable {
 	 * @return the launch or ex apply id
 	 */
 	public String getLaunchOrExApplyId() {
-        return launchOrExApplyId;
-    }
+		return launchOrExApplyId;
+	}
 
 	/**
 	 * Sets launch or ex apply id.
@@ -2519,8 +2557,8 @@ public class Order extends Document implements Serializable {
 	 * @param launchOrExApplyId the launch or ex apply id
 	 */
 	public void setLaunchOrExApplyId(String launchOrExApplyId) {
-        this.launchOrExApplyId = launchOrExApplyId;
-    }
+		this.launchOrExApplyId = launchOrExApplyId;
+	}
 
 	/**
 	 * Gets pu ex info json.
@@ -2528,8 +2566,8 @@ public class Order extends Document implements Serializable {
 	 * @return the pu ex info json
 	 */
 	public String getPuExInfoJson() {
-        return puExInfoJson;
-    }
+		return puExInfoJson;
+	}
 
 	/**
 	 * Sets pu ex info json.
@@ -2537,8 +2575,8 @@ public class Order extends Document implements Serializable {
 	 * @param puExInfoJson the pu ex info json
 	 */
 	public void setPuExInfoJson(String puExInfoJson) {
-        this.puExInfoJson = puExInfoJson;
-    }
+		this.puExInfoJson = puExInfoJson;
+	}
 
 	/**
 	 * Gets used.
@@ -2564,11 +2602,11 @@ public class Order extends Document implements Serializable {
 	 * @return pu ex info map
 	 */
 	@JSONField(serialize = false)
-    @JsonIgnore
-    public Map<String, AfterSaleStatus> getPuExInfoMap() {
-        if(CollectionUtils.isEmpty(puExInfoMap) && StringUtils.hasText( puExInfoJson)) {
-            puExInfoMap = ExceptionUtil.puExInfoJsonToMap(puExInfoJson);
-        }
+	@JsonIgnore
+	public Map<String, AfterSaleStatus> getPuExInfoMap() {
+		if(CollectionUtils.isEmpty(puExInfoMap) && StringUtils.hasText( puExInfoJson)) {
+			puExInfoMap = ExceptionUtil.puExInfoJsonToMap(puExInfoJson);
+		}
 		return puExInfoMap;
 	}
 
@@ -2718,4 +2756,36 @@ public class Order extends Document implements Serializable {
 	public void setDissociative(Integer dissociative) {
 		this.dissociative = dissociative;
 	}
+
+	public String getJsonMoreRule() {
+		return jsonMoreRule;
+	}
+
+	public void setJsonMoreRule(String jsonMoreRule) {
+		this.jsonMoreRule = jsonMoreRule;
+	}
+
+	public Double getFare() {
+		return fare;
+	}
+
+	public void setFare(Double fare) {
+		this.fare = fare;
+	}
+
+	public String getJsonTakeSelf() {
+		return jsonTakeSelf;
+	}
+
+	public void setJsonTakeSelf(String jsonTakeSelf) {
+		this.jsonTakeSelf = jsonTakeSelf;
+	}
+
+	public String getJsonMoreTake() {
+		return jsonMoreTake;
+	}
+
+	public void setJsonMoreTake(String jsonMoreTake) {
+		this.jsonMoreTake = jsonMoreTake;
+	}
 }

+ 14 - 0
src/main/java/com/uas/platform/b2c/trade/order/model/OrderDetail.java

@@ -443,6 +443,12 @@ public class OrderDetail extends Document implements Serializable{
 	@Column(name = "detail_remark", length = 4000)
 	private String remark;
 
+	/**
+	 * 物料编号
+	 */
+	@Column(name = "detail_go_number")
+	private String goodsnumber;
+
 	/*******************************
 	 * 交货周期
 	 *******************************/
@@ -1399,6 +1405,14 @@ public class OrderDetail extends Document implements Serializable{
 		return this;
 	}
 
+	public String getGoodsnumber() {
+		return goodsnumber;
+	}
+
+	public void setGoodsnumber(String goodsnumber) {
+		this.goodsnumber = goodsnumber;
+	}
+
 	/****************************************************
 	 * others
 	 * @param uu the uu

+ 57 - 1
src/main/java/com/uas/platform/b2c/trade/order/model/Purchase.java

@@ -453,14 +453,38 @@ public class Purchase extends Document implements Serializable {
 	/**
 	 * 交易备注
 	 */
-	@Column(name = "pu_remark")
+	@Column(name = "pu_remark", length = 4000)
 	private String purchaseRemark;
 
+	/**
+	 * 配送类型 --第三方配送 1301,卖家配送 1302,上门自提1303
+	 */
+	@Column(name = "pu_send_type")
+	private Integer sendType;
+
 	/**
 	 * 自己送货还是第三方物流送货
 	 */
 	@Column(name = "pu_deliverytype")
 	private String deliveryType;
+
+	/**
+	 * 使用的配送规则
+	 */
+	@Column(name = "pu_rule", length = 2000)
+	private String jsonRule;
+
+	/**
+	 * 自提点信息
+	 */
+	@Column(name = "pu_take_self", length = 2000)
+	private String jsonTakeSelf;
+
+	/**
+	 * 运费
+	 */
+	@Column(name = "pu_fare")
+	private Double fare;
 	
 	/*
 	 * 自己送货的送货人
@@ -574,6 +598,14 @@ public class Purchase extends Document implements Serializable {
 		this.statushistory = addStatusHistory(statushistory, uu, this.status);
 	}
 
+	public Integer getSendType() {
+		return sendType;
+	}
+
+	public void setSendType(Integer sendType) {
+		this.sendType = sendType;
+	}
+
 	/**
 	 * Sets status to be shipped.
 	 *
@@ -1513,6 +1545,14 @@ public class Purchase extends Document implements Serializable {
 		this.ensurePrice = ensurePrice;
 	}
 
+	public Double getFare() {
+		return fare;
+	}
+
+	public void setFare(Double fare) {
+		this.fare = fare;
+	}
+
 	/**
 	 * Gets transation price.
 	 *
@@ -1715,6 +1755,14 @@ public class Purchase extends Document implements Serializable {
 		return this;
 	}
 
+	public String getJsonRule() {
+		return jsonRule;
+	}
+
+	public void setJsonRule(String jsonRule) {
+		this.jsonRule = jsonRule;
+	}
+
 	/**
 	 * @Tip 对象初始化时必须给历史记录赋值,为showTip属性设置默认值
 	 */
@@ -2050,6 +2098,14 @@ public class Purchase extends Document implements Serializable {
 		this.exchangeStatus = exchangeStatus;
 	}
 
+	public String getJsonTakeSelf() {
+		return jsonTakeSelf;
+	}
+
+	public void setJsonTakeSelf(String jsonTakeSelf) {
+		this.jsonTakeSelf = jsonTakeSelf;
+	}
+
 	/**
 	 * Gets storeid.
 	 *

+ 15 - 0
src/main/java/com/uas/platform/b2c/trade/order/model/PurchaseDetail.java

@@ -309,6 +309,12 @@ public class PurchaseDetail extends Document {
 	@Column(name = "detail_remark", length = 4000)
 	private String remark;
 
+	/**
+	 * 物料编号
+	 */
+	@Column(name = "detail_go_number")
+	private String goodsnumber;
+
 	/**
 	 * 商城最长交期
 	 */
@@ -1068,6 +1074,14 @@ public class PurchaseDetail extends Document {
 		this.changeQty = changeQty;
 	}
 
+	public String getGoodsnumber() {
+		return goodsnumber;
+	}
+
+	public void setGoodsnumber(String goodsnumber) {
+		this.goodsnumber = goodsnumber;
+	}
+
 	/**
 	 * Instantiates a new Purchase detail.
 	 *
@@ -1105,6 +1119,7 @@ public class PurchaseDetail extends Document {
 		this.b2cMaxDelivery = oDetail.getB2cMaxDelivery();
 		this.b2cMinDelivery = oDetail.getB2cMinDelivery();
 		this.remark = oDetail.getRemark();
+		this.goodsnumber = oDetail.getGoodsnumber();
 	}
 
 	/**

+ 2 - 0
src/main/java/com/uas/platform/b2c/trade/order/service/PurchaseService.java

@@ -398,4 +398,6 @@ public interface PurchaseService {
 	 * @return Logistics
 	 */
 	Logistics findByLgtId(Long lgtId);
+
+	Logistics modifyPurchaseLogistics(Long id);
 }

+ 58 - 15
src/main/java/com/uas/platform/b2c/trade/order/service/impl/OrderServiceImpl.java

@@ -645,6 +645,11 @@ public class OrderServiceImpl implements OrderService {
     @Transactional
     private ResultMap updateOrder(String orderid, JSONObject[] ordersInfos) {
         ResultMap resultMap1 = convertInfoToOrder(ordersInfos);
+        JSONObject orderInfo  = ordersInfos[0];
+
+        JSONObject splitObject = orderInfo.getJSONObject("splitInfo");
+        System.out.println(splitObject);
+
         if(resultMap1.getCode() != ResultMapType.OK.getCode()) {
             return resultMap1;
         }
@@ -670,7 +675,7 @@ public class OrderServiceImpl implements OrderService {
         }
 
         List<Order> orderList = null;
-        ResultMap resultMap = splitOrder(order);
+        ResultMap resultMap = splitOrder(order, splitObject);
         if(resultMap.getCode() == CodeType.OK.code()) {
             orderList = (List<Order>) resultMap.getData();
         }else {
@@ -683,6 +688,12 @@ public class OrderServiceImpl implements OrderService {
         }
         str1 = StringUtils.isEmpty(str1) ? str1 : str1.substring(0, str1.length() - 1);
         order.setOrderids(str1);
+        //保存配送规则Map
+        String ruleJson = splitObject.getString("ruleList");
+        order.setJsonMoreRule(ruleJson);
+        String takeJson = splitObject.getString("takeList");
+        order.setJsonMoreTake(takeJson);
+        order.setEnsurePrice(orderInfo.getDouble("totalprice"));
         orderDao.save(order);
 
         // 记录确认订单操作日志
@@ -703,11 +714,19 @@ public class OrderServiceImpl implements OrderService {
      * 针对[501]待确认付款的订单拆单
      */
     @Transactional
-    private ResultMap splitOrder(Order order) {
+    private ResultMap splitOrder(Order order, JSONObject object) {
         //确认付款这里将不同的店铺的商品拆单
         Map<String, List<OrderDetail>> listMap = new HashMap<>();
         //获得订单备注Map
         JSONObject remarkMap = FastjsonUtils.fromJson(order.getOrderRemark(), JSONObject.class);
+
+        //获取适用配送规则列表
+        String jsonRule = object.getString("ruleList");
+        JSONObject ruleObject = FastjsonUtils.fromJson(jsonRule, JSONObject.class);
+        //获取自提点信息
+        String jsonTake = object.getString("takeList");
+        JSONObject takeObject = FastjsonUtils.fromJson(jsonTake, JSONObject.class);
+
         for (OrderDetail detail : order.getOrderDetails()) {
             List<OrderDetail> orderDetails = listMap.get(detail.getStoreid());
             if (orderDetails == null) {
@@ -748,6 +767,22 @@ public class OrderServiceImpl implements OrderService {
 
                 newOrderDetails.add(orderDetail1);
             }
+            /**
+             *  加入运费
+             */
+            JSONObject rule = ruleObject.getJSONObject(storeid);
+            JSONObject take = takeObject.getJSONObject(storeid);
+            System.out.println(rule);
+            or.setJsonRule(FastjsonUtils.toJson(rule));
+            if(take != null){
+                or.setJsonTakeSelf(FastjsonUtils.toJson(take));
+            }
+
+            or.setDeliverytype(Integer.parseInt(rule.getString("method")));
+            or.setFare(Double.parseDouble(rule.getString("fare")));
+            ensurePrices += or.getFare();
+            transationPrice += or.getFare();
+
             or.setBatchQty(newOrderDetails.size());
             or.setEnsurePrice(NumberUtil.fractionNumCeil(ensurePrices, 2));
             or.setPrice(NumberUtil.fractionNumCeil(prices, 2));
@@ -759,6 +794,7 @@ public class OrderServiceImpl implements OrderService {
             map.put(storeid, remarkMap.getString(storeid));
             String orRemark = FastjsonUtils.toJson(map);
             or.setOrderRemark(orRemark);
+//            or.setDeliverytype(Integer.parseInt(methodMap.getString(storeid)));
 
             StoreIn storeIn = storeInDao.findByUuid(storeid);
             if (storeIn == null && storeIn.getStatus() != StoreStatus.OPENED) {
@@ -801,13 +837,21 @@ public class OrderServiceImpl implements OrderService {
     private ResultMap convertInfoToOrder(JSONObject[] ordersInfo) {
         JSONObject orderInfo  = ordersInfo[0];
         Order order = orderDao.findOne(orderInfo.getLong("id"));
-        order.setDeliverytype(orderInfo.getInteger("deliverytype"));
+        /**
+         * 这里的deliverytype为key,value的map形式
+         */
+//        order.setDeliverytypes(orderInfo.getString("deliverytypes"));
+//        order.setFares(orderInfo.getString("fares"));
 
         // TODO huxz 暂时设置为1301
         if (order.getDeliverytype() == null) {
             order.setDeliverytype(Type.Delivery_ByUU_Code.value());
         }
+
         Long add_id = orderInfo.getLong("add_id");
+        /**
+         * TODO hulh 这里需要转化地址。暂时设为1301
+         */
         String jsonAddress = getAddressFormateToString(order.getDeliverytype(), add_id);
         order.setJsonAddress(jsonAddress);
         order.setInvoicetype(orderInfo.getInteger("invoicetype"));
@@ -844,6 +888,7 @@ public class OrderServiceImpl implements OrderService {
                     detail.setDeliveryTime(goods);
                     detail.setPircesByNumber(goods.getPrices(), detail.getNumber());
                     detail.setRemark(detailInfo.getString("remark"));
+                    detail.setGoodsnumber(detailInfo.getString("goodsnumber"));
                     String storeid = detailInfo.getString("storeid");
                     if(!goods.getStoreid().equals(storeid)) {
                         detail.setStoreid(goods.getStoreid());
@@ -2271,18 +2316,16 @@ public class OrderServiceImpl implements OrderService {
 
     @Override
     public Page<Order> getBillByStatus(final PageInfo page, String keyword, int status) {
-        SimpleExpression simpleExpression1 = new SimpleExpression("status", Status.CANCELLED.value(), Operator.NE);
-        SimpleExpression simpleExpression2 = new SimpleExpression("status", Status.UNAVAILABLE_NOPAID.value(),
-                Operator.NE);
-        page.expression(simpleExpression1);
-        page.expression(simpleExpression2);
-        if (status != 799) {
-            page.filter("vatBillStatus", status);
-        } else { // 如果等于799,代表是要找处于待收发票状态的明细的订单
-            page.filter("tobeReceiveinvoice", Status.TOCONFIRM_BILL.value());
-        }
-        if ((keyword != null) && (!keyword.equals(""))) {
-            page.filter("orderid", keyword);
+        page.expression(PredicateUtils.eq("status", status, false));
+        page.expression(PredicateUtils.isNull("invoiceid"));
+        page.expression(PredicateUtils.eq("invoicetype", Type.Bill_No.value(), false));
+
+        if (StringUtils.hasText(keyword)) {
+            SimpleExpression sellername = new SimpleExpression("sellername", keyword , Operator.LIKE);
+            SimpleExpression orderid = new SimpleExpression("orderid", keyword, Operator.LIKE);
+            SimpleExpression[] simpleExpressions = new SimpleExpression[]{sellername, orderid};
+            LogicalExpression logicalExpression = PredicateUtils.or(simpleExpressions);
+            page.expression(logicalExpression);
         }
 
         return orderDao.findAll(new Specification<Order>() {

+ 24 - 5
src/main/java/com/uas/platform/b2c/trade/order/service/impl/PurchaseServiceImpl.java

@@ -10,6 +10,7 @@ import com.uas.platform.b2c.common.account.model.TradeLog;
 import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.core.config.SysConf;
 import com.uas.platform.b2c.core.constant.SplitChar;
+import com.uas.platform.b2c.core.constant.Type;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.core.support.log.TradeBufferedLogger;
 import com.uas.platform.b2c.core.utils.FastjsonUtils;
@@ -55,7 +56,6 @@ import com.uas.platform.core.logging.BufferedLoggerManager;
 import com.uas.platform.core.model.EncodingRulesConstant;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.Status;
-import com.uas.platform.core.model.Type;
 import com.uas.platform.core.persistence.criteria.CriterionExpression;
 import com.uas.platform.core.persistence.criteria.LogicalExpression;
 import com.uas.platform.core.persistence.criteria.PredicateUtils;
@@ -352,6 +352,8 @@ public class PurchaseServiceImpl implements PurchaseService {
 		price = NumberUtil.pricesScaleTwo(price);
 		purchase.setPrice(price);
 		// TODO 这里需要考虑确认总价的问题 (默认和总价相等,打折或优惠券逻辑待考虑)
+		// 加入运费
+		ensurePrices += purchase.getFare();
 		ensurePrices = NumberUtil.pricesScaleTwo(ensurePrices);
 		purchase.setEnsurePrice(ensurePrices);
 	}
@@ -409,6 +411,8 @@ public class PurchaseServiceImpl implements PurchaseService {
 			purchase.setInvoicetype(Type.Bill_Deduct.value());
 			purchase.setInvoiceAddress(FastjsonUtils.toJson(billOne.get(0)));
 			purchase.setInvoicetitle(billOne.get(0).getHead());
+			purchase.setFare(0d);//默认为0
+			purchase.setSendType(Type.Delivery_ByUU_Code.value());//寄售类型统一为第三方配送
 		}else {
 			if(orderFromCust.getBuyerentername() == null) {
 				Enterprise enterprise = enterpriseDao.findByUu(orderFromCust.getBuyerenuu());
@@ -426,6 +430,13 @@ public class PurchaseServiceImpl implements PurchaseService {
 			purchase.setInvoicetype(orderFromCust.getInvoicetype());
 			purchase.setInvoiceAddress(orderFromCust.getInvoiceAddress());
 			purchase.setInvoicetitle(orderFromCust.getInvoicetitle());
+			//如果是自营的,则保存配送规则和运费信息,自提点信息和配送方式
+			purchase.setFare(orderFromCust.getFare());
+			purchase.setJsonRule(orderFromCust.getJsonRule());
+			purchase.setSendType(orderFromCust.getDeliverytype());
+			if (orderFromCust.getJsonTakeSelf() != null){
+				purchase.setJsonTakeSelf(orderFromCust.getJsonTakeSelf());
+			}
 		}
 		List<User> users = userDao.findUserByUserUU(purchase.getBuyeruu());
 		User user = null;
@@ -1365,9 +1376,11 @@ public class PurchaseServiceImpl implements PurchaseService {
 			countPurchaseTaxes += NumberUtil.mul(CountPurchaseDetailPrice, 0.17);
 			countPurchasePrice += CountPurchaseDetailPrice;
 			double countFractionPurchasePrice = NumberUtil.fractionNumCeil(countPurchasePrice,2);
-			purchase.setEnsurePrice(countFractionPurchasePrice);
+			//加入运费
+			double priceAddFara = NumberUtil.add(countFractionPurchasePrice, purchase.getFare());
+			purchase.setEnsurePrice(priceAddFara);
 			purchase.setPrice(countFractionPurchasePrice);
-			purchase.setTransationPrice(countFractionPurchasePrice);
+			purchase.setTransationPrice(priceAddFara);
 			purchase.setTaxes(countPurchaseTaxes);
 			purchaseDao.save(purchase);
 			// 修改订单明细单价,不含税单价,价税合计(三个字段),税金
@@ -1398,10 +1411,11 @@ public class PurchaseServiceImpl implements PurchaseService {
 			}
 			countOrderPrice += CountPurchaseDetailPrice;
 			double countFractionOrderPrice = NumberUtil.fractionNumCeil(countOrderPrice,2);
+			double orderPriceAddFare = NumberUtil.add(countFractionOrderPrice, order.getFare());
 			countOrderTaxes += NumberUtil.mul(CountPurchaseDetailPrice, 0.17);
-			order.setEnsurePrice(countFractionOrderPrice);
+			order.setEnsurePrice(orderPriceAddFare);
 			order.setPrice(countFractionOrderPrice);
-			order.setTransationPrice(countFractionOrderPrice);
+			order.setTransationPrice(orderPriceAddFare);
 			order.setTaxes(countOrderTaxes);
 			orderDao.save(order);
 			// 保存卖家采购单修改单价的记录
@@ -1435,4 +1449,9 @@ public class PurchaseServiceImpl implements PurchaseService {
 	public Logistics findByLgtId(Long lgtId) {
 		return logisticsDao.findOne(lgtId);
 	}
+
+	@Override
+	public Logistics modifyPurchaseLogistics(Long id) {
+		return null;
+	}
 }

+ 160 - 10
src/main/webapp/resources/css/common.css

@@ -451,7 +451,7 @@ input.ng-invalid.ng-dirty,textarea.ng-invalid.ng-dirty {
 .u-panel {
 	border: 1px solid #1BA5F8;
 	-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
-          box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
+    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
 }
 .u-panel-heading {
 	height: 57px;
@@ -479,7 +479,6 @@ input.ng-invalid.ng-dirty,textarea.ng-invalid.ng-dirty {
 /* 提示框 */
 .callout {
 	position: absolute;
-	
 	border: 1px solid #dddddd;
 	background-color: white;
 	box-shadow: 5px 5px 5px #E2E3E4;
@@ -635,7 +634,7 @@ table th.before-blank:before, table th.before-blank:after {
 .search-check .search button{
 	background: #d3e1fc;
 	border-radius: 0;
-	border: #e2dbdb 1px solid;
+	border: none !important;
 	border-left: none;
 }
 .search-check .search a{
@@ -672,7 +671,7 @@ table th.before-blank:before, table th.before-blank:after {
 .check-input input{
 	display: none;
 }
-.check-input label {
+.check-input label label {
 	width: 15px;
 	height: 15px;
 	display: inline-block;
@@ -710,14 +709,15 @@ div.ng-table-pager a.page-a{
 .down-goods-btn{
 	display: inline-block;
 	width: 94px;
-	height: 34px;
-	line-height: 34px;
+	height: 30px;
+	line-height: 30px;
 	text-align: center;
 	font-size: 14px;
 	background: #5078cb;
 	color: #fff;
 	float: right;
 	margin-right: 15px;
+	margin-top: 2px;
 }
 .down-goods-btn:hover{
 	background: #3f7ae3;
@@ -730,18 +730,37 @@ div.ng-table-pager a.page-a{
 .ng-table-pager .ng-table-pagination li.active a{
 	background: #5078cb !important;
 }
+.ng-table-pager .ng-table-pagination li.active a:hover{
+	color: #fff !important;
+}
 div.ng-table-pager div.page-go-block{
 	margin-top: 0 !important;
 }
-div.ng-table-pager a.page-a{
+.ng-table-pagination .page-number{
+	height: 30px !important;
+	border-bottom-right-radius: 0;
+	border-top-right-radius: 0;
+}
+body div.ng-table-pager input.page-number{
+	width: 40px;
+	height: 30px;
+	padding: 0 !important;
+	line-height: 30px;
+}
+body div.ng-table-pager a.page-a{
 	color: #fff;
 	border-color: #4574E8;
-	padding: 6px 6px;
+	/*padding: 6px 6px !important;*/
 	font-size: 14px;
 	border-top-right-radius: 4px;
 	border-bottom-right-radius: 4px;
 	text-decoration: none;
-	height: 31px;
+	height: 30px !important;
+	display: inline-block;
+	width: 35px;
+	padding: 0;
+	text-align: center;
+	line-height: 30px;
 }
 .ng-table-pagination .page-a:hover{
 	background: none !important;
@@ -782,4 +801,135 @@ div.ng-table-pager a.page-a{
 #left-nav-fragment .user_left ul li a:focus,#left-nav-fragment .user_left p:hover{
 	color: #fff !important;
 }
-input:required:invalid, input:focus:invalid, textarea:required:invalid, textarea:focus:invalid{box-shadow: none;}
+input:required:invalid, input:focus:invalid, textarea:required:invalid, textarea:focus:invalid{box-shadow: none;}
+
+.color333{
+	color: #333 !important;
+}
+.color666{
+	color: #666 !important;
+}
+.color999{
+	color: #999 !important;
+}
+
+::-webkit-input-placeholder { /* WebKit, Blink, Edge */
+	color:    #999;
+}
+:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
+	color:    #999;
+}
+::-moz-placeholder { /* Mozilla Firefox 19+ */
+	color:    #999;
+}
+:-ms-input-placeholder { /* Internet Explorer 10-11 */
+	color:    #999;
+}
+/*显示多少条下拉*/
+.show-input{
+	margin-right: 40px;
+	width: 116px;
+	display: inline-block;
+}
+.show-input .form-control{
+	width: 45px;
+	height: 22px;
+	line-height: 22px;
+	border-radius: 1px;
+	padding: 0 2px;
+	float: right;
+	margin-left: 5px;
+	font-size: 12px;
+}
+.search-check .more-hover {
+	color: #fff !important;
+}
+.search-check .check{
+	position: relative;
+}
+.search-check .check ul{
+	width: 94px;
+	position: absolute;
+	left: 0;
+	top: 30px;
+	background: #fff;
+	border: #e8e8e8 1px solid;
+	padding: 5px 0;
+	display: none;
+	z-index: 200;
+}
+.search-check .check:hover ul{
+	display: inline-block;
+}
+.search-check .check ul li{
+	width: 100%;
+	line-height: 22px;
+	float: left;
+}
+.search-check .check ul li a{
+	display: inline-block;
+	width: 100%;
+	height: 22px;
+	text-align: center;
+	font-size: 14px;
+	line-height: 22px;
+}
+.red{
+	color: #f00 !important;
+}
+.blue{
+	color: #5078cb !important;
+}
+
+/*全选操作*/
+.operation-btn{
+	margin-right: 15px;
+	margin-top: 4px;
+}
+.operation-btn a{
+	width: 55px;
+	height: 26px;
+	line-height: 26px;
+	display: inline-block;
+	text-align: center;
+	font-size: 14px;
+}
+.operation-btn a.off{
+	background: #b4b5b9;
+	color: #333;
+	margin-right: 10px;
+}
+.operation-btn a.ok{
+	background: #5078cb;
+	color: #fff;
+}
+
+/*改为按钮*/
+.edit-icon button {
+	width: 50px;
+	height: 24px;
+	border: none;
+	color: #fff;
+	float: left;
+}
+.edit-icon button:nth-of-type(2){
+	margin-top: 3px;
+}
+.edit-icon button.ok {
+	background: #33b401;
+}
+.edit-icon button.off {
+	background: #f15601;
+}
+.edit-icon button.edit {
+	background: #5078cb;
+}
+.edit-icon button.up {
+	background: #fff;
+	border: #5078cb 1px solid;
+	color: #5078cb;
+}
+.edit-icon button.up:hover{
+	background: #5078cb;
+	color: #fff;
+}

+ 1 - 1
src/main/webapp/resources/css/user/user.css

@@ -1077,7 +1077,7 @@ body {
     float: left;
     vertical-align: middle;
     margin-top: 35px;
-    border: #e8e8e8 1px solid;
+    border: #e8e8e8 1px solid !important;
 }
 
 .oder_list dl .pro_xq p {

+ 1 - 1
src/main/webapp/resources/css/vendor/sell.css

@@ -1806,7 +1806,7 @@ body {
     width:100%;
     margin:0 auto;
     background: #fff;
-    padding-top: 10px;
+    padding: 10px 0;
 }
 .logistics_list01 .oder_xq p {
     line-height:30px;

BIN
src/main/webapp/resources/img/user/images/ticket01.jpg


BIN
src/main/webapp/resources/img/user/images/ticket02.jpg


+ 1 - 1
src/main/webapp/resources/js/admin/controllers/product/KindContrastDetailCtrl.js

@@ -127,7 +127,7 @@ define(['app/app'], function(app) {
 		$scope.upload = function() {
 			var file = $scope.myFiles[0];
 			$upload.upload({
-				url: 'product/componentSubmit/upload/componentCrawlsWithSame/' + $scope.kindContrast.id,
+				url: 'produce/componentSubmit/upload/componentCrawlsWithSame/' + $scope.kindContrast.id,
 				file: file,
 				method: 'POST'
 			}).success(function(data) {

+ 2 - 2
src/main/webapp/resources/js/admin/controllers/product/UploadComponentCrawlCtrl.js

@@ -91,7 +91,7 @@ define(['app/app'], function(app) {
 		$scope.upload = function() {
 			var file = $scope.myFiles[0];
 			$upload.upload({
-				url: 'product/componentSubmit/upload/componentCrawls',
+				url: 'produce/componentSubmit/upload/componentCrawls',
 				file: file,
 				method: 'POST'
 			}).success(function(data) {
@@ -126,7 +126,7 @@ define(['app/app'], function(app) {
 		// 确认继续上传数据
 		var uploadToSame = function(myFile, kindContrastId) {
 			$upload.upload({
-				url: 'product/componentSubmit/upload/componentCrawlsWithSame/' + kindContrastId,
+				url: 'produce/componentSubmit/upload/componentCrawlsWithSame/' + kindContrastId,
 				file: myFile,
 				method: 'POST'
 			}).success(function(data) {

+ 20 - 17
src/main/webapp/resources/js/admin/controllers/trade/InvoicefromOrderDetailCtrl.js

@@ -16,15 +16,14 @@ define([ 'app/app' ], function(app) {
 //					$scope.logisticsDetail = angular.fromJson($scope.logistics.companyName);
 					
 					//查看物流详情
-					$scope.listLogistics = function(data){
-						var lgtid = $scope.logistics.id;
+					$scope.listLogistics = function(){
 						var modalInstance = $modal.open({
 							animation: true,
 							templateUrl: 'static/view/admin/modal/listLogistics_modal.html',
 							controller: 'listLogisticsCtrl',
 							resolve: {
-								lgtid: function() {
-									return lgtid;
+								logistics : function () {
+									return $scope.logistics
 								}
 							}
 						});
@@ -86,22 +85,26 @@ define([ 'app/app' ], function(app) {
 		}]);
 	
 	// 物流信息
-	app.register.controller('listLogisticsCtrl', [
-			'$scope',
-			'$modal',
-			'ResponseLogistics',
-			'$modalInstance',
-			'lgtid',
-			function($scope, $modal, ResponseLogistics, $modalInstance,
-					lgtid) {
+	app.register.controller('listLogisticsCtrl', ['$scope', '$modal', 'ResponseLogistics', '$modalInstance', 'logistics', 'KdnLogistics', 'toaster', function($scope, $modal, ResponseLogistics, $modalInstance, logistics, KdnLogistics, toaster) {
 				$scope.Info = [];
 				$scope.getlogistics = function() {
-					ResponseLogistics.get({
-						id : lgtid
-					}, {}, function(data) {
-						$scope.Info = data;
-						console.log(data);
+					var params = {};
+					params.companyName = logistics.companyName;
+					params.logisticsCode = logistics.number;
+					KdnLogistics.kdnQuery(params, {}, function(response){
+						if(!response.errorInfo) {
+							$scope.Info = eval ("(" + response.traces + ")");
+						}
+					}, function(){
+						// $scope.Info = [];
+						toaster.pop('info', '查询物流信息失败,请核对物流公司和运单号');
 					});
+					// ResponseLogistics.get({
+					// 	id : lgtid
+					// }, {}, function(data) {
+					// 	$scope.Info = data;
+					// 	console.log(data);
+					// });
 				};
 				$scope.getlogistics();
 				$scope.cancel = function() {

+ 19 - 17
src/main/webapp/resources/js/admin/controllers/trade/InvoicefromPurcDetailCtrl.js

@@ -14,15 +14,14 @@ define([ 'app/app' ], function(app) {
 					$scope.logistics = angular.fromJson($scope.invoiceFPur.logistics);
 					console.log($scope.logistics);
 					//查看物流详情
-					$scope.listLogistics = function(data){
-						var lgtid = $scope.logistics.id;
+					$scope.listLogistics = function(){
 						var modalInstance = $modal.open({
 							animation: true,
 							templateUrl: 'static/view/admin/modal/listLogistics_modal.html',
 							controller: 'listLogisticsCtrl',
 							resolve: {
-								lgtid: function() {
-									return lgtid;
+								logistics : function () {
+									return $scope.logistics
 								}
 							}
 						});
@@ -94,22 +93,25 @@ define([ 'app/app' ], function(app) {
 	
 
 				// 物流信息
-			app.register.controller('listLogisticsCtrl', [
-					'$scope',
-					'$modal',
-					'ResponseLogistics',
-					'$modalInstance',
-					'lgtid',
-					function($scope, $modal, ResponseLogistics, $modalInstance,
-							lgtid) {
+			app.register.controller('listLogisticsCtrl', ['$scope', '$modal', 'ResponseLogistics', '$modalInstance', 'logistics', 'KdnLogistics', 'toaster', function($scope, $modal, ResponseLogistics, $modalInstance, logistics, KdnLogistics, toaster) {
 						$scope.Info = [];
 						$scope.getlogistics = function() {
-							ResponseLogistics.get({
-								id : lgtid
-							}, {}, function(data) {
-								$scope.Info = data;
-								console.log(data);
+							var params = {};
+							params.companyName = logistics.companyName;
+							params.logisticsCode = logistics.number;
+							KdnLogistics.kdnQuery(params, {}, function(response){
+								if(!response.errorInfo) {
+									$scope.Info = eval ("(" + response.traces + ")");
+									// statusOfLogistics($scope.logisticsInfo[$scope.logisticsInfo.length - 1].AcceptStation);
+								}
+							}, function(){
+								// $scope.Info = [];
+								toaster.pop('info', '查询物流信息失败,请核对物流公司和运单号');
 							});
+							// ResponseLogistics.get({id : lgtid}, {}, function(data) {
+							// 	$scope.Info = data;
+							// 	console.log(data);
+							// });
 						};
 						$scope.getlogistics();
 						$scope.cancel = function() {

+ 18 - 6
src/main/webapp/resources/js/admin/controllers/trade/TradePurchaseDetailCtrl.js

@@ -26,8 +26,8 @@ define([ 'app/app' ], function(app) {
 						templateUrl: 'static/view/admin/modal/listLogistics_modal.html',
 						controller: 'listLogisticsCtrl',
 						resolve: {
-							lgtid: function() {
-								return lgtid;
+							logistics : function () {
+								return $scope.logistics
 							}
 						}
 					});
@@ -106,13 +106,25 @@ define([ 'app/app' ], function(app) {
 		loadData();
 	}]);
 	
-	app.register.controller('listLogisticsCtrl', [ '$scope', '$modal', 'ResponseLogistics', '$modalInstance', 'lgtid', function($scope, $modal, ResponseLogistics, $modalInstance, lgtid){
+	app.register.controller('listLogisticsCtrl', [ '$scope', '$modal', 'ResponseLogistics', '$modalInstance', 'logistics', 'KdnLogistics', 'toaster', function($scope, $modal, ResponseLogistics, $modalInstance, logistics, KdnLogistics, toaster){
 		$scope.Info = [];
 		$scope.getlogistics = function() {
-			ResponseLogistics.get({id: lgtid}, {}, function(data) {
-				$scope.Info = data;
-				console.log(data);
+			var params = {};
+			params.companyName = logistics.companyName;
+			params.logisticsCode = logistics.number;
+			KdnLogistics.kdnQuery(params, {}, function(response){
+				if(!response.errorInfo) {
+					$scope.Info = eval ("(" + response.traces + ")");
+					// statusOfLogistics($scope.logisticsInfo[$scope.logisticsInfo.length - 1].AcceptStation);
+				}
+			}, function(){
+				// $scope.Info = [];
+				toaster.pop('info', '查询物流信息失败,请核对物流公司和运单号');
 			});
+			// ResponseLogistics.get({id : lgtid}, {}, function(data) {
+			// 	$scope.Info = data;
+			// 	console.log(data);
+			// });
 		};
 		$scope.getlogistics();
 		$scope.cancel = function() {

+ 20 - 1
src/main/webapp/resources/js/common/query/bill.js

@@ -33,12 +33,31 @@ define([ 'ngResource' ], function() {
 				method : 'DELETE'
 			},
 			getPersonalSpecial : {
-				url : 'trade/bill//personal',
+				url : 'trade/bill/personal',
 				method : 'GET',
 				params : {
 					'type' : 'special'
 				}
 			}
 		});
+	}]).factory('BillSubmit', ['$resource', function($resource) {
+			//获取ComponentSubmit的分页数据
+		return $resource('trade/billSubmit', {}, {
+			submitBillApply : {
+				url : ' trade/billSubmit',
+				method : 'POST',
+				isArray: true
+			},
+			getSubmitBillApply : {
+				url : ' trade/billSubmit',
+				method : 'GET'
+			},
+			sureBillApply : {
+				url : 'trade/billSubmit/:ids',
+				method : 'PUT',
+				isArray : 'true'
+			}
+
+		});
 	}]);
 });

+ 17 - 17
src/main/webapp/resources/js/common/query/brand.js

@@ -1,7 +1,7 @@
 define([ 'ngResource' ], function() {
 	angular.module('brandServices', [ 'ngResource' ]).factory('BrandsSubmit', ['$resource', function($resource) {
 		//获取BrandSubmit的分页数据
-		return $resource('product/brandSubmit', {}, {
+		return $resource('produce/brandSubmit', {}, {
 			//未审核
 			getUnAudited : {
 				params : { _state : 'unAudited'}
@@ -17,15 +17,15 @@ define([ 'ngResource' ], function() {
 		});
 	}]).factory('BrandSubmit', ['$resource', function($resource) {
 		//对单个BrandSubmit的操作
-		return $resource('product/brandSubmit/:id', {}, {
+		return $resource('produce/brandSubmit/:id', {}, {
 			//提交(保存)
 			submit : {
-				url : 'product/brandSubmit/saveBrandSubmit',
+				url : 'produce/brandSubmit/saveBrandSubmit',
 				method : 'POST'
 			},
 			//审核通过
 			valid : {
-				url : 'product/brandSubmit/audit',
+				url : 'produce/brandSubmit/audit',
 				method : 'PUT',
 				params : {
 					valid : true
@@ -33,7 +33,7 @@ define([ 'ngResource' ], function() {
 			},
 			//审核不通过
 			invalid : {
-				url : 'product/brandSubmit/audit/:id',
+				url : 'produce/brandSubmit/audit/:id',
 				method : 'PUT',
 				params : {
 					valid : false
@@ -41,34 +41,34 @@ define([ 'ngResource' ], function() {
 			},
 			// 审核通过信息冲突的更新申请
 			validUpdate : {
-				url : 'product/brandSubmit/audituUpdate',
+				url : 'produce/brandSubmit/audituUpdate',
 				method : 'PUT'
 			}
 		});
 	}]).factory('BrandVersion', ['$resource', function($resource) {
 		//获取根据uuid获取BrandVersion列表
-		return $resource('product/brandVersion/:uuid', {}, {
+		return $resource('produce/brandVersion/:uuid', {}, {
 			/*
 			 * get,根据uuid,version获取BrandVersion对象
 			 */
 			//根据uuid获取BrandVersion列表
 			getList : {
-				url : 'product/brandVersion/list/:uuid',
+				url : 'produce/brandVersion/list/:uuid',
 				method : 'GET',
 				isArray : true
 			},
 			//根据uuid获取BrandVersion名称
 			getCount : {
-				url : 'product/brandVersion/count/:uuid',
+				url : 'produce/brandVersion/count/:uuid',
 				method : 'GET'
 			}
 		});
 	}]).factory('BrandActive', ['$resource', function($resource) {
 		//对单个BrandActive对象操作
-		return $resource('product/brand/:uuid', {}, {
+		return $resource('produce/brand/:uuid', {}, {
 			//禁用BrandActive
 			disable : {
-				url : 'product/brand/disable/:uuid',
+				url : 'produce/brand/disable/:uuid',
 				method : 'PUT',
 				isArray : true
 			},
@@ -96,18 +96,18 @@ define([ 'ngResource' ], function() {
 			},
 			// 验证品牌名是否存在
 			nameExist : {
-				url: 'product/brand/nameExist',
+				url: 'produce/brand/nameExist',
 				method: 'GET',
 				isArray: true
 			},
 			// 更新与修改
 			update : {
-				url: 'product/brand/saveBrandActive',
+				url: 'produce/brand/saveBrandActive',
 				method: 'POST'
 			},
 			// 获取各月新增品牌数量
 			getIncreaseCount : {
-				url: 'product/brand/increaseCount',
+				url: 'produce/brand/increaseCount',
 				method: 'GET',
 				isArray: true
 			}
@@ -185,19 +185,19 @@ define([ 'ngResource' ], function() {
 		})
 	}]).factory('BrandDisable', ['$resource', function($resource) {
 		//对BrandDisable禁用品牌的操作
-		return $resource('product/brandDisable/:uuid', {}, {
+		return $resource('produce/brandDisable/:uuid', {}, {
 			/**
 			 * get, 根据uuid获取BrandDisable
 			 */
 			// 获取全部已禁用品牌的简要信息
 			getSimpleInfo : {
-				url: 'product/brandDisable/info',
+				url: 'produce/brandDisable/info',
 				method: 'GET',
 				isArray: true
 			},
 			// 分页获取全部已禁用品牌的简要信息
 			getSimpleInfoPage : {
-				url: 'product/brandDisable/info/ByPage',
+				url: 'produce/brandDisable/info/ByPage',
 				method: 'GET'
 			}
 		});

+ 37 - 37
src/main/webapp/resources/js/common/query/component.js

@@ -1,7 +1,7 @@
 define([ 'ngResource' ], function() {
 	angular.module('componentServices', [ 'ngResource' ]).factory('ComponentsSubmit', ['$resource', function($resource) {
 		//获取ComponentSubmit的分页数据
-		return $resource('product/componentSubmit', {}, {
+		return $resource('produce/componentSubmit', {}, {
 			//未审核
 			getUnAudited : {
 				params : { _state : 'unAudited'}
@@ -17,13 +17,13 @@ define([ 'ngResource' ], function() {
 		});
 	}]).factory('ComponentSubmit', ['$resource', function($resource) {
 		//对单个ComponentSubmit的操作
-		return $resource('product/componentSubmit/:id', {}, {
+		return $resource('produce/componentSubmit/:id', {}, {
 			/**
 			 * get,根据uuid查找ComponentSubmit详细信息
 			 */
 			//审核通过
 			valid : {
-				url : 'product/componentSubmit/audit',
+				url : 'produce/componentSubmit/audit',
 				method : 'PUT',
 				params : {
 					valid : true
@@ -31,7 +31,7 @@ define([ 'ngResource' ], function() {
 			},
 			//审核不通过
 			invalid : {
-				url : 'product/componentSubmit/audit/:id',
+				url : 'produce/componentSubmit/audit/:id',
 				method : 'PUT',
 				params : {
 					valid : false
@@ -39,122 +39,122 @@ define([ 'ngResource' ], function() {
 			},
 			// 下载批量器件建档模板
 			downloadExcel : {
-				url : 'product/componentSubmit/template',
+				url : 'produce/componentSubmit/template',
 				method : 'POST'
 			},
 			// 未审核批量申请(用户)
 			unAuditedBatch : {
-				url : 'product/componentSubmit/batch',
+				url : 'produce/componentSubmit/batch',
 				method : 'GET',
 				params : { _status : 'unAudited'}
 			},
 			// 已通过批量申请(用户)
 			passBatch : {
-				url : 'product/componentSubmit/batch',
+				url : 'produce/componentSubmit/batch',
 				method : 'GET',
 				params : { _status : 'pass'}
 			},
 			// 全部批量申请(用户)
 			allBatch : {
-				url : 'product/componentSubmit/batch',
+				url : 'produce/componentSubmit/batch',
 				method : 'GET',
 				params : { _status : 'all'}
 			},
 			// 未通过批量申请(用户)
 			forbiddenBatch : {
-				url : 'product/componentSubmit/batch',
+				url : 'produce/componentSubmit/batch',
 				method : 'GET',
 				params : { _status : 'forbidden'}
 			},
 			// 全部批量申请(后台)
 			allBatchManage : {
-				url : 'product/componentSubmit/manage/batch',
+				url : 'produce/componentSubmit/manage/batch',
 				method : 'GET',
 				params : { _status : 'all'}
 			},
 			// 未审核批量申请(后台)
 			unAuditedBatchManage : {
-				url : 'product/componentSubmit/manage/batch',
+				url : 'produce/componentSubmit/manage/batch',
 				method : 'GET',
 				params : { _status : 'unAudited'}
 			},
 			// 已通过批量申请(后台)
 			passBatchManage : {
-				url : 'product/componentSubmit/manage/batch',
+				url : 'produce/componentSubmit/manage/batch',
 				method : 'GET',
 				params : { _status : 'pass'}
 			},
 			// 未通过批量申请(后台)
 			forbiddenBatchManage : {
-				url : 'product/componentSubmit/manage/batch',
+				url : 'produce/componentSubmit/manage/batch',
 				method : 'GET',
 				params : { _status : 'forbidden'}
 			},
 			// 获取批量申请详情
 			getBatchDetails : {
-				url : 'product/componentSubmit/batch/:submitId',
+				url : 'produce/componentSubmit/batch/:submitId',
 				method : 'GET'
 			},
 			// 批量器件建档审核通过
 			auditBatch : {
-				url : 'product/componentSubmit/audit/batch',
+				url : 'produce/componentSubmit/audit/batch',
 				method : 'PUT'
 			},
 			// 批量器件建档审核不通过
 			unAuditBatch : {
-				url : 'product/componentSubmit/unAudit/batch',
+				url : 'produce/componentSubmit/unAudit/batch',
 				method : 'PUT'
 			},
 			// 获取尚未处理的建档申请
 			tobe_handleTask : {
-				url : 'product/componentSubmit/getDetail/batch',
+				url : 'produce/componentSubmit/getDetail/batch',
 				method : 'GET',
 				params : {_status : 'tobe_handle'}
 			},
 			// 获取任务中的建档申请
 			pendingTask : {
-				url : 'product/componentSubmit/getDetail/batch',
+				url : 'produce/componentSubmit/getDetail/batch',
 				method : 'GET',
 				params : {_status : 'pending'}
 			},
 			// 获取已完成的建档申请
 			completeTask : {
-				url : 'product/componentSubmit/getDetail/batch',
+				url : 'produce/componentSubmit/getDetail/batch',
 				method : 'GET',
 				params : {_status : 'complete'}
 			},
 			// 获取爬取失败的建档申请
 			failedTask : {
-				url : 'product/componentSubmit/getDetail/batch',
+				url : 'produce/componentSubmit/getDetail/batch',
 				method : 'GET',
 				params : {_status : 'failed'}
 			},
 			// 选取用户申请发起任务
 			saveTask : {
-				url : 'product/componentSubmit/task',
+				url : 'produce/componentSubmit/task',
 				method : 'POST'
 			},
 			// 用户直接提交批量建档申请
 			saveSubmits : {
-				url : 'product/componentSubmit/submitBatch',
+				url : 'produce/componentSubmit/submitBatch',
 				method : 'POST'
 			}
 		});
 	}]).factory('ComponentVersion', ['$resource', function($resource) {
 		//获取根据uuid获取ComponentVersion列表
-		return $resource('product/componentVersion/:uuid', {}, {
+		return $resource('produce/componentVersion/:uuid', {}, {
 			/**
 			 * get,根据uuid,version获取ComponentVersion对象
 			 */
 			//根据uuid获取ComponentVersion列表
 			getList : {
-				url : 'product/componentVersion/list/:uuid',
+				url : 'produce/componentVersion/list/:uuid',
 				method : 'GET',
 				isArray : true
 			},
 			//根据uuid获取ComponentVersion数量
 			getCount : {
-				url : 'product/componentVersion/count/:uuid',
+				url : 'produce/componentVersion/count/:uuid',
 				method : 'GET'
 			}
 		});
@@ -171,7 +171,7 @@ define([ 'ngResource' ], function() {
 			},
 			//获取ComponentInfo的分页数据
 			getInfoPage: {
-				url: 'product/component/list',
+				url: 'produce/component/list',
 				method: 'GET'
 			},
 			// 根据UUid获取单个器件的简要信息
@@ -193,7 +193,7 @@ define([ 'ngResource' ], function() {
 			},
 			// 禁用ComponentActive
 			disable : {
-				url : 'product/component/:uuid/disable',
+				url : 'produce/component/:uuid/disable',
 				method : 'PUT'
 			},
 			// 根据UUid 获取列表
@@ -204,16 +204,16 @@ define([ 'ngResource' ], function() {
 			},
 			//根据批次号获取器件信息
 			getByBatchCode: {
-				url : 'product/component/:batchCode/detail',
+				url : 'produce/component/:batchCode/detail',
 				method : 'GET'
 			},//根据原厂型号和品牌获取器件信息
 			getByCodeAndBrandId: {
-				url: 'product/component/codeAndBrandId/:code',
+				url: 'produce/component/codeAndBrandId/:code',
 				method: 'GET',
 				isArray: true
 			},//根据原厂型号和类目获取器件信息
 			getByCodeAndKindId: {
-				url: 'product/component/codeAndKindId/:code',
+				url: 'produce/component/codeAndKindId/:code',
 				method: 'GET',
 				isArray: true
 			},
@@ -243,31 +243,31 @@ define([ 'ngResource' ], function() {
 			},
 			// 根据类目id获取封装规格
 			getPackagingByKindid: {
-				url: 'product/component/packaging/:kindid',
+				url: 'produce/component/packaging/:kindid',
 				method: 'GET',
 				isArray: true
 			},
 			// 批量修改器件类目
 			moveCmp: {
-				url: 'product/component/moveCmp',
+				url: 'produce/component/moveCmp',
 				method: 'PUT',
 				isArray : true
 			},
 			// 获取每月器件增长数量
 			getIncreaseCount: {
-				url: 'product/component/increaseCount',
+				url: 'produce/component/increaseCount',
 				method: 'GET',
 				isArray: true
 			}
 		});
 	}]).factory('ComponentDisable', ['$resource', function($resource) {
-		return $resource('product/componentDisable/:uuid', {}, {
+		return $resource('produce/componentDisable/:uuid', {}, {
 			/*
 			 * get 根据uuid获得ComponentDisable
 			 */
 			// 分页获取全部已禁用器件的简要信息
 			getSimpleInfoPage : {
-				url: 'product/componentDisable/info/ByPage',
+				url: 'produce/componentDisable/info/ByPage',
 				method: 'GET'
 			}
 		})
@@ -296,13 +296,13 @@ define([ 'ngResource' ], function() {
 			}
 		});
 	}]).factory('ComponentTest', ['$resource', function($resource) {
-		return $resource('product/component/:uuid', {}, {
+		return $resource('produce/component/:uuid', {}, {
 			/*
 			 * get 获ComponentsActive的分页数据,根据uuid获得ComponentActive
 			 */
 			//获取ComponentActive的分页数据
 			getInfoPage: {
-				url: 'product/component/info',
+				url: 'produce/component/info',
 				method: 'GET'
 			}
 		});

+ 12 - 12
src/main/webapp/resources/js/common/query/crawlTask.js

@@ -1,67 +1,67 @@
 define([ 'ngResource' ], function() {
 	angular.module('crawlTaskServices', [ 'ngResource' ]).factory('CrawlTask', ['$resource', function($resource) {
 		//获取数据爬取的分页数据
-		return $resource('product/crawlTask', {}, {
+		return $resource('produce/crawlTask', {}, {
 			// 获取未完成的任务
 			to_crawl : {
-				url : 'product/crawlTask',
+				url : 'produce/crawlTask',
 				method : 'GET',
 				params : {_status : 'to_crawl'}
 			},
 			// 获取进行中的任务
 			running : {
-				url : 'product/crawlTask',
+				url : 'produce/crawlTask',
 				method : 'GET',
 				params : {_status : 'running'}
 			},
 			// 获取已完成的任务
 			crawled : {
-				url : 'product/crawlTask',
+				url : 'produce/crawlTask',
 				method : 'GET',
 				params : {_status : 'crawled'}
 			},
 			// 获取失败的任务
 			failed : {
-				url : 'product/crawlTask',
+				url : 'produce/crawlTask',
 				method : 'GET',
 				params : {_status : 'failed'}
 			},
 			// 新增任务(来自参数对应关系)
 			save : {
-				url : 'product/crawlTask/:id',
+				url : 'produce/crawlTask/:id',
 				method : 'POST'
 			},
 			// 新增任务(来自用户申请列表)
 			saveBySubmit : {
-				url : 'product/crawlTask/saveBySubmit/:ids',
+				url : 'produce/crawlTask/saveBySubmit/:ids',
 				method : 'POST'
 			},
 			// 根据id获取任务详情
 			getOne : {
-				url : 'product/crawlTask/:id',
+				url : 'produce/crawlTask/:id',
 				method : 'GET'
 			},
 			// 任务开启
 			crawlStart : {
-				url : 'product/crawlTask/crawl',
+				url : 'produce/crawlTask/crawl',
 				params : { _status : 'start'},
 				method : 'PUT'
 			},
 			// 任务完成
 			crawlSuccess : {
-				url : 'product/crawlTask/crawl',
+				url : 'produce/crawlTask/crawl',
 				params : { _status : 'success'},
 				method : 'PUT'
 			},
 			// 任务异常
 			crawlFail : {
-				url : 'product/crawlTask/crawl',
+				url : 'produce/crawlTask/crawl',
 				params : { _status : 'fail'},
 				method : 'PUT'
 			},
 			// 获取已完成任务的维护器件列表
 			getCmpList : {
-				url : 'product/crawlTask/cmpList',
+				url : 'produce/crawlTask/cmpList',
 				method : 'GET'
 			}
 		});

+ 11 - 11
src/main/webapp/resources/js/common/query/kind.js

@@ -1,31 +1,31 @@
 define([ 'ngResource'], function() {
 	angular.module('common.query.kind', [ 'ngResource' ]).factory('Kind', ['$resource', '$cacheFactory', function($resource, $cacheFactory) {
 		var cache = $cacheFactory('Kind');
-		return $resource('product/kind/:kindIds', {}, {
+		return $resource('produce/kind/:kindIds', {}, {
 			// 修改分类的属性
 			updateProperties: {
-				url: 'product/kind/:kindId/properties',
+				url: 'produce/kind/:kindId/properties',
 				method: 'POST',
 				isArray: true
 			},
 			//重置类属性值
 			resetKindPropertyValues: {
-				url: 'product/kind/kindPropertyValues/reset',
+				url: 'produce/kind/kindPropertyValues/reset',
 				method:  'GET'
 			},
 			// 编辑修改
 			update: {
-				url: 'product/kind/:kindId',
+				url: 'produce/kind/:kindId',
 				method: 'POST'
 			},
 			// 新增保存
 			save: {
-				url: 'product/kind',
+				url: 'produce/kind',
 				method: 'POST'
 			},
 			// 交换序号
 			exchangeNumber: {
-				url: 'product/kind/number',
+				url: 'produce/kind/number',
 				method: 'POST',
 				params: {
 					operate: 'exchange'
@@ -33,28 +33,28 @@ define([ 'ngResource'], function() {
 			},
 			// 删除类目属性
 			deleteKindProperty: {
-				url: 'product/kind/kindProperty/:kindPropertyId',
+				url: 'produce/kind/kindProperty/:kindPropertyId',
 				method: 'DELETE',
 			},
 			// 添加类目属性
 			addKindProperty: {
-				url: 'product/kind/kindProperty/add',
+				url: 'produce/kind/kindProperty/add',
 				method: 'PUT'
 			},
 			// 修改类目属性具体值
 			updateKindProperty: {
-				url: 'product/kind/kindProperty/update',
+				url: 'produce/kind/kindProperty/update',
 				method: 'PUT'
 			},
 			// 改变类目属性顺序
 			changeDetno: {
-				url: 'product/kind/kindProperty/changeDetno',
+				url: 'produce/kind/kindProperty/changeDetno',
 				method: 'PUT',
 				isArray: true
 			},
 			// 更换类目属性
 			changeKindProperty: {
-				url: 'product/kind/kindProperty/changeKindProperty',
+				url: 'produce/kind/kindProperty/changeKindProperty',
 				method: 'PUT'
 			}
 		});

+ 1 - 1
src/main/webapp/resources/js/common/query/kindAdvice.js

@@ -5,7 +5,7 @@ define([ 'ngResource'], function() {
 	angular.module('common.query.kindAdvice', [ 'ngResource'
 	]).factory('KindAdvice', ['$resource', '$cacheFactory', function($resource, $cacheFactory) {
 		var cache = $cacheFactory('KindAdvice');
-		return $resource('product/kindAdvice/:id', {}, {
+		return $resource('produce/kindAdvice/:id', {}, {
 			
 		});
 	}]);

+ 12 - 12
src/main/webapp/resources/js/common/query/kindContrast.js

@@ -1,66 +1,66 @@
 define([ 'ngResource' ], function() {
 	angular.module('kindContrastServices', [ 'ngResource' ]).factory('KindContrast', ['$resource', function($resource) {
 		//获取属性对应关系的分页数据
-		return $resource('product/kindContrast', {}, {
+		return $resource('produce/kindContrast', {}, {
 			// 获取全部参数对照规则
 			all: {
-				url : 'product/kindContrast',
+				url : 'produce/kindContrast',
 				method : 'GET',
 				params : {_status : 'all'}
 			},
 			// 获取待发起参数对照规则
 			outTask: {
-				url : 'product/kindContrast',
+				url : 'produce/kindContrast',
 				method : 'GET',
 				params : {_status : 'outTask'}
 			},
 			// 获取全部参数对照规则
 			inTask: {
-				url : 'product/kindContrast',
+				url : 'produce/kindContrast',
 				method : 'GET',
 				params : {_status : 'inTask'}
 			},
 			// 获取任务进行中的参数对应规则
 			running : {
-				url : 'product/kindContrast',
+				url : 'produce/kindContrast',
 				method : 'GET',
 				params : {_status : 'running'}
 			},
 			// 获取已结案的参数对应规则
 			concluded : {
-				url : 'product/kindContrast',
+				url : 'produce/kindContrast',
 				method : 'GET',
 				params : {_status : 'concluded'}
 			},
 			// 获取异常参数对应关系规则
 			failed : {
-				url : 'product/kindContrast',
+				url : 'produce/kindContrast',
 				method : 'GET',
 				params : {_status : 'failed'}
 			},
  			// 获取参数对照规则详情
 			getOne : {
-				url : 'product/kindContrast/:id',
+				url : 'produce/kindContrast/:id',
 				method : 'GET'
 			},
 			// 更新基础属性
 			updateBasic : {
-				url : 'product/kindContrast/update/basic',
+				url : 'produce/kindContrast/update/basic',
 				method : 'PUT'
 			},
 			// 更新参数对照
 			updateProperty : {
-				url : 'product/kindContrast/update/property',
+				url : 'produce/kindContrast/update/property',
 				method : 'PUT'
 			},
 			// 新增参数对照明细
 			newProperty : {
-				url : 'product/kindContrast/create/property',
+				url : 'produce/kindContrast/create/property',
 				method : 'PUT'
 			},
 			// 删除参数对照
 			deleteOne : {
-				url : 'product/kindContrast/:id',
+				url : 'produce/kindContrast/:id',
 				method : 'DELETE'
 			}
 		});

+ 9 - 1
src/main/webapp/resources/js/common/query/logistics.js

@@ -46,7 +46,15 @@ define([ 'ngResource' ], function() {
 			 updateLogistics : {
 				 url : 'trade/logistics/:id',
 				 method : 'POST'
-			 }
+			 },
+			addLogistics : {
+				url : 'trade/logistics/add',
+				method : 'POST'
+			},
+			clearLogistics : {
+				url : 'trade/logistics/clear',
+				method : 'PUT'
+			}
 		});
 	}]);
 });

+ 49 - 0
src/main/webapp/resources/js/common/query/logisticsPort.js

@@ -77,5 +77,54 @@ define([ 'ngResource' ], function() {
 				isArray : true
 			}
 		});
+	}]).factory('DistributionRule', ['$resource', function ($resource) {
+		return $resource('trade/distributionRule', {}, {
+			saveRule : {
+				url: 'trade/distributionRule/save',
+				method: 'POST'
+			},
+			deleteOne : {
+				url: 'trade/distributionRule/delete/:id',
+				method: 'PUT'
+			},
+			/**
+			 * 分页获取配送规则列表
+			 */
+			findAllRule : {
+				url: 'trade/distributionRule/page',
+				method: 'GET'
+			},
+			findAllRuleName : {
+				url: 'trade/distributionRule/ruleName',
+				method: 'GET',
+				isArray : true
+			},
+			changeActive : {
+				url: 'trade/distributionRule/status',
+				method: 'POST'
+			},
+			findCountOfRule : {
+				url: 'trade/distributionRule/count',
+				method: 'GET'
+			},
+			checkRuleName : {
+				url: 'trade/distributionRule/checkName',
+				method: 'GET'
+			},
+			findMatchRule : {
+				url: 'trade/distributionRule/rule/matchArea',
+				method: 'GET',
+				isArray : true
+			},
+			findFareOfRule : {
+				url: 'trade/distributionRule/fare',
+				method: 'POST',
+				isArray : true
+			},
+			findUsableRule : {
+				url: 'trade/distributionRule/usable/rule',
+				method: 'POST'
+			}
+		})
 	}]);
 });

+ 11 - 11
src/main/webapp/resources/js/common/query/property.js

@@ -1,53 +1,53 @@
 define([ 'ngResource' ], function() {
 	angular.module('propertyServices', [ 'ngResource' ]).factory('Property', ['$resource', function($resource) {
-		return $resource('product/property/:id', {}, {
+		return $resource('produce/property/:id', {}, {
 			// 根据id获取属性信息
 			get : {
-				url : 'product/property/:id',
+				url : 'produce/property/:id',
 				method : 'GET'
 			},
 			//获得所有属性数据
 			getProperties : {
-				url : 'product/property',
+				url : 'produce/property',
 				method : 'GET',
 				isArray: true
 			},
 			// 分页获取所有属性
 			getPropertiesPage : {
-				url : 'product/property/pageInfo',
+				url : 'produce/property/pageInfo',
 				method : 'GET'
 			},
 			// 添加属性
 			add : {
-				url : 'product/property',
+				url : 'produce/property',
 				method : 'POST'
 			},
 			// 更新属性
 			update : {
-				url : 'product/property/update',
+				url : 'produce/property/update',
 				method : 'POST'
 			}
 		});
 	}]).factory('propertiesSubmit', ['$resource', function($resource) {
 		//获取ComponentSubmit的数据
-		return $resource('product/propertySubmit', {}, {
+		return $resource('produce/propertySubmit', {}, {
 			//根据ComponentSubmit.id查找对应的propertiesSubmit
 			getList : {
-				url : 'product/propertySubmit/:id',
+				url : 'produce/propertySubmit/:id',
 				method : 'GET',
 				isArray : true
 			},
 			getPropertySubmit : {
-				url : 'product/propertySubmit/property',
+				url : 'produce/propertySubmit/property',
 				method : 'GET'
 			}
 		});
 	}]).factory('propertiesActive', ['$resource', function($resource) {
 		//获取propertiesActive的数据
-		return $resource('product/propertyActive', {}, {
+		return $resource('produce/propertyActive', {}, {
 			//根据ComponentActive.id查找对应的propertiesActive
 			getList : {
-				url : 'product/propertyActive/:id',
+				url : 'produce/propertyActive/:id',
 				method : 'GET',
 				isArray : true
 			}

+ 1 - 1
src/main/webapp/resources/js/common/query/propertyAdvice.js

@@ -5,7 +5,7 @@ define([ 'ngResource'], function() {
 	angular.module('common.query.propertyAdvice', [ 'ngResource'
 	]).factory('PropertyAdvice', ['$resource', '$cacheFactory', function($resource, $cacheFactory) {
 		var cache = $cacheFactory('PropertyAdvice');
-		return $resource('product/propertyAdvice/:id', {}, {
+		return $resource('produce/propertyAdvice/:id', {}, {
 			
 		});
 	}]);

+ 4 - 0
src/main/webapp/resources/js/common/query/vendor.js

@@ -52,6 +52,10 @@ define(['ngResource'], function() {
 				url : 'trade/takeSelf/takeName',
 				method : 'GET',
 				isArray : true
+			},
+			findTakeSelfByStore : {
+				url : 'trade/takeSelf/store/takeSelf',
+				method : 'POST'
 			}
 		});
 	}]);

+ 3 - 2
src/main/webapp/resources/js/common/services.js

@@ -581,8 +581,9 @@ define([ 'angular', 'common/utils', 'big'], function(angular, utils, Big) {
 			"1202":"17%增值税不可抵扣,累计开票,8%税点",
 			"1203":"17%增值税可抵扣,随元器件一起发货,10%税点",
 			"1204":"17%增值税不可抵扣,,随元器件一起发货,10%税点",
-			"1301":"UU配送",
-			"1302":"上门自取"
+			"1301":"第三方配送",
+            "1302":"卖家配送",
+			"1303":"上门自取"
 			};
 		return function(data) {
 			return statusConfig[data];

+ 1 - 1
src/main/webapp/resources/js/prod/controllers/InfoCtrl.js

@@ -80,7 +80,7 @@ define([ 'app/app', 'jquery-summernote' ], function(app) {
 				
 				// 不是通过路由过来的,再检查地址栏的参数kindIds
 				if($location.search().kindIds && /^(\d{1,}_)*(\d){1,}$/.test($location.search().kindIds)) {
-					$http.get('product/kinds/' + $location.search().kindIds.replace(/_/g, ','), {
+					$http.get('produce/kinds/' + $location.search().kindIds.replace(/_/g, ','), {
 						cache: $templateCache
 					}).success(function(kinds){
 						if(kinds.length > 0 && kinds.last().isLeaf) {

+ 4 - 4
src/main/webapp/resources/js/prod/controllers/MgrCtrl.js

@@ -6,7 +6,7 @@ define(['app/app'], function(app) {
 		// 不是通过路由过来的,再检查地址栏的参数kindIds
 		if(!$scope.productKinds && $stateParams.kindIds && 
 				/^(\d{1,}_)*(\d){1,}$/.test($stateParams.kindIds)) {
-			$http.get('product/kinds/' + $stateParams.kindIds.replace(/_/g, ','), {
+			$http.get('produce/kinds/' + $stateParams.kindIds.replace(/_/g, ','), {
 				cache: $templateCache
 			}).success(function(kinds){
 				if(kinds.length > 0 && kinds.last().isLeaf) {
@@ -33,7 +33,7 @@ define(['app/app'], function(app) {
 		 */
 		var getKindProperties = function(kindId) {
 			setLoading(true);
-			$http.get('product/kinds/' + kindId + '/properties').success(function(response){
+			$http.get('produce/kinds/' + kindId + '/properties').success(function(response){
 				$scope.properties = response;
 				setLoading(false);
 			});
@@ -140,7 +140,7 @@ define(['app/app'], function(app) {
 					data.push(_p);
 				});
 				setLoading(true);
-				$http.post('product/kinds/' + kindId + '/properties', data).success(function(response){
+				$http.post('produce/kinds/' + kindId + '/properties', data).success(function(response){
 					setLoading(false);
 					toaster.pop('success', '提示', '保存成功!');
 					$scope.properties = response;
@@ -237,7 +237,7 @@ define(['app/app'], function(app) {
 			} ]
 		} ];
 		var getCategories = function(parentId) {
-			return $http.get('product/kinds/' + parentId + '/children_all');
+			return $http.get('produce/kinds/' + parentId + '/children_all');
 		};
 		getCategories(0).success(function(response) {
 			var cates = [];

+ 4 - 4
src/main/webapp/resources/js/prod/data/city.json

@@ -1,5 +1,5 @@
 {
-    "北京": {
+    "北京": {
         "北京市": [
             "东城区",
 		    "西城区",
@@ -19,7 +19,7 @@
 		    "延庆县"         
         ]
     },
-    "上海": {
+    "上海": {
         "上海市": [
 			"黄浦区",
 		    "徐汇区",
@@ -41,7 +41,7 @@
 		    "崇明县"
         ]
     },
-    "天津": {
+    "天津": {
         "天津市": [
 		  	"和平区",
 		    "河东区",
@@ -64,7 +64,7 @@
 		    "蓟县"
         ]
     },
-    "重庆": {
+    "重庆": {
         "重庆市": [
 		  	"万州区",
 		    "涪陵区",

+ 14 - 2
src/main/webapp/resources/js/usercenter/app.js

@@ -1,7 +1,7 @@
 
-define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'common/services', 'common/directives','common/query/kind', 'common/query/brand', 'common/query/component', 'common/query/order', 'common/query/cart', 'common/query/goods', 'common/query/return' ,'angular-toaster', 'common/query/urlencryption', 'ui-jquery', 'common/query/bankTransfer', 'common/query/bankInfo', 'common/query/change', 'common/query/logistics', 'common/query/address' ,'angular-toaster','common/query/collection', 'common/query/proofing', 'common/query/bill', 'common/query/user','file-upload', 'file-upload-shim', 'common/query/bankInfo' , 'common/query/responseLogistics', 'common/query/payment', 'common/query/afterSale', 'common/query/messageBoard', 'common/query/importDeclaration', 'common/query/enterprise', 'common/query/invoice', 'common/query/refund', 'common/query/recommendation', 'common/query/logisticsPort', 'common/query/storeInfo', 'common/query/tradeMessageNotice', 'common/query/tradeBasicProperties', 'common/query/browsingHistory', 'common/query/internalMessage', 'common/module/chat_web_module', 'angular-filter'], function(angularAMD) {
+define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'common/services', 'common/directives','common/query/kind', 'common/query/brand', 'common/query/component', 'common/query/order', 'common/query/cart', 'common/query/goods', 'common/query/return' ,'angular-toaster', 'common/query/urlencryption', 'ui-jquery', 'common/query/bankTransfer', 'common/query/bankInfo', 'common/query/change', 'common/query/logistics', 'common/query/address' ,'angular-toaster','common/query/collection', 'common/query/proofing', 'common/query/bill', 'common/query/user','file-upload', 'file-upload-shim', 'common/query/bankInfo' , 'common/query/responseLogistics', 'common/query/payment', 'common/query/afterSale', 'common/query/messageBoard', 'common/query/importDeclaration', 'common/query/enterprise', 'common/query/invoice', 'common/query/refund', 'common/query/recommendation', 'common/query/logisticsPort', 'common/query/storeInfo', 'common/query/tradeMessageNotice', 'common/query/tradeBasicProperties', 'common/query/browsingHistory', 'common/query/internalMessage', 'common/module/chat_web_module', 'angular-filter', 'common/query/vendor'], function(angularAMD) {
 	'use strict';
-	var app = angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ng.local', 'ngTable', 'common.services', 'common.directives', 'tool.directives', 'common.query.kind', 'brandServices', 'componentServices', 'orderServices', 'cartServices', 'goodsServices', 'returnServices' , 'toaster', 'urlencryptionServices', 'ui.jquery', 'bankTransfer', 'bankInfo', 'changeServices', 'logisticsServices', 'addressServices', 'toaster','collection','proofingServices', 'billServices', 'common.query.user', 'angularFileUpload', 'bankInfo', 'responseLogisticsService', 'PaymentService', 'afterSaleService', 'messageBoardServices', 'table.directives', 'importDeclaration', 'common.query.enterprise', 'invoiceServices', 'refundModule', 'recommendation','logisticsPortService', 'storeInfoServices', 'tradeMessageNoticeModule', 'tradeBasicPropertiesServices', 'BrowsingHistory', 'internalMessageServices', 'WebChatModule', 'angular.filter']);
+	var app = angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ng.local', 'ngTable', 'common.services', 'common.directives', 'tool.directives', 'common.query.kind', 'brandServices', 'componentServices', 'orderServices', 'cartServices', 'goodsServices', 'returnServices' , 'toaster', 'urlencryptionServices', 'ui.jquery', 'bankTransfer', 'bankInfo', 'changeServices', 'logisticsServices', 'addressServices', 'toaster','collection','proofingServices', 'billServices', 'common.query.user', 'angularFileUpload', 'bankInfo', 'responseLogisticsService', 'PaymentService', 'afterSaleService', 'messageBoardServices', 'table.directives', 'importDeclaration', 'common.query.enterprise', 'invoiceServices', 'refundModule', 'recommendation','logisticsPortService', 'storeInfoServices', 'tradeMessageNoticeModule', 'tradeBasicPropertiesServices', 'BrowsingHistory', 'internalMessageServices', 'WebChatModule', 'angular.filter', 'vendorServices']);
 	app.init = function() {
 		angularAMD.bootstrap(app);
 	};
@@ -65,6 +65,18 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'commo
 			templateUrl: 'static/view/usercenter/forstore/buyer_invoice.html',
 			controller: 'invoiceCtrl',
 			controllerUrl: 'app/controllers/forstore/buyer_invoice_ctrl'
+		})).state('buyer_no_invoice', angularAMD.route({
+			url: '/noInvoice',
+			title: '未开票',
+			templateUrl: 'static/view/usercenter/forstore/buyer_no_invoice.html',
+			controller: 'NoInvoiceCtrl',
+			controllerUrl: 'app/controllers/forstore/buyer_no_invoice_ctrl'
+		})).state('buyer_invoice-record', angularAMD.route({
+			url: '/invoiceRecord',
+			title: '开票记录',
+			templateUrl: 'static/view/usercenter/forstore/buyer_invoice_record.html',
+			controller: 'buyerInvoiceRecordCtrl',
+			controllerUrl: 'app/controllers/forstore/buyer_invoice_record_ctrl'
 		})).state('pay_center', angularAMD.route({
 			url: '/payCenter',
 			templateUrl: 'static/view/usercenter/forstore/pay_center.html',

+ 3 - 3
src/main/webapp/resources/js/usercenter/controllers/forstore/account_manager_ctrl.js

@@ -308,7 +308,7 @@ define(['app/app'], function(app) {
 				var size;
 				if(num == 1) {
 					if ($scope.address.name){
-						size = $scope.address.name.replace(/[^x00-xFF]/g,'**').length;
+						size = $scope.address.name.replace(/[^\x00-\xff]/g,'**').length;
 						if (size > 20) {
 							console.log(size);
 							$scope.userError = true;
@@ -318,7 +318,7 @@ define(['app/app'], function(app) {
 					}
 				} else if(num == 2) {
 					if ($scope.address.tel){
-						size = $scope.address.tel.replace(/[^x00-xFF]/g,'**').length;
+						size = $scope.address.tel.replace(/[^\x00-\xff]/g,'**').length;
 						if (size < 8 || size > 11) {
 							$scope.telError = true;
 							return;
@@ -333,7 +333,7 @@ define(['app/app'], function(app) {
 					}
 				} else if(num == 3) {
 					if ($scope.address.detailAddress){
-						size = $scope.address.detailAddress.replace(/[^x00-xFF]/g,'**').length;
+						size = $scope.address.detailAddress.replace(/[^\x00-\xff]/g,'**').length;
 						if (size > 60) {
 							$scope.addrError = true;
 							return;

+ 322 - 243
src/main/webapp/resources/js/usercenter/controllers/forstore/buyer_invoice_ctrl.js

@@ -6,19 +6,27 @@ define(['app/app'], function(app) {
     'use strict';
     app.register.controller('invoiceCtrl', ['$scope', '$rootScope', 'toaster', '$modal', '$q', 'Bill', '$upload', '$http', '$location', '$stateParams', '$state', function($scope, $rootScope, toaster, $modal, $q, Bill, $upload, $http, $location, $stateParams, $state) {
         $rootScope.active = 'buyer_invoice';
-
+        $scope.tab = 'buyer_invoice';
         $scope.invoiceType = 1205;
-
+        $scope.isSpecial = true; //专票,等于true为不存在
+        $scope.isNormal = true; //普票,等于true为不存在
         // 获取发票信息方法	1205为增值税专用发票	1206为增值税普通发票	1207为不开发票
         var getInvoiceInfo = function() {
             Bill.getListPersonal(null, function(data) {
                 $scope.invoices = data;
+                angular.forEach($scope.invoices, function (item) {
+                    if(item.kind == '1205'){
+                        $scope.isSpecial = false;
+                    } else if (item.kind == '1206') {
+                        $scope.isNormal = false;
+                    }
+                })
             }, function(error) {
                 toaster.pop('error', '获取发票信息失败');
             });
         };
         getInvoiceInfo();
-
+        // $scope.bill = {};
         // 获取省市区地理信息
         var getGeoInfo = function () {
             $http.get('static/js/prod/data/city.json').success(function(data) {
@@ -36,276 +44,347 @@ define(['app/app'], function(app) {
             });
         };
         getGeoInfo();
-        
-        // 新建发票类型	1205专用增值税发票   --1206普通发票  --1207不开发票
-        /*$scope.addInvoice = function () {
-            $modal.open({
-                templateUrl : 'static/view/prod/modal/edit-invoice-modal.html',
-                controller : 'BillInputCtrl',
-                size : 'lg',
-                resolve : {
-                    invoiceInfo: function() {
-                        if($scope.invoiceType == 1205) {
-                            return 1205 + "";
-                        }
-                        if($scope.invoiceType == 1206) {
-                            return 1206 + "";
-                        }
-                    }
-                }
-            }).result.then(function(invoice){
-                if(invoice) {
-                    getInvoiceInfo();
-                }
-            }, function(reason){
-                toaster.pop('info', '提示 ' + '您已取消新建发票信息');
-            });
-        };*/
 
         $scope.bill = {};
-        $scope.bill.kind = sessionStorage.getItem('invoiceType') ? sessionStorage.getItem('invoiceType') : 1205;
         $scope.bill.address = {};
-        $scope.bill.is_agree = true;
-        $scope.linkError = false;
-        $scope.addressError = false;
-        $scope.saveInvoice = function() {
-            $scope.bill.area = $scope.bill.address.province + "," + $scope.bill.address.city + "," + $scope.bill.address.district;
-            var file = null;
-            if($scope.bill.billInfo&&$scope.bill.billInfo[0]) {
-                file = $scope.bill.billInfo[0];
-            }
-            $upload.upload({
-                url: 'trade/bill/save',
-                file: file,
-                method: 'POST',
-                data: {
-                    bill: $scope.bill
-                }
-            }).success(function(data){
-                toaster.pop('success', '保存成功');
-                sessionStorage.setItem('invoiceType', $scope.bill.kind);
-                $state.reload();
-            }).error(function(data){
-                toaster.pop('error', data);
-            });
-        };
 
-
-        $scope.deleteInvoice = function(invoice) {
-            var isToDelete = confirm("确定要删除吗?");
-            if(!isToDelete) {
-                return;
+            //保存发票信息
+            $scope.saveBill = function(flag) {
+                var dataValidFlag = $scope.checkValidFrom();
+                if (!flag && dataValidFlag && $scope.bill.is_agree) {
+                    $scope.bill.kind = $scope.billType
+                    if (!$scope.isAdd) { //修改
+                        doSave('修改发票信息');
+                    } else { // 新增
+                        doSave('添加发票');
+                    }
+                } else if (flag || !dataValidFlag) {
+                    toaster.pop('error', '请填写正确的发票信息');
+                } else {
+                    toaster.pop('error', '请勾选并阅读《发票须知》');
+                }
+            };
+            var doSave = function (message) {
+                $scope.bill.area = $scope.bill.address.province + "," + $scope.bill.address.city + "," + $scope.bill.address.district;
+                var file = null;
+                if($scope.bill.billInfo&&$scope.bill.billInfo[0]) {
+                    file = $scope.bill.billInfo[0];
+                }
+                $upload.upload({
+                    url: 'trade/bill/save',
+                    file: file,
+                    method: 'POST',
+                    data: {
+                        bill: $scope.bill
+                    }
+                }).success(function(data){
+                    toaster.pop('success', message + '成功');
+                    $scope.changeBillStatusFlag = false
+                    $state.reload();
+                }).error(function(data){
+                    toaster.pop('error', message + '失败');
+                });
             }
-            Bill.deleteById({id: invoice.id}, function(data) {
-                toaster.pop('success', '删除成功');
-                sessionStorage.setItem('invoiceType', $scope.bill.kind);
-                $state.reload();
-            }, function(error) {
-                toaster.pop('error', '删除发票资料失败', error);
-            });
-        };
 
-        $scope.viewInvoice = function(invoice) {
-            $modal.open({
-                templateUrl : 'static/view/common/billInfoModal.html',
-                controller : 'BillInfoCtrl',
-                resolve : {
-                    invoice : function() {
-                        //深拷贝一份
-                        return angular.copy(invoice);
-                    }
+            $scope.isDoUpload = false;
+            //上传发票许可证
+            $scope.onUploadPermission = function () {
+                $scope.isDoUpload = true;
+                if (event.target.files[0].size < 3*1024*1024) {
+                    $scope.bill.attachUrl = event.target.files[0].name;
+                } else {
+                    $scope.bill.attachUrl = '';
                 }
-            });
-        };
-        $scope.linkmanLen = function() {
-            // if (num == 1){
-            //     console.log($scope.bill.name.length);
-            //     size = document.getElementById("pbillname").value.length;
-            // }else if (num == 2){
-            //     size = document.getElementById("zbillname").value.length;
-            //     console.log($scope.bill.name.length);
-            // }
-            var size = $scope.bill.name.length;
-            if (size > 10) {
-                $scope.linkError = true;
-                return;
             }
-            $scope.linkError = false;
-        };
-        $scope.addressLen = function() {
-            // if (num == 1){
-            //     size = document.getElementById("paddress").value.length;
-            // }else if (num == 2){
-            //     size = document.getElementById("zaddress").value.length;
-            // }
-            var size = $scope.bill.detailAddress.length;
-            if (size > 30) {
-                $scope.addressError = true;
-                return;
+
+            //判断中文字符串的长度
+            var getRealStringLen = function (str) {
+                var realLength = 0, len = str.length, charCode = -1;
+                for (var i = 0; i < len; i++) {
+                    charCode = str.charCodeAt(i);
+                    if (charCode >= 0 && charCode <= 128) realLength += 1;
+                    else realLength += 2;
+                }
+                return realLength;
             }
-            $scope.addressError = false;
-        };
 
-        // $scope.$watch('bill.kind', function (newValue, oldValue) {
-        //     console.log(oldValue);
-        //     console.log(newValue);
-        //     if (newValue !== oldValue){
-        //         $scope.bill = {};
-        //         $scope.bill.kind = newValue;
-        //     }
-        // });
+            $scope.validForm = {
+                validBillHead: true,
+                validBillName: true,
+                validBankName: true,
+                validDetailAddress: true,
+                validCompanyAddress: true
+            }
 
-        $scope.modifyInvoice = function(invoice) {
-            $modal.open({
-                templateUrl : 'static/view/prod/modal/edit-invoice-modal.html',
-                controller : 'BillInputCtrl',
-                size : 'lg',
-                resolve : {
-                    invoiceInfo: function() {
-                        if($scope.invoiceType == 1205) {
-                            return 1205 + "-" +invoice.id;
-                        }
-                        if($scope.invoiceType == 1206) {
-                            return 1206 + "-" +invoice.id;
-                        }
+            $scope.checkValidFrom = function () {
+                var flag = true
+                angular.forEach($scope.validForm, function (item) {
+                    if (!item) {
+                        flag = false;
                     }
+                })
+                return flag;
+            }
+        $scope.checkValidFrom();
+            //发票抬头check
+            $scope.checkBillHead = function () {
+                var len = getRealStringLen($scope.bill.head);
+                if (len > 100) {
+                    $scope.validForm.validBillHead = false;
+                } else {
+                    $scope.validForm.validBillHead = true;
                 }
-            }).result.then(function(invoice){
-                if(invoice) {
-                    getInvoiceInfo();
-                }
-            }, function(reason){
-                toaster.pop('info', '提示 ' + '您已取消编辑发票信息');
-            });
-        };
-    }]);
+            }
 
-    // 发票详情
-    app.register.controller('BillInfoCtrl', ['$scope', '$modalInstance', 'invoice', function($scope, $modalInstance, invoice) {
-        $scope.bill = invoice;
-        $scope.dismiss = function() {
-            $modalInstance.dismiss();
+        //收票人check
+        $scope.checkBillName = function () {
+            var len = getRealStringLen($scope.bill.name);
+            if (len > 20) {
+                $scope.validForm.validBillName = false;
+            } else {
+                $scope.validForm.validBillName = true;
+            }
         }
-    }]);
-
-    // 发票编辑模态框
-    app.register.controller('BillInputCtrl', ['$scope', '$http', 'BaseService', 'Bill', 'toaster', '$stateParams', '$state', 'invoiceInfo', '$upload', '$modalInstance', '$q', function($scope, $http, BaseService, Bill, toaster, $stateParams, $state, invoiceInfo, $upload, $modalInstance, $q) {
-        //BaseService.scrollBackToTop();
 
-        $scope.bill = {};
-        $scope.bill.address = {};
-        $scope.bill.is_agree = true;
-        $scope.linkError = false;
-        $scope.addressError = false;
-        $scope.bill.kind = Number(invoiceInfo.split("-")[0]);
-        if(invoiceInfo.split("-").length == 2) {
-            $scope.invoiceId = Number(invoiceInfo.split("-")[1]);
-        }
-        $scope.setType = function() {
-            switch($scope.bill.kind) {
-                case 1206:
-                    $scope.isNormal = true;
-                    $scope.isSpecial = false; break;
-                case 1205:
-                    $scope.isNormal = false;
-                    $scope.isSpecial = true; break;
-                default:
-                    $scope.isNormal = true;
-                    $scope.isSpecial = true;
+        //开户银行Check
+        $scope.checkBankName = function () {
+            var len = getRealStringLen($scope.bill.bankName);
+            if (len > 60) {
+                $scope.validForm.validBankName = false;
+            } else {
+                $scope.validForm.validBankName = true;
             }
-        };
-
-        //设置发票类型
-        $scope.setType();
+        }
 
-        //获取发票信息
-        $scope.getData = function() {
-            if($scope.invoiceId) {
-               return Bill.getBillById({id: $scope.invoiceId}, function(data) {
-                    $scope.bill = data;
-                    $scope.bill.is_agree = true;
-                    $scope.setType();
-                }, function(response) {
-                    toaster.pop('error', '获取指定的发票信息失败');
-                });
+        //详细地址Check
+        $scope.checkDetailAddress = function () {
+            var len = getRealStringLen($scope.bill.detailAddress);
+            if (len > 60) {
+                $scope.validForm.validDetailAddress = false;
             } else {
-                return {};
+                $scope.validForm.validDetailAddress = true;
             }
-        };
+        }
 
-        $scope.linkmanLen = function() {
-            var size = $scope.bill.name.length;
-            // if (num == 1){
-            //     size = document.getElementById("mpbillname").value.length;
-            // }else if (num == 2){
-            //     size = document.getElementById("mzbillname").value.length;
-            // }
-            if (size > 10) {
-                $scope.linkError = true;
-                return;
+        //单位地址check
+        $scope.checkCompanyAddress = function () {
+            var len = getRealStringLen($scope.bill.companyAddress);
+            if (len > 100) {
+                $scope.validForm.validCompanyAddress = false;
+            } else {
+                $scope.validForm.validCompanyAddress = true;
             }
-            $scope.linkError = false;
-        };
+        }
 
-        $scope.addressLen = function() {
-            var size = $scope.bill.detailAddress.length;
-            // if (num == 1){
-            //     size = document.getElementById("mpaddress").value.length;
-            // }else if (num == 2){
-            //     size = document.getElementById("mzaddress").value.length;
-            // }
-            if (size > 30) {
-                $scope.addressError = true;
-                return;
+        //设置新增栏目切换发票类型
+        $scope.billType = 1206
+        //设置发票类型
+        $scope.setType = function() {
+            angular.forEach($scope.invoices, function (item) {
+                if(item.kind == '1205'){
+                    $scope.isSpecial = false;
+                } else if (item.kind == '1206') {
+                    $scope.isNormal = false;
+                }
+            })
+            if (!$scope.isNormal) {
+                $scope.billType = 1205
+            }
+            if (!$scope.isSpecial) {
+                $scope.billType = 1206
             }
-            $scope.addressError = false;
         };
-
-        //等到获取到发票信息,
-        $q.all([$scope.getData().$promise]).then(function () {
-            $http.get('static/js/prod/data/city.json').success(function(data) {
-                $scope.division = data;
-                if($scope.bill.area){
-                    $scope.bill.address = {};
-                    //拼装下拉选择框
-                    var arr = $scope.bill.area.split(',');
-                    $scope.bill.address.province = arr[0];
-                    $scope.bill.address.city = arr[1];
-                    $scope.bill.address.district = arr[2];
-                }
-            }).error(function(e) {
-                toaster.pop('error', '系统错误 ' + '加载城市信息失败');
-            });
-        }, function () {
-            //ERROR
-        });
-
-        //保存发票信息
-        $scope.saveBill = function() {
-            $scope.bill.area = $scope.bill.address.province + "," + $scope.bill.address.city + "," + $scope.bill.address.district;
-            var file = null;
-            if($scope.bill.billInfo&&$scope.bill.billInfo[0]) {
-                file = $scope.bill.billInfo[0];
+        //设置修改区域显示标志
+        $scope.changeBillStatusFlag = false;
+        $scope.showDeleteBox = false
+        $scope.setChangeBillStatusFlag = function (flag) {
+            $scope.changeBillStatusFlag = flag;
+            if (!flag) {
+                $scope.bill = {};
+            }
+        }
+        $scope.exitEdit = function () {
+            $state.reload();
+        }
+        $scope.addBill = function () {
+            $scope.setType();
+            $scope.bill = {};
+            $scope.changeBillStatusFlag = true;
+            $scope.isAdd = true;
+        }
+        $scope.setBillType = function (type) {
+            $scope.bill = {};
+            $scope.billType = type;
+            this.form.$setPristine();
+            this.form.$setUntouched();
+        }
+        //修改发票
+        $scope.modifyInvoice = function (invoice) {
+            $scope.changeBillStatusFlag = true;
+            $scope.isAdd = false;
+            $scope.billType = invoice.kind
+            $scope.bill = invoice;
+            $scope.bill.is_agree = true;
+            $scope.bill.address = {};
+            var area = invoice.area.split(',');
+            angular.forEach(area, function (item, index) {
+                switch(index) {
+                    case 0:
+                        $scope.bill.address.province = item;
+                        break;
+                    case 1:
+                        $scope.bill.address.city = item;
+                        break;
+                    case 2:
+                        $scope.bill.address.district = item;
+                        break;
             }
-            $upload.upload({
-                url: 'trade/bill/save',
-                file: file,
-                method: 'POST',
-                data: {
-                    bill: $scope.bill
-                }
-            }).success(function(data){
-                toaster.pop('success', '保存发票信息成功');
-                $modalInstance.close(data);
-            }).error(function(data){
-                toaster.pop('error', '保存发票信息失败');
             });
         };
+        //删除按钮点击
+        $scope.deleteInvoice = function (invoice) {
+            $scope.tempDeleteId = invoice.id //删除发票临时存放
+            $scope.setDeleteBox(true)
+        }
+        //设置提示框状态
+        $scope.setDeleteBox = function (flag) {
+            $scope.showDeleteBox = flag
+        }
+        //确定删除
+        $scope.doDeleteInvoice = function () {
+            Bill.deleteById({id: $scope.tempDeleteId}, null, function (data) {
+                toaster.pop('success', '删除发票成功')
+                $state.reload();
+            }, function (error) {
+                toaster.pop('error', '删除发票失败')
+            })
+        }
+    }]);
 
-        //取消发票信息操作
-        $scope.exit = function() {
+    // 发票详情
+    app.register.controller('BillInfoCtrl', ['$scope', '$modalInstance', 'invoice', function($scope, $modalInstance, invoice) {
+        $scope.bill = invoice;
+        $scope.dismiss = function() {
             $modalInstance.dismiss();
         }
-
     }]);
+
+    // 发票编辑模态框
+    // app.register.controller('BillInputCtrl', ['$scope', '$http', 'BaseService', 'Bill', 'toaster', '$stateParams', '$state', 'invoiceInfo', '$upload', '$modalInstance', '$q', function($scope, $http, BaseService, Bill, toaster, $stateParams, $state, invoiceInfo, $upload, $modalInstance, $q) {
+    //     //BaseService.scrollBackToTop();
+    //
+    //     $scope.bill = {};
+    //     $scope.bill.address = {};
+    //     $scope.bill.is_agree = true;
+    //     $scope.linkError = false;
+    //     $scope.addressError = false;
+    //     $scope.bill.kind = Number(invoiceInfo.split("-")[0]);
+    //     if(invoiceInfo.split("-").length == 2) {
+    //         $scope.invoiceId = Number(invoiceInfo.split("-")[1]);
+    //     }
+    //     $scope.setType = function() {
+    //         switch($scope.bill.kind) {
+    //             case 1206:
+    //                 $scope.isNormal = true;
+    //                 $scope.isSpecial = false; break;
+    //             case 1205:
+    //                 $scope.isNormal = false;
+    //                 $scope.isSpecial = true; break;
+    //             default:
+    //                 $scope.isNormal = true;
+    //                 $scope.isSpecial = true;
+    //         }
+    //     };
+    //
+    //     //设置发票类型
+    //     $scope.setType();
+    //
+    //     //获取发票信息
+    //     $scope.getData = function() {
+    //         if($scope.invoiceId) {
+    //             return Bill.getBillById({id: $scope.invoiceId}, function(data) {
+    //                 $scope.bill = data;
+    //                 $scope.bill.is_agree = true;
+    //                 $scope.setType();
+    //             }, function(response) {
+    //                 toaster.pop('error', '获取指定的发票信息失败');
+    //             });
+    //         }
+    //     };
+    //
+    //     $scope.linkmanLen = function() {
+    //         var size = $scope.bill.name.length;
+    //         // if (num == 1){
+    //         //     size = document.getElementById("mpbillname").value.length;
+    //         // }else if (num == 2){
+    //         //     size = document.getElementById("mzbillname").value.length;
+    //         // }
+    //         if (size > 10) {
+    //             $scope.linkError = true;
+    //             return;
+    //         }
+    //         $scope.linkError = false;
+    //     };
+    //
+    //     $scope.addressLen = function() {
+    //         var size = $scope.bill.detailAddress.length;
+    //         // if (num == 1){
+    //         //     size = document.getElementById("mpaddress").value.length;
+    //         // }else if (num == 2){
+    //         //     size = document.getElementById("mzaddress").value.length;
+    //         // }
+    //         if (size > 30) {
+    //             $scope.addressError = true;
+    //             return;
+    //         }
+    //         $scope.addressError = false;
+    //     };
+    //
+    //     //等到获取到发票信息,
+    //     $q.all([$scope.getData().$promise]).then(function () {
+    //         $http.get('static/js/prod/data/city.json').success(function(data) {
+    //             $scope.division = data;
+    //             if($scope.bill.area){
+    //                 $scope.bill.address = {};
+    //                 //拼装下拉选择框
+    //                 var arr = $scope.bill.area.split(',');
+    //                 $scope.bill.address.province = arr[0];
+    //                 $scope.bill.address.city = arr[1];
+    //                 $scope.bill.address.district = arr[2];
+    //             }
+    //         }).error(function(e) {
+    //             toaster.pop('error', '系统错误 ' + '加载城市信息失败');
+    //         });
+    //     }, function () {
+    //         //ERROR
+    //     });
+    //
+    //     //保存发票信息
+    //     $scope.saveBill = function() {
+    //         $scope.bill.area = $scope.bill.address.province + "," + $scope.bill.address.city + "," + $scope.bill.address.district;
+    //         var file = null;
+    //         if($scope.bill.billInfo&&$scope.bill.billInfo[0]) {
+    //             file = $scope.bill.billInfo[0];
+    //         }
+    //         $upload.upload({
+    //             url: 'trade/bill/save',
+    //             file: file,
+    //             method: 'POST',
+    //             data: {
+    //                 bill: $scope.bill
+    //             }
+    //         }).success(function(data){
+    //             toaster.pop('success', '保存发票信息成功');
+    //             $modalInstance.close(data);
+    //         }).error(function(data){
+    //             toaster.pop('error', '保存发票信息失败');
+    //         });
+    //     };
+    //
+    //     //取消发票信息操作
+    //     $scope.exit = function() {
+    //         $modalInstance.dismiss();
+    //     }
+    //
+    // }]);
 });

+ 78 - 0
src/main/webapp/resources/js/usercenter/controllers/forstore/buyer_invoice_record_ctrl.js

@@ -0,0 +1,78 @@
+define([ 'app/app' ], function(app) {
+    'use strict';
+    app.register.controller('buyerInvoiceRecordCtrl', ['$scope','$rootScope','$modal','BillSubmit','BaseService', 'toaster','ngTableParams', function ($scope, $rootScope, $modal, BillSubmit, BaseService, toaster, ngTableParams) {
+        $scope.tab = 'buyer_invoice-record';
+        // 开票申请
+        $scope.keyword = '';
+        $scope.invoiceType = '';
+
+        var initDataRule = function () {
+            $scope.param = {
+                page: 1,
+                count: 10,
+                sorting: {
+                    createTime : "DESC"
+                },
+                keyword: '',
+                invoiceType: '',
+                status: '',
+                role: 'BUYER'
+            };
+        };
+        initDataRule();
+
+        // 切换发票类型
+        $scope.changeInvoiceType = function(invoiceType) {
+            $scope.invoiceType = invoiceType;
+            $scope.billRecordTableParam.page(1);
+            $scope.billRecordTableParam.reload();
+        };
+
+        // 切换状态
+        $scope.changeStatus = function (status) {
+            $scope.status = status;
+            $scope.billRecordTableParam.page(1);
+            $scope.billRecordTableParam.reload();
+        };
+
+        $scope.$$kdnData = {};
+        var initTable = function () {
+            $scope.billRecordTableParam = new ngTableParams($scope.param,{
+                total : 0,
+                getData : function ($defer, params) {
+                    var param = BaseService.parseParams(params.url());
+                    param.keyword = $scope.keyword;
+                    param.invoicetype = $scope.invoiceType;
+                    param.status = $scope.status;
+                    BillSubmit.getSubmitBillApply(param, function (page) {
+                        $scope.$$kdnData.totalElements = page.totalElements;
+                        if(Number(page.totalElements) > 0) {
+                            $scope.$$kdnData.start = Number(page.size) * (Number(page.number) - 1) + 1;
+                        }else {
+                            $scope.$$kdnData.start = 0;
+                        }
+                        $scope.$$kdnData.end = Number(page.size) * (Number(page.number) - 1) + Number(page.numberOfElements);
+                        params.total(page.totalElements);
+                        $defer.resolve(page.content);
+                        //划分数据
+                        $scope.billData = page.content;
+                    }, function () {
+                        toaster.pop('error', '获取开票记录失败');
+                    });
+                }
+            });
+        };
+        initTable();
+        
+        $scope.searchByKey = function () {
+            $scope.param.keyword = $scope.keyword;
+            initTable();
+        }
+        $scope.enterEvent = function (e) {
+            var keycode = window.event?e.keyCode:e.which;
+            if(keycode==13){
+                $scope.searchByKey();
+            }
+        }
+    }]);
+});

+ 216 - 0
src/main/webapp/resources/js/usercenter/controllers/forstore/buyer_no_invoice_ctrl.js

@@ -0,0 +1,216 @@
+define([ 'app/app' ], function(app) {
+    'use strict';
+    app.register.controller('NoInvoiceCtrl', ['$scope','$rootScope','$modal', 'Order', 'toaster','ngTableParams','BaseService','Bill', function ($scope, $rootScope, $modal, Order, toaster, ngTableParams, BaseService, Bill) {
+        $scope.tab = 'buyer_no_invoice';
+
+        // 开票申请
+        $scope.applyInvoice = function () {
+            var applyItem = [];
+            angular.forEach($scope.orderData, function (item) {
+                if (item.checked) {
+                    applyItem.push(item);
+                }
+            })
+            if (applyItem.length > 0) {
+                if ($scope.invoices.length > 0) {
+                    $modal.open({
+                        templateUrl : $rootScope.rootPath + '/static/view/usercenter/modal/apply-invoice.html',
+                        size : 'lg',
+                        controller : 'NoInvoiceSubmitCtrl',
+                        resolve : {
+                            submitInvoice : function () {
+                                return applyItem;
+                            },
+                            invoiceData: function () {
+                                return $scope.invoices;
+                            }
+                        }
+                    })
+                } else {
+                    toaster.pop('error','请前往开票信息页面新增发票');
+                }
+            } else {
+                toaster.pop('error','请勾选未开票订单');
+            }
+        };
+        var initDataRule = function () {
+            $scope.param = {
+                page : 1,
+                count : 10,
+                status : 520,
+                sorting: {creattime : "DESC"},
+                keyword : ''
+            };
+            $scope.keyword = '';
+
+            Bill.getListPersonal(null, function(data) {
+                $scope.invoices = data;
+            }, function(error) {
+                toaster.pop('error', '获取发票信息失败');
+            });
+        }
+        initDataRule();
+
+        $scope.$$kdnData = {};
+
+        var initTable = function () {
+            $scope.orderBillTableParam = new ngTableParams($scope.param,{
+                total : 0,
+                getData : function ($defer, params) {
+                    var param = BaseService.parseParams(params.url());
+                    // param.pageParams.sorting = {creattime : "DESC"};
+                    param.keyword = $scope.keyword;
+                    Order.getOrderOnBillByPersonal(param, function (page) {
+                        $scope.$$kdnData.totalElements = page.totalElements;
+                        if(Number(page.totalElements) > 0) {
+                            $scope.$$kdnData.start = Number(page.size) * (Number(page.number) - 1) + 1;
+                        }else {
+                            $scope.$$kdnData.start = 0;
+                        }
+                        $scope.$$kdnData.end = Number(page.size) * (Number(page.number) - 1) + Number(page.numberOfElements);
+                        params.total(page.totalElements);
+                        $defer.resolve(page.content);
+                        //划分数据
+                        $scope.orderData = page.content;
+                        //初始化选中状态
+                        angular.forEach($scope.orderData, function (item) {
+                            item.checked = false;
+                        })
+                    }, function () {
+                        toaster.pop('error', '获取未开票订单信息失败');
+                    });
+                }
+            });
+        };
+        initTable();
+
+        $scope.searchByKeyword = function () {
+            $scope.param.keyword = $scope.keyword;
+            initTable();
+        }
+        $scope.enterEvent = function (e) {
+            var keycode = window.event?e.keyCode:e.which;
+            if(keycode==13){
+                $scope.searchByKeyword();
+            }
+        }
+
+        //全选状态
+        $scope.isAllCheck = false;
+        //全选
+        $scope.onAllChecked = function () {
+            if (!$scope.isAllCheck) {
+                angular.forEach($scope.orderData, function (item, index) {
+                    item.checked = true;
+                })
+            } else {
+                angular.forEach($scope.orderData, function (item, index) {
+                    item.checked = false;
+                })
+            }
+            $scope.isAllCheck = !$scope.isAllCheck;
+        }
+
+
+        //单选
+        $scope.checkInvoice = function (item) {
+            var temAllCheck = true;
+            item.checked = !item.checked;
+            angular.forEach($scope.orderData, function (itemss) {
+                if (!itemss.checked) {
+                    temAllCheck = false;
+                }
+            })
+            $scope.isAllCheck = temAllCheck;
+        }
+
+    }]);
+    app.register.controller('NoInvoiceSubmitCtrl', ['$scope','$rootScope','$modal', 'Order', 'toaster', 'submitInvoice', '$modalInstance','invoiceData','BillSubmit','$state', function ($scope, $rootScope, $modal, Order, toaster, submitInvoice, $modalInstance, invoiceData, BillSubmit, $state) {
+        //公司列表
+        $scope.submitInvoice = [];
+
+        //订单数
+        $scope.orderCount = submitInvoice.length || 0;
+
+        //总金额
+        $scope.allPrice = 0;
+
+        //发票信息
+        $scope.invoiceData = {};
+
+        $scope.orderIdArr = [];
+        // 数据处理
+        $scope.dealData = function () {
+            var submitItem = submitInvoice;
+            var temStoreIdArr = [];
+            var tmpPriceArr = [];
+            angular.forEach(submitItem, function (item) {
+                var index = temStoreIdArr.indexOf(item.storeid);
+                $scope.orderIdArr.push(item.orderid);
+                if (index == -1) {
+                    temStoreIdArr.push(item.storeid);
+                    tmpPriceArr.push({price: item.price, storeName: item.storeName, orderid: item.orderid});
+                } else {
+                    tmpPriceArr[index].price += item.price;
+                }
+            })
+            angular.forEach(tmpPriceArr, function (item, index) {
+                $scope.submitInvoice.push(tmpPriceArr[index]);
+                $scope.allPrice += tmpPriceArr[index].price;
+            })
+        }
+        $scope.dealData();
+
+        $scope.hasSpecial = false;
+        $scope.hasNormal = false;
+
+        $scope.getInvoiceData = function (invoiceKind) {
+            var tmpInvoice = invoiceData;
+            if (!invoiceKind) {
+                if (tmpInvoice.length == 1) {
+                    $scope.invoiceData = tmpInvoice[0];
+                    if (tmpInvoice[0].kind == 1205) {
+                        $scope.hasSpecial = true;
+                    } else if (tmpInvoice[0].kind == 1206) {
+                        $scope.hasNormal = true;
+                    }
+                } else if (tmpInvoice.length > 1) {
+                    $scope.getInvoiceData(1206);
+                }
+            } else {
+                angular.forEach(tmpInvoice, function (item) {
+                    if (item.kind == 1205) {
+                        $scope.hasSpecial = true;
+                    }
+
+                    if (item.kind == 1206) {
+                        $scope.hasNormal = true;
+                    }
+
+                    if (item.kind == invoiceKind) {
+                        $scope.invoiceData = item;
+                    }
+                })
+            }
+        }
+
+        $scope.getInvoiceData();
+
+        //关闭模态框
+        $scope.closeModal = function () {
+            $modalInstance.dismiss();
+        }
+
+        //提交申请
+        $scope.apply = function () {
+            BillSubmit.submitBillApply(null, {orderids: $scope.orderIdArr.join(','), invoiceid: $scope.invoiceData.id}, function (data) {
+                toaster.pop('success', '申请发票成功');
+                $scope.closeModal();
+                $state.reload();
+            },function (error) {
+                toaster.pop('error', '申请发票失败');
+            })
+        }
+
+    }]);
+});

+ 19 - 6
src/main/webapp/resources/js/usercenter/controllers/forstore/buyer_order_ctrl.js

@@ -720,7 +720,7 @@ define(['app/app'], function (app) {
 	/**
 	 * 与现在的时间对比,距离多少天多少小时
 	 */
-	app.register.filter('restTime', function () {
+	app.register.filter('restTime', ['NumberService', function (NumberService) {
 		var day = 0, hours = 0;
 		return function (time) {
 			if(!time) {
@@ -728,12 +728,25 @@ define(['app/app'], function (app) {
 			}
 			var nowTime = new Date();
 			var s1 = time - nowTime.getTime();
-			var totalHours = s1/(1000*60*60);//算多少个小时
-			day = parseInt(totalHours) / 24;
-			hours = parseInt(totalHours) % 24;
-			return "还剩 " + parseInt(day) + "天" + parseInt(hours) + "小时";
+			if(parseInt(s1) <= 0) {
+				return "到期未付款";
+			}else {
+				var totalHours = Math.ceil(s1/(1000*60*60));//算多少个小时
+				day = parseInt(totalHours) / 24;
+				hours = parseInt(totalHours) % 24;
+				var str = "还剩";
+				if(parseInt(day) > 0) {
+					str = str + parseInt(day) + "天";
+				}
+				if(parseInt(hours) > 0) {
+					str = str + parseInt(hours) + "小时";
+				}
+				return str;
+			}
+
+
 		}
-	});
+	}]);
 
 	/**
 	 * totalHours传入小时,被减去minuesTime转换成天数

+ 29 - 0
src/main/webapp/resources/js/usercenter/controllers/forstore/order_detail_ctrl.js

@@ -27,6 +27,13 @@ define(['app/app'], function(app) {
 			603: true
 		};
 
+		//配送方式列表
+		$scope.deliveryMethod = {
+			1301 : '第三方配送',
+			1302 : '卖家配送',
+			1303 : '上门自提'
+		};
+
 		// TODO 暂时假设运费固定为0
 		$scope.freight = 0;
 
@@ -60,6 +67,14 @@ define(['app/app'], function(app) {
 		/**
 		 * 确认当前订单所属状态
 		 */
+		// 联系卖家弹框
+		$scope.contactBNox = false;
+		$scope.contactSeller = function () {
+			$scope.contactBNox = !$scope.contactBNox;
+		};
+		$scope.closeBox = function () {
+			$scope.contactBNox = false;
+		};
 		$scope.stepStyle = function (status) {
 			if (!status || status == '') {
 				$scope.error('订单状态不能为空');
@@ -176,6 +191,17 @@ define(['app/app'], function(app) {
 				}
 				$scope.order = data;
 				$scope.order.orderHistory = angular.fromJson($scope.order.statushistory);
+				if ($scope.order.orderRemark){
+					$scope.remarkList = angular.fromJson($scope.order.orderRemark);
+				}
+				if ($scope.order.jsonRule){
+					$scope.rule = angular.fromJson($scope.order.jsonRule);
+				}
+				//自提点信息
+				if ($scope.order.jsonTakeSelf){
+					$scope.takeSelf = angular.fromJson($scope.order.jsonTakeSelf);
+					$scope.takeSelf.area = $scope.takeSelf.area.replace(/,/g,' ');
+				}
 				// 设置状态样式
 				$scope.stepStyle($scope.order.status);
 				// 获取物流信息
@@ -193,6 +219,9 @@ define(['app/app'], function(app) {
 				//发票信息
 				$scope.order.invoiceInfo = angular.fromJson($scope.order.invoiceAddress);
 
+				// 取消原因
+				$scope.order.unavailableReason = angular.fromJson($scope.order.unavailableReason);
+
 				//收货地址
 				$scope.order.deliveryAddress = angular.fromJson($scope.order.jsonAddress);
 

+ 260 - 51
src/main/webapp/resources/js/usercenter/controllers/forstore/order_pay_ctrl.js

@@ -3,7 +3,7 @@
  *  订单付款的界面
  */
 define(['app/app'], function(app) {
-	app.register.controller('orderPayCtrl', ['$scope', '$rootScope', '$stateParams', '$modal', '$state', 'Bill', 'toaster', 'Order', '$filter', 'ShippingAddress', 'Ysepay', '$q', 'NumberService', 'Cart', '$timeout', function($scope, $rootScope, $stateParams, $modal, $state, Bill, toaster, Order, $filter, ShippingAddress, Ysepay, $q, NumberService, Cart, $timeout) {
+	app.register.controller('orderPayCtrl', ['$scope', '$rootScope', '$stateParams', '$modal', '$state', 'Bill', 'toaster', 'Order', '$filter', 'ShippingAddress', 'Ysepay', '$q', 'NumberService', 'Cart', '$timeout', 'DistributionRule', 'TakeSelf', function($scope, $rootScope, $stateParams, $modal, $state, Bill, toaster, Order, $filter, ShippingAddress, Ysepay, $q, NumberService, Cart, $timeout, DistributionRule, TakeSelf) {
 
 		$rootScope.active = 'buyer_cart';
 
@@ -21,38 +21,38 @@ define(['app/app'], function(app) {
 		$scope.bills = [];
 
 		//获取个人的发票信息
-        var getBillInfo = function() {
-            Bill.getListPersonal(null, function(data) {
-                $scope.bill = {};
-                $scope.bills = data;
+		var getBillInfo = function() {
+			Bill.getListPersonal(null, function(data) {
+				$scope.bill = {};
+				$scope.bills = data;
 				$scope.bill.kind = '1207';
 				$scope.order.invoicetype = '1207';
-                // angular.forEach($scope.bills, function(item) {
-                //     if(item.kind == '1205') {
-                //         $scope.bill = item;
-                //     }
-                // });
-            }, function(response) {
+				// angular.forEach($scope.bills, function(item) {
+				//     if(item.kind == '1205') {
+				//         $scope.bill = item;
+				//     }
+				// });
+			}, function(response) {
 				if(angular.equals('系统错误',  response.data)) {
 					toaster.pop('error', '获取信息失败');
 				}else {
 					toaster.pop('error', '获取订单的信息失败,' + response.data);
 				}
-            });
-        };
+			});
+		};
 
-        $scope.deliveryMethod = {
+		$scope.deliveryMethod = {
 			1301 : '第三方配送',
 			1302 : '卖家配送',
 			1303 : '上门自提'
 		};
 
-        //选择相应的发票信息
+		//选择相应的发票信息
 		$scope.selectBill = function(kind) {
 			if(!kind || (kind != '1205' && kind != '1206' &&  kind != '1207')) {
 				return ;
 			}
-            getTheKindBill(kind);
+			getTheKindBill(kind);
 			$scope.order.invoicetype = kind;
 			$scope.bill.kind = kind;
 		};
@@ -70,20 +70,25 @@ define(['app/app'], function(app) {
 			});
 		};
 
-        //查看价格分段。
-        $scope.togglePrice = function (detail) {
-            detail.display = detail.display == 'block' ? 'none' : 'block';
-        };
+		//查看价格分段。
+		$scope.togglePrice = function (detail) {
+			detail.display = detail.display == 'block' ? 'none' : 'block';
+		};
 
 		//获取订单的信息
 		var getOrderData = function() {
 			return Order.findStatusByOrderid({enOrderid : $stateParams.orderid}, function (response) {
 
+				$scope.storeArray = [];
+				$scope.ruleMap = {};
 				if (response.status == 501){
 					Order.orderContainGoods({enOrderid : $stateParams.orderid}, function(data) {
 						$scope.order = data;
 						$scope.$$orderDetailsMap = {};
-						$scope.remarkList = {};
+						$scope.remarkList = {};//订单备注列表
+						$scope.deliveryList = {};//配送方式列表
+						$scope.takeSelfList = {};
+						$scope.fareList = {};//运费列表
 						if($scope.order.orderDetails.length == 0) {
 							toaster.pop('warning', '您购买的商品已全部失效,请您前往购物车重新勾选');
 							$timeout(function () {
@@ -99,6 +104,9 @@ define(['app/app'], function(app) {
 							}else {
 								$scope.$$orderDetailsMap[detail.storeName] = [];
 								$scope.remarkList[detail.storeid] = "";
+								$scope.deliveryList[detail.storeid] = '';
+								$scope.takeSelfList[detail.storeid] = null;
+								$scope.fareList[detail.storeid] = 0;
 								$scope.$$orderDetailsMap[detail.storeName].push(detail);
 							}
 							$scope.disabledAddAndSub(detail);
@@ -106,7 +114,15 @@ define(['app/app'], function(app) {
 						if($scope.order.status == 501) { //如果不是待确认状态,则不需要计算
 							//计算总价格
 							$scope.calculateTotal();
+							getTakeSelf();
 						}
+						angular.forEach($scope.$$orderDetailsMap, function (value, key) {
+							var object = {
+								uuid : value[0].storeid,
+								fare : $scope.storePrice[key]
+							};
+							$scope.storeArray.push(object);
+						});
 						initOrder();
 					}, function(response) {
 						toaster.pop('error', "获取订单的类型失败。" + response.data);
@@ -117,6 +133,12 @@ define(['app/app'], function(app) {
 					if ($scope.order.orderRemark){
 						$scope.remarkList = angular.fromJson($scope.order.orderRemark);
 					}
+					if ($scope.order.jsonRule){
+						$scope.rule = angular.fromJson($scope.order.jsonRule);
+					}
+					if ($scope.order.jsonTakeSelf){
+						$scope.takeSelf = angular.fromJson($scope.order.jsonTakeSelf);
+					}
 					if($scope.order.orderDetails.length == 0) {
 						$state.go('buyer_order');
 					}
@@ -124,16 +146,67 @@ define(['app/app'], function(app) {
 						if($scope.$$orderDetailsMap[detail.storeName]) {
 							$scope.$$orderDetailsMap[detail.storeName].push(detail);
 						}else {
+							$scope.storeArray.push(detail.storeid);
 							$scope.$$orderDetailsMap[detail.storeName] = [];
 							$scope.$$orderDetailsMap[detail.storeName].push(detail);
 						}
 					});
+					if ($scope.order.jsonMoreRule){
+						$scope.deliveryList = angular.fromJson($scope.order.jsonMoreRule);
+					}
+					if ($scope.order.jsonMoreTake){
+						$scope.takeList = angular.fromJson($scope.order.jsonMoreTake);
+					}
+					if ($scope.storeArray.length != 1){
+						$scope.calculateTotal();
+					}
 					initOrder();
 				}
 			});
 		};
 
 		getOrderData();
+		// 联系卖家弹框
+		$scope.contactBNox = false;
+		$scope.contactSeller = function (details) {
+			details.contactSeller = !details.contactSeller;
+			angular.forEach($scope.order.orderDetails, function (order) {
+				if(order.id != details.id) {
+					order.contactSeller = false;
+				}
+			});
+		};
+		$scope.closeBox = function () {
+			$scope.contactBNox = false;
+		};
+
+		var getTakeSelf = function () {
+			if ($scope.order.status == 501){
+				TakeSelf.findTakeSelfByStore({}, $scope.storeArray, function (data) {
+					if(data){
+						$scope.takeSelfMap = data;
+					}
+				})
+			}
+		};
+
+		$scope.changeFare = function (details) {
+			var storeid = details[0].storeid;
+			var rule = $scope.deliveryList[storeid];
+			$scope.fareList[storeid] = rule.fare;
+			$scope.calculateFare();
+		};
+
+		/**
+		 * 计算运费和店铺费用合计
+		 */
+		$scope.calculateFare = function () {
+			var fare = 0;
+			angular.forEach($scope.fareList, function (v) {
+				fare = NumberService.add(v, fare);
+			});
+			$scope.order.ensurePrice = NumberService.add($scope.order.totalprice, fare);
+		};
 
 
 		/**
@@ -166,11 +239,36 @@ define(['app/app'], function(app) {
 			$scope.calculatePrice(detail.number, detail, detail.currencyName);
 			//计算总价格
 			$scope.calculateTotal();
-        };
-        //选择收货的地址。
+		};
+		//选择收货的地址。
 		$scope.selectAdd = function(address) {
 			$scope.payment.address = address;
-            $scope.formatArea = $scope.payment.address.area.replace(/,/g,' ');
+			$scope.formatArea = $scope.payment.address.area.replace(/,/g,' ');
+			if ($scope.order.status == 501){
+				DistributionRule.findUsableRule({area:$scope.payment.address.area}, $scope.storeArray, function (data) {
+					if (data){
+						//更换地址后先清空数据
+						$scope.deliveryList = {};
+						$scope.fareList = {};
+						angular.forEach($scope.storeArray, function (item) {
+							$scope.ruleMap[item.uuid] = [];
+							var arr = data[item.uuid];
+							$scope.ruleMap[item.uuid] = arr;
+							if (arr.length != 0){
+								$scope.deliveryList[item.uuid] = arr[0];
+								$scope.fareList[item.uuid] = arr[0].fare;
+							}
+						});
+						$scope.calculateFare();
+					}
+				},function (error) {
+					toaster.pop('info', '提示', error.data);
+				})
+			}
+		};
+
+		$scope.updateTakeSelf = function (uuid, item) {
+			$scope.takeSelfList[uuid] = item;
 		};
 
 		// 添加按钮,每次加1
@@ -190,6 +288,21 @@ define(['app/app'], function(app) {
 			$scope.calculatePrice(detail.number, detail, detail.currencyName);
 			//计算总价格
 			$scope.calculateTotal();
+			updateStoreArray(detail);
+			$q.all([updateFare($scope.ruleMap[detail.storeid], $scope.storePrice[detail.storeName]).$promise]).then(function (data) {
+				if (data){
+					var id = $scope.deliveryList[detail.storeid].id;
+					var arr = data[0];
+					$scope.ruleMap[detail.storeid] = arr;
+					angular.forEach(arr, function (item) {
+						if (item.id == id){
+							$scope.deliveryList[detail.storeid] = item;
+							$scope.fareList[detail.storeid] = item.fare;
+						}
+					});
+					$scope.calculateFare();
+				}
+			});
 		};
 
 		// 减少按钮,每次减minPackQty
@@ -205,6 +318,49 @@ define(['app/app'], function(app) {
 			$scope.calculatePrice(detail.number, detail, detail.currencyName);
 			//计算总价格
 			$scope.calculateTotal();
+			updateStoreArray(detail);
+			$q.all([updateFare($scope.ruleMap[detail.storeid], $scope.storePrice[detail.storeName]).$promise]).then(function (data) {
+				if (data){
+					var id = $scope.deliveryList[detail.storeid].id;
+					var arr = data[0];
+					$scope.ruleMap[detail.storeid] = arr;
+					angular.forEach(arr, function (item) {
+						if (item.id == id){
+							$scope.deliveryList[detail.storeid] = item;
+							$scope.fareList[detail.storeid] = item.fare;
+						}
+					});
+					$scope.calculateFare();
+				}
+			});
+
+		};
+
+		/**
+		 * 更新配送规则请求参数
+		 */
+		var updateStoreArray = function (detail) {
+			angular.forEach($scope.storeArray, function (item) {
+				if (item.uuid == detail.storeid){
+					item.fare = $scope.storePrice[detail.storeName];
+				}
+			})
+		};
+
+		/**
+		 * 更新运费列表
+		 * @param ruleList
+		 * @param price
+		 * @returns {*|{url, method, isArray}}
+		 */
+		var updateFare = function (ruleList, price) {
+			return DistributionRule.findFareOfRule({price:price}, ruleList, function (data) {
+				if (data){
+
+				}
+			}, function (error) {
+				// toaster.pop("error", error.data);
+			})
 		};
 
 		// 输入购买量限制
@@ -235,6 +391,21 @@ define(['app/app'], function(app) {
 			$scope.calculatePrice(detail.number, detail, detail.currencyName);
 			//计算总价格
 			$scope.calculateTotal();
+			updateStoreArray(detail);
+			$q.all([updateFare($scope.ruleMap[detail.storeid], $scope.storePrice[detail.storeName]).$promise]).then(function (data) {
+				if (data){
+					var id = $scope.deliveryList[detail.storeid].id;
+					var arr = data[0];
+					$scope.ruleMap[detail.storeid] = arr;
+					angular.forEach(arr, function (item) {
+						if (item.id == id){
+							$scope.deliveryList[detail.storeid] = item;
+							$scope.fareList[detail.storeid] = item.fare;
+						}
+					});
+					$scope.calculateFare();
+				}
+			});
 		};
 
 		/**
@@ -253,6 +424,29 @@ define(['app/app'], function(app) {
 			}
 		};
 
+		//验证配送规则
+		var checkRule = function () {
+			var value = true;
+			angular.forEach($scope.ruleMap, function (v) {
+				if (v.length == 0){
+					value = false;
+				}
+			});
+			return value;
+		};
+		//验证是否选择上门自提,却没有选择自提点
+		var checkTakeSelf = function () {
+			var value = true;
+			angular.forEach($scope.deliveryList, function (v, k) {
+				if (v.method == 1303){
+					if ($scope.takeSelfList[k] == null){
+						value = false;
+					}
+				}
+			});
+			return value;
+		};
+
 		//确认付款
 		$scope.confirmPay = function() {
 			if($scope.order.status == 502 || $scope.order.status == 503) {
@@ -271,6 +465,16 @@ define(['app/app'], function(app) {
 				}
 				return ;
 			}
+			var validRule = checkRule();
+			if (!validRule){
+				toaster.pop("info", "当前地址部分卖家无法配送,请重新选择地址或与卖家协商处理");
+				return ;
+			}
+			var validTakeSelf = checkTakeSelf();
+			if (!validTakeSelf){
+				toaster.pop("info", "请选择一个自提点");
+				return ;
+			}
 			var orderInfos = [], orderInfo;
 			orderInfo = generateOrderInfo();
 			if(orderInfo == null) {
@@ -354,7 +558,7 @@ define(['app/app'], function(app) {
 
 			orderInfo.id = $scope.order.id;
 			orderInfo.orderid = $scope.order.orderid;
-			orderInfo.deliverytype = $scope.order.deliverytype; // 配送方式
+			// orderInfo.deliverytype = $scope.order.deliverytype; // 配送方式
 
 			if($scope.order.currency == 'USD' && $scope.order.paytype == '1102') {
 				toaster.pop('info', '美元请线下付款');
@@ -366,7 +570,8 @@ define(['app/app'], function(app) {
 			}
 
 			// 收货地址,上门自提暂不提供
-			if($scope.order.deliverytype == '1301'){
+			if($scope.deliveryList){
+				console.log("进来了");
 				/*var address = angular.fromJson($scope.selectAddress);
 				 delete address.isSelect;
 				 orderInfo.jsonAddress = angular.toJson(address);*/
@@ -386,9 +591,10 @@ define(['app/app'], function(app) {
 					}
 				}
 				orderInfo.add_id = $scope.payment.address.id;
-			}else if($scope.order.deliverytype == '1302'){
-				orderInfo.add_id = $scope.pickAddress.id;
 			}
+			// else if($scope.order.deliverytype == '1302'){
+			// 	orderInfo.add_id = $scope.pickAddress.id;
+			// }
 			orderInfo.invoicetype = $scope.order.invoicetype; // 发票类型
 			if($scope.order.invoicetype != '1207') {
 				if(!$scope.bill.id) {
@@ -398,11 +604,14 @@ define(['app/app'], function(app) {
 				orderInfo.invoiceid = $scope.bill.id; // 发票主键
 			}
 
-			orderInfo.totalprice = $scope.order.ensurePrice; // 应付总额
+			orderInfo.totalprice = $scope.order.totalprice; // 应付总额,不含运费
 			orderInfo.currency = $scope.order.currency; // 币别
-			orderInfo.orderRemark = angular.toJson($scope.remarkList);
-			// console.log(orderInfo.orderRemark);
-			// orderInfo.orderRemark = $scope.order.orderRemark; // 交易备注
+			orderInfo.orderRemark = angular.toJson($scope.remarkList);//订单备注
+			orderInfo.splitInfo = {
+				ruleList : angular.toJson($scope.deliveryList),
+				takeList : angular.toJson($scope.takeSelfList)
+			};
+
 			orderInfo.paytype =  $scope.order.paytype;
 			orderInfo.orderDetails = convertOrderDetails(); // 订单明细信息:id、number
 
@@ -418,6 +627,7 @@ define(['app/app'], function(app) {
 					number: v.number,
 					taxUnitprice: v.taxUnitprice,
 					remark : v.remark,
+					goodsnumber : v.goodsnumber,
 					storeid : v.storeid
 				});
 			});
@@ -440,13 +650,13 @@ define(['app/app'], function(app) {
 			}
 			// 人民币为专用增值税发票,美元不开发票    --1205专用增值税发票   --1206普通发票  --1207不开发票
 			if($scope.order.currency == 'USD') {
-			    $scope.order.invoicetype = 1207;
+				$scope.order.invoicetype = 1207;
 				$scope.order.paytype = '1103';
 			}else {
-			    $scope.order.invoicetype = 1205;
+				$scope.order.invoicetype = 1205;
 				$scope.order.paytype = '1102';
 			}
-			// 默认选择UU配送  --1301UU配送  --1302上门自提
+			// 默认选择第三方配送  --1301第三方配送 --卖家配送  --1303上门自提
 			$scope.order.deliverytype = 1301;
 
 			//获取地址的信息
@@ -491,8 +701,7 @@ define(['app/app'], function(app) {
 						$scope.sendAddress.push(address);
 					}
 				}
-				$scope.payment.address = address;
-				$scope.formatArea = $scope.payment.address.area.replace(/,/g,' ');
+				$scope.selectAdd(address);
 			}, function(){
 				toaster.pop('info', '提示 ' + '您已取消收货地址的编辑');
 			});
@@ -527,13 +736,13 @@ define(['app/app'], function(app) {
 
 
 			// 获取当前数量的对应价格区间的单据信息
-            if(properPrice.length > 0) {
-                detail.usdUnitPrice = properPrice[0].uSDPrice;
-                detail.rmbUnitPrice = properPrice[0].rMBPrice;
-            }else {
-                detail.usdUnitPrice = detail.goodsHistory.prices[detail.goodsHistory.prices.length - 1].uSDPrice;
-                detail.rmbUnitPrice = detail.goodsHistory.prices[detail.goodsHistory.prices.length - 1].rMBPrice;
-            }
+			if(properPrice.length > 0) {
+				detail.usdUnitPrice = properPrice[0].uSDPrice;
+				detail.rmbUnitPrice = properPrice[0].rMBPrice;
+			}else {
+				detail.usdUnitPrice = detail.goodsHistory.prices[detail.goodsHistory.prices.length - 1].uSDPrice;
+				detail.rmbUnitPrice = detail.goodsHistory.prices[detail.goodsHistory.prices.length - 1].rMBPrice;
+			}
 
 			if (currency == 'RMB') {
 				detail.taxUnitprice = detail.rmbUnitPrice;
@@ -546,7 +755,7 @@ define(['app/app'], function(app) {
 		 * 计算总金额
 		 */
 		$scope.calculateTotal = function () {
-			$scope.order.ensurePrice = 0;
+			$scope.order.totalprice = 0;
 			$scope.storePrice = {};
 			angular.forEach($scope.order.orderDetails, function(detail) {
 				detail.ensurePrice = Number(NumberService.mul(detail.taxUnitprice, detail.number));
@@ -557,7 +766,7 @@ define(['app/app'], function(app) {
 			});
 			angular.forEach($scope.$$orderDetailsMap, function (value, key) {
 				$scope.storePrice[key] = Number(NumberService.toCeil($scope.storePrice[key], 2));
-				$scope.order.ensurePrice = NumberService.add($scope.storePrice[key], $scope.order.ensurePrice)
+				$scope.order.totalprice = NumberService.add($scope.storePrice[key], $scope.order.totalprice)
 			});
 		};
 
@@ -602,7 +811,7 @@ define(['app/app'], function(app) {
 		$scope.isModify = isModify;
 		$scope.validEmail = function (email) {
 			return /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(email)
-        };
+		};
 
 		$http.get('static/js/prod/data/city.json').success(function(data) {
 			$scope.division = data;
@@ -620,12 +829,12 @@ define(['app/app'], function(app) {
 			toaster.pop('error', '系统错误 ' + '加载城市信息失败');
 		});
 
-        //验证数据
+		//验证数据
 		$scope.checkForm = function(num) {
 			var size;
 			if(num == 1) {
 				if ($scope.address.name){
-					size = $scope.address.name.replace(/[^x00-xFF]/g,'**').length;
+					size = $scope.address.name.replace(/[^\x00-\xff]/g,'**').length;
 					if (size > 20) {
 						$scope.userError = true;
 						return;
@@ -634,7 +843,7 @@ define(['app/app'], function(app) {
 				}
 			} else if(num == 2) {
 				if ($scope.address.tel){
-					size = $scope.address.tel.replace(/[^x00-xFF]/g,'**').length;
+					size = $scope.address.tel.replace(/[^\x00-\xff]/g,'**').length;
 					if (size < 8 || size > 11) {
 						$scope.telError = true;
 						return;
@@ -649,7 +858,7 @@ define(['app/app'], function(app) {
 				}
 			} else if(num == 3) {
 				if ($scope.address.detailAddress){
-					size = $scope.address.detailAddress.replace(/[^x00-xFF]/g,'**').length;
+					size = $scope.address.detailAddress.replace(/[^\x00-\xff]/g,'**').length;
 					if (size > 60) {
 						$scope.addrError = true;
 						return;

+ 9 - 2
src/main/webapp/resources/js/usercenter/controllers/forstore/query_logistics_ctrl.js

@@ -58,14 +58,21 @@ define(['app/app', 'calendar'], function(app) {
                 str.indexOf("发出")!=-1||str.indexOf("收入")!=-1||str.indexOf("扫描")!=-1||str.indexOf("到达")!=-1){
                 $scope.status = "transit";
             }
-            if(str.indexOf("派送")!=-1){
+            if(str.indexOf("派送")!=-1 || str.indexOf("派件")!=-1){
                 $scope.status = "send";
             }
             if(str.indexOf("签收")!=-1){
                 $scope.status = "signin";
             }
         }
-
+        // 联系卖家弹框
+        $scope.contactBNox = false;
+        $scope.contactSeller = function () {
+            $scope.contactBNox = !$scope.contactBNox;
+        };
+        $scope.closeBox = function () {
+            $scope.contactBNox = false;
+        };
         /**
          *  日历组件
          *

+ 1 - 1
src/main/webapp/resources/js/usercenter/controllers/forstore/shipping_address_edit_ctrl.js

@@ -146,7 +146,7 @@ define(['app/app'], function(app) {
 			// }else {
 			//     if(!$scope.order.invoicetype) $scope.order.invoicetype = 1205;
 			// }
-			// 默认选择UU配送  --1301UU配送  --1302上门自提
+			// 默认选择UU配送  --1301第三方配送  --1302卖家配送 --1303上门自提
 			if(!$scope.order.deliverytype) $scope.order.deliverytype = 1301;
 		};
 

+ 12 - 1
src/main/webapp/resources/js/usercenter/controllers/forstore/store_focus_ctrl.js

@@ -30,7 +30,18 @@ define(['app/app'], function(app) {
 			});
 		}
 		loadData();
-				
+        // 联系卖家弹框
+        $scope.contactSeller = function (item) {
+            item.contactBNox = !item.contactBNox;
+            angular.forEach($scope.store, function (store) {
+                if (store.id != item.id){
+                    store.contactBNox = false;
+                }
+            })
+        };
+        $scope.closeBox = function () {
+            $scope.contactBNox = false;
+        };
 		$scope.isBatch = false;	 // 是否批量标识
 		$scope.isChooseAll = false; // 是否全选标识
 		

Some files were not shown because too many files changed in this diff