1
This commit is contained in:
@@ -171,6 +171,8 @@ type IPurchasePlatformStoreSkuHandler interface {
|
||||
|
||||
// GetVendorAllSkuList 同平台商品复制(饿了么复制饿了么,美团复制美团),获取商品
|
||||
|
||||
// UploadInvoice 发票回复
|
||||
UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error)
|
||||
}
|
||||
|
||||
type ISingleStoreStoreSkuHandler interface {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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" {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user