1
This commit is contained in:
@@ -63,17 +63,17 @@ var (
|
||||
}
|
||||
refreshPageActTimeList = []string{
|
||||
"7:00:00",
|
||||
"8:00:00",
|
||||
//"8:00:00",
|
||||
"9:00:00",
|
||||
"10:00:00",
|
||||
//"10:00:00",
|
||||
"11:00:00",
|
||||
"12:00:00",
|
||||
//"12:00:00",
|
||||
"13:00:00",
|
||||
"14:00:00",
|
||||
//"14:00:00",
|
||||
"15:00:00",
|
||||
"16:00:00",
|
||||
//"16:00:00",
|
||||
"17:00:00",
|
||||
"18:00:00",
|
||||
//"18:00:00",
|
||||
"19:00:00",
|
||||
"22:00:00",
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -229,6 +229,21 @@ func (c *DjswController) OrderInfoChange() {
|
||||
}
|
||||
}
|
||||
|
||||
// ApplyOrderInvoiceStatus 发票申请
|
||||
func (c *DjswController) ApplyOrderInvoiceStatus() {
|
||||
if c.Ctx.Input.Method() == http.MethodPost {
|
||||
callbackResponse := c.handleMsg(func(a *jdapi.API, obj interface{}) (callbackResponse *jdapi.CallbackResponse) {
|
||||
callbackResponse = jd.OnInvoiceMsg(obj.(*jdapi.CallbackInvoiceMsg))
|
||||
return callbackResponse
|
||||
})
|
||||
callbackResponse = jdapi.Err2CallbackResponse(nil, "")
|
||||
c.Data["json"] = c.transferResponse("StoreCrud", callbackResponse)
|
||||
c.ServeJSON()
|
||||
} else {
|
||||
c.Abort("404")
|
||||
}
|
||||
}
|
||||
|
||||
//免费开卡接不到回调
|
||||
//func (c *DjswController) MemberCreateCard() {
|
||||
// if c.Ctx.Input.Method() == http.MethodPost {
|
||||
|
||||
@@ -1527,6 +1527,7 @@ func (c *OrderController) GetInvoiceRecord() {
|
||||
// @Param orderId formData string true "订单ID"
|
||||
// @Param invoiceUrl formData string true "发票地址[10M内pdf/png/jpeg/jpg]"
|
||||
// @Param invoiceId formData string true "发票号码"
|
||||
// @Param imgBase64 formData string false "京东发票pdf二进制文件流"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UploadOrderInvoice [post]
|
||||
@@ -1542,7 +1543,7 @@ func (c *OrderController) UploadOrderInvoice() {
|
||||
invoice.InvoiceUrl = params.InvoiceUrl
|
||||
invoice.InvoiceId = params.InvoiceId
|
||||
handler, _ := partner.GetPurchasePlatformFromVendorID(invoice.VendorID).(partner.IPurchasePlatformStoreSkuHandler)
|
||||
success, _, err := handler.UploadInvoice(invoice)
|
||||
success, _, err := handler.UploadInvoice(invoice, params.ImgBase64)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
@@ -1555,6 +1556,7 @@ func (c *OrderController) UploadOrderInvoice() {
|
||||
invoice.Status = model.InvoiceStatusBillingSuccess
|
||||
}
|
||||
}
|
||||
case model.VendorIDJD:
|
||||
|
||||
}
|
||||
dao.UpdateEntity(db, invoice, "InvoiceUrl", "InvoiceId", "Status")
|
||||
|
||||
@@ -154,8 +154,6 @@ func (c *MtwmController) Invoice() {
|
||||
return
|
||||
}
|
||||
|
||||
//ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "MtwmController发票推送", utils.Format4Output(msg, false))
|
||||
globals.SugarLogger.Debugf("-----Invoice:data %s", utils.Format4Output(msg, false))
|
||||
data := &mtwmapi.InvoiceCallback{}
|
||||
utils.Map2StructByJson(utils.URLValues2Map(msg.FormData), data, false)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user