Merge branch 'refactor-supplier' into develop
This commit is contained in:
commit
70a8d4e847
|
@ -176,3 +176,56 @@ func (s Supplier) CreateCashflow(p model.SupplierCashflowCreatePayload) (*model.
|
||||||
}
|
}
|
||||||
return r.Data, nil
|
return r.Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s Supplier) UpdateBalance(p model.SupplierUpdateBalanceReq) (*model.SupplierUpdateBalanceRes, error) {
|
||||||
|
msg, err := natsio.GetServer().Request(subject.Supplier.UpdateBalance, toBytes(p))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var r struct {
|
||||||
|
Error string `json:"error"`
|
||||||
|
Data *model.SupplierUpdateBalanceRes `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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Supplier) GetCurrentBalance(p model.SupplierGetCurrentBalanceReq) (*model.SupplierGetCurrentBalanceRes, error) {
|
||||||
|
msg, err := natsio.GetServer().Request(subject.Supplier.GetCurrentBalance, toBytes(p))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var r struct {
|
||||||
|
Error string `json:"error"`
|
||||||
|
Data *model.SupplierGetCurrentBalanceRes `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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Supplier) DeleteCashflow(p model.SupplierDeleteCashflowReq) error {
|
||||||
|
msg, err := natsio.GetServer().Request(subject.Supplier.DeleteCashflow, toBytes(p))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var r struct {
|
||||||
|
Error string `json:"error"`
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal(msg.Data, &r); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if r.Error != "" {
|
||||||
|
return errors.New(r.Error)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -52,3 +52,15 @@ type SupplierCashflowCreatePayload struct {
|
||||||
type SupplierFreeShipInfoRequestPayload struct {
|
type SupplierFreeShipInfoRequestPayload struct {
|
||||||
SupplierIDs []string `json:"supplierIds"`
|
SupplierIDs []string `json:"supplierIds"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SupplierUpdateBalanceReq struct {
|
||||||
|
SupplierID string `json:"supplierId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SupplierGetCurrentBalanceReq struct {
|
||||||
|
SupplierID string `json:"supplierId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SupplierDeleteCashflowReq struct {
|
||||||
|
CashflowID string `json:"cashflowId"`
|
||||||
|
}
|
||||||
|
|
|
@ -55,3 +55,20 @@ type SupplierShort struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Logo interface{} `json:"logo"`
|
Logo interface{} `json:"logo"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SupplierUpdateBalanceRes struct {
|
||||||
|
CurrentCash float64 `json:"currentCash"`
|
||||||
|
TotalPendingCash float64 `json:"totalPendingCash"`
|
||||||
|
OrderPendingCash float64 `json:"orderPendingCash"`
|
||||||
|
OrderWaitingForReconcileCash float64 `json:"orderWaitingForReconcileCash"`
|
||||||
|
OrderReconciledCash float64 `json:"orderReconciledCash"`
|
||||||
|
WithdrawPendingCash float64 `json:"withdrawPendingCash"`
|
||||||
|
WithdrawSuccessCash float64 `json:"withdrawSuccessCash"`
|
||||||
|
WithdrawRejectCash float64 `json:"withdrawRejectCash"`
|
||||||
|
ChangeBalanceRequestApproved float64 `json:"changeBalanceRequestApproved"`
|
||||||
|
UpdatedAt string `json:"updatedAt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SupplierGetCurrentBalanceRes struct {
|
||||||
|
CurrentCash float64 `json:"currentCash"`
|
||||||
|
}
|
||||||
|
|
|
@ -12,6 +12,9 @@ var Supplier = struct {
|
||||||
FindAll string
|
FindAll string
|
||||||
GetListWarehouseFreeShip string
|
GetListWarehouseFreeShip string
|
||||||
CreateCashflow string
|
CreateCashflow string
|
||||||
|
DeleteCashflow string
|
||||||
|
UpdateBalance string
|
||||||
|
GetCurrentBalance string
|
||||||
GetFreeShipInfo string
|
GetFreeShipInfo string
|
||||||
}{
|
}{
|
||||||
GetListSupplierInfo: getSupplierValue("get_list_supplier_info"),
|
GetListSupplierInfo: getSupplierValue("get_list_supplier_info"),
|
||||||
|
@ -19,5 +22,8 @@ var Supplier = struct {
|
||||||
FindAll: getSupplierValue("find_all"),
|
FindAll: getSupplierValue("find_all"),
|
||||||
GetListWarehouseFreeShip: getSupplierValue("get_list_warehouse_free_ship"),
|
GetListWarehouseFreeShip: getSupplierValue("get_list_warehouse_free_ship"),
|
||||||
CreateCashflow: getSupplierValue("create_cashflow"),
|
CreateCashflow: getSupplierValue("create_cashflow"),
|
||||||
|
DeleteCashflow: getSupplierValue("delete_cashflow"),
|
||||||
|
UpdateBalance: getSupplierValue("update_balance"),
|
||||||
|
GetCurrentBalance: getSupplierValue("get_current_balance"),
|
||||||
GetFreeShipInfo: getSupplierValue("get_free_ship_info"),
|
GetFreeShipInfo: getSupplierValue("get_free_ship_info"),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue