Compare commits

...

88 Commits

Author SHA1 Message Date
Sinh Luu d80090cfb5
Merge pull request #39 from Selly-Modules/global-care-car-insurance
Global care car insurance
2022-10-04 11:44:31 +07:00
Sinh 9ba66dae05 Merge branch 'master' of github.com:Selly-Modules/natsio into global-care-car-insurance 2022-10-04 11:38:47 +07:00
trunglt251292 89f4e1a11d
Merge pull request #38 from Selly-Modules/feature/seller-by-id
Feature/seller by
2022-10-03 10:48:13 +07:00
Sinh Luu 99f75cfbc7
Merge pull request #37 from Selly-Modules/export-warehouse-data
define warehouse method
2022-09-30 18:12:03 +07:00
Sinh aab1103fc8 define warehouse method 2022-09-30 10:32:33 +07:00
trunglt251292 e6b620ca6c CommissionTransactionPending 2022-09-30 10:29:14 +07:00
Sinh 57d6cb18a9 update global care - integrate car insurance 2022-09-28 08:59:18 +07:00
Nguyen Minh dcea3798f8 js cashflow seller 2022-09-23 23:32:23 +07:00
Nguyen Minh 68b9cab1e2 pull js seller affiliate statistic 2022-09-23 22:11:28 +07:00
Nguyen Minh d9763edd75 pull js seller affiliate statistic 2022-09-23 22:11:24 +07:00
Nguyen Minh 547b3b8dd9 update js stream 2022-09-23 14:47:00 +07:00
Nguyen Minh 047037f123 stream name 2022-09-23 11:57:19 +07:00
Nguyen Minh f80f89e793 jestream 2022-09-23 11:17:03 +07:00
Nguyen Minh b718162cd4 jestream-push-notification 2022-09-23 10:13:14 +07:00
Nguyen Minh e16a537ed2 Merge branch 'master' into feature/seller-by-id 2022-09-22 23:18:01 +07:00
trunglt251292 cc89feac0d
Merge pull request #31 from Selly-Modules/update-inventory-detail
Update inventory detail
2022-09-22 17:58:29 +07:00
Nguyen Minh 4ac7ec3b0c support chat get seller info 2022-09-22 13:49:11 +07:00
trunglt251292 4319d2644c
Merge pull request #29 from Selly-Modules/selly-food
Selly food
2022-09-22 09:41:47 +07:00
Nguyen Minh 583f2abda5 get seller info support chat 2022-09-21 10:19:17 +07:00
trunglt251292 952c09ccba fix news to bytes 2022-09-20 14:46:29 +07:00
trunglt251292 4452be1474 [Update] Add subjects 2022-09-20 13:49:58 +07:00
trunglt251292 34c61ccfcc [Update] 2022-09-20 10:57:08 +07:00
trunglt251292 1d58e55af7 [Update] Request news 2022-09-20 10:28:35 +07:00
anbuiselly 99eacb44a8
Merge pull request #26 from Selly-Modules/get-seller-by-ids
edit type id
2022-09-19 14:53:25 +07:00
phuanbui 35a811886b edit type id 2022-09-19 14:52:26 +07:00
Minh Nguyen c043a03861
Merge pull request #24 from Selly-Modules/get-seller-by-ids
get list seller by ids
2022-09-19 11:50:41 +07:00
phuanbui 89967955ea get list seller by ids 2022-09-19 11:48:30 +07:00
trunglt251292 92040d0b9f [Update] Payload 2022-09-16 15:36:32 +07:00
trunglt251292 fb8a8bd471 [Update] Add request updateIsClosedSupplier 2022-09-16 14:49:53 +07:00
Nguyen Minh 40533e1805 seller by id 2022-09-15 14:09:54 +07:00
trunglt251292 9f1f2faf9e [Update] Response supplier 2022-09-14 14:39:16 +07:00
trunglt251292 cc48a083f2 [Update] Response warehouse 2022-09-13 11:47:46 +07:00
Sinh Luu 738089755a
Merge pull request #22 from Selly-Modules/develop
Develop
2022-09-13 09:28:18 +07:00
Sinh d605e3f291 Merge branch 'integrate-global-care' into develop 2022-09-12 10:01:58 +07:00
Sinh 26a116a2a4 add json tag 2022-09-12 10:01:47 +07:00
Sinh Luu 3c5fa1207e
Merge pull request #21 from Selly-Modules/integrate-global-care
add order func
2022-09-08 14:48:24 +07:00
Sinh 943fff292d add order func 2022-09-08 14:47:52 +07:00
trunglt251292 06b2398e3d
Merge pull request #20 from Selly-Modules/warehouse-nats
[Update] WarehouseNatsResponse
2022-09-07 17:04:07 +07:00
trunglt251292 6059889551 [Update] WarehouseNatsResponse 2022-09-07 17:03:29 +07:00
Sinh Luu 6cf422cf59
Merge pull request #19 from Selly-Modules/get-location-warehouse
fix get-location-warehouse
2022-09-07 14:18:17 +07:00
phuanbui 218123ccfb fix 2022-09-07 14:10:23 +07:00
phuanbui 9b40f5f9ba fix get-location-warehouse 2022-09-07 14:01:29 +07:00
Sinh Luu 40e71440f1
Merge pull request #18 from Selly-Modules/integrate-global-care
add order func
2022-09-07 12:01:04 +07:00
Sinh 367dc7edd9 add order func 2022-09-07 12:00:40 +07:00
Sinh af6e0843b9 update order OR model 2022-09-06 11:09:52 +07:00
trunglt251292 9413158b8a
Merge pull request #17 from Selly-Modules/warehouse-nats
[Update] Add reponse other
2022-08-31 18:06:27 +07:00
trunglt251292 e387471efe [Update] Add reponse other 2022-08-31 18:06:00 +07:00
trunglt251292 d65c98f646
Merge pull request #16 from Selly-Modules/warehouse-nats
[Update] Action create + update warehouse
2022-08-31 16:51:59 +07:00
trunglt251292 e0a4a508a6 [Update] Action create + update warehouse 2022-08-31 16:51:13 +07:00
nguyenphamquangtue 9295a8e13f
Intergrate model for supplier (#15)
* build nats supplier

* build nats supplier

* build nats supplier

* build nats supplier
2022-08-31 14:48:24 +07:00
Sinh 3bc5f0673d Merge branch 'integrate-global-care' into develop 2022-08-31 10:54:04 +07:00
Sinh 12afbd81fe add order func 2022-08-31 10:53:51 +07:00
Sinh Luu 8cabf2f4a4
Merge pull request #14 from Selly-Modules/integrate-global-care
Integrate global care
2022-08-31 09:47:33 +07:00
Sinh b9a7d9648e Merge branch develop into integrate-global-care 2022-08-31 09:43:46 +07:00
Sinh 01c28e1ee3 add err log 2022-08-30 15:55:20 +07:00
trunglt251292 e89273aa70 Merge branch 'warehouse-nats' of github.com:Selly-Modules/natsio into develop 2022-08-30 15:15:48 +07:00
trunglt251292 8cdfdcb4e6 [Update] Condition dao 2022-08-30 15:15:11 +07:00
trunglt251292 9e645a60c0
Merge pull request #13 from Selly-Modules/warehouse-nats
Warehouse nats
2022-08-30 14:47:51 +07:00
trunglt251292 0156d2d661 fix conflict 2022-08-30 14:47:31 +07:00
trunglt251292 6a7db08c98 [Update] Add 2022-08-30 14:44:48 +07:00
trunglt251292 868c3166ce [Update] Add dao request warehouse 2022-08-30 14:03:49 +07:00
trunglt251292 4bf17d74fa [Update] Add dao request warehouse 2022-08-30 11:03:02 +07:00
anbuiselly 22da1b76c5
Merge pull request #12 from Selly-Modules/get-location-warehouse
edit type field code
2022-08-29 18:09:13 +07:00
phuanbui 21aa37507a edit type field code 2022-08-29 18:07:58 +07:00
anbuiselly 61ae0b325c
Merge pull request #11 from Selly-Modules/get-location-warehouse
add field code
2022-08-29 17:55:49 +07:00
phuanbui 05103803ff add field code 2022-08-29 17:54:50 +07:00
Sinh Luu 16e50a081b
Merge pull request #10 from Selly-Modules/integrate-tnc
Integrate tnc
2022-08-29 15:58:53 +07:00
Sinh 0b30ee0893 Merge develop into integrate-tnc 2022-08-29 15:57:18 +07:00
Sinh 43aa67fa2e update GC 2022-08-29 15:55:17 +07:00
Sinh Luu 50c9c9e65f
Merge pull request #9 from Selly-Modules/get-location-warehouse
fix get supplier
2022-08-29 14:38:31 +07:00
phuanbui 8dcc6504b9 change reponse get supplier 2022-08-29 14:37:45 +07:00
phuanbui 8d62dc710d fix get supplier 2022-08-29 14:25:12 +07:00
Sinh 9acd7e48b4 Merge branch 'develop' of github.com:Selly-Modules/natsio into integrate-global-care 2022-08-27 09:53:07 +07:00
anbuiselly df340fefda
Merge pull request #8 from Selly-Modules/get-location-warehouse
edit types param supplier
2022-08-26 23:37:51 +07:00
phuanbui cfab692331 edit types param supplier 2022-08-26 23:37:01 +07:00
Sinh Luu 9275ede421
Merge pull request #7 from Selly-Modules/get-location-warehouse
get supplier info
2022-08-26 23:23:29 +07:00
phuanbui 3c4e331c6f get supplier info 2022-08-26 23:13:18 +07:00
Sinh Luu 3da067b159
Merge pull request #6 from Selly-Modules/get-location-warehouse
nats-location-supplier
2022-08-26 17:37:24 +07:00
phuanbui d79739aa0f refactor-code 2022-08-26 17:36:02 +07:00
phuanbui cab7525f50 Merge branch 'master' of github.com:Selly-Modules/natsio into get-location-warehouse 2022-08-26 17:22:16 +07:00
phuanbui 3458f885ec nats-location-supplier 2022-08-26 17:15:49 +07:00
Sinh 35737a34ab Merge branch 'master' of github.com:Selly-Modules/natsio into integrate-global-care 2022-08-26 16:40:13 +07:00
namhq1989 6593315859 refactor subject name 2022-08-26 15:56:36 +07:00
Sinh 5ca473ffc1 define model 2022-08-26 10:28:49 +07:00
Sinh Luu c0b13e3539
Merge pull request #5 from Selly-Modules/define-communication-func
define communication, warehouse func
2022-08-24 09:42:24 +07:00
trunglt251292 095f3779db Merge branch 'master' of github.com:Selly-Modules/natsio into add-timeout 2022-04-19 09:53:45 +07:00
trunglt251292 2a9897e137 [Update] Config 2022-03-30 19:17:14 +07:00
trunglt251292 1e3bfd7392 [Update] 2022-03-30 17:55:28 +07:00
38 changed files with 1304 additions and 39 deletions

View File

@ -18,7 +18,7 @@ func GetCommunication() Communication {
// RequestHttp ...
func (c Communication) RequestHttp(p model.CommunicationRequestHttp) (r *model.CommunicationHttpResponse, err error) {
msg, err := natsio.GetServer().Request(subject.CommunicationRequestHTTP, toBytes(p))
msg, err := natsio.GetServer().Request(subject.Communication.RequestHTTP, toBytes(p))
if err != nil {
return nil, err
}

106
client/location.go Normal file
View File

@ -0,0 +1,106 @@
package client
import (
"encoding/json"
"errors"
"github.com/Selly-Modules/natsio"
"github.com/Selly-Modules/natsio/model"
"github.com/Selly-Modules/natsio/subject"
)
// Location ...
type Location struct{}
// GetLocation ...
func GetLocation() Location {
return Location{}
}
// GetLocationByCode ...
func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*model.ResponseLocationAddress, error) {
msg, err := natsio.GetServer().Request(subject.Location.GetLocationByCode, toBytes(payload))
if err != nil {
return nil, err
}
var r struct {
Data *model.ResponseLocationAddress `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
}
// GetProvincesByCodes ... ...
func (l Location) GetProvincesByCodes(p model.ProvinceRequestPayload) (*model.LocationProvinceResponse, error) {
msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCodes, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.LocationProvinceResponse `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
}
// GetDistrictsByCodes ...
func (l Location) GetDistrictsByCodes(p model.DistrictRequestPayload) (*model.LocationDistrictResponse, error) {
msg, err := natsio.GetServer().Request(subject.Location.GetDistrictsByCodes, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.LocationDistrictResponse `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
}
// GetWardsByCodes ...
func (l Location) GetWardsByCodes(p model.WardRequestPayload) (*model.LocationWardResponse, error) {
msg, err := natsio.GetServer().Request(subject.Location.GetWardsByCodes, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.LocationWardResponse `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
}

36
client/news.go Normal file
View File

@ -0,0 +1,36 @@
package client
import (
"encoding/json"
"errors"
"github.com/Selly-Modules/natsio"
"github.com/Selly-Modules/natsio/model"
"github.com/Selly-Modules/natsio/subject"
)
// News ...
type News struct{}
// GetNews ...
func GetNews() News {
return News{}
}
// GetProductNoticesByInventory ...
func (n News) GetProductNoticesByInventory(p model.GetProductNoticesByInventoryRequest) (*model.GetProductNoticesByInventoryResponse, error) {
msg, err := natsio.GetServer().Request(subject.News.GetProductNoticesByInventory, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.GetProductNoticesByInventoryResponse `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
}

View File

@ -19,7 +19,7 @@ func GetOrder() Order {
// UpdateORStatus ...
func (o Order) UpdateORStatus(p model.OrderUpdateORStatus) error {
msg, err := natsio.GetServer().Request(subject.OrderUpdateORStatus, toBytes(p))
msg, err := natsio.GetServer().Request(subject.Order.UpdateORStatus, toBytes(p))
if err != nil {
return err
}
@ -37,7 +37,55 @@ func (o Order) UpdateORStatus(p model.OrderUpdateORStatus) error {
// CancelDelivery ...
func (o Order) CancelDelivery(p model.OrderCancelDelivery) error {
msg, err := natsio.GetServer().Request(subject.OrderCancelDelivery, toBytes(p))
msg, err := natsio.GetServer().Request(subject.Order.CancelDelivery, toBytes(p))
if err != nil {
return err
}
var r model.CommonResponseData
if err = json.Unmarshal(msg.Data, &r); err != nil {
return err
}
if r.Error != "" {
return errors.New(r.Error)
}
return nil
}
// ChangeDeliveryStatus ...
func (o Order) ChangeDeliveryStatus(p model.OrderChangeDeliveryStatus) error {
msg, err := natsio.GetServer().Request(subject.Order.ChangeDeliveryStatus, toBytes(p))
if err != nil {
return err
}
var r model.CommonResponseData
if err = json.Unmarshal(msg.Data, &r); err != nil {
return err
}
if r.Error != "" {
return errors.New(r.Error)
}
return nil
}
// UpdateLogisticInfoFailed ...
func (o Order) UpdateLogisticInfoFailed(p model.OrderUpdateLogisticInfoFailed) error {
msg, err := natsio.GetServer().Request(subject.Order.UpdateLogisticInfoFailed, toBytes(p))
if err != nil {
return err
}
var r model.CommonResponseData
if err = json.Unmarshal(msg.Data, &r); err != nil {
return err
}
if r.Error != "" {
return errors.New(r.Error)
}
return nil
}
// ORNotUpdateStatus ...
func (o Order) ORNotUpdateStatus(p model.OrderORsNotUpdateStatus) error {
msg, err := natsio.GetServer().Request(subject.Order.ORNotUpdateStatus, toBytes(p))
if err != nil {
return err
}

88
client/seller.go Normal file
View File

@ -0,0 +1,88 @@
package client
import (
"encoding/json"
"errors"
"github.com/Selly-Modules/natsio"
"github.com/Selly-Modules/natsio/model"
"github.com/Selly-Modules/natsio/subject"
)
// Seller ...
type Seller struct{}
// GetSeller ...
func GetSeller() Seller {
return Seller{}
}
// GetSellerInfoByID ...
func (s Seller) GetSellerInfoByID(p model.GetSellerByIDRequest) (*model.ResponseSellerInfo, error) {
msg, err := natsio.GetServer().Request(subject.Seller.GetSellerInfoByID, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.ResponseSellerInfo `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
}
// GetListSellerInfoByIDs ...
func (s Seller) GetListSellerInfoByIDs(p model.GetListSellerByIDsRequest) (*model.ResponseListSellerInfo, error) {
msg, err := natsio.GetServer().Request(subject.Seller.GetListSellerInfoByIDs, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.ResponseListSellerInfo `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
}
// GetListSellerInfoSupportChatByIDs ...
func (s Seller) GetListSellerInfoSupportChatByIDs(p model.GetListSellerSupportChatByIDsRequest) (*model.ResponseListSellerInfoSupportChat, error) {
msg, err := natsio.GetServer().Request(subject.SupportChat.GetListSellerInfoSupportChatByIDs, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.ResponseListSellerInfoSupportChat `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
}

81
client/supplier.go Normal file
View File

@ -0,0 +1,81 @@
package client
import (
"encoding/json"
"errors"
"github.com/Selly-Modules/natsio"
"github.com/Selly-Modules/natsio/model"
"github.com/Selly-Modules/natsio/subject"
)
// Supplier ...
type Supplier struct{}
// GetSupplier ...
func GetSupplier() Supplier {
return Supplier{}
}
func (s Supplier) GetListSupplierInfo(p model.GetSupplierRequest) ([]*model.ResponseSupplierInfo, error) {
msg, err := natsio.GetServer().Request(subject.Supplier.GetListSupplierInfo, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data []*model.ResponseSupplierInfo `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
}
func (s Supplier) GetSupplierContractBySupplierID(p model.GetSupplierContractRequest) (*model.ResponseSupplierContract, error) {
msg, err := natsio.GetServer().Request(subject.Supplier.GetSupplierContractBySupplierID, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.ResponseSupplierContract `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
}
func (s Supplier) FindAll(supplierID model.SupplierRequestPayload) (*model.SupplierAll, error) {
msg, err := natsio.GetServer().Request(subject.Supplier.FindAll, toBytes(supplierID))
if err != nil {
return nil, err
}
var r struct {
Data *model.SupplierAll `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
}

View File

@ -2,6 +2,7 @@ package client
import (
"encoding/json"
"go.mongodb.org/mongo-driver/bson"
"log"
)
@ -12,3 +13,9 @@ func toBytes(data interface{}) []byte {
}
return b
}
// bsonToBytes ...
func bsonToBytes(data interface{}) []byte {
b, _ := bson.Marshal(data)
return b
}

View File

@ -17,9 +17,63 @@ func GetWarehouse() Warehouse {
return Warehouse{}
}
// UpdateIsClosedSupplier ...
func (w Warehouse) UpdateIsClosedSupplier(p model.UpdateSupplierIsClosedRequest) error {
msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateIsClosedSupplier, 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
}
// AfterCreateWarehouse ...
func (w Warehouse) AfterCreateWarehouse(p model.WarehouseNatsResponse) error {
msg, err := natsio.GetServer().Request(subject.Warehouse.AfterCreateWarehouse, 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
}
// AfterUpdateWarehouse ...
func (w Warehouse) AfterUpdateWarehouse(p model.WarehouseNatsResponse) error {
msg, err := natsio.GetServer().Request(subject.Warehouse.AfterUpdateWarehouse, 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
}
// CreateOutboundRequest ...
func (w Warehouse) CreateOutboundRequest(p model.OutboundRequestPayload) (*model.OutboundRequestResponse, error) {
msg, err := natsio.GetServer().Request(subject.WarehouseCreateOutboundRequest, toBytes(p))
msg, err := natsio.GetServer().Request(subject.Warehouse.CreateOutboundRequest, toBytes(p))
if err != nil {
return nil, err
}
@ -38,7 +92,7 @@ func (w Warehouse) CreateOutboundRequest(p model.OutboundRequestPayload) (*model
// UpdateOutboundRequestLogisticInfo ...
func (w Warehouse) UpdateOutboundRequestLogisticInfo(p model.UpdateOutboundRequestLogisticInfoPayload) error {
msg, err := natsio.GetServer().Request(subject.WarehouseUpdateOutboundRequestLogistic, toBytes(p))
msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateOutboundRequestLogistic, toBytes(p))
if err != nil {
return err
}
@ -56,7 +110,7 @@ func (w Warehouse) UpdateOutboundRequestLogisticInfo(p model.UpdateOutboundReque
// CancelOutboundRequest ...
func (w Warehouse) CancelOutboundRequest(p model.CancelOutboundRequest) error {
msg, err := natsio.GetServer().Request(subject.WarehouseCancelOutboundRequest, toBytes(p))
msg, err := natsio.GetServer().Request(subject.Warehouse.CancelOutboundRequest, toBytes(p))
if err != nil {
return err
}
@ -74,7 +128,7 @@ func (w Warehouse) CancelOutboundRequest(p model.CancelOutboundRequest) error {
// GetConfigByWarehouseID ...
func (w Warehouse) GetConfigByWarehouseID(warehouseID string) (*model.WarehouseConfiguration, error) {
msg, err := natsio.GetServer().Request(subject.WarehouseGetConfiguration, toBytes(warehouseID))
msg, err := natsio.GetServer().Request(subject.Warehouse.GetConfiguration, toBytes(warehouseID))
if err != nil {
return nil, err
}
@ -90,3 +144,22 @@ func (w Warehouse) GetConfigByWarehouseID(warehouseID string) (*model.WarehouseC
}
return r.Data, nil
}
// GetWarehouses ...
func (w Warehouse) GetWarehouses(p model.GetWarehousesRequest) (*model.GetWarehousesResponse, error) {
msg, err := natsio.GetServer().Request(subject.Warehouse.GetWarehouses, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.GetWarehousesResponse `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
}

85
client/warehouse_dao.go Normal file
View File

@ -0,0 +1,85 @@
package client
import (
"encoding/json"
"errors"
"github.com/Selly-Modules/natsio"
"github.com/Selly-Modules/natsio/model"
"github.com/Selly-Modules/natsio/subject"
)
// DistinctWithField ...
func (w Warehouse) DistinctWithField(p model.DistinctWithField) ([]interface{}, error) {
msg, err := natsio.GetServer().Request(subject.Warehouse.Distinct, bsonToBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data []interface{} `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
}
// FindOneByCondition ...
func (w Warehouse) FindOneByCondition(p model.FindOneCondition) (*model.WarehouseNatsResponse, error) {
msg, err := natsio.GetServer().Request(subject.Warehouse.FindOne, bsonToBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.WarehouseNatsResponse `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
}
// CountByCondition ...
func (w Warehouse) CountByCondition(p model.FindWithCondition) (int64, error) {
msg, err := natsio.GetServer().Request(subject.Warehouse.Count, bsonToBytes(p))
if err != nil {
return 0, err
}
var r struct {
Data int64 `json:"data"`
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return 0, err
}
if r.Error != "" {
return 0, errors.New(r.Error)
}
return r.Data, nil
}
// FindByCondition ...
func (w Warehouse) FindByCondition(p model.FindWithCondition) ([]*model.WarehouseNatsResponse, error) {
msg, err := natsio.GetServer().Request(subject.Warehouse.FindByCondition, bsonToBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data []*model.WarehouseNatsResponse `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
}

2
go.mod
View File

@ -4,9 +4,9 @@ go 1.16
require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible
github.com/nats-io/nats-server/v2 v2.6.1 // indirect
github.com/nats-io/nats.go v1.13.0
github.com/thoas/go-funk v0.9.1
go.mongodb.org/mongo-driver v1.10.1
google.golang.org/protobuf v1.27.1 // indirect
)

37
go.sum
View File

@ -1,5 +1,6 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
@ -9,17 +10,25 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/klauspost/compress v1.13.4 h1:0zhec2I8zGnjWcKyLl6i3gPqKANCCn5e9xmviEEeX6s=
github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
github.com/minio/highwayhash v1.0.1 h1:dZ6IIu8Z14VlC0VpfKofAhCy74wu/Qb5gcn52yWoz/0=
github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/nats-io/jwt v1.2.2 h1:w3GMTO969dFg+UOKTmmyuu7IGdusK+7Ytlt//OYH/uU=
github.com/nats-io/jwt v1.2.2/go.mod h1:/xX356yQA6LuXI9xWW7mZNpxgF2mBmGecH+Fj34sP5Q=
github.com/nats-io/jwt/v2 v2.0.3 h1:i/O6cmIsjpcQyWDYNcq2JyZ3/VTF8SJ4JWluI5OhpvI=
@ -34,29 +43,44 @@ github.com/nats-io/nkeys v0.3.0 h1:cgM5tL53EvYRU+2YLXIK0G2mJtK12Ft9oeooSZMA2G8=
github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4=
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M=
github.com/thoas/go-funk v0.9.1/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
go.mongodb.org/mongo-driver v1.10.1 h1:NujsPveKwHaWuKUer/ceo9DzEe7HIj1SlJ6uvXZG0S4=
go.mongodb.org/mongo-driver v1.10.1/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 h1:NusfzzA6yGQ+ua51ck7E3omNUX/JuqbFSaRGqU8CcLI=
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@ -72,5 +96,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

4
jestream_name.go Normal file
View File

@ -0,0 +1,4 @@
package natsio
// StreamNameSelly ...
const StreamNameSelly = "selly"

12
js/consumer/selly.go Normal file
View File

@ -0,0 +1,12 @@
package jsconsumer
// Selly ...
var Selly = struct {
PushNotification string
UpdateSellerAffiliateStatistic string
CheckAnDInsertCashflowBySeller string
}{
PushNotification: "PULL_PUSH_NOTIFICATION",
UpdateSellerAffiliateStatistic: "PULL_UPDATE_SELLER_AFFILIATE_STATISTIC",
CheckAnDInsertCashflowBySeller: "PULL_CHECK_AND_INSERT_CASHFLOW_BY_SELLER",
}

60
js/model/selly.go Normal file
View File

@ -0,0 +1,60 @@
package jsmodel
// PushNotification ...
type PushNotification struct {
User string `json:"user"`
Type string `json:"type"`
TargetID string `json:"targetId"`
IsFromAdmin bool `json:"isFromAdmin"`
Category string `json:"category"`
Options NotificationOptions `json:"options"`
}
// NotificationOptions ...
type NotificationOptions struct {
Title string `json:"title"`
Content string `json:"content"`
}
// PayloadUpdateSellerAffiliateStatistic ...
type PayloadUpdateSellerAffiliateStatistic struct {
SellerID string `json:"sellerId"`
Statistic SellerAffiliateStatistic `json:"statistic"`
}
// SellerAffiliateStatistic ...
type SellerAffiliateStatistic struct {
TransactionTotal int `json:"transactionTotal"`
TransactionCashback int `json:"transactionCashback"`
TransactionPending int `json:"transactionPending"`
TransactionApproved int `json:"transactionApproved"`
TransactionRejected int `json:"transactionRejected"`
CommissionTransactionTotal float64 `json:"commissionTransactionTotal"`
CommissionTransactionCashback float64 `json:"commissionTransactionCashback"`
CommissionTransactionApproved float64 `json:"commissionTransactionApproved"`
CommissionTransactionPending float64 `json:"commissionTransactionPending"`
CommissionTransactionRejected float64 `json:"commissionTransactionRejected"`
}
// PayloadCashflowsBySeller ...
type PayloadCashflowsBySeller struct {
SellerID string `json:"sellerId"`
List []CashflowSeller `json:"list"`
}
// CashflowSeller ...
type CashflowSeller struct {
Value float64 `json:"value"`
Action string `json:"action"`
Category string `json:"category"`
TargetID string `json:"targetId"`
TargetType string `json:"targetType"`
Options *CashFlowOptions `json:"options"`
}
// CashFlowOptions ...
type CashFlowOptions struct {
AffiliateTransactionCode string `json:"affiliateTransactionCode,omitempty"`
AffiliateCampaignID string `json:"affiliateCampaignId,omitempty"`
AffiliateCampaignName string `json:"affiliateCampaignName,omitempty"`
}

10
js/subject/config.go Normal file
View File

@ -0,0 +1,10 @@
package jssubject
var root = "js"
// prefixes ...
var prefixes = struct {
Selly string
}{
Selly: "selly",
}

21
js/subject/selly.go Normal file
View File

@ -0,0 +1,21 @@
package jssubject
import (
"fmt"
)
// getSellyValue ...
func getSellyValue(val string) string {
return fmt.Sprintf("%s.%s.%s", root, prefixes.Selly, val)
}
// Selly ...
var Selly = struct {
PushNotification string
UpdateSellerAffiliateStatistic string
CheckAnDInsertCashflowBySeller string
}{
PushNotification: getSellyValue("push_notifications"),
UpdateSellerAffiliateStatistic: getSellyValue("update_seller_affiliate_statistic"),
CheckAnDInsertCashflowBySeller: getSellyValue("check_and_insert_cashflow_statistic"),
}

22
model/common_request.go Normal file
View File

@ -0,0 +1,22 @@
package model
import "go.mongodb.org/mongo-driver/mongo/options"
type FindWithCondition struct {
Conditions interface{} `json:"conditions"`
Opts []*options.FindOptions `json:"opts"`
}
type FindOneCondition struct {
Conditions interface{} `json:"conditions"`
}
type DistinctWithField struct {
Conditions interface{} `json:"conditions"`
Filed string `json:"filed"`
}
type ActionBy struct {
ID string `json:"id"`
Name string `json:"name"`
}

23
model/location_request.go Normal file
View File

@ -0,0 +1,23 @@
package model
// LocationRequestPayload ...
type LocationRequestPayload struct {
Province int `json:"province"`
District int `json:"district"`
Ward int `json:"ward"`
}
// ProvinceRequestPayload ...
type ProvinceRequestPayload struct {
Codes []int `json:"codes"`
}
// DistrictRequestPayload ...
type DistrictRequestPayload struct {
Codes []int `json:"codes"`
}
// WardRequestPayload ...
type WardRequestPayload struct {
Codes []int `json:"codes"`
}

View File

@ -0,0 +1,43 @@
package model
type ResponseLocationAddress struct {
Province LocationProvince `json:"province"`
District LocationDistrict `json:"district"`
Ward LocationWard `json:"ward"`
}
// LocationProvince ...
type LocationProvince struct {
ID string `json:"id"`
Name string `json:"name"`
Code int `json:"code"`
}
// LocationDistrict ...
type LocationDistrict struct {
ID string `json:"id"`
Name string `json:"name"`
Code int `json:"code"`
}
// LocationWard ...
type LocationWard struct {
ID string `json:"id"`
Name string `json:"name"`
Code int `json:"code"`
}
// LocationProvinceResponse ...
type LocationProvinceResponse struct {
Provinces []LocationProvince `json:"provinces"`
}
// LocationDistrictResponse ...
type LocationDistrictResponse struct {
Districts []LocationDistrict `json:"districts"`
}
// LocationWardResponse ...
type LocationWardResponse struct {
Wards []LocationWard `json:"wards"`
}

6
model/news_request.go Normal file
View File

@ -0,0 +1,6 @@
package model
// GetProductNoticesByInventoryRequest ....
type GetProductNoticesByInventoryRequest struct {
InventoryIds []string `json:"inventoryIds"`
}

38
model/news_response.go Normal file
View File

@ -0,0 +1,38 @@
package model
// GetProductNoticesByInventoryResponse ....
type GetProductNoticesByInventoryResponse struct {
Notices []NewsAppResponse `json:"notices"`
}
// NewsAppResponse ...
type NewsAppResponse struct {
ID string `json:"_id"`
Title string `json:"title,omitempty"`
Target *TargetNewDoc `json:"target,omitempty"`
ActionType *ActionType `json:"action"`
ShortDesc string `json:"shortDesc,omitempty"`
Type string `json:"type"`
ShortTitle string `json:"shortTitle,omitempty"`
Color string `json:"color"`
Options *NewsOptions `json:"options,omitempty"`
DisplayStyle string `json:"displayStyle"`
}
// NewsOptions ...
type NewsOptions struct {
Category string `json:"category"`
}
// TargetNewDoc ...
type TargetNewDoc struct {
Type string `json:"type,omitempty"`
Value string `json:"value,omitempty"`
}
// ActionType ...
type ActionType struct {
Type string `json:"type"`
Value string `json:"value"`
Text string `json:"text,omitempty"`
}

View File

@ -2,13 +2,39 @@ package model
// OrderUpdateORStatus ...
type OrderUpdateORStatus struct {
OrderCode string `json:"orderCode"`
ORCode string `json:"orCode"`
Status string `json:"status"`
Reason string `json:"reason"`
OrderCode string `json:"orderCode"`
ORCode string `json:"orCode"`
Status string `json:"status"`
DeliveryStatus string `json:"deliveryStatus"`
Reason string `json:"reason"`
Data OrderORData `json:"data"`
}
// OrderCancelDelivery ...
type OrderCancelDelivery struct {
OrderID string `json:"orderId"`
}
// OrderChangeDeliveryStatus ...
type OrderChangeDeliveryStatus struct {
OrderID string `json:"orderId"`
DeliveryStatus string `json:"deliveryStatus"`
ActionBy ActionBy `json:"actionBy"`
}
// OrderORData ...
type OrderORData struct {
Link string `json:"link"`
}
// OrderUpdateLogisticInfoFailed ...
type OrderUpdateLogisticInfoFailed struct {
OrderID string `json:"orderId"`
ORCode string `json:"orCode"`
Reason string `json:"reason"`
}
// OrderORsNotUpdateStatus ...
type OrderORsNotUpdateStatus struct {
ORCodes []string `json:"orCodes"`
}

18
model/seller_request.go Normal file
View File

@ -0,0 +1,18 @@
package model
import "go.mongodb.org/mongo-driver/bson/primitive"
// GetSellerByIDRequest ...
type GetSellerByIDRequest struct {
SellerID primitive.ObjectID `json:"sellerId"`
}
// GetListSellerByIDsRequest ...
type GetListSellerByIDsRequest struct {
SellerIDs []primitive.ObjectID `json:"sellerIds"`
}
// GetListSellerSupportChatByIDsRequest ...
type GetListSellerSupportChatByIDsRequest struct {
SellerIDs []primitive.ObjectID `json:"sellerIds"`
}

81
model/seller_response.go Normal file
View File

@ -0,0 +1,81 @@
package model
import "time"
// ResponseSellerInfo ...
type ResponseSellerInfo struct {
ID string `json:"_id"`
Name string `json:"name"`
Code string `json:"code"`
}
// ResponseListSellerInfo ...
type ResponseListSellerInfo struct {
Sellers []ResponseSellerInfo `json:"sellers"`
}
// ResponseListSellerInfoSupportChat ...
type ResponseListSellerInfoSupportChat struct {
Sellers []ResponseSellerInfoSupportChat `json:"sellers"`
}
// ResponseSellerInfoSupportChat ...
type ResponseSellerInfoSupportChat struct {
ID string `json:"_id"`
Name string `json:"name"`
Code string `json:"code"`
Membership SellerMembershipInfo `json:"membership"`
Info SellerContactInfo `json:"info"`
Team *TeamInfo `json:"team,omitempty"`
Statistic SellerStatistic `json:"statistic"`
TrackingTime *SellerTrackingTime `json:"trackingTime"`
Invitee *InviteeInfo `json:"invitee"`
CreatedAt time.Time `json:"createdAt"`
}
// SellerTrackingTime ...
type SellerTrackingTime struct {
FirstOrderDeliveredAt time.Time `json:"firstOrderDeliveredAt,omitempty"`
ThirdOrderDeliveredAt time.Time `json:"thirdOrderDeliveredAt,omitempty"`
}
// SellerStatistic ...
type SellerStatistic struct {
ThisMonthSale float64 `bson:"thisMonthSale" json:"thisMonthSale"`
LastMonthSale float64 `bson:"lastMonthSale" json:"lastMonthSale"`
Sale float64 `bson:"sale" json:"sale"`
TransactionTotal int `json:"transactionTotal"`
TransactionPaymentProcessing int `json:"transactionPaymentProcessing"`
TransactionWaitingApprove int `json:"transactionWaitingApprove"`
TransactionPending int `json:"transactionPending"`
TransactionSuccess int `json:"transactionSuccess"`
TransactionRejected int `json:"transactionRejected"`
TransactionDelivering int `json:"transactionDelivering"`
TransactionDelivered int `json:"transactionDelivered"`
}
// TeamInfo ...
type TeamInfo struct {
ID string `json:"_id"`
Name string `json:"name"`
Role string `json:"role"`
}
// InviteeInfo ...
type InviteeInfo struct {
ID string `json:"_id"`
Name string `json:"name"`
}
// SellerContactInfo ...
type SellerContactInfo struct {
City int `json:"cityCode"`
CityName string `json:"cityName"`
Gender string `json:"gender"`
}
// SellerMembershipInfo ...
type SellerMembershipInfo struct {
Level int `json:"level"`
Name string `json:"name"`
}

24
model/supplier_request.go Normal file
View File

@ -0,0 +1,24 @@
package model
import (
"go.mongodb.org/mongo-driver/bson/primitive"
)
// GetSupplierRequest ...
type GetSupplierRequest struct {
ListID []primitive.ObjectID `json:"listID"`
}
type GetSupplierContractRequest struct {
SupplierID primitive.ObjectID `json:"supplierID"`
}
// SupplierRequestPayload ...
type SupplierRequestPayload struct {
Limit int
Page int
Keyword string
Status string
PIC string
ContractStatus string
}

View File

@ -0,0 +1,31 @@
package model
// ResponseSupplierInfo ...
type ResponseSupplierInfo struct {
ID string `json:"id"`
Name string `json:"name"`
BusinessType string `json:"businessType"`
}
// ResponseSupplierContract ...
type ResponseSupplierContract struct {
ID string `json:"id"`
Supplier string `json:"supplier"`
Name string `json:"name"`
Status string `json:"status"`
}
// SupplierBrief ...
type SupplierBrief struct {
ID string `json:"_id"`
Name string `json:"name"`
Status string `json:"status"`
BusinessType string `json:"businessType"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type SupplierAll struct {
Suppliers []SupplierBrief `json:"suppliers"`
Total int64 `json:"total"`
}

View File

@ -12,6 +12,26 @@ type OutboundRequestPayload struct {
TPLCode string `json:"tplCode"`
Customer CustomerInfo `json:"customer"`
Items []OutboundRequestItem `json:"items"`
Insurance *InsuranceOpts `json:"insurance"`
}
// InsuranceOpts ...
type InsuranceOpts struct {
InsuranceType string `json:"insuranceType"`
VehicleTypeID string `json:"vehicleTypeId"`
VehicleTypeName string `json:"vehicleTypeName"`
InsuranceTypeID string `json:"insuranceTypeId"`
YearsOfInsurance int `json:"yearsOfInsurance"`
License string `json:"license"`
Chassis string `json:"chassis"`
Engine string `json:"engine"`
BeginDate string `json:"beginDate"`
// For car insurance
NumberOfSeatsCarOccupantAccidentInsurance int `json:"numberOfSeatsCarOccupantAccidentInsurance"`
NumberOfSeats int `json:"numberOfSeats"`
NumberOfSeatsOrTonnageId string `json:"numberOfSeatsOrTonnageId"`
NumberOfSeatsOrTonnageName string `json:"numberOfSeatsOrTonnageName"`
}
// OutboundRequestItem ...
@ -25,6 +45,7 @@ type OutboundRequestItem struct {
type CustomerInfo struct {
Name string `json:"name"`
PhoneNumber string `json:"phoneNumber"`
Email string `json:"email"`
Address AddressDetail `json:"address"`
}
@ -49,3 +70,31 @@ type CancelOutboundRequest struct {
ORCode string `json:"orCode"`
Note string `json:"note"`
}
// SyncORStatusRequest ...
type SyncORStatusRequest struct {
ORCode string `json:"orCode"`
OrderCode string `json:"orderCode"`
}
// UpdateSupplierIsClosedRequest ...
type UpdateSupplierIsClosedRequest struct {
Suppliers []SupplierIsClosed `json:"suppliers"`
}
// SupplierIsClosed ...
type SupplierIsClosed struct {
Supplier string `json:"supplier"`
IsClosed bool `json:"isClosed"`
}
// GetWarehousesRequest ...
type GetWarehousesRequest struct {
Keyword string `json:"keyword"`
Status string `json:"status"`
Supplier string `json:"supplier"`
BusinessType string `json:"businessType"`
Page int64 `json:"page"`
Limit int64 `json:"limit"`
}

View File

@ -1,5 +1,7 @@
package model
import "time"
// OutboundRequestResponse ...
type OutboundRequestResponse struct {
// System code
@ -22,6 +24,26 @@ type WarehouseConfiguration struct {
Order WarehouseOrder `json:"order"`
Partner WarehousePartner `json:"partner"`
Delivery WarehouseDelivery `json:"delivery"`
Other WarehouseOther `json:"other"`
Food WarehouseFood `json:"food"`
}
// WarehouseFood ...
type WarehouseFood struct {
ForceClosed bool `json:"forceClosed"`
IsClosed bool `json:"isClosed"`
TimeRange []TimeRange `json:"timeRange"`
}
// TimeRange ...
type TimeRange struct {
From int64 `json:"from"`
To int64 `json:"to"`
}
// WarehouseOther ...
type WarehouseOther struct {
DoesSupportSellyExpress bool `json:"doesSupportSellyExpress"`
}
// WarehouseSupplier ...
@ -59,3 +81,84 @@ type WarehousePartner struct {
Enabled bool `json:"enabled"`
Authentication string `json:"authentication"`
}
// SyncORStatusResponse ...
type SyncORStatusResponse struct {
ORCode string `json:"orCode"`
OrderCode string `json:"orderCode"`
Status string `json:"status"`
DeliveryStatus string `json:"deliveryStatus"`
}
// ResponseWarehouseContact ...
type ResponseWarehouseContact struct {
Name string `json:"name"`
Phone string `json:"phone"`
Address string `json:"address"`
Email string `json:"email"`
}
// ResponseWarehouseLocation ...
type ResponseWarehouseLocation struct {
Province CommonLocation `json:"province"`
District CommonLocation `json:"district"`
Ward CommonLocation `json:"ward"`
Address string `json:"address"`
LocationCoordinates ResponseLatLng `json:"locationCoordinates"`
}
type CommonLocation struct {
ID string `json:"id"`
Name string `json:"name"`
Code int `json:"code"`
}
// ResponseLatLng ...
type ResponseLatLng struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
}
// WarehouseNatsResponse ...
type WarehouseNatsResponse struct {
ID string `json:"_id"`
Staff string `json:"staff"`
BusinessType string `json:"businessType"`
Name string `json:"name"`
SearchString string `json:"searchString"`
Slug string `json:"slug"`
Status string `json:"status"`
Supplier string `json:"supplier"`
Contact ResponseWarehouseContact `json:"contact"`
Location ResponseWarehouseLocation `json:"location"`
Configurations WarehouseConfiguration `json:"configurations"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// WarehouseInfo ...
type WarehouseInfo struct {
ID string `json:"_id"`
Name string `json:"name"`
BusinessType string `json:"businessType"`
Status string `json:"status"`
Slug string `json:"slug"`
Supplier WarehouseSupplierInfo `json:"supplier"`
Location ResponseWarehouseLocation `json:"location"`
Contact ResponseWarehouseContact `json:"contact"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
// WarehouseSupplierInfo ...
type WarehouseSupplierInfo struct {
ID string `json:"_id"`
Name string `json:"name"`
}
// GetWarehousesResponse ...
type GetWarehousesResponse struct {
Total int64 `json:"total"`
Limit int64 `json:"limit"`
List []WarehouseInfo `json:"list"`
}

View File

@ -3,7 +3,6 @@ package natsio
import (
"errors"
"fmt"
"github.com/logrusorgru/aurora"
"github.com/nats-io/nats.go"
)
@ -49,7 +48,7 @@ func Connect(cfg Config) error {
return errors.New(msg)
}
fmt.Println(aurora.Green("*** CONNECTED TO NATS: " + cfg.URL))
fmt.Printf("⚡️[natsio]: connected to %s \n", cfg.URL)
// Set client
natsServer.instance = nc

View File

@ -18,7 +18,11 @@ func (sv Server) Request(subject string, payload []byte) (*nats.Msg, error) {
if sv.Config.RequestTimeout > 0 {
timeout = sv.Config.RequestTimeout
}
return sv.instance.Request(subject, payload, timeout)
msg, err := sv.instance.Request(subject, payload, timeout)
if errors.Is(err, nats.ErrNoResponders) {
log.Printf("[NATS SERVER]: request - no responders for subject: %s", subject)
}
return msg, err
}
// Reply ...

View File

@ -1,10 +1,15 @@
package subject
const communicationPrefix = "communication_"
import "fmt"
const (
CommunicationRequestHTTP = communicationPrefix + "request_http"
CommunicationResponseHTTP = communicationPrefix + "response_http"
CommunicationWebhookTNC = communicationPrefix + "webhook_tnc"
CommunicationWebhookGlobalCare = communicationPrefix + "webhook_global_care"
)
func getCommunicationValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.Communication, val)
}
var Communication = struct {
RequestHTTP string
ResponseHTTP string
}{
RequestHTTP: getCommunicationValue("request_http"),
ResponseHTTP: getCommunicationValue("response_http"),
}

19
subject/config.go Normal file
View File

@ -0,0 +1,19 @@
package subject
var prefixes = struct {
Communication string
Order string
News string
Warehouse string
Location string
Supplier string
Seller string
}{
Communication: "communication",
Order: "order",
News: "news",
Warehouse: "warehouse",
Location: "location",
Supplier: "supplier",
Seller: "seller",
}

19
subject/location.go Normal file
View File

@ -0,0 +1,19 @@
package subject
import "fmt"
func getLocationValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.Location, val)
}
var Location = struct {
GetLocationByCode string
GetProvincesByCodes string
GetDistrictsByCodes string
GetWardsByCodes string
}{
GetLocationByCode: getLocationValue("get_location_warehouse"),
GetProvincesByCodes: getLocationValue("get_provinces_by_codes"),
GetDistrictsByCodes: getLocationValue("get_districts_by_codes"),
GetWardsByCodes: getLocationValue("get_wards_by_codes"),
}

13
subject/news.go Normal file
View File

@ -0,0 +1,13 @@
package subject
import "fmt"
func getNewsValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.News, val)
}
var News = struct {
GetProductNoticesByInventory string
}{
GetProductNoticesByInventory: getNewsValue("get_product_notices_by_inventory"),
}

View File

@ -1,8 +1,21 @@
package subject
const orderPrefix = "order_"
import "fmt"
const (
OrderUpdateORStatus = orderPrefix + "update_outbound_request_status"
OrderCancelDelivery = orderPrefix + "cancel_delivery"
)
func getOrderValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.Order, val)
}
var Order = struct {
UpdateORStatus string
CancelDelivery string
ChangeDeliveryStatus string
UpdateLogisticInfoFailed string
ORNotUpdateStatus string
}{
UpdateORStatus: getOrderValue("update_outbound_request_status"),
CancelDelivery: getOrderValue("cancel_delivery"),
ChangeDeliveryStatus: getOrderValue("change_delivery_status"),
UpdateLogisticInfoFailed: getOrderValue("update_logistic_info_failed"),
ORNotUpdateStatus: getOrderValue("outbound_request_not_update_status"),
}

23
subject/seller.go Normal file
View File

@ -0,0 +1,23 @@
package subject
import "fmt"
func getSellerValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.Seller, val)
}
// Seller ...
var Seller = struct {
GetSellerInfoByID string
GetListSellerInfoByIDs string
}{
GetSellerInfoByID: getSellerValue("get_seller_info_by_id"),
GetListSellerInfoByIDs: getSellerValue("get_list_seller_info_by_ids"),
}
// SupportChat ...
var SupportChat = struct {
GetListSellerInfoSupportChatByIDs string
}{
GetListSellerInfoSupportChatByIDs: "SELLY_CHAT.REQUEST.SELLER_INFO",
}

17
subject/supplier.go Normal file
View File

@ -0,0 +1,17 @@
package subject
import "fmt"
func getSupplierValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.Supplier, val)
}
var Supplier = struct {
GetListSupplierInfo string
GetSupplierContractBySupplierID string
FindAll string
}{
GetListSupplierInfo: getSupplierValue("get_list_supplier_info"),
GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"),
FindAll: getSupplierValue("find_all"),
}

View File

@ -1,10 +1,41 @@
package subject
const warehousePrefix = "warehouse_"
import "fmt"
const (
WarehouseCreateOutboundRequest = warehousePrefix + "create_outbound_request"
WarehouseUpdateOutboundRequestLogistic = warehousePrefix + "update_outbound_request_logistic_info"
WarehouseCancelOutboundRequest = warehousePrefix + "cancel_outbound_request"
WarehouseGetConfiguration = warehousePrefix + "get_configuration"
)
func getWarehouseValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.Warehouse, val)
}
var Warehouse = struct {
CreateOutboundRequest string
UpdateOutboundRequestLogistic string
CancelOutboundRequest string
GetConfiguration string
SyncORStatus string
WebhookTNC string
WebhookGlobalCare string
FindOne string
FindByCondition string
Distinct string
Count string
AfterUpdateWarehouse string
AfterCreateWarehouse string
UpdateIsClosedSupplier string
GetWarehouses string
}{
AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"),
AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"),
CreateOutboundRequest: getWarehouseValue("create_outbound_request"),
UpdateOutboundRequestLogistic: getWarehouseValue("update_outbound_request_logistic_info"),
CancelOutboundRequest: getWarehouseValue("cancel_outbound_request"),
GetConfiguration: getWarehouseValue("get_configuration"),
SyncORStatus: getWarehouseValue("sync_or_status"),
WebhookTNC: getWarehouseValue("webhook_tnc"),
WebhookGlobalCare: getWarehouseValue("webhook_global_care"),
FindOne: getWarehouseValue("find_one"),
FindByCondition: getWarehouseValue("find_all_by_condition"),
Distinct: getWarehouseValue("distinct"),
Count: getWarehouseValue("count"),
UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"),
GetWarehouses: getWarehouseValue("get_warehouses"),
}