|
@@ -38,6 +38,9 @@ func Supplier(r *GinRouter) {
|
|
|
// 供应商获取自己的单据列表
|
|
|
r.GETJWT("/supplier/bill/list", SupplierBillList)
|
|
|
|
|
|
+ // 供应商接单
|
|
|
+ r.POSTJWT("/supplier/bill/ack", SupplierBillAck)
|
|
|
+
|
|
|
// 单据分配给供应商
|
|
|
r.GET("/supplier/bill/alloc", SupplierBillAlloc)
|
|
|
|
|
@@ -77,6 +80,46 @@ func SupplierBillAlloc(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 供应商-接单
|
|
|
+// purchase produce product
|
|
|
+// POST /supplier/bill/ack?id=xxxx&type=purchase
|
|
|
+func SupplierBillAck(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
+ userId, _ := primitive.ObjectIDFromHex(apictx.User.Parent)
|
|
|
+ billType := c.Query("type")
|
|
|
+ _id := c.Query("id")
|
|
|
+ id, _ := primitive.ObjectIDFromHex(_id)
|
|
|
+ if id.IsZero() {
|
|
|
+ return nil, errors.New("id为空")
|
|
|
+ }
|
|
|
+ if userId.IsZero() {
|
|
|
+ return nil, errors.New("非法用户")
|
|
|
+ }
|
|
|
+ // purchase produce product
|
|
|
+ billTypes := []string{"purchase", "produce", "product"}
|
|
|
+ flagType := false
|
|
|
+ for _, bt := range billTypes {
|
|
|
+ if bt == billType {
|
|
|
+ flagType = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !flagType {
|
|
|
+ return nil, errors.New("订单类型错误")
|
|
|
+ }
|
|
|
+ isAck := true
|
|
|
+ switch billType {
|
|
|
+ case "purchase":
|
|
|
+ return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionBillPurchase, _id, &model.PurchaseBill{IsAck: &isAck, AckTime: time.Now()})
|
|
|
+ case "produce":
|
|
|
+ return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionBillProduce, _id, &model.ProduceBill{IsAck: &isAck, AckTime: time.Now()})
|
|
|
+ case "product":
|
|
|
+ return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionBillProduct, _id, &model.ProductBill{IsAck: &isAck, AckTime: time.Now()})
|
|
|
+ default:
|
|
|
+ return nil, errors.New("更新类型错误")
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
// 供应商-订单列表
|
|
|
// purchase produce product
|
|
|
// /supplier/bill/list?type=purchase&query={"status":"created"}
|