1
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user