From aa6d673936c6704f2b422f7532dbe634e6fcde44 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 21 Oct 2019 17:44:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95GoodsOrder=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=AD=97=E6=AE=B5InvoiceTitle,InvoiceTaxerID=E5=92=8CInvoiceEm?= =?UTF-8?q?ail=E8=A1=A8=E7=A4=BA=E5=BC=80=E5=8F=91=E7=A5=A8=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=20GetOrders=E6=B7=BB=E5=8A=A0=E5=8F=AF=E9=80=89?= =?UTF-8?q?=E5=8F=82=E6=95=B0mustInvoice=E8=A1=A8=E7=A4=BA=E5=8F=AA?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=A6=81=E6=B1=82=E5=BC=80=E5=8F=91=E7=A5=A8?= =?UTF-8?q?=E7=9A=84=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/orderman_ext.go | 3 +++ business/jxutils/jxutils.go | 12 +++++++++++ business/jxutils/jxutils_test.go | 21 ++++++++++++++++++++ business/model/order.go | 4 ++++ business/partner/purchase/ebai/order.go | 4 ++++ business/partner/purchase/jd/order.go | 5 +++++ business/partner/purchase/mtwm/order.go | 4 ++++ controllers/jx_order.go | 1 + routers/commentsRouter_controllers.go | 18 +++++++++++++++++ 9 files changed, 72 insertions(+) diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index 31bceb2a7..ad5aca131 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -380,6 +380,9 @@ func (c *OrderManager) getOrders(ctx *jxcontext.Context, isIncludeSku, isInclude sqlWhere += " AND t1.adjust_count >= ?" sqlParams = append(sqlParams, params["adjustCount"]) } + if mustInvoice, ok := params["mustInvoice"].(bool); ok && mustInvoice { + sqlWhere += " AND t1.invoice_taxer_id <> ''" + } } if params["vendorIDs"] != nil { var vendorIDs []int diff --git a/business/jxutils/jxutils.go b/business/jxutils/jxutils.go index a2ae15d83..1dd523dbe 100644 --- a/business/jxutils/jxutils.go +++ b/business/jxutils/jxutils.go @@ -27,6 +27,7 @@ import ( var ( routinePool *routinepool.Pool skuNamePat *regexp.Regexp + emailPat *regexp.Regexp resourceTypeMap = map[int][]string{ model.VendorIDQiNiuCloud: []string{ @@ -67,6 +68,7 @@ func init() { // Go regex does not support lookarounds. // https://stackoverflow.com/questions/38933898/error-parsing-regexp-invalid-or-unsupported-perl-syntax skuNamePat = regexp.MustCompile(`([\((\[【][^\((\[【\))\]】]*[\))\]】])?(.*?)([((].*[))])?\s*约?([1-9][\d\.]*)(g|G|kg|kG|Kg|KG|l|L|ml|mL|Ml|ML|克)\s*([((].*[))])?\s*(?:\/|/|)\s*([^\s()()]{0,2})\s*([((].*[))])?$`) + emailPat = regexp.MustCompile(`[A-Za-z0-9_\-\.]+@(?:[A-Za-z0-9_\-]+\.)+[A-Za-z]+`) } func getJxStoreIDFromOrder(order *model.GoodsOrder) (retVal int) { @@ -771,3 +773,13 @@ func CalcStageValue(stageList [][]float64, totalVolume float64) (value float64) } return value } + +func GetOneEmailFromStr(str string) (email string) { + if str != "" { + searchResult := emailPat.FindStringSubmatch(str) + if searchResult != nil && len(searchResult) > 0 { + email = searchResult[0] + } + } + return email +} diff --git a/business/jxutils/jxutils_test.go b/business/jxutils/jxutils_test.go index c4f3191ff..2e1f22a93 100644 --- a/business/jxutils/jxutils_test.go +++ b/business/jxutils/jxutils_test.go @@ -259,3 +259,24 @@ func TestCalcStageValue(t *testing.T) { } } } + +func TestGetOneEmailFromStr(t *testing.T) { + for _, v := range [][]string{ + []string{ + "test@kk.com", + "中人国test@kk.com", + }, + []string{ + "", + "91b8dcb5cb6b462bc96078b7210470b7.jpg", + }, + []string{ + "test@kk.com", + "中人国test@kk.com2342", + }, + } { + if str := GetOneEmailFromStr(v[1]); str != v[0] { + t.Errorf("%s failed, result:%s, expect:%s", v[1], str, v[0]) + } + } +} diff --git a/business/model/order.go b/business/model/order.go index 7a4cb0f55..5ea267da4 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -67,6 +67,10 @@ type GoodsOrder struct { ModelTimeInfo `json:"-"` Flag int `json:"flag"` //非运单调整相关的其它状态 + InvoiceTitle string `orm:"size(64)" json:"invoiceTitle"` // 发票抬头 + InvoiceTaxerID string `orm:"size(32);column(invoice_taxer_id)" json:"invoiceTaxerID"` // 发票纳税人识别码 + InvoiceEmail string `orm:"size(64)" json:"invoiceEmail"` // 发票邮箱 + // 以下只是用于传递数据 OriginalData string `orm:"-" json:"-"` Skus []*OrderSku `orm:"-" json:"-"` diff --git a/business/partner/purchase/ebai/order.go b/business/partner/purchase/ebai/order.go index 44e8a2590..2658dc3f1 100644 --- a/business/partner/purchase/ebai/order.go +++ b/business/partner/purchase/ebai/order.go @@ -202,6 +202,10 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo ActualPayPrice: utils.ForceInterface2Int64(orderMap["user_fee"]), TotalShopMoney: utils.ForceInterface2Int64(orderMap["shop_fee"]), DeliveryType: mapDeliveryType(int(utils.ForceInterface2Int64(orderMap["delivery_party"]))), + + InvoiceTitle: utils.Interface2String(orderMap["invoice_title"]), + InvoiceTaxerID: utils.Interface2String(orderMap["taxer_id"]), + InvoiceEmail: jxutils.GetOneEmailFromStr(utils.Interface2String(orderMap["remark"])), } if utils.IsTimeZero(order.PickDeadline) && !utils.IsTimeZero(order.StatusTime) { order.PickDeadline = order.StatusTime.Add(pickupOrderDelay) // 饿百要求在5分钟内拣货,不然订单会被取消 diff --git a/business/partner/purchase/jd/order.go b/business/partner/purchase/jd/order.go index cad01ed81..f923c12ba 100644 --- a/business/partner/purchase/jd/order.go +++ b/business/partner/purchase/jd/order.go @@ -179,6 +179,11 @@ func (c *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo DistanceFreightMoney: utils.Interface2Int64WithDefault(result["merchantPaymentDistanceFreightMoney"], 0), DeliveryType: deliveryTypeMap[int(utils.Str2Int64WithDefault(utils.Interface2String(result["deliveryCarrierNo"]), 0))], } + if orderInvoice, ok := result["orderInvoice"].(map[string]interface{}); ok && orderInvoice != nil { + order.InvoiceTitle = utils.Interface2String(orderInvoice["invoiceTitle"]) + order.InvoiceTaxerID = utils.Interface2String(orderInvoice["invoiceDutyNo"]) + order.InvoiceEmail = utils.Interface2String(orderInvoice["invoiceMail"]) + } order.Status = c.getStatusFromVendorStatus(order.VendorStatus) businessTage := utils.Interface2String(result["businessTag"]) if strings.Index(businessTage, "dj_aging_immediately") >= 0 { diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index eb08f522a..6a8209a0d 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -121,6 +121,10 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo OrderCreatedAt: getTimeFromTimestamp(utils.MustInterface2Int64(result["ctime"])), OriginalData: string(utils.MustMarshal(result)), ActualPayPrice: jxutils.StandardPrice2Int(utils.MustInterface2Float64(result["total"])), + + InvoiceTitle: utils.Interface2String(result["invoice_title"]), + InvoiceTaxerID: utils.Interface2String(result["taxpayer_id"]), + InvoiceEmail: jxutils.GetOneEmailFromStr(utils.Interface2String(result["caution"])), } pickType := int(utils.Interface2Int64WithDefault(result["pick_type"], 0)) if pickType == mtwmapi.OrderPickTypeSelf { diff --git a/controllers/jx_order.go b/controllers/jx_order.go index 31a170894..b28ab30b9 100644 --- a/controllers/jx_order.go +++ b/controllers/jx_order.go @@ -278,6 +278,7 @@ func (c *OrderController) ExportMTWaybills() { // @Param skuIDs query string false "包含的skuID列表,或的关系" // @Param isJxFirst query bool false "排序是否京西订单优先(缺省为否)" // @Param adjustCount query int false "最小调整次数" +// @Param mustInvoice query bool false "是否必须要求开发票" // @Param offset query int false "结果起始序号(以0开始,缺省为0)" // @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)" // @Success 200 {object} controllers.CallResult diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 98a888ade..9345a8936 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -1881,6 +1881,15 @@ func init() { Filters: nil, Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"], + beego.ControllerComments{ + Method: "LoadMyCart", + Router: `/LoadMyCart`, + AllowHTTPMethods: []string{"get"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"], beego.ControllerComments{ Method: "QueryMyDeliveryAddress", @@ -1899,6 +1908,15 @@ func init() { Filters: nil, Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"], + beego.ControllerComments{ + Method: "SaveMyCart", + Router: `/SaveMyCart`, + AllowHTTPMethods: []string{"post"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"], beego.ControllerComments{ Method: "TransferLegacyWeixins",