This commit is contained in:
邹宗楠
2025-09-16 14:22:34 +08:00
parent 5480380c90
commit c55847dda0
29 changed files with 401 additions and 21 deletions

View File

@@ -1207,7 +1207,7 @@ func (c *OrderManager) GetStoresOrderSaleInfoNew(ctx *jxcontext.Context, storeID
fineList, _ := dao.StatisticsFineFee(db, fromTime, toTime, storeIDList)
for _, v := range saleInfoList {
for _, f := range feeList {
if v.StoreID == f.JxStoreID && v.VendorID == f.VendorID {
if v.StoreID == f.JxStoreID && v.VendorID == f.VendorID && v.Status == model.OrderStatusFinished {
v.ServerFee = f.ServerFee
}
}

View File

@@ -656,7 +656,8 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku, isQueryMidPric
t1.mt_attribute,
t1.qua_pictures,
t1.qua_effective_date,
t1.qua_approval_date
t1.qua_approval_date,
t1.special_pictures
`
if isBySku {
sqlData += " ,t2.id sku_id"
@@ -3471,6 +3472,7 @@ func GetSkuNamesNew(ctx *jxcontext.Context, keyword string, skuIDs, skuNameIDs [
t1.qua_pictures,
t1.qua_effective_date,
t1.qua_approval_date,
t1.special_pictures,
t1.best_seller
FROM sku_name t1
LEFT JOIN sku t2 ON t1.id = t2.name_id AND t2.deleted_at = ?
@@ -3516,6 +3518,7 @@ func GetSkuNamesNew(ctx *jxcontext.Context, keyword string, skuIDs, skuNameIDs [
t1.qua_pictures,
t1.qua_effective_date,
t1.qua_approval_date,
t1.special_pictures,
t2.id sku_id
FROM sku_name t1
LEFT JOIN sku t2 ON t1.id = t2.name_id AND t2.deleted_at = ?

View File

@@ -72,6 +72,14 @@ const (
AlarmFee = 1500 // 配送费报警阈值
)
const (
InvoiceStatusInit = "1" // INIT-初始化,未受理
InvoiceStatusFailUre = "2" // APPLY_FAILURE-申请受理失败
InvoiceStatusBilling = "3" // 开具中
InvoiceStatusBillingSuccess = "4" // 开具成功
InvoiceStatusBillingFail = "5" // 开具失败
)
type VendorInfo struct {
Name string `json:"name"`

View File

@@ -1,6 +1,7 @@
package dao
import (
"fmt"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/model"
@@ -9,12 +10,12 @@ import (
func GetInvoiceInfo(db *DaoDB, vendorOrderId string) (*model.InvoiceMsg, error) {
data := &model.InvoiceMsg{}
sql := ` SELECT * FROM invoice_msg WHERE order_id = ? `
err := GetRow(db, data, sql, []interface{}{vendorOrderId}...)
sql := ` SELECT * FROM invoice_msg WHERE order_id = ? OR remark LIKE ?`
err := GetRow(db, data, sql, []interface{}{vendorOrderId, "%" + fmt.Sprintf("%s", vendorOrderId) + "%"}...)
return data, err
}
func GetStoreInvoiceList(storeID int, startTime, endTime time.Time, status string, offset, pageSize int) (info *model.PagedInfo, err error) {
func GetStoreInvoiceList(storeID, vendorId int, startTime, endTime time.Time, status string, offset, pageSize int) (info *model.PagedInfo, err error) {
parameter := []interface{}{}
sql := ` SELECT * FROM invoice_msg WHERE 1=1 `
if storeID != 0 {
@@ -29,6 +30,10 @@ func GetStoreInvoiceList(storeID int, startTime, endTime time.Time, status strin
sql += ` AND created_at <= ? `
parameter = append(parameter, endTime)
}
if vendorId != 0 {
sql += ` AND vendor_id = ? `
parameter = append(parameter, vendorId)
}
if status != "" {
switch status {
case "1": // 未回复
@@ -53,3 +58,24 @@ func GetStoreInvoiceList(storeID int, startTime, endTime time.Time, status strin
return nil, err
}
func GetInvoiceInfoByTaskId(db *DaoDB, taskId string) (*model.InvoiceMsg, error) {
data := &model.InvoiceMsg{}
sql := ` SELECT * FROM invoice_msg WHERE invoice_task_id = ?`
err := GetRow(db, data, sql, []interface{}{taskId}...)
return data, err
}
func GetInvoiceByStoreId(db *DaoDB, storeId, vendorId int) ([]*model.InvoiceMsg, error) {
param := []interface{}{}
data := make([]*model.InvoiceMsg, 0, 0)
sql := ` SELECT * FROM invoice_msg WHERE store_id = ? `
param = append(param, storeId)
if vendorId != 0 {
sql += ` AND vendor_id = ?`
param = append(param, vendorId)
}
err := GetRows(db, data, sql, param...)
return data, err
}

View File

@@ -131,6 +131,7 @@ type StoreSkuSyncInfo struct {
QuaPictures string // 资质图片
QuaEffectiveDate int64 // 资质有效期
QuaApprovalDate int64 // 批准日期
SpecialPictures string // 商品扩展规则(营业成分)
VendorVendorCatID int64 `orm:"column(vendor_vendor_cat_id)"` // 平台商品分类(叶子结点)
CategoryName string `json:"categoryName"` //分类名
@@ -591,7 +592,7 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo
%s vendor_sku_id, t1.%s_sync_status sku_sync_status, t1.%s_price vendor_price, t1.%s_lock_time lock_time,t1.vendor_son_sku_id,t1.vendor_sku_attr_id,t1.vendor_main_id,
t1.store_id, t1.deleted_at bind_deleted_at,t1.status_sale_begin,t1.status_sale_end, t1.jds_ware_id, t1.stock, t1.mt_ladder_box_price,t1.location_code,
t2.*,
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc, t3.status name_status, t3.category_id name_category_id, t3.yb_name_suffix,t3.tiktok_attribute,t3.mt_attribute,t3.qua_pictures,t3.qua_effective_date,t3.qua_approval_date,
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc, t3.status name_status, t3.category_id name_category_id, t3.yb_name_suffix,t3.tiktok_attribute,t3.mt_attribute,t3.qua_pictures,t3.qua_effective_date,t3.qua_approval_date,t3.special_pictures,
t3.sell_point,t3.sell_point_times,t3.jds_stock_switch, t3.preparation_time, t3.img_watermark, t3.ex_vendor_id, t3.img img_origin,t3.upc_brand_name,t3.upc_tiktok_brand_id,
IF(t11.%s <> '', t11.%s, t3.img) img,
IF(t12.%s <> '', t12.%s, t3.img2) img2,
@@ -722,7 +723,7 @@ func GetFullStoreSkus(db *DaoDB, vendorID, storeID int) (skus []*StoreSkuSyncInf
t1.store_id, t1.deleted_at bind_deleted_at, t1.stock,t1.location_code,
t2.*, t2.id sku_id, t2m.vendor_thing_id vendor_sku_id,
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc, t3.status name_status, t3.ex_prefix, t3.ex_prefix_begin, t3.ex_prefix_end, t3.category_id name_category_id,t3.tiktok_attribute,
t3.mt_attribute,t3.qua_pictures,t3.qua_effective_date,t3.qua_approval_date,t3.sell_point,t3.sell_point_times,t3.upc_brand_name,t3.upc_tiktok_brand_id,
t3.mt_attribute,t3.qua_pictures,t3.qua_effective_date,t3.qua_approval_date,t3.special_pictures,t3.sell_point,t3.sell_point_times,t3.upc_brand_name,t3.upc_tiktok_brand_id,
IF(t11.%s <> '', t11.%s, t3.img) img,
IF(t12.%s <> '', t12.%s, t3.img2) img2,
IF(t13.%s <> '', t13.%s, t3.desc_img) desc_img,

View File

@@ -6,6 +6,7 @@ type InvoiceMsg struct {
StoreID int `orm:"column(store_id)" json:"storeID"` // 外部系统里记录的 jxstoreid
VendorID int `orm:"column(vendor_id);size(2)" json:"vendorID"` // 平台ID
InvoiceTaskId string `orm:"column(invoice_task_id);size(64)" json:"invoiceTaskId"` // 任务ID
Status string `orm:"column(status);size(8)" json:"status"` // 发票状态 INIT-初始化,未受理 1 APPLY_FAILURE-申请受理失败 2 BILLING-开具中 3 BILLING_SUCCESS-开具成功 4 BILLING_FAILURE- 开具失败 5
PushType int `orm:"column(push_type);size(2)" json:"pushType"` // 消息类型1-开发票3-催发票
InvoiceTitle string `orm:"column(invoice_title);size(256)" json:"invoiceTitle"` // 发票抬头,为用户填写的开发票的抬头。
TaxpayerId string `orm:"column(taxpayer_id);size(32)" json:"taxpayerId"` // 纳税人识别号
@@ -18,6 +19,7 @@ type InvoiceMsg struct {
InvoiceAmount int64 `orm:"column(invoice_amount);size(16)" json:"invoiceAmount"` // 商家开票金额,单位分
InvoiceUrl string `orm:"column(invoice_url);size(512)" json:"invoiceUrl"` // 发票文件链接
InvoiceId string `orm:"column(invoice_id);size(32)" json:"invoiceId"` // 发票号码
Remark string `orm:"column(remark);size(512)" json:"remark"` // 备注
}
func (o *InvoiceMsg) TableUnique() [][]string {
@@ -27,5 +29,6 @@ func (o *InvoiceMsg) TableIndex() [][]string {
return [][]string{
[]string{"CreatedAt", "StoreID"},
[]string{"OrderId"},
[]string{"InvoiceTaskId"},
}
}

View File

@@ -196,6 +196,7 @@ type SkuName struct {
QuaPictures string `orm:"column(qua_pictures);size(512)" json:"quaPictures"` // 商品资质图片,非必填,医疗器械必须传,保健食品、特殊医学配方食品建议传
QuaEffectiveDate int64 `orm:"column(qua_effective_date)" json:"quaEffectiveDate"` // 商品资质有效期传10位秒级的时间戳。-1永久有效。
QuaApprovalDate int64 `orm:"column(qua_approval_date)" json:"quaApprovalDate"` // 批准日期格式为10位秒级的时间戳。
SpecialPictures string `orm:"column(special_pictures);type(text)" json:"specialPictures"` // 批准日期格式为10位秒级的时间戳。
}
func (*SkuName) TableUnique() [][]string {

View File

@@ -171,6 +171,8 @@ type IPurchasePlatformStoreSkuHandler interface {
// GetVendorAllSkuList 同平台商品复制(饿了么复制饿了么,美团复制美团),获取商品
// UploadInvoice 发票回复
UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error)
}
type ISingleStoreStoreSkuHandler interface {

View File

@@ -35,6 +35,8 @@ func OnCallbackMsg(msg *ebaiapi.CallbackMsg) (response *ebaiapi.CallbackResponse
response = api.EbaiAPI.Err2CallbackResponse(msg.Cmd, err, msg.Cmd)
} else if msg.Cmd == ebaiapi.CmdImMessageSendEvent /*|| msg.Cmd == ebaiapi.CmdImMessageReadEvent*/ {
response = CurPurchaseHandler.OnImMessage(msg)
} else if msg.Cmd == ebaiapi.CmdImInvoicApply || msg.Cmd == ebaiapi.CmdImInvoicEmail {
response = CurPurchaseHandler.InvoiceApply(msg)
}
}
return response

View File

@@ -2,10 +2,16 @@ package ebai
import (
"encoding/json"
"fmt"
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg"
"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/im"
"git.rosy.net.cn/jx-callback/globals/api"
"time"
)
const (
@@ -23,6 +29,81 @@ func (p *PurchaseHandler) OnImMessage(msg *ebaiapi.CallbackMsg) (response *ebaia
return nil
}
// InvoiceApply 用户申请发票
func (p *PurchaseHandler) InvoiceApply(msg *ebaiapi.CallbackMsg) (response *ebaiapi.CallbackResponse) {
var (
db = dao.GetDB()
applyNo = ""
storeId = ""
vendorStoreId = ""
)
switch msg.Cmd {
case ebaiapi.CmdImInvoicApply:
invoice := &ebaiapi.InvoiceApplyBody{}
if err := utils.Map2StructByJson(msg.Body, invoice, false); err != nil {
return api.EbaiAPI.Err2CallbackResponse(msg.Cmd, err, msg.Cmd)
}
invoiceData, _ := dao.GetInvoiceInfo(db, utils.Int64ToStr(invoice.OrderList[0].OrderId))
applyNo = invoice.ApplicationNo
storeId = invoice.ShopId
vendorStoreId = invoice.BaiduShopId
if invoiceData == nil {
invoiceObj := model.InvoiceMsg{
ModelIDCUL: model.ModelIDCUL{},
OrderId: utils.Int64ToStr(invoice.OrderList[0].OrderId),
StoreID: utils.Str2Int(invoice.ShopId),
VendorID: model.VendorIDEBAI,
InvoiceTaskId: invoice.ApplicationNo,
Status: invoice.Status,
PushType: 1,
InvoiceTitle: invoice.BuyerTitle.TitleName,
TaxpayerId: invoice.BuyerTitle.TaxPayerNum,
NeedInvoiceByCategory: 1,
CompanyAddress: invoice.BuyerTitle.RegisterAddress,
CompanyPhone: invoice.BuyerTitle.RegisterPhone,
AccountBank: invoice.BuyerTitle.BankName,
AccountNumber: invoice.BuyerTitle.BankAccount,
Email: invoice.BuyerContact.Email,
InvoiceAmount: utils.Float64TwoInt64(invoice.TotalInvoiceAmount * 100),
InvoiceUrl: "",
InvoiceId: "",
}
if len(invoice.OrderList) > 1 {
orderList := make(map[int64]float64, 0)
for _, v := range invoice.OrderList {
orderList[v.OrderId] = v.InvoiceAmount
}
invoiceObj.Remark = string(utils.MustMarshal(orderList))
}
dao.WrapAddIDCULEntity(invoiceObj, "system")
if err := dao.CreateEntity(db, invoiceObj); err != nil {
return api.EbaiAPI.Err2CallbackResponse(msg.Cmd, err, msg.Cmd)
}
}
case ebaiapi.CmdImInvoicEmail:
invoice := &ebaiapi.InvoiceEmailPush{}
if err := utils.Map2StructByJson(msg.Body, invoice, false); err != nil {
return api.EbaiAPI.Err2CallbackResponse(msg.Cmd, err, msg.Cmd)
}
applyNo = invoice.ApplicationNo
storeId = invoice.ShopId
vendorStoreId = invoice.BaiduShopId
invoiceData, _ := dao.GetInvoiceInfoByTaskId(db, invoice.ApplicationNo)
if invoiceData != nil {
invoiceData.UpdatedAt = time.Now()
invoiceData.Email = invoice.Email
dao.UpdateEntity(db, invoiceData, "UpdatedAt", "Email")
}
}
content2 := fmt.Sprintf("发票单号:%s,用户申请发票,请老板提供发票信息!", applyNo)
if _, err := weixinmsg.SendStoreMessage(jxcontext.AdminCtx, "美团用户申请发票", content2, []int{utils.Str2Int(storeId)}, nil, "", model.MessageTypeStore, true, true); err != nil {
im.PushMsgByCid(vendorStoreId, model.VendorIDEBAI, content2)
}
return api.EbaiAPI.Err2CallbackResponse(msg.Cmd, nil, msg.Cmd)
}
// BusinessSendMsg 向门店发送消息
//func BusinessSendMsg(param *ebaiapi.BusinessSendMsgReq) error {
// err := api.EbaiAPI.BusinessSendMsg(param)

View File

@@ -1074,3 +1074,16 @@ func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (strin
}
return "", err
}
// UploadInvoice 回复用户发票申请
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error) {
goodsOrder, err := partner.CurOrderManager.LoadOrder(param.OrderId, param.VendorID)
if err != nil {
return nil, nil, err
}
result, err := api.EbaiAPI.UploadInvoice(goodsOrder.VendorStoreID, param.InvoiceTaskId, param.InvoiceUrl)
if err != nil {
return nil, nil, err
}
return result.SuccessfulApplicationNoList, result.FailedApplicationNoList, nil
}

View File

@@ -920,3 +920,68 @@ func (c *PurchaseHandler) UpdateStoreLineStatus(ctx *jxcontext.Context, vendorOr
return err
}
// QueryInvoiceSetting 获取门店发票设置
func QueryInvoiceSetting(baiDuStoreId string) ([]*ebaiapi.SettingList, error) {
return api.EbaiAPI.QueryInvoiceSetting([]string{baiDuStoreId})
}
// BathUpdateInvoiceSetting 批量更新门店发票设置
func BathUpdateInvoiceSetting(baiDuStoreId string, setting *ebaiapi.StoreInvoiceSetting) ([]*ebaiapi.ResultList, []*ebaiapi.ResultList, error) {
return api.EbaiAPI.BathUpdateInvoiceSetting(baiDuStoreId, setting)
}
// QueryUnansweredInvoice 查询门店未回复发票信息
func QueryUnansweredInvoice(baiDuStoreId string, jxStoreId int) (*ebaiapi.QueryUnansweredInvoiceResult, error) {
var db = dao.GetDB()
unansweredList, err := api.EbaiAPI.QueryUnansweredInvoice(baiDuStoreId)
if err != nil {
return nil, err
}
if len(unansweredList.RecordList) != 0 {
invoiceData, _ := dao.GetInvoiceByStoreId(db, jxStoreId, model.VendorIDEBAI)
invoiceDataMap := make(map[string]*model.InvoiceMsg, 0)
for i := 0; i < len(invoiceData); i++ {
invoiceDataMap[invoiceData[i].InvoiceTaskId] = invoiceData[i]
}
for i := 0; i < len(unansweredList.RecordList); i++ {
if invoiceDataMap[unansweredList.RecordList[i].ApplicationNo] != nil {
invoiceDataMap[unansweredList.RecordList[i].ApplicationNo].Status = model.InvoiceStatusInit
dao.UpdateEntity(db, invoiceDataMap[unansweredList.RecordList[i].ApplicationNo], "Status")
} else {
invoiceObj := model.InvoiceMsg{
ModelIDCUL: model.ModelIDCUL{},
OrderId: utils.Int64ToStr(unansweredList.RecordList[i].OrderList[0].OrderId),
StoreID: utils.Str2Int(unansweredList.RecordList[i].ShopId),
VendorID: model.VendorIDEBAI,
InvoiceTaskId: unansweredList.RecordList[i].ApplicationNo,
Status: unansweredList.RecordList[i].Status,
PushType: 1,
InvoiceTitle: unansweredList.RecordList[i].BuyerTitle.TitleName,
TaxpayerId: unansweredList.RecordList[i].BuyerTitle.TaxPayerNum,
NeedInvoiceByCategory: 1,
CompanyAddress: unansweredList.RecordList[i].BuyerTitle.RegisterAddress,
CompanyPhone: unansweredList.RecordList[i].BuyerTitle.RegisterPhone,
AccountBank: unansweredList.RecordList[i].BuyerTitle.BankName,
AccountNumber: unansweredList.RecordList[i].BuyerTitle.BankAccount,
Email: unansweredList.RecordList[i].BuyerContact.Email,
InvoiceAmount: utils.Float64TwoInt64(unansweredList.RecordList[i].TotalInvoiceAmount * 100),
InvoiceUrl: "",
InvoiceId: "",
}
if len(unansweredList.RecordList[i].OrderList) > 1 {
orderList := make(map[int64]float64, 0)
for _, v := range unansweredList.RecordList[i].OrderList {
orderList[v.OrderId] = v.InvoiceAmount
}
invoiceObj.Remark = string(utils.MustMarshal(orderList))
}
dao.WrapAddIDCULEntity(invoiceObj, "system")
dao.CreateEntity(db, invoiceObj)
}
}
}
return unansweredList, err
}

View File

@@ -457,6 +457,12 @@ func genSkuParamsFromStoreSkuInfo2(storeSku *dao.StoreSkuSyncInfo, isCreate, isE
"url": storeSku.Img5,
})
}
if storeSku.SpecialPictures != "" {
photos = append(photos, map[string]interface{}{
"is_master": 0,
"url": storeSku.SpecialPictures,
})
}
params = map[string]interface{}{
// "name": utils.LimitMixedStringLen(storeSku.SkuName, ebaiapi.MaxSkuNameByteCount),

View File

@@ -354,3 +354,8 @@ func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64
func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) {
return "", nil
}
// UploadInvoice 回复用户发票申请
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error) {
return nil, nil, nil
}

View File

@@ -706,3 +706,8 @@ func (c *PurchaseHandler) GetPlatformLogisticsFee(order *model.GoodsOrder) (int6
func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) {
return "", nil
}
// UploadInvoice 回复用户发票申请
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error) {
return nil, nil, nil
}

View File

@@ -179,9 +179,9 @@ func skuInfo2Param(ctx *jxcontext.Context, sku *dao.StoreSkuSyncInfo) (param *jd
param.ShopCategories = append(param.ShopCategories, utils.Str2Int64(sku.VendorCatID))
}
if sku.ImgMix != "" {
param.Images = jxutils.BatchString2Slice(sku.ImgMix, sku.Img2, sku.Img3, sku.Img4, sku.Img5)
param.Images = jxutils.BatchString2Slice(sku.ImgMix, sku.Img2, sku.Img3, sku.Img4, sku.Img5, sku.SpecialPictures)
} else {
param.Images = jxutils.BatchString2Slice(sku.Img, sku.Img2, sku.Img3, sku.Img4, sku.Img5)
param.Images = jxutils.BatchString2Slice(sku.Img, sku.Img2, sku.Img3, sku.Img4, sku.Img5, sku.SpecialPictures)
}
if sku.SkuVendorMapCatID != "" && sku.SkuVendorMapCatID != "0" {

View File

@@ -343,3 +343,8 @@ func (c *PurchaseHandler) GetPlatformLogisticsFee(order *model.GoodsOrder) (int6
func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) {
return "", nil
}
// UploadInvoice 回复用户发票申请
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error) {
return nil, nil, nil
}

View File

@@ -169,5 +169,10 @@ func (c *PurchaseHandler) GetPlatformLogisticsFee(order *model.GoodsOrder) (int6
// ApplyCompensationOrder 订单索赔
func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) {
return "",nil
return "", nil
}
// UploadInvoice 回复用户发票申请
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error) {
return nil, nil, nil
}

View File

@@ -147,6 +147,7 @@ func InvoiceCallback(invoice *mtwmapi.InvoiceCallback) (err error) {
OrderId: invoice.OrderId,
StoreID: localOrder.JxStoreID,
VendorID: model.VendorIDMTWM,
Status: model.InvoiceStatusInit,
InvoiceTaskId: invoice.InvoiceTaskId,
PushType: invoice.PushType,
InvoiceTitle: invoice.InvoiceTitle,

View File

@@ -1058,11 +1058,11 @@ func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (strin
})
}
func UploadInvoice(param *model.InvoiceMsg) error {
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error) {
goodsOrder, err := partner.CurOrderManager.LoadOrder(param.OrderId, param.VendorID)
if err != nil {
return err
return nil, nil, err
}
return getAPI(goodsOrder.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(goodsOrder), goodsOrder.VendorStoreID).UploadInvoice(param.OrderId, param.InvoiceUrl, param.InvoiceId, param.InvoiceTaskId)
return nil, nil, getAPI(goodsOrder.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(goodsOrder), goodsOrder.VendorStoreID).UploadInvoice(param.OrderId, param.InvoiceUrl, param.InvoiceId, param.InvoiceTaskId)
}

View File

@@ -253,6 +253,14 @@ func GetCategoryAttrList(appOrgCode string, tagID int) (categoryAttrListResult [
return nil, err
}
// GetMTProductRule 获取美团商品上传规则
func GetMTProductRule(tagID int) (categoryAttrListResult *mtwmapi.ProductRulesObj, err error) {
if resp, err := getAPI(beego.AppConfig.DefaultString("mtwmAppID2", ""), 0, "").RetailProductRules(int64(tagID)); err == nil {
return resp, nil
}
return nil, err
}
//GetCategoryAttrValueList 查询特殊属性的属性值列表
func GetCategoryAttrValueList(appOrgCode, keyword string, attrID int) (categoryAttrValueListResult []*mtwmapi.CategoryAttrValueListResult, err error) {
if attrID != utils.Str2Int(mtwmapi.SpecialAttrBrand) && attrID != utils.Str2Int(mtwmapi.SpecialAttrProducer) || len(keyword) == 0 || len(appOrgCode) == 0 {
@@ -406,6 +414,9 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
foodData["qua_effective_date"] = storeSku.QuaEffectiveDate
foodData["qua_approval_date"] = storeSku.QuaApprovalDate
}
if storeSku.SpecialPictures != "" {
foodData["special_pictures"] = storeSku.SpecialPictures
}
// 周期性可售时间段
if storeSku.StatusSaleBegin != model.NO && storeSku.StatusSaleEnd != model.NO {

View File

@@ -998,3 +998,8 @@ func (c *PurchaseHandler) GetPlatformLogisticsFee(order *model.GoodsOrder) (int6
func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) {
return "", nil
}
// UploadInvoice 回复用户发票申请
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error) {
return nil, nil, nil
}

View File

@@ -255,7 +255,7 @@ func UpdateTaoVegetable(api *tao_vegetable.API, storeSkuList []*dao.StoreSkuSync
updateSku.PurchaseQuantity = utils.Int64ToPointer(int64(v.MinOrderCount)) // 起购单位
}
// 修改暂时不修改图片,保持效率
updateSku.SkuPicUrls = uploadImg(api, v.SkuID, model.VendorIDTaoVegetable, []string{v.Img, v.Img2, v.Img3, v.Img4, v.Img5, v.DescImg})
updateSku.SkuPicUrls = uploadImg(api, v.SkuID, model.VendorIDTaoVegetable, []string{v.Img, v.Img2, v.Img3, v.Img4, v.Img5, v.DescImg, v.SpecialPictures})
if updateSku.SkuPicUrls == nil {
continue
}
@@ -329,7 +329,7 @@ func createTaoVegetable(ctx *jxcontext.Context, api *tao_vegetable.API, storeSku
if storeSku.VendorCatID == "175" {
sku.MerchantCatCode = utils.String2Pointer("1751")
}
sku.SkuPicUrls = uploadImg(api, storeSku.SkuID, model.VendorIDTaoVegetable, []string{storeSku.Img, storeSku.Img2, storeSku.Img3, storeSku.Img4, storeSku.Img5, storeSku.DescImg})
sku.SkuPicUrls = uploadImg(api, storeSku.SkuID, model.VendorIDTaoVegetable, []string{storeSku.Img, storeSku.Img2, storeSku.Img3, storeSku.Img4, storeSku.Img5, storeSku.DescImg, storeSku.SpecialPictures})
if sku.SkuPicUrls == nil {
continue
}

View File

@@ -1116,3 +1116,8 @@ func (c *PurchaseHandler) GetPlatformLogisticsFee(order *model.GoodsOrder) (int6
func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) {
return "", nil
}
// UploadInvoice 回复用户发票申请
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error) {
return nil, nil, nil
}

View File

@@ -122,3 +122,8 @@ func (c *PurchaseHandler) GetPlatformLogisticsFee(order *model.GoodsOrder) (int6
func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (string, error) {
return "", nil
}
// UploadInvoice 回复用户发票申请
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error) {
return nil, nil, nil
}

View File

@@ -810,6 +810,21 @@ func (c *SkuController) GetTiktokCategoryValue() {
})
}
// @Title 根据美团分类id获取平台扩展规则
// @Description 根据美团分类id获取平台扩展规则
// @Param token header string true "认证token"
// @Param mtCategoryId query int64 true "美团类目id"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetMTProductRule [get]
func (c *SkuController) GetMTProductRule() {
c.callGetMTProductRule(func(params *tSkuGetMTProductRuleParams) (retVal interface{}, errCode string, err error) {
data, err := mtwm.GetMTProductRule(params.MtCategoryId)
return data, "", err
})
}
// @Title 根据美团分类id获取平台属性值
// @Description 根据美团分类id获取平台属性值
// @Param token header string true "认证token"

View File

@@ -4,12 +4,13 @@ import (
"encoding/json"
"errors"
"fmt"
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
"git.rosy.net.cn/jx-callback/business/auth2"
"git.rosy.net.cn/jx-callback/business/bidding"
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
"git.rosy.net.cn/jx-callback/business/jxstore/permission"
"git.rosy.net.cn/jx-callback/business/partner/delivery"
"git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
"git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
"strings"
"time"
@@ -1512,7 +1513,7 @@ func (c *OrderController) UpdateTiktokSettlement() {
// @router /GetInvoiceRecord [post]
func (c *OrderController) GetInvoiceRecord() {
c.callGetInvoiceRecord(func(params *tOrderGetInvoiceRecordParams) (retVal interface{}, errCode string, err error) {
retVal, err = dao.GetStoreInvoiceList(params.StoreId, utils.Str2Time(params.StartTime), utils.Str2Time(params.EndTime), params.Status, params.Offset, params.PageSize)
retVal, err = dao.GetStoreInvoiceList(params.StoreId, 0, utils.Str2Time(params.StartTime), utils.Str2Time(params.EndTime), params.Status, params.Offset, params.PageSize)
return retVal, errCode, err
})
}
@@ -1537,9 +1538,78 @@ func (c *OrderController) UploadOrderInvoice() {
}
invoice.InvoiceUrl = params.InvoiceUrl
invoice.InvoiceId = params.InvoiceId
dao.UpdateEntity(db, invoice, "InvoiceUrl", "InvoiceId")
handler, _ := partner.GetPurchasePlatformFromVendorID(invoice.VendorID).(partner.IPurchasePlatformStoreSkuHandler)
success, _, err := handler.UploadInvoice(invoice)
if err != nil {
return nil, "", err
}
switch invoice.VendorID {
case model.VendorIDMTWM:
invoice.Status = model.InvoiceStatusBillingSuccess
case model.VendorIDEBAI:
for _, v := range success {
if v == invoice.InvoiceTaskId {
invoice.Status = model.InvoiceStatusBillingSuccess
}
}
err = mtwm.UploadInvoice(invoice)
}
dao.UpdateEntity(db, invoice, "InvoiceUrl", "InvoiceId", "Status")
return retVal, errCode, err
})
}
// @Title 查询门店发票设置
// @Description 查询门店发票设置
// @Param token header string true "认证token"
// @Param vendorId formData string true "平台ID"
// @Param vendorStoreID formData string true "平台门店ID"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /QueryInvoiceSetting [get]
func (c *OrderController) QueryInvoiceSetting() {
c.callQueryInvoiceSetting(func(params *tOrderQueryInvoiceSettingParams) (retVal interface{}, errCode string, err error) {
retVal, err = ebai.QueryInvoiceSetting(params.VendorStoreID)
return
})
}
// @Title 批量更新门店发票设置
// @Description 批量更新门店发票设置
// @Param token header string true "认证token"
// @Param vendorId formData string true "平台ID"
// @Param vendorStoreID formData string true "平台门店ID"
// @Param payload formData string true "json数据,格式为 ebaiapi.StoreInvoiceSetting"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /BathUpdateInvoiceSetting [post]
func (c *OrderController) BathUpdateInvoiceSetting() {
c.callBathUpdateInvoiceSetting(func(params *tOrderBathUpdateInvoiceSettingParams) (retVal interface{}, errCode string, err error) {
setting := &ebaiapi.StoreInvoiceSetting{}
if err = utils.UnmarshalUseNumber([]byte(params.Payload), setting); err == nil {
success, fail, err := ebai.BathUpdateInvoiceSetting(params.VendorStoreID, setting)
return map[string]interface{}{
"success": success,
"fail": fail,
}, "", err
}
return
})
}
// @Title 批量更新店铺开票申请
// @Description 批量更新店铺开票申请
// @Param token header string true "认证token"
// @Param vendorId formData string true "平台ID"
// @Param vendorStoreID formData string true "平台门店ID"
// @Param storeID formData int true "京西门店ID"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /QueryUnansweredInvoice [get]
func (c *OrderController) QueryUnansweredInvoice() {
c.callQueryUnansweredInvoice(func(params *tOrderQueryUnansweredInvoiceParams) (retVal interface{}, errCode string, err error) {
retVal, err = ebai.QueryUnansweredInvoice(params.VendorStoreID, params.StoreID)
return
})
}

View File

@@ -150,7 +150,7 @@ func (c *MtwmController) Invoice() {
return
}
globals.SugarLogger.Debugf("------Invoice:= %s", string(body))
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "淘鲜达token过期", string(body))
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "MtwmController发票推送", string(body))
data := &mtwmapi.InvoiceCallback{}
if err = json.Unmarshal(body, data); err != nil {

View File

@@ -1722,6 +1722,35 @@ func init() {
MethodParams: param.Make(),
Filters: nil,
Params: nil})
// 获取饿了么门店发票设置
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
web.ControllerComments{
Method: "QueryInvoiceSetting",
Router: `/QueryInvoiceSetting`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
// 批量更新门店发票设置
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
web.ControllerComments{
Method: "BathUpdateInvoiceSetting",
Router: `/BathUpdateInvoiceSetting`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
// 批量更新店铺开票申请
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
web.ControllerComments{
Method: "QueryUnansweredInvoice",
Router: `/QueryUnansweredInvoice`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
web.ControllerComments{
@@ -2064,6 +2093,14 @@ func init() {
MethodParams: param.Make(),
Filters: nil,
Params: nil})
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
web.ControllerComments{
Method: "GetMTProductRule",
Router: `/GetMTProductRule`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
web.ControllerComments{