This commit is contained in:
suyl
2021-06-02 18:28:38 +08:00
parent c219481ad5
commit 34e3dc9910
8 changed files with 95 additions and 39 deletions

View File

@@ -226,7 +226,6 @@ func (c *BaseScheduler) AgreeOrRefuseRefund(ctx *jxcontext.Context, afsOrderID s
for _, sku := range order.Skus {
skuMap[sku.SkuID] = sku
}
storeDetail, _ := dao.GetStoreDetail(db, jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, "")
waybills, _ := dao.GetWaybills(db, order.VendorOrderID)
//京东商城和京西要重新算totalshopmoney等
if order.VendorID == model.VendorIDJDShop || order.VendorID == model.VendorIDJX {
@@ -238,9 +237,9 @@ func (c *BaseScheduler) AgreeOrRefuseRefund(ctx *jxcontext.Context, afsOrderID s
}
order.TotalShopMoney = utils.Float64TwoInt64(float64(float64(order.TotalShopMoney)/jdshopapi.JdsPayPercentage-float64(diff)) * jdshopapi.JdsPayPercentage)
if len(waybills) > 0 {
jxutils.RefreshOrderEarningPrice3(order, storeDetail.PayPercentage, waybills[0])
jxutils.RefreshOrderEarningPrice3(order, order.OrderPayPercentage, waybills[0])
} else {
jxutils.RefreshOrderEarningPrice2(order, storeDetail.PayPercentage)
jxutils.RefreshOrderEarningPrice2(order, order.OrderPayPercentage)
}
dao.UpdateEntity(db, order, "TotalShopMoney", "NewEarningPrice")
}

View File

@@ -1323,14 +1323,11 @@ func (s *DefScheduler) updateOrderByBill(order *model.GoodsOrder, bill *model.Wa
} else {
order.WaybillVendorID = bill.WaybillVendorID
order.VendorWaybillID = bill.VendorWaybillID
if bill.Status == model.WaybillStatusDelivered {
storeDetail, _ := partner.CurOrderManager.LoadStoreDetail(jxutils.GetSaleStoreIDFromOrder(order), order.VendorID)
if storeDetail != nil {
jxutils.RefreshOrderEarningPrice3(order, storeDetail.PayPercentage, bill)
if bill.DesiredFee != 0 {
jxutils.RefreshOrderEarningPrice3(order, order.OrderPayPercentage, bill)
updateFields = append(updateFields, "NewEarningPrice")
}
}
}
if revertStatus {
order.Status = model.OrderStatusFinishedPickup
updateFields = append(updateFields, "Status")

View File

@@ -2,6 +2,7 @@ package cms
import (
"bytes"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
@@ -4816,3 +4817,29 @@ func GetPageBrands(ctx *jxcontext.Context) (brands []*model.PageBrand, err error
dao.GetRows(db, &brands, sql)
return brands, err
}
func AddStoreMapAudit(ctx *jxcontext.Context, storeID, vendorID int, vendorOrgCode, vendorStoreID, vendorStoreName, vendorAccount, vendorPasswaord string) (err error) {
var (
db = dao.GetDB()
storeMapAudit = &model.StoreMapAudit{
StoreID: storeID,
VendorID: vendorID,
VendorOrgCode: vendorOrgCode,
VendorStoreID: vendorStoreID,
VendorStoreName: vendorStoreName,
VendorAccount: vendorAccount,
}
)
if vendorPasswaord != "" {
if configList, err := dao.QueryConfigs(db, "jxKeyIV", model.ConfigTypeSys, ""); err == nil && len(configList) > 0 {
aesKey, iv := configList[0].Value, configList[0].Value
if data, err2 := utils.AESCBCEncpryt([]byte(vendorPasswaord), []byte(aesKey), []byte(iv)); err2 == nil {
vendorPasswaord = base64.StdEncoding.EncodeToString(data)
}
}
storeMapAudit.VendorPasswaord = vendorPasswaord
}
dao.WrapAddIDCULDEntity(storeMapAudit, ctx.GetUserName())
dao.CreateEntity(db, storeMapAudit)
return err
}

View File

@@ -25,9 +25,9 @@ const (
StoreAuditStatusUpdated = 2
StoreAuditStatusAll = -9
StoreMapAuditStatusWait = 1 //待审核
StoreMapAuditStatusPass = 2 //审核通过
StoreMapAuditStatusUnPass = 3 //审核不通过
StoreMapAuditStatusWait = 0 //待审核
StoreMapAuditStatusPass = 1 //审核通过
StoreMapAuditStatusUnPass = -1 //审核不通过
)
const (
@@ -894,3 +894,27 @@ func (v *StoreManageState) TableUnique() [][]string {
[]string{"StoreID", "VendorID"},
}
}
type StoreMapAudit struct {
ModelIDCULD
StoreID int `orm:"column(store_id)" json:"storeID"`
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"`
VendorStoreName string `orm:"size(255)" json:"vendorStoreName"` //平台门店名,由京西到平台
VendorAccount string `orm:"size(255)" json:"vendorAccount"` //商户在平台上的账号(授权用
VendorPasswaord string `orm:"size(255)" json:"vendorPasswaord"` //商户在平台上的密码( aes cbc base64后的
AuditStatus int `json:"auditStatus"` //审核状态(授权状态
AuditAt time.Time `json:"auditAt"` //审核时间
AuditOperator string `json:"auditOperator"` //审核人
Comment string `orm:"size(255)" json:"comment"` //备注(审核不通过原因
}
func (v *StoreMapAudit) TableIndex() [][]string {
return [][]string{
[]string{"StoreID", "VendorStoreID"},
}
}

View File

@@ -78,7 +78,6 @@ func (c *PurchaseHandler) updateOrderFinancialInfo(a *jdapi.API, orderID string)
if err == nil {
if orderSettlement != nil {
updateOrderBySettleMent(order, orderSettlement)
globals.SugarLogger.Debugf("updateOrderBySettleMent: %v , %v", order.NewEarningPrice, order.TotalShopMoney)
err = partner.CurOrderManager.UpdateOrderFields(order, []string{ /*"WaybillTipMoney", */ "TotalShopMoney", "PmSubsidyMoney", "NewEarningPrice"})
}
}
@@ -178,18 +177,11 @@ func updateOrderBySettleMent(order *model.GoodsOrder, orderSettlement *jdapi.Ord
order.TotalShopMoney = orderSettlement.SettlementAmount
order.PmSubsidyMoney = orderSettlement.PlatOrderGoodsDiscountMoney + orderSettlement.PlatSkuGoodsDiscountMoney
if order.TotalShopMoney > 0 {
if jxutils.GetSaleStoreIDFromOrder(order) != 0 {
storeDetail, err := partner.CurOrderManager.LoadStoreDetail(jxutils.GetSaleStoreIDFromOrder(order), order.VendorID)
if storeDetail != nil && err == nil {
jxutils.RefreshOrderEarningPrice2(order, storeDetail.PayPercentage)
}
if order2, _ := partner.CurOrderManager.LoadOrder(order.VendorOrderID, order.VendorID); order2 != nil {
if order2.EarningType == model.EarningTypePoints {
order.NewEarningPrice = order.TotalShopMoney * int64((100 - order2.OrderPayPercentage/2)) / 100
} else {
order2, err := partner.CurOrderManager.LoadOrder(order.VendorOrderID, order.VendorID)
if order2 != nil && err == nil {
storeDetail, err := partner.CurOrderManager.LoadStoreDetail(jxutils.GetSaleStoreIDFromOrder(order2), order.VendorID)
if storeDetail != nil && err == nil {
jxutils.RefreshOrderEarningPrice2(order, storeDetail.PayPercentage)
}
order.NewEarningPrice = order2.EarningPrice
}
}
} else {

View File

@@ -214,19 +214,6 @@ func (c *StoreController) AddStoreVendorMap() {
})
}
// @Title 商户新增门店映射信息
// @Description 商户新增门店映射信息
// @Param token header string true "认证token"
// @Param storeID formData int true "门店IDpayload中的相应字段会被忽略"
// @Param vendorID formData int true "厂商IDpayload中的相应字段会被忽略"
// @Param vendorOrgCode formData string false "厂商内组织代码"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /AddStoreVendorMapByUser [post]
func (c *StoreController) AddStoreVendorMapByUser() {
}
// @Title 删除门店映射信息
// @Description 删除门店映射信息
// @Param token header string true "认证token"
@@ -1111,3 +1098,23 @@ func (c *StoreController) UpdateVendorStoreBussinessStatus() {
return retVal, "", err
})
}
// @Title 商户申请授权绑定
// @Description 商户申请授权绑定
// @Param token header string true "认证token"
// @Param storeID formData int true "门店IDpayload中的相应字段会被忽略"
// @Param vendorID formData int true "厂商IDpayload中的相应字段会被忽略"
// @Param vendorOrgCode formData string false "厂商内组织代码"
// @Param vendorStoreID formData string false "平台门店ID"
// @Param vendorStoreName formData string false "平台门店名"
// @Param vendorAccount formData string true "平台账号"
// @Param vendorPasswaord formData string false "平台账号密码"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /AddStoreMapAudit [post]
func (c *StoreController) AddStoreMapAudit() {
c.callAddStoreMapAudit(func(params *tStoreAddStoreMapAuditParams) (retVal interface{}, errCode string, err error) {
err = cms.AddStoreMapAudit(params.Ctx, params.StoreID, params.VendorID, params.VendorOrgCode, params.VendorStoreID, params.VendorStoreName, params.VendorAccount, params.VendorPasswaord)
return retVal, "", err
})
}

View File

@@ -38,6 +38,7 @@ func Init() {
orm.RegisterModel(&model.VendorCategoryMap{}) //平台分类
orm.RegisterModel(&model.StoreSkuBindHistory{})
orm.RegisterModel(&model.StoreSkuAudit{})
orm.RegisterModel(&model.StoreMapAudit{}) //商户申请授权绑定
orm.RegisterModel(&model.SkuCategory{})
orm.RegisterModel(&model.ThingMap{})
orm.RegisterModel(&model.SkuExinfoMap{})

View File

@@ -2097,6 +2097,15 @@ func init() {
Filters: nil,
Params: nil})
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
web.ControllerComments{
Method: "AddStoreMapAudit",
Router: `/AddStoreMapAudit`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
web.ControllerComments{
Method: "AddStoreCategoryMap",