1
This commit is contained in:
@@ -172,7 +172,7 @@ type IPurchasePlatformStoreSkuHandler interface {
|
||||
// GetVendorAllSkuList 同平台商品复制(饿了么复制饿了么,美团复制美团),获取商品
|
||||
|
||||
// UploadInvoice 发票回复
|
||||
UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error)
|
||||
UploadInvoice(param *model.InvoiceMsg, base64 string) ([]string, []string, error)
|
||||
}
|
||||
|
||||
type ISingleStoreStoreSkuHandler interface {
|
||||
|
||||
@@ -1076,7 +1076,7 @@ func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (strin
|
||||
}
|
||||
|
||||
// UploadInvoice 回复用户发票申请
|
||||
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error) {
|
||||
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg, base64 string) ([]string, []string, error) {
|
||||
goodsOrder, err := partner.CurOrderManager.LoadOrder(param.OrderId, param.VendorID)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
||||
103
business/partner/purchase/jd/Invoice.go
Normal file
103
business/partner/purchase/jd/Invoice.go
Normal file
@@ -0,0 +1,103 @@
|
||||
package jd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"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"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/im"
|
||||
)
|
||||
|
||||
func (c *PurchaseHandler) GetOrderInvoice(vendorOrderId string, msg *jdapi.CallbackInvoiceMsg) (response *jdapi.CallbackResponse) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
a = getAPI(vendorOrderId)
|
||||
)
|
||||
|
||||
localOrder, _ := partner.CurOrderManager.LoadOrder(msg.BillID, model.VendorIDJD)
|
||||
if localOrder == nil {
|
||||
return jdapi.Err2CallbackResponse(fmt.Errorf("订单不存在:%s", msg.BillID), "jd invoice")
|
||||
}
|
||||
invoiceData, _ := dao.GetInvoiceInfo(db, msg.BillID)
|
||||
invoice, err := a.QueryInvoiceDetail(msg.BillID)
|
||||
if err != nil {
|
||||
return jdapi.Err2CallbackResponse(err, "query invoice err")
|
||||
}
|
||||
if invoiceData == nil {
|
||||
invoiceObj := &model.InvoiceMsg{
|
||||
ModelIDCUL: model.ModelIDCUL{},
|
||||
OrderId: utils.Int64ToStr(invoice.OrderId),
|
||||
StoreID: localOrder.JxStoreID,
|
||||
VendorID: model.VendorIDJD,
|
||||
Status: model.InvoiceStatusInit,
|
||||
InvoiceTaskId: utils.Int64ToStr(invoice.ApplyId),
|
||||
PushType: invoice.InvoiceType,
|
||||
InvoiceTitle: invoice.InvoiceTitle,
|
||||
TaxpayerId: invoice.ConsumerTaxId,
|
||||
NeedInvoiceByCategory: invoice.IvcContentType,
|
||||
CompanyAddress: invoice.ConsumerAddress,
|
||||
CompanyPhone: invoice.ConsumerPhone,
|
||||
AccountBank: invoice.ConsumerBankName,
|
||||
AccountNumber: invoice.ConsumerBankAccount,
|
||||
Email: invoice.CustomerEmail,
|
||||
InvoiceAmount: utils.Float64TwoInt64(invoice.ShouldInvoiceAmount * 100),
|
||||
InvoiceUrl: "",
|
||||
InvoiceId: "",
|
||||
}
|
||||
// 发票状态 1:待开票, 3:开票中, 4:开票成功, 5:开票失败, 6:冲红中, 7:冲红成功, 8:冲红失败, 9:已驳回, 11:蓝票审核失败, 12:红票审核失败, 13:待换开, 14:换开中, 15:换开驳回, 16:退款关闭, 17:驳回关闭
|
||||
switch invoice.InvoiceStatus {
|
||||
case 1:
|
||||
invoiceObj.Status = model.InvoiceStatusInit
|
||||
case 3, 6:
|
||||
invoiceObj.Status = model.InvoiceStatusBilling
|
||||
case 4, 7:
|
||||
invoiceObj.Status = model.InvoiceStatusBillingSuccess
|
||||
case 5, 8, 9, 11, 12, 15, 16, 17:
|
||||
invoiceObj.Status = model.InvoiceStatusBillingFail
|
||||
case 13, 14:
|
||||
invoiceObj.Status = utils.Int2Str(invoice.InvoiceStatus)
|
||||
}
|
||||
dao.WrapAddIDCULEntity(invoiceObj, "system")
|
||||
if err = dao.CreateEntity(db, invoiceObj); err != nil {
|
||||
return jdapi.Err2CallbackResponse(err, "CreateEntity invoice err")
|
||||
}
|
||||
} else {
|
||||
// 发票状态 1:待开票, 3:开票中, 4:开票成功, 5:开票失败, 6:冲红中, 7:冲红成功, 8:冲红失败, 9:已驳回, 11:蓝票审核失败, 12:红票审核失败, 13:待换开, 14:换开中, 15:换开驳回, 16:退款关闭, 17:驳回关闭
|
||||
switch invoice.InvoiceStatus {
|
||||
case 1:
|
||||
invoiceData.Status = model.InvoiceStatusInit
|
||||
case 3, 6:
|
||||
invoiceData.Status = model.InvoiceStatusBilling
|
||||
case 4, 7:
|
||||
invoiceData.Status = model.InvoiceStatusBillingSuccess
|
||||
case 5, 8, 9, 11, 12, 15, 16, 17:
|
||||
invoiceData.Status = model.InvoiceStatusBillingFail
|
||||
case 13, 14:
|
||||
invoiceData.Status = utils.Int2Str(invoice.InvoiceStatus)
|
||||
}
|
||||
invoiceData.UpdatedAt = utils.Str2Time(msg.Modified)
|
||||
dao.UpdateEntity(db, invoiceData, "Status", "UpdatedAt")
|
||||
|
||||
//invoiceData.InvoiceTaskId = utils.Int64ToStr(invoice.ApplyId)
|
||||
//invoiceData.PushType = invoice.InvoiceType
|
||||
//invoiceData.InvoiceTitle = invoice.InvoiceTitle
|
||||
//invoiceData.TaxpayerId = invoice.ConsumerTaxId
|
||||
//invoiceData.NeedInvoiceByCategory = invoice.IvcContentType
|
||||
//invoiceData.CompanyAddress = invoice.ConsumerAddress
|
||||
//invoiceData.CompanyPhone = invoice.ConsumerPhone
|
||||
//invoiceData.AccountBank = invoice.ConsumerBankName
|
||||
//invoiceData.AccountNumber = invoice.ConsumerBankAccount
|
||||
//invoiceData.Email = invoice.CustomerEmail
|
||||
//invoiceData.InvoiceAmount = utils.Float64TwoInt64(invoice.ShouldInvoiceAmount * 100)
|
||||
//dao.UpdateEntity(db, invoiceData)
|
||||
}
|
||||
|
||||
content2 := fmt.Sprintf("订单:%s,用户申请发票,请老板提供发票信息!", localOrder.VendorOrderID)
|
||||
im.PushMsgByCid(localOrder.VendorStoreID, localOrder.VendorID, content2)
|
||||
weixinmsg.SendStoreMessage(jxcontext.AdminCtx, fmt.Sprintf("京东用户申请发票:%s", localOrder.StoreName), content2, []int{localOrder.JxStoreID}, nil, "", model.MessageTypeStore, true, true)
|
||||
return jdapi.Err2CallbackResponse(nil, "")
|
||||
}
|
||||
@@ -31,3 +31,10 @@ func OnOrderInfoChangeMsg(msg *jdapi.CallbackOrderInfoChangeMsg) (retVal *jdapi.
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
func OnInvoiceMsg(msg *jdapi.CallbackInvoiceMsg) (retVal *jdapi.CallbackResponse) {
|
||||
if CurPurchaseHandler != nil {
|
||||
retVal = CurPurchaseHandler.GetOrderInvoice(AppKey2OrgCode(msg.AppKey), msg)
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
@@ -708,6 +708,29 @@ func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (strin
|
||||
}
|
||||
|
||||
// UploadInvoice 回复用户发票申请
|
||||
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error) {
|
||||
return nil, nil, nil
|
||||
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg, base64 string) ([]string, []string, error) {
|
||||
order, _ := partner.CurOrderManager.LoadOrder(param.OrderId, model.VendorIDJD)
|
||||
storeDetail, err := partner.CurOrderManager.LoadStoreDetail(order.JxStoreID, model.VendorIDJD)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if storeDetail == nil {
|
||||
return nil, nil, fmt.Errorf("未查询到门店[%d]", order.JxStoreID)
|
||||
}
|
||||
if storeDetail.LicenceCode == "" {
|
||||
return nil, nil, fmt.Errorf("未查询到门店营业执照编号,请天假门店营业执照信息[%s]", storeDetail.Name)
|
||||
}
|
||||
blue := &jdapi.BlueTicketParam{
|
||||
OrderId: order.VendorOrderID,
|
||||
ReceiverTaxNo: storeDetail.LicenceCode,
|
||||
ReceiverName: storeDetail.Name,
|
||||
InvoiceCode: param.InvoiceId,
|
||||
IvcTitle: "个人", // 4-个人,5-公司
|
||||
TotalPrice: utils.Float64ToStr(float64(param.InvoiceAmount) / float64(100)),
|
||||
InvoiceTime: utils.Time2DateStr(time.Now()),
|
||||
PdfInfo: base64,
|
||||
FullEleInvoiceNo: param.InvoiceId,
|
||||
}
|
||||
|
||||
return nil, nil, getAPI(order.VendorOrgCode).UploadBlueTicket(blue)
|
||||
}
|
||||
|
||||
@@ -345,6 +345,6 @@ func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (strin
|
||||
}
|
||||
|
||||
// UploadInvoice 回复用户发票申请
|
||||
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error) {
|
||||
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg, base64 string) ([]string, []string, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
@@ -1058,7 +1058,7 @@ func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (strin
|
||||
})
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error) {
|
||||
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg, base64 string) ([]string, []string, error) {
|
||||
goodsOrder, err := partner.CurOrderManager.LoadOrder(param.OrderId, param.VendorID)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
||||
@@ -1000,6 +1000,6 @@ func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (strin
|
||||
}
|
||||
|
||||
// UploadInvoice 回复用户发票申请
|
||||
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error) {
|
||||
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg, base64 string) ([]string, []string, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
@@ -1118,6 +1118,6 @@ func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (strin
|
||||
}
|
||||
|
||||
// UploadInvoice 回复用户发票申请
|
||||
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error) {
|
||||
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg, base64 string) ([]string, []string, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
@@ -124,6 +124,6 @@ func (c *PurchaseHandler) ApplyCompensationOrder(order *model.GoodsOrder) (strin
|
||||
}
|
||||
|
||||
// UploadInvoice 回复用户发票申请
|
||||
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg) ([]string, []string, error) {
|
||||
func (c *PurchaseHandler) UploadInvoice(param *model.InvoiceMsg, base64 string) ([]string, []string, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user