Merge branch 'refactor-supplier' into develop
This commit is contained in:
commit
855cf4ad5f
|
@ -138,3 +138,22 @@ func (s Supplier) GetWarehouseFreeship() (*model.ResponseListWarehouseIDByBusine
|
||||||
|
|
||||||
return r.Data, nil
|
return r.Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateCashflow ...
|
||||||
|
func (s Supplier) CreateCashflow(p model.SupplierCashflowCreatePayload) (*model.SupplierCashflowCreateResponse, error) {
|
||||||
|
msg, err := natsio.GetServer().Request(subject.Supplier.CreateCashflow, toBytes(p))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var r struct {
|
||||||
|
Error string `json:"error"`
|
||||||
|
Data *model.SupplierCashflowCreateResponse `json:"data"`
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal(msg.Data, &r); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if r.Error != "" {
|
||||||
|
return nil, errors.New(r.Error)
|
||||||
|
}
|
||||||
|
return r.Data, nil
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"git.selly.red/Selly-Modules/natsio"
|
||||||
|
"git.selly.red/Selly-Modules/natsio/model"
|
||||||
|
"git.selly.red/Selly-Modules/natsio/subject"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SupplierUser ...
|
||||||
|
type SupplierUser struct{}
|
||||||
|
|
||||||
|
// GetSupplierUser ...
|
||||||
|
func GetSupplierUser() SupplierUser {
|
||||||
|
return SupplierUser{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s SupplierUser) CreateSupplierUserS(p model.CreateSupplierUserRequest) (*model.CreateSupplierUserResponse, error) {
|
||||||
|
msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateSupplierUser, toBytes(p))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var r struct {
|
||||||
|
Data *model.CreateSupplierUserResponse `json:"data"`
|
||||||
|
Error string `json:"error"`
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = json.Unmarshal(msg.Data, &r); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if r.Error != "" {
|
||||||
|
return nil, errors.New(r.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r.Data, nil
|
||||||
|
}
|
|
@ -20,3 +20,9 @@ type ActionBy struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClickAction ...
|
||||||
|
type ClickAction struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
Value string `json:"value"`
|
||||||
|
}
|
||||||
|
|
|
@ -38,3 +38,13 @@ type UpdateSupplierWarehousePayload struct {
|
||||||
DistrictCode int `json:"districtCode"`
|
DistrictCode int `json:"districtCode"`
|
||||||
WardCode int `json:"wardCode"`
|
WardCode int `json:"wardCode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SupplierCashflowCreatePayload ...
|
||||||
|
type SupplierCashflowCreatePayload struct {
|
||||||
|
Supplier string `json:"supplier"`
|
||||||
|
Action string `json:"action"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
TargetID string `json:"targetId"`
|
||||||
|
Value float64 `json:"value"`
|
||||||
|
ClickAction *ClickAction `json:"clickAction"`
|
||||||
|
}
|
||||||
|
|
|
@ -33,3 +33,7 @@ type SupplierAll struct {
|
||||||
type ResponseListWarehouseIDByBusinessType struct {
|
type ResponseListWarehouseIDByBusinessType struct {
|
||||||
Warehouses []string `json:"warehouses"`
|
Warehouses []string `json:"warehouses"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SupplierCashflowCreateResponse struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
type CreateUserSMSRequest struct {
|
type CreateSupplierUserRequest struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Phone string `json:"phone"`
|
Phone string `json:"phone"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
|
@ -1,6 +1,6 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
type CreateUserSMSResponse struct {
|
type CreateSupplierUserResponse struct {
|
||||||
ID string `json:"_id"`
|
ID string `json:"_id"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package subject
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func getAuthSMSValue(val string) string {
|
func getAuthSMSValue(val string) string {
|
||||||
return fmt.Sprintf("%s.%s", prefixes.AuthSMS, val)
|
return fmt.Sprintf("%s.%s", prefixes.SupplierUser, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
var AuthSMS = struct {
|
var AuthSMS = struct {
|
||||||
|
|
|
@ -9,7 +9,7 @@ var prefixes = struct {
|
||||||
Bank string
|
Bank string
|
||||||
Supplier string
|
Supplier string
|
||||||
Seller string
|
Seller string
|
||||||
AuthSMS string
|
SupplierUser string
|
||||||
}{
|
}{
|
||||||
Communication: "communication",
|
Communication: "communication",
|
||||||
Order: "order",
|
Order: "order",
|
||||||
|
@ -19,5 +19,5 @@ var prefixes = struct {
|
||||||
Supplier: "supplier",
|
Supplier: "supplier",
|
||||||
Bank: "bank",
|
Bank: "bank",
|
||||||
Seller: "seller",
|
Seller: "seller",
|
||||||
AuthSMS: "auth_sms",
|
SupplierUser: "supplier_user",
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,11 @@ var Supplier = struct {
|
||||||
GetSupplierContractBySupplierID string
|
GetSupplierContractBySupplierID string
|
||||||
FindAll string
|
FindAll string
|
||||||
GetListWarehouseFreeship string
|
GetListWarehouseFreeship string
|
||||||
|
CreateCashflow string
|
||||||
}{
|
}{
|
||||||
GetListSupplierInfo: getSupplierValue("get_list_supplier_info"),
|
GetListSupplierInfo: getSupplierValue("get_list_supplier_info"),
|
||||||
GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"),
|
GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"),
|
||||||
FindAll: getSupplierValue("find_all"),
|
FindAll: getSupplierValue("find_all"),
|
||||||
GetListWarehouseFreeship: getSupplierValue("get_list_warehouse_freeship"),
|
GetListWarehouseFreeship: getSupplierValue("get_list_warehouse_freeship"),
|
||||||
|
CreateCashflow: getSupplierValue("create_cashflow"),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue