订单GoodsOrder添加字段InvoiceTitle,InvoiceTaxerID和InvoiceEmail表示开发票信息
GetOrders添加可选参数mustInvoice表示只查询要求开发票的订单
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:"-"`
|
||||
|
||||
@@ -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分钟内拣货,不然订单会被取消
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user