Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop
This commit is contained in:
@@ -323,12 +323,6 @@ func (c *DeliveryHandler) getBillParams(db *dao.DaoDB, order *model.GoodsOrder)
|
||||
}
|
||||
if billParams.ShopNo, err = c.getDadaShopID(order, db); err == nil {
|
||||
if billParams.CityCode, err = c.getDataCityCodeFromOrder(order, db); err == nil {
|
||||
// storeTel := ""
|
||||
// storeID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||
// storeDeatail, _ := dao.GetStoreDetail(db, storeID, order.VendorID)
|
||||
// if storeDeatail.Tel2 != "" {
|
||||
// storeTel = ",门店电话:" + storeDeatail.Tel2
|
||||
// }
|
||||
billParams.ReceiverLng, billParams.ReceiverLat, _ = jxutils.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType)
|
||||
billParams.Info = fmt.Sprintf("%s第%d号订单, %s", model.VendorChineseNames[order.VendorID], order.OrderSeq, utils.FilterMb4("客户电话:"+order.ConsigneeMobile+","+order.BuyerComment+"配送遇到问题,可联系18048531223取消配送单。"))
|
||||
billParams.CargoType = dadaapi.CargoTypeFresh
|
||||
@@ -339,7 +333,7 @@ func (c *DeliveryHandler) getBillParams(db *dao.DaoDB, order *model.GoodsOrder)
|
||||
return billParams, err
|
||||
}
|
||||
|
||||
// IDeliveryPlatformHandler
|
||||
// CreateWaybill IDeliveryPlatformHandler
|
||||
func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
|
||||
db := dao.GetDB()
|
||||
|
||||
|
||||
@@ -18,13 +18,11 @@ const (
|
||||
warningWeight = 50 * 1000 // 克
|
||||
// maxDiffFee2Mtps = 200 // 与美团配送最多差价
|
||||
// maxAddFee = 200 // 最大增加费用,单位为分,超过不发三方配送了
|
||||
defMaxDeliveryFee = 10000 // 创建运单最高价
|
||||
alarmFee = 1500 // 配送费报警阈值
|
||||
)
|
||||
|
||||
func CallCreateWaybillPolicy(deliveryFee, maxDeliveryFee int64, order *model.GoodsOrder, waybillVendorID int) (err error) {
|
||||
if maxDeliveryFee <= 0 || maxDeliveryFee > defMaxDeliveryFee {
|
||||
maxDeliveryFee = defMaxDeliveryFee
|
||||
if maxDeliveryFee <= 0 || maxDeliveryFee > model.DefMaxDeliveryFee {
|
||||
maxDeliveryFee = model.DefMaxDeliveryFee
|
||||
}
|
||||
if deliveryFee > maxDeliveryFee {
|
||||
errStr := fmt.Sprintf("超最高限价, 所需运费:%s, 最高限价:%s", jxutils.IntPrice2StandardCurrencyString(deliveryFee), jxutils.IntPrice2StandardCurrencyString(maxDeliveryFee))
|
||||
@@ -139,8 +137,8 @@ func CalculateBillDeliveryFee(bill *model.Waybill) (deliveryFee, addFee int64) {
|
||||
// 日志提示检查订单运费
|
||||
func OnWaybillCreated(waybill *model.Waybill) {
|
||||
deliveryFee := int64(math.Max(float64(waybill.DesiredFee), float64(waybill.ActualFee)))
|
||||
if deliveryFee > alarmFee {
|
||||
if deliveryFee > model.AlarmFee {
|
||||
globals.SugarLogger.Infof("[运营]%s订单, orderID:%s, 成功创建%s运单:%s, 配送费:%s太高(大于%s),请知悉!", model.VendorChineseNames[waybill.OrderVendorID], waybill.VendorOrderID,
|
||||
model.VendorChineseNames[waybill.WaybillVendorID], waybill.VendorWaybillID, jxutils.IntPrice2StandardCurrencyString(deliveryFee), jxutils.IntPrice2StandardCurrencyString(alarmFee))
|
||||
model.VendorChineseNames[waybill.WaybillVendorID], waybill.VendorWaybillID, jxutils.IntPrice2StandardCurrencyString(deliveryFee), jxutils.IntPrice2StandardCurrencyString(model.AlarmFee))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,17 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment)
|
||||
}
|
||||
|
||||
if maxDeliveryFee == model.NO {
|
||||
// 获取配送费
|
||||
fee, err := c.GetWaybillFee(order)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if fee.DeliveryFee >= model.DefMaxDeliveryFee {
|
||||
return nil, fmt.Errorf("蜂鸟超最高限价, 所需运费:%s, 最高限价:%s", jxutils.IntPrice2StandardCurrencyString(fee.DeliveryFee), jxutils.IntPrice2StandardCurrencyString(model.DefMaxDeliveryFee))
|
||||
}
|
||||
}
|
||||
|
||||
// 蜂鸟入参结构体
|
||||
parameter := &fnpsapi.CreateOrderReqParam{
|
||||
PartnerOrderCode: order.VendorOrderID,
|
||||
|
||||
@@ -323,7 +323,7 @@ func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInf
|
||||
func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
|
||||
db := dao.GetDB()
|
||||
// 检查配送平台是否被禁用
|
||||
vendorOrgCode, err := dao.GetVendorOrgCode(db, model.VendorIDFengNiao, "", model.VendorOrgTypeDelivery)
|
||||
vendorOrgCode, err := dao.GetVendorOrgCode(db, model.VendorIDMTPS, "", model.VendorOrgTypeDelivery)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -331,6 +331,17 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment)
|
||||
}
|
||||
|
||||
globals.SugarLogger.Debugf("===================maxDeliveryFee := %d", maxDeliveryFee)
|
||||
if maxDeliveryFee == model.NO {
|
||||
fee, err := c.GetWaybillFee(order)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if fee.DeliveryFee >= model.DefMaxDeliveryFee {
|
||||
return nil, fmt.Errorf("美团配送超最高限价, 所需运费:%s, 最高限价:%s", jxutils.IntPrice2StandardCurrencyString(fee.DeliveryFee), jxutils.IntPrice2StandardCurrencyString(model.DefMaxDeliveryFee))
|
||||
}
|
||||
}
|
||||
|
||||
// 忽略坐标转换错误,即使是转换出错,也只能当成转换成功来处理,底层会有错误日志输出
|
||||
lngFloat, latFloat, _ := jxutils.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType)
|
||||
billParams := &mtpsapi.CreateOrderByShopParam{
|
||||
|
||||
@@ -89,6 +89,16 @@ func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee i
|
||||
return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment)
|
||||
}
|
||||
|
||||
if maxDeliveryFee == model.NO {
|
||||
fee, err := d.GetWaybillFee(order)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if fee.DeliveryFee >= model.DefMaxDeliveryFee {
|
||||
return nil, fmt.Errorf("顺丰超最高限价, 所需运费:%s, 最高限价:%s", jxutils.IntPrice2StandardCurrencyString(fee.DeliveryFee), jxutils.IntPrice2StandardCurrencyString(model.DefMaxDeliveryFee))
|
||||
}
|
||||
}
|
||||
|
||||
store, err := dao.GetStoreDetail(dao.GetDB(), getReallyStoreID(order.StoreID, order.JxStoreID), 0, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -139,6 +139,16 @@ func (d DeliveryHandler) IsErrStoreExist(err error) bool {
|
||||
}
|
||||
|
||||
func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
|
||||
if maxDeliveryFee == model.NO {
|
||||
fee, err := d.GetWaybillFee(order)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if fee.DeliveryFee >= model.DefMaxDeliveryFee {
|
||||
return nil, fmt.Errorf("顺丰超最高限价, 所需运费:%s, 最高限价:%s", jxutils.IntPrice2StandardCurrencyString(fee.DeliveryFee), jxutils.IntPrice2StandardCurrencyString(model.DefMaxDeliveryFee))
|
||||
}
|
||||
|
||||
}
|
||||
//获取门店老板详情
|
||||
storeOwner, err := dao.GetStoreDetail(dao.GetDB(), getReallyStoreID(order.StoreID, order.JxStoreID), 0, "")
|
||||
if err != nil {
|
||||
|
||||
@@ -397,10 +397,12 @@ func (c *PrinterHandler) UnregisterPrinter(ctx *jxcontext.Context, machineCode,
|
||||
func (c *PrinterHandler) BindPrinter(ctx *jxcontext.Context, mapData map[string]interface{}) (bindResult *partner.BindPrinterResult, err error) {
|
||||
machineCode := utils.Interface2String(mapData["machineCode"])
|
||||
qrKey := utils.Interface2String(mapData["qrKey"])
|
||||
if machineCode == "" || qrKey == "" {
|
||||
msign := utils.Interface2String(mapData["msign"])
|
||||
if machineCode == "" || (qrKey == "" && msign == "") {
|
||||
return nil, fmt.Errorf("易联云扫描数据格式不正确")
|
||||
}
|
||||
tokenInfo, err := api.YilianyunAPI2.GetPrinterToken(machineCode, qrKey)
|
||||
|
||||
tokenInfo, err := api.YilianyunAPI2.GetPrinterToken(machineCode, qrKey, msign)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package jd
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
func OnOrderMsg(msg *jdapi.CallbackOrderMsg, a *jdapi.API) (retVal *jdapi.CallbackResponse) {
|
||||
@@ -21,6 +23,7 @@ func OnWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) (retVal *jdapi.CallbackR
|
||||
func OnStoreMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
if CurPurchaseHandler != nil {
|
||||
retVal = CurPurchaseHandler.OnStoreMsg(AppKey2OrgCode(msg.AppKey), msg)
|
||||
globals.SugarLogger.Debugf("retVal========= %s", utils.Format4Output(retVal, false))
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
@@ -142,12 +142,10 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
if err = dao.GetRows(db, &stores, sql, model.VendorIDJD, utils.DefaultTimeValue, storeID); err == nil {
|
||||
for _, store := range stores {
|
||||
a := getAPI(store.VendorOrgCode)
|
||||
// phone := ""
|
||||
// if store.MarketManPhone != "" {
|
||||
// phone = store.MarketManPhone
|
||||
// } else {
|
||||
// phone = model.VendorStoreTel
|
||||
// }
|
||||
if store.Status == model.StoreStatusDisabled {
|
||||
continue
|
||||
}
|
||||
|
||||
storeParams := &jdapi.OpStoreParams{
|
||||
StationNo: store.VendorStoreID,
|
||||
Operator: userName,
|
||||
@@ -339,6 +337,7 @@ func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorOrgCode s
|
||||
|
||||
// 当前京东的storeCrud消息不会在门店状态改变时发送,所以意义不大,先放在这里
|
||||
func (c *PurchaseHandler) OnStoreMsg(vendorOrgCode string, msg *jdapi.CallbackOrderMsg) (response *jdapi.CallbackResponse) {
|
||||
globals.SugarLogger.Debugf("OnStoreMsg========= %s", utils.Format4Output(msg, false))
|
||||
var err error
|
||||
if msg.StatusID == jdapi.StatusIDUpdateStore {
|
||||
var storeStatus int
|
||||
|
||||
@@ -900,31 +900,34 @@ func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string)
|
||||
return "", err
|
||||
}
|
||||
|
||||
func UpdateBoxPrice(ctx *jxcontext.Context, db *dao.DaoDB, storeId int) error {
|
||||
storeDetail, err := dao.GetStoreDetail(db, storeId, model.VendorIDMTWM, "")
|
||||
type SetBoxPrice struct {
|
||||
StoreId int `json:"store_id"` // 门店id
|
||||
SkuId int `json:"sku_id"` // 商品id
|
||||
BoxPrice float64 `json:"box_price"` // 打包价格
|
||||
}
|
||||
|
||||
func UpdateBoxPrice(ctx *jxcontext.Context, db *dao.DaoDB, list []*SetBoxPrice) error {
|
||||
storeDetail, err := dao.GetStoreDetail(db, list[0].StoreId, model.VendorIDMTWM, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
storeSkuList, err := dao.GetStoresSkusInfo(db, []int{storeId}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//storeSkuList, err := dao.GetStoresSkusInfo(db, []int{list[0].StoreId}, nil)
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
|
||||
api := getAPI(storeDetail.VendorOrgCode, storeId, storeDetail.VendorStoreID)
|
||||
api := getAPI(storeDetail.VendorOrgCode, list[0].StoreId, storeDetail.VendorStoreID)
|
||||
foodDataList := make([]map[string]interface{}, 0)
|
||||
for _, v := range storeSkuList {
|
||||
if v.MtwmID != model.NO {
|
||||
continue
|
||||
}
|
||||
for _, v := range list {
|
||||
|
||||
foodDataList = append(foodDataList, map[string]interface{}{
|
||||
"app_spu_code": utils.Int2Str(v.SkuID),
|
||||
"app_spu_code": utils.Int2Str(v.SkuId),
|
||||
"skus": []map[string]interface{}{
|
||||
{
|
||||
"sku_id": utils.Int2Str(v.SkuID),
|
||||
"ladder_box_num": "0",
|
||||
"ladder_box_price": "0",
|
||||
"sku_id": utils.Int2Str(v.SkuId),
|
||||
"ladder_box_num": "1",
|
||||
"ladder_box_price": utils.Float64ToStr(v.BoxPrice),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user