From 46f705278fe28ef8f8fe6321591e8b10639b98b3 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Mon, 6 Sep 2021 10:49:12 +0800 Subject: [PATCH] aa --- .../jxcallback/scheduler/defsch/defsch.go | 6 ++- .../secretNumber/secretNum.go | 47 +++++++++++++++++++ business/jxstore/tempop/tempop.go | 2 +- business/model/dao/store.go | 6 ++- business/model/store.go | 11 +++-- controllers/aliapi_callback.go | 15 +++++- 6 files changed, 76 insertions(+), 11 deletions(-) rename business/{jxutils => jxstore}/secretNumber/secretNum.go (76%) diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index f7d79a4f8..d647f9488 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -1571,8 +1571,10 @@ func (s *DefScheduler) ProxyCancelWaybill(order *model.GoodsOrder, bill *model.W if err = s.CancelWaybill(bill, cancelReasonID, cancelReason); err != nil { partner.CurOrderManager.OnOrderMsg(order, "取消三方运单失败", err.Error()) } else { - if storeDetail, _ := dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, order.VendorOrgCode); storeDetail != nil { - s.reverseBrandAccount(storeDetail, bill) + if cancelReasonID != partner.CancelWaybillReasonNotAcceptIntime { + if storeDetail, _ := dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, order.VendorOrgCode); storeDetail != nil { + s.reverseBrandAccount(storeDetail, bill) + } } } return err diff --git a/business/jxutils/secretNumber/secretNum.go b/business/jxstore/secretNumber/secretNum.go similarity index 76% rename from business/jxutils/secretNumber/secretNum.go rename to business/jxstore/secretNumber/secretNum.go index c5b8dcb81..2218141c0 100644 --- a/business/jxutils/secretNumber/secretNum.go +++ b/business/jxstore/secretNumber/secretNum.go @@ -2,10 +2,12 @@ package secretNumber import ( "fmt" + "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/baseapi/utils/errlist" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/model/dao" + "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/globals/api" "github.com/alibabacloud-go/dyplsapi-20170525/client" "github.com/alibabacloud-go/tea/tea" @@ -193,3 +195,48 @@ func UnbindSubscription(poolKey, subsId, phoneNoX string) (err error) { } return err } + +type SecretNumberMsgRes struct { + PhoneNo string `json:"phone_no"` + PoolKey string `json:"pool_key"` + City string `json:"city"` + SubID int64 `json:"sub_id"` + UnconnectedCause int `json:"unconnected_cause"` + CallTime string `json:"call_time"` + CallOutTime string `json:"call_out_time"` + PeerNo string `json:"peer_no"` + CalledDisplayNo string `json:"called_display_no"` + ReleaseDir int `json:"release_dir"` + RingTime string `json:"ring_time"` + CallID string `json:"call_id"` + StartTime string `json:"start_time"` + CallStatus string `json:"call_status"` + FreeRingTime string `json:"free_ring_time"` + PartnerKey string `json:"partner_key"` + ControlMsg string `json:"control_msg"` + ID int64 `json:"id"` + SecretNo string `json:"secret_no"` + CallType int `json:"call_type"` + ReleaseCause int `json:"release_cause"` + ControlType string `json:"control_type"` + ReleaseTime string `json:"release_time"` +} + +func CallbackBrandBill(res *SecretNumberMsgRes) (err error) { + var ( + db = dao.GetDB() + ) + if brands, _ := dao.GetBrands(db, "", 0, res.PoolKey); len(brands) > 0 { + if brandID := brands[0].ID; brandID != 0 { + price := utils.Float64TwoInt(utils.Str2Time(res.ReleaseTime).Sub(utils.Str2Time(res.StartTime)).Minutes()+1) * 6 + if err = partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, brandID, price, model.BrandBillTypeExpend, model.BrandBillFeeTypeSecretNumber, ""); err == nil { + //计算余额,小于10就解绑 + balance, _ := partner.CurStoreAcctManager.GetBrandBalance(brandID) + if balance < model.BrandBalanceLimit { + + } + } + } + } + return err +} diff --git a/business/jxstore/tempop/tempop.go b/business/jxstore/tempop/tempop.go index 3025d4c9f..6ce1c0664 100644 --- a/business/jxstore/tempop/tempop.go +++ b/business/jxstore/tempop/tempop.go @@ -4,7 +4,7 @@ import ( "bytes" "context" "fmt" - "git.rosy.net.cn/jx-callback/business/jxutils/secretNumber" + "git.rosy.net.cn/jx-callback/business/jxstore/secretNumber" "net" "regexp" "strconv" diff --git a/business/model/dao/store.go b/business/model/dao/store.go index b955da5b6..6b6fe6f36 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -990,7 +990,7 @@ func GetStoreAuditPage(db *DaoDB, statuss []int, keyword string, applyTimeStart, return pagedInfo, err } -func GetBrands(db *DaoDB, name string, brandID int) (brands []*model.Brand, err error) { +func GetBrands(db *DaoDB, name string, brandID int, poolKey string) (brands []*model.Brand, err error) { sql := ` SELECT * FROM brand @@ -1007,6 +1007,10 @@ func GetBrands(db *DaoDB, name string, brandID int) (brands []*model.Brand, err sql += " AND id = ?" sqlParams = append(sqlParams, brandID) } + if poolKey != "" { + sql += " AND secret_number_pool_key = ?" + sqlParams = append(sqlParams, poolKey) + } err = GetRows(db, &brands, sql, sqlParams) return brands, err } diff --git a/business/model/store.go b/business/model/store.go index f97a6dc58..4d6768942 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -22,11 +22,12 @@ const ( BrandBillTypeIncome = 1 //收入 BrandBillTypeExpend = 2 //支出 - BrandBillFeeTypeSys = 1 //系统划入 - BrandBillFeeTypeCharge = 2 //人工充值 - BrandBillFeeTypeSms = 3 //短信费用 - BrandBillFeeTypeVoice = 4 //语音费用 - BrandBillFeeTypeDelivery = 5 //三方配送费 + BrandBillFeeTypeSys = 1 //系统划入 + BrandBillFeeTypeCharge = 2 //人工充值 + BrandBillFeeTypeSms = 3 //短信费用 + BrandBillFeeTypeVoice = 4 //语音费用 + BrandBillFeeTypeDelivery = 5 //三方配送费 + BrandBillFeeTypeSecretNumber = 6 //隐私号电话 BrandOpenMTPS = 1 //品牌开关标志, 美团配送 BrandOpenDaDa = 2 //达达 diff --git a/controllers/aliapi_callback.go b/controllers/aliapi_callback.go index 7eeccfb8a..3bc599054 100644 --- a/controllers/aliapi_callback.go +++ b/controllers/aliapi_callback.go @@ -1,9 +1,11 @@ package controllers import ( - "fmt" + "encoding/json" "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/business/jxstore/secretNumber" "github.com/astaxie/beego/server/web" + "io/ioutil" ) type AliApiController struct { @@ -16,7 +18,16 @@ type CallBack struct { } func (c *AliApiController) SecretNumberMsg() { - fmt.Println(utils.Format4Output(c.Ctx.Request, true)) + data, _ := ioutil.ReadAll(c.Ctx.Request.Body) + values, _ := utils.HTTPBody2Values(data, false) + mapData := utils.URLValues2Map(values) + //东西在key上 + var res *secretNumber.SecretNumberMsgRes + for k, _ := range mapData { + if err := json.Unmarshal([]byte(k), &res); err == nil { + secretNumber.CallbackBrandBill(res) + } + } c.Data["json"] = &CallBack{ Code: 0, Msg: "成功",