sfps
This commit is contained in:
@@ -122,3 +122,14 @@ func (a *Auther) getAPI() *weixinapi.API {
|
||||
func (a *Auther) GetUserType() (userType int8) {
|
||||
return model.UserTypeStoreBoss
|
||||
}
|
||||
|
||||
func GetAPI(appID string) *weixinapi.API {
|
||||
miniApi := api.WeixinMiniAPI
|
||||
if len(appID) > 0 && appID == api.WeixinMiniAppID2 {
|
||||
miniApi = api.WeixinMiniAPI2
|
||||
}
|
||||
if len(appID) > 0 && appID == api.WeixinMiniAppIDsc {
|
||||
miniApi = api.WeixinMiniAPIsc
|
||||
}
|
||||
return miniApi
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ func LoadingLogistics(paramLogistic []*model.UpdateMaterialLogistic) []error {
|
||||
}
|
||||
|
||||
// 获取当前订单运单状态
|
||||
wayBill, err := dao.GetWaybills(db, logistics.OrderId)
|
||||
wayBill, err := dao.GetWaybills(db, logistics.OrderId, nil)
|
||||
if err != nil {
|
||||
errList = append(errList, err)
|
||||
continue
|
||||
|
||||
@@ -3,15 +3,15 @@ package auto_delivery
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/json"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"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/globals"
|
||||
)
|
||||
|
||||
@@ -92,75 +92,84 @@ func AutoSettingFakeDelivery() {
|
||||
}
|
||||
|
||||
// 获取刷单门店订单
|
||||
orderList, err := dao.GetOrderListByStoreList(db, utils.StringSlice2Int64(strings.Split(configList[0].Value, ",")))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Errorf("获取门店刷单记录错误")
|
||||
return
|
||||
}
|
||||
if len(orderList) == model.NO {
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range orderList {
|
||||
//jxutils.CallMsgHandler(func() {
|
||||
// 1.根据订单客户地址获取骑手列表
|
||||
riderKey := ""
|
||||
if strings.Contains(v.ConsigneeAddress, "重庆") || strings.Contains(v.ConsigneeAddress, "上海") || strings.Contains(v.ConsigneeAddress, "北京") {
|
||||
riderKey = strings.Split(v.ConsigneeAddress, "市")[0]
|
||||
} else if strings.Contains(v.ConsigneeAddress, "省") {
|
||||
riderKey = strings.Split(v.ConsigneeAddress, "省")[0]
|
||||
} else {
|
||||
storeDetail, _ := dao.GetStoreDetail(db, v.JxStoreID, 0, "")
|
||||
if strings.Contains(storeDetail.Address, "重庆") || strings.Contains(storeDetail.Address, "上海") || strings.Contains(storeDetail.Address, "北京") {
|
||||
riderKey = strings.Split(storeDetail.Address, "市")[0]
|
||||
} else {
|
||||
riderKey = strings.Split(storeDetail.Address, "省")[0]
|
||||
}
|
||||
}
|
||||
|
||||
if len(riderListInfo[riderKey]) == model.NO {
|
||||
// 骑手列表
|
||||
configRiderList, err := dao.QueryConfigs(db, "riderList", "Sys", "")
|
||||
if err != nil {
|
||||
globals.SugarLogger.Errorf("抖音自动刷单获取骑手列表错误:%v", err)
|
||||
return
|
||||
}
|
||||
if err := json.Unmarshal([]byte(configRiderList[0].Value), &riderListInfo); err != nil {
|
||||
globals.SugarLogger.Errorf("抖音自动刷单获取骑手列表错误:%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
randNumber, _ := rand.Int(rand.Reader, big.NewInt(int64(len(riderListInfo[riderKey]))))
|
||||
randTime := randNumber.Int64()
|
||||
if randTime < 0 {
|
||||
randTime = 1
|
||||
}
|
||||
if randTime >= int64(len(riderListInfo[riderKey])) {
|
||||
randTime = int64(len(riderListInfo[riderKey])) - 1
|
||||
}
|
||||
if (v.PhoneAscription == "" || strings.Split(v.PhoneAscription, "-")[0] != model.PhoneAscriptionAddressYes) && v.VendorID == model.VendorIDDD {
|
||||
storeList := strings.Split(configList[0].Value, ",")
|
||||
for _, v := range storeList {
|
||||
storeIdAndVendorId := strings.Split(v, "-")
|
||||
orderList, err := dao.GetOrderListByStoreList(db, []int64{utils.Str2Int64(storeIdAndVendorId[0])}, utils.Str2Int(storeIdAndVendorId[1]))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Errorf("获取门店刷单记录错误")
|
||||
continue
|
||||
}
|
||||
// 自动拣货
|
||||
if v.Status < model.OrderStatusFinishedPickup { // 未拣货
|
||||
handler := partner.GetPurchaseOrderHandlerFromVendorID(v.VendorID)
|
||||
flag := model.IsOrderDeliveryByStore(v) || model.IsOrderDeliveryBySelf(v)
|
||||
if err := handler.PickupGoods(v, flag, jxcontext.AdminCtx.GetUserName()); err != nil {
|
||||
globals.SugarLogger.Errorf("自动拣货错误:[%v]", err)
|
||||
break
|
||||
if len(orderList) == model.NO {
|
||||
continue
|
||||
}
|
||||
|
||||
// 1.根据订单客户地址获取骑手列表
|
||||
riderKey := ""
|
||||
storeDetail, _ := dao.GetStoreDetail(db, utils.Str2Int(storeIdAndVendorId[0]), 0, "")
|
||||
if strings.Contains(storeDetail.Address, "重庆") || strings.Contains(storeDetail.Address, "上海") || strings.Contains(storeDetail.Address, "北京") || strings.Contains(storeDetail.Address, "天津") {
|
||||
riderKey = strings.Split(storeDetail.Address, "市")[0]
|
||||
} else if strings.Contains(storeDetail.Address, "省") {
|
||||
riderKey = strings.Split(storeDetail.Address, "省")[0]
|
||||
} else {
|
||||
place, err := dao.GetParentCodeByCode(db, storeDetail.CityCode)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("根据门店的城市code获取省份code错误: %s", err)
|
||||
return
|
||||
}
|
||||
if strings.Contains(place.Name, "省") {
|
||||
riderKey = strings.Split(place.Name, "省")[0]
|
||||
} else {
|
||||
riderKey = strings.Split(place.Name, "市")[0]
|
||||
}
|
||||
}
|
||||
//自动发单
|
||||
if len(riderListInfo[riderKey]) == 0 {
|
||||
globals.SugarLogger.Errorf("riderListInfo[riderKey][randTime] :%s,%s,%d", riderListInfo[riderKey][randTime], riderKey, randTime)
|
||||
break
|
||||
}
|
||||
for riderName, riderPhone := range riderListInfo[riderKey][randTime] {
|
||||
if err := defsch.FixedScheduler.SelfDeliveringAndUpdateStatus(jxcontext.AdminCtx, v.VendorOrderID, v.VendorID, jxcontext.AdminCtx.GetUserName(), riderName, riderPhone); err != nil {
|
||||
globals.SugarLogger.Errorf("自动发货错误:[%v]", err)
|
||||
|
||||
for _, v := range orderList {
|
||||
if len(riderListInfo[riderKey]) == model.NO {
|
||||
// 骑手列表
|
||||
configRiderList, err := dao.QueryConfigs(db, "riderList", "Sys", "")
|
||||
if err != nil {
|
||||
globals.SugarLogger.Errorf("抖音自动刷单获取骑手列表错误:%v", err)
|
||||
return
|
||||
}
|
||||
if err := json.Unmarshal([]byte(configRiderList[0].Value), &riderListInfo); err != nil {
|
||||
globals.SugarLogger.Errorf("抖音自动刷单获取骑手列表错误:%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
randNumber, _ := rand.Int(rand.Reader, big.NewInt(int64(len(riderListInfo[riderKey]))))
|
||||
randTime := randNumber.Int64()
|
||||
if randTime < 0 {
|
||||
randTime = 1
|
||||
}
|
||||
if randTime >= int64(len(riderListInfo[riderKey])) {
|
||||
randTime = int64(len(riderListInfo[riderKey])) - 1
|
||||
}
|
||||
if (v.PhoneAscription == "" || strings.Split(v.PhoneAscription, "-")[0] != model.PhoneAscriptionAddressYes) && v.VendorID == model.VendorIDDD {
|
||||
continue
|
||||
}
|
||||
// 自动拣货
|
||||
if v.Status < model.OrderStatusFinishedPickup { // 未拣货
|
||||
handler := partner.GetPurchaseOrderHandlerFromVendorID(v.VendorID)
|
||||
flag := model.IsOrderDeliveryByStore(v) || model.IsOrderDeliveryBySelf(v)
|
||||
if err := handler.PickupGoods(v, flag, jxcontext.AdminCtx.GetUserName()); err != nil {
|
||||
globals.SugarLogger.Errorf("自动拣货错误:[%v]", err)
|
||||
break
|
||||
}
|
||||
}
|
||||
//自动发单
|
||||
if len(riderListInfo[riderKey]) == 0 {
|
||||
globals.SugarLogger.Errorf("riderListInfo[riderKey][randTime] :%s,%s,%d", riderListInfo[riderKey][randTime], riderKey, randTime)
|
||||
break
|
||||
}
|
||||
for riderName, riderPhone := range riderListInfo[riderKey][randTime] {
|
||||
if err := defsch.FixedScheduler.SelfDeliveringAndUpdateStatus(jxcontext.AdminCtx, v.VendorOrderID, v.VendorID, jxcontext.AdminCtx.GetUserName(), riderName, riderPhone); err != nil {
|
||||
globals.SugarLogger.Errorf("自动发货错误:[%v]", err)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
//}, jxutils.ComposeUniversalOrderID(v.VendorOrderID, model.VendorIDDD))
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -262,9 +262,6 @@ func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *m
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug("Get store Detail Err: ", err)
|
||||
}
|
||||
|
||||
//门店发单的订单,取消后要退回配送费
|
||||
ResetCreateWaybillFee(db, order)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,70 +450,225 @@ func filterOrderInfo(order *model.GoodsOrder) {
|
||||
order.ConsigneeAddress = strings.ReplaceAll(order.ConsigneeAddress, "·", "")
|
||||
}
|
||||
|
||||
func ResetCreateWaybillFee(db *dao.DaoDB, order *model.GoodsOrder) (err error) {
|
||||
// FinisOrderWaybillFee 订单完成时,计算结算信息
|
||||
func FinisOrderWaybillFee(db *dao.DaoDB, order *model.GoodsOrder, bill *model.Waybill) (err error) {
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
store, _ := dao.GetStoreDetail(db, jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, order.VendorOrgCode)
|
||||
if store != nil && store.CreateDeliveryType == model.YES { // 门店发单(非京西品牌)
|
||||
// 无运单不参与退款
|
||||
if order.VendorWaybillID == "" {
|
||||
if bill.WaybillVendorID != model.VendorIDMTPS && bill.WaybillVendorID != model.VendorIDDada && bill.WaybillVendorID != model.VendorIDFengNiao && bill.WaybillVendorID != model.VendorIDUUPT {
|
||||
return nil
|
||||
}
|
||||
// 查询所有运单
|
||||
bills, err := dao.GetWaybills(db, order.VendorOrderID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
store, _ := dao.GetStoreDetail(db, order.JxStoreID, order.VendorID, order.VendorOrgCode)
|
||||
// 正常来说只会出现一个完成运单,之前有bug会出现多个完成订单,这不做考虑.默认一个运单完成,其他运单取消状态
|
||||
// 1.完成当前运单的金额核算,正常完成的订单金额不需要核算
|
||||
// 2.取消运单的金额核算
|
||||
cancelWaybill := make(map[string]*model.Waybill, 0)
|
||||
for _, v := range bills {
|
||||
if v.Status != model.WaybillStatusCanceled {
|
||||
continue
|
||||
}
|
||||
if v.VendorWaybillID == bill.VendorWaybillID {
|
||||
continue
|
||||
}
|
||||
cancelWaybill[v.VendorWaybillID] = v
|
||||
}
|
||||
// 已经全部运单取消,退款结算
|
||||
for _, v := range bills {
|
||||
if v.VendorWaybillID == bill.VendorWaybillID {
|
||||
continue
|
||||
}
|
||||
// 已经取消订单的违约金计算
|
||||
if err = countWaybillSettleInfo(db, order, v, store); err != nil {
|
||||
return err
|
||||
}
|
||||
// 自配送不参与退款
|
||||
if order.VendorOrderID == order.VendorWaybillID {
|
||||
}
|
||||
|
||||
// 3.总的收支核算
|
||||
if err = orderFeeSettle(db, order, bill, bills, store); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ResetCreateWaybillFee 取消所有运单时计算结算信息
|
||||
func ResetCreateWaybillFee(db *dao.DaoDB, order *model.GoodsOrder, bill *model.Waybill) (err error) {
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
|
||||
if bill.WaybillVendorID != model.VendorIDMTPS && bill.WaybillVendorID != model.VendorIDDada && bill.WaybillVendorID != model.VendorIDFengNiao && bill.WaybillVendorID != model.VendorIDUUPT {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 获取订单运单详情列表
|
||||
store, _ := dao.GetStoreDetail(db, jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, order.VendorOrgCode)
|
||||
|
||||
// 订单被取消了,所有运单应该也被取消了,检查是否退还配送费
|
||||
// 1.查询订单创建的所有运单,三方配送运单(达达,蜂鸟,uu,美团配送),平台自配送订单不参与
|
||||
if err := countWaybillSettleInfo(db, order, bill, store); err != nil {
|
||||
return err
|
||||
}
|
||||
// 所有运单停止调度之后才开始退还余额
|
||||
bills, err := dao.GetWaybills(db, order.VendorOrderID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 所有取消的运单
|
||||
cancelWaybill := make(map[string]*model.Waybill, 0)
|
||||
for _, v := range bills {
|
||||
if v.Status == model.WaybillStatusCanceled && v.VendorWaybillID != bill.VendorWaybillID {
|
||||
cancelWaybill[v.VendorWaybillID] = v
|
||||
}
|
||||
}
|
||||
cancelWaybill[bill.VendorWaybillID] = bill
|
||||
// 已经全部运单取消,退款结算
|
||||
if len(bills) == len(cancelWaybill) {
|
||||
//for _, v := range bills {
|
||||
// if v.VendorWaybillID == bill.VendorWaybillID {
|
||||
// continue
|
||||
// }
|
||||
// // 已经取消订单的违约金计算
|
||||
// if err = countWaybillSettleInfo(db, order, v, store); err != nil {
|
||||
// return err
|
||||
// }
|
||||
//}
|
||||
|
||||
// 最终的金额核算,多退少补
|
||||
if err = orderFeeSettle(db, order, bill, bills, store); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// countWaybillSettleInfo 计算订单的结算信息
|
||||
func countWaybillSettleInfo(db *dao.DaoDB, order *model.GoodsOrder, bill *model.Waybill, store *dao.StoreDetail) error {
|
||||
if handlerInfo := partner.GetDeliveryPlatformFromVendorID(bill.WaybillVendorID); handlerInfo != nil {
|
||||
// 这一步必须要做,可能不是最后取消订单,需要更新违约金和取消状态
|
||||
deductFee, err := handlerInfo.Handler.GetDeliverLiquidatedDamages(bill.VendorOrderID, bill.VendorWaybillID)
|
||||
if err != nil {
|
||||
partner.CurOrderManager.OnOrderMsg(order, fmt.Sprintf("订单[%s],运单平台[%d],运单[%s]取消,获取违约金异常:%v", order.VendorOrderID, bill.WaybillVendorID, bill.VendorWaybillID, err), "")
|
||||
return err
|
||||
}
|
||||
|
||||
// 获取运单记录
|
||||
orderStatusList, err := GetOrderStatusList2(order.VendorOrderID, order.VendorWaybillID, 2, order.WaybillVendorID)
|
||||
if err = dao.UpdateWaybillActualFee(db, bill.VendorWaybillID, bill.VendorOrderID, deductFee, deductFee); err != nil {
|
||||
return err
|
||||
}
|
||||
// 门店发单,支付运单违约金
|
||||
if store != nil && store.CreateDeliveryType == model.YES && deductFee != model.NO {
|
||||
err = partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(jxcontext.AdminCtx, store.ID, int(deductFee), partner.StoreAcctTypeExpendCreateWaybillDeductFee, bill.VendorOrderID, bill.VendorWaybillID, 0)
|
||||
if err != nil {
|
||||
partner.CurOrderManager.OnOrderMsg(order, fmt.Sprintf("订单[%s],运单平台[%d],运单[%s]取消,获取违约金门店扣除失败:%v,金额[%d]", order.VendorOrderID, bill.WaybillVendorID, bill.VendorWaybillID, err, deductFee), "")
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if store != nil && store.CreateDeliveryType == model.NO && deductFee != model.NO {
|
||||
err = partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, int(deductFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeDeductFee, order.VendorOrderID, order.VendorWaybillID)
|
||||
if err != nil {
|
||||
partner.CurOrderManager.OnOrderMsg(order, fmt.Sprintf("订单[%s],运单平台[%d],运单[%s]取消,获取违约金品牌扣除失败:%v,金额[%d]", order.VendorOrderID, bill.WaybillVendorID, bill.VendorWaybillID, err, deductFee), "")
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
partner.CurOrderManager.OnOrderMsg(order, fmt.Sprintf("订单[%s],运单平台[%d],运单[%s]取消,违约金扣除成功:%d", order.VendorOrderID, bill.WaybillVendorID, bill.VendorWaybillID, deductFee), "")
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 订单金额核算
|
||||
func orderFeeSettle(db *dao.DaoDB, order *model.GoodsOrder, bill *model.Waybill, bills []*model.Waybill, store *dao.StoreDetail) (err error) {
|
||||
billExpend := 0
|
||||
billIncome := 0
|
||||
allFee := 0
|
||||
// 门店结算,全部支出
|
||||
if store.CreateDeliveryType == model.YES {
|
||||
// 此订单支出的费用
|
||||
expendType := []int{partner.StoreAcctTypeExpendCreateWaybillEx, partner.StoreAcctTypeExpendCreateWaybillTip, partner.StoreAcctTypeExpendCreateWaybill2ndMore, partner.StoreAcctTypeExpendCreateWaybillDeductFee, partner.StoreAcctTypeRealFeeExpend}
|
||||
billExpend, err = dao.GetStoreAcctExpendTotal(db, store.ID, expendType, bill.VendorOrderID, utils.ZeroTimeValue, utils.ZeroTimeValue)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Errorf("GetStoreAcctExpendTotal 545 err :%v", err)
|
||||
return err
|
||||
}
|
||||
// 此订单退还的费用
|
||||
incomeType := []int{partner.StoreAcctTypeRealFeeIncome, partner.StoreAcctTypeIncomeCancelTemp, partner.StoreAcctTypeIncomeCancelReal}
|
||||
billIncome, err = dao.GetStoreAcctIncomeTotal(db, store.ID, incomeType, bill.VendorOrderID, utils.ZeroTimeValue, utils.ZeroTimeValue)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Errorf("GetStoreAcctIncomeTotal 551 err :%v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
} else {
|
||||
billExpend, err = dao.GetBrandBillOrderExpend(db, store.BrandID, bill.VendorOrderID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
billIncome, err = dao.GetBrandBillOrderIncome(db, store.BrandID, bill.VendorOrderID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
isRefund := false // 默认可以退费
|
||||
for _, v := range orderStatusList {
|
||||
if order.WaybillVendorID == model.VendorIDMTPS && v.VendorStatus == "30" {
|
||||
isRefund = true
|
||||
break
|
||||
}
|
||||
if order.WaybillVendorID == model.VendorIDFengNiao && v.VendorStatus == "80" {
|
||||
isRefund = true
|
||||
break
|
||||
}
|
||||
if order.WaybillVendorID == model.VendorIDDada && v.VendorStatus == "3" {
|
||||
isRefund = true
|
||||
break
|
||||
for _, v := range bills {
|
||||
allFee += int(v.DesiredFee)
|
||||
allFee += int(v.TipFee)
|
||||
}
|
||||
// 运单支出费用统计,应该等于 支出费用- 退还费用
|
||||
globals.SugarLogger.Errorf("计算错误:订单支出费用应该=退还费用+运单支出费用,支出费用:%d,已经退还费用:%d,运单计算费用:%d", billExpend, billIncome, allFee)
|
||||
if allFee != billExpend-billIncome {
|
||||
globals.SugarLogger.Errorf("计算错误:订单支出费用应该=退还费用+运单支出费用,支出费用:%d,已经退还费用:%d,剩余退还费用:%d", billExpend, billIncome, billExpend-billIncome)
|
||||
}
|
||||
|
||||
if billExpend-billIncome == allFee {
|
||||
globals.SugarLogger.Debugf("计算正确,运单消耗[%d],账户支出[%d],账户退回[%d]", allFee, billExpend, billIncome)
|
||||
partner.CurOrderManager.OnOrderMsg(order, fmt.Sprintf("计算正确,运单消耗[%d],账户支出[%d],账户退回[%d]", allFee, billExpend, billIncome), "")
|
||||
return nil
|
||||
}
|
||||
|
||||
abnormalAmount := billExpend - billIncome - allFee
|
||||
switch store.CreateDeliveryType {
|
||||
case model.NO: // 品牌结算
|
||||
if abnormalAmount > 0 { // 多退
|
||||
err = partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, abnormalAmount, model.BrandBillTypeIncome, model.BrandBillFeeTypeDelivery, order.VendorOrderID, order.VendorWaybillID)
|
||||
if err != nil {
|
||||
partner.CurOrderManager.OnOrderMsg(order, fmt.Sprintf("订单[%s],运单平台[%d],运单[%s]取消,品牌支出大于消耗,多退:%v,金额[%d]", order.VendorOrderID, bill.WaybillVendorID, bill.VendorWaybillID, err, abnormalAmount), "")
|
||||
globals.SugarLogger.Errorf("InsertBrandBill 489 : %v", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if isRefund { // 骑手已经到店了,无法退款
|
||||
return errors.New("骑手已到店,无法退款")
|
||||
}
|
||||
|
||||
// 获取品牌的支付记录
|
||||
orderBill, _ := dao.GetBrandBill(db, store.BrandID, order.VendorOrderID, 0, model.BrandBillFeeTypeDelivery, order.VendorWaybillID)
|
||||
if len(orderBill) <= 0 {
|
||||
return errors.New("无记录,不退款")
|
||||
}
|
||||
for _, v := range orderBill {
|
||||
if v.BillType == model.BrandBillTypeIncome { // 已经退款了
|
||||
return errors.New("无法重复退款")
|
||||
if abnormalAmount < 0 {
|
||||
err = partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, abnormalAmount*-1, model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, order.VendorOrderID, order.VendorWaybillID)
|
||||
if err != nil {
|
||||
partner.CurOrderManager.OnOrderMsg(order, fmt.Sprintf("订单[%s],运单平台[%d],运单[%s]取消,品牌支出小于消耗,少补:%v,金额[%d]", order.VendorOrderID, bill.WaybillVendorID, bill.VendorWaybillID, err, abnormalAmount), "")
|
||||
globals.SugarLogger.Errorf("InsertBrandBill 489 : %v", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// 将支出记录修改为退款记录,支付类型为收入,且类型为三方配送时:退费
|
||||
newBill := &model.BrandBill{
|
||||
BrandID: store.BrandID,
|
||||
Price: orderBill[0].Price,
|
||||
BillType: model.BrandBillTypeIncome,
|
||||
FeeType: model.BrandBillFeeTypeDelivery,
|
||||
VendorOrderID: orderBill[0].VendorOrderID,
|
||||
OrderID: orderBill[0].OrderID,
|
||||
case model.YES: // 门店结算
|
||||
if abnormalAmount > 0 { // 多退
|
||||
err = partner.CurStoreAcctManager.InsertStoreAcctIncomeAndUpdateStoreAcctBalance(jxcontext.AdminCtx, store.ID, int(billExpend-billIncome-allFee), partner.StoreAcctTypeIncomeCancelReal, bill.VendorOrderID, bill.VendorWaybillID, 0)
|
||||
if err != nil {
|
||||
partner.CurOrderManager.OnOrderMsg(order, fmt.Sprintf("订单[%s],运单平台[%d],运单[%s]取消,支出大于消耗,多退:%v,金额[%d]", order.VendorOrderID, bill.WaybillVendorID, bill.VendorWaybillID, err, abnormalAmount), "")
|
||||
globals.SugarLogger.Errorf("InsertStoreAcctIncomeAndUpdateStoreAcctBalance 483 : %v", err)
|
||||
}
|
||||
}
|
||||
if abnormalAmount < 0 {
|
||||
err = partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(jxcontext.AdminCtx, store.ID, int(abnormalAmount)*-1, partner.StoreAcctTypeExpendCreateWaybill2ndMore, bill.VendorOrderID, bill.VendorWaybillID, 0)
|
||||
if err != nil {
|
||||
partner.CurOrderManager.OnOrderMsg(order, fmt.Sprintf("订单[%s],运单平台[%d],运单[%s]取消,支出小于消耗,少补:%v,金额[%d]", order.VendorOrderID, bill.WaybillVendorID, bill.VendorWaybillID, err, abnormalAmount), "")
|
||||
globals.SugarLogger.Errorf("InsertStoreAcctIncomeAndUpdateStoreAcctBalance 483 : %v", err)
|
||||
}
|
||||
}
|
||||
dao.WrapAddIDCULEntity(newBill, "系统退费")
|
||||
err = dao.CreateEntity(db, newBill)
|
||||
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -1342,7 +1494,7 @@ func MergeJdsOrders(ctx *jxcontext.Context, vendorOrderIDs []string) (vendorOrde
|
||||
for _, order := range orders {
|
||||
var waybill *model.Waybill
|
||||
//将订单和运单取消
|
||||
waybills, err := dao.GetWaybills(db, order.VendorOrderID)
|
||||
waybills, err := dao.GetWaybills(db, order.VendorOrderID, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -1475,7 +1627,7 @@ func TransferJdsOrder(ctx *jxcontext.Context, vendorOrderID string, storeID int)
|
||||
return "", fmt.Errorf("未查询到该订单商品!订单号:[%v]", vendorOrderID)
|
||||
}
|
||||
//将订单和运单取消
|
||||
waybills, err := dao.GetWaybills(db, vendorOrderID)
|
||||
waybills, err := dao.GetWaybills(db, vendorOrderID, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -1656,7 +1808,7 @@ func SendJdwlForJdsOrder(ctx *jxcontext.Context, vendorOrderID string) (err erro
|
||||
return fmt.Errorf("订单当前状态不支持创建!")
|
||||
}
|
||||
waybill := &model.Waybill{}
|
||||
waybills, err := dao.GetWaybills(db, vendorOrderID)
|
||||
waybills, err := dao.GetWaybills(db, vendorOrderID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -336,11 +336,7 @@ func (c *OrderManager) GetOrders(ctx *jxcontext.Context, isIncludeFake bool, fro
|
||||
}
|
||||
}
|
||||
}
|
||||
//if isJxIncomeArea {
|
||||
// begin = utils.MustInterface2Int64(params["jxIncomeBegin"])
|
||||
// end = utils.MustInterface2Int64(params["jxIncomeEnd"])
|
||||
//pageSize = math.MaxInt32
|
||||
//}
|
||||
|
||||
orders, totalCount, err := dao.GetOrders(db, nil, false, isIncludeFake, fromDateStr, toDateStr, isDateFinish, skuIDs, isJxFirst, "", params, offset, pageSize)
|
||||
if err == nil {
|
||||
pagedInfo = &model.PagedInfo{
|
||||
@@ -382,24 +378,15 @@ func (c *OrderManager) GetOrders(ctx *jxcontext.Context, isIncludeFake bool, fro
|
||||
}
|
||||
}
|
||||
}
|
||||
//count := &struct {
|
||||
// Count int
|
||||
//}{}
|
||||
//sql2 := `
|
||||
// SELECT COUNT(*) count
|
||||
// FROM goods_order WHERE IF(store_id = 0, jx_store_id ,store_id) = ?
|
||||
// WHERE order_created_at > ? AND order_created_at < ?
|
||||
//`
|
||||
//storeID := 0
|
||||
//if order.StoreID == 0 {
|
||||
// storeID = order.JxStoreID
|
||||
//} else {
|
||||
// storeID = order.StoreID
|
||||
//}
|
||||
//sqlParams2 := []interface{}{storeID, time.Now().Format("2006-01-02 00:00:00"), time.Now().Format("2006-01-02 23:59:59")}
|
||||
//if err = dao.GetRow(db, &count, sql2, sqlParams2); err == nil {
|
||||
// order.StoreDayOrderCount = count.Count
|
||||
//}
|
||||
// 统计订单的违约金
|
||||
var damages = &struct {
|
||||
Damages int64 `json:"damages"`
|
||||
}{}
|
||||
sqlDamages := ` SELECT SUM(w.desired_fee) damages FROM waybill w WHERE w.vendor_order_id = ? AND w.status = ? `
|
||||
paramDamages := []interface{}{order.VendorOrderID, model.OrderStatusCanceled}
|
||||
if err := dao.GetRow(db, damages, sqlDamages, paramDamages); err == nil {
|
||||
order.LiquidatedDamages = damages.Damages
|
||||
}
|
||||
return retVal, err
|
||||
}, orders)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
@@ -515,6 +502,15 @@ func (c *OrderManager) ExportOrders(ctx *jxcontext.Context, fromDateStr, toDateS
|
||||
v.CourierVendorName = model.VendorChineseNames[v.WaybillVendorID]
|
||||
v.Status2 = model.OrderStatusName[v.Status]
|
||||
v.SkuInfo = skuStr
|
||||
// 统计订单的违约金
|
||||
var damages = &struct {
|
||||
Damages int64 `json:"damages"`
|
||||
}{}
|
||||
sqlDamages := ` SELECT SUM(w.desired_fee) damages FROM waybill w WHERE w.vendor_order_id = ? AND w.status = ? `
|
||||
paramDamages := []interface{}{v.VendorOrderID, model.OrderStatusCanceled}
|
||||
if err := dao.GetRow(dao.GetDB(), damages, sqlDamages, paramDamages); err == nil {
|
||||
v.LiquidatedDamages = damages.Damages
|
||||
}
|
||||
orders2 = append(orders2, v)
|
||||
} else {
|
||||
order.SkuInfo += ";" + skuStr
|
||||
@@ -555,6 +551,7 @@ func (c *OrderManager) ExportOrders(ctx *jxcontext.Context, fromDateStr, toDateS
|
||||
"courierMobile",
|
||||
"courierMobile",
|
||||
"desiredFee",
|
||||
"liquidated_damages",
|
||||
"waybillCreatedAt",
|
||||
"waybillFinishedAt",
|
||||
"status2",
|
||||
@@ -715,6 +712,24 @@ func (c *OrderManager) GetLogisticsOrderStatusList(orderId, LogisticsId string,
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetWayBillStatusList 根据订单号和物流号查询运单的变化状态
|
||||
func (c *OrderManager) GetWayBillStatusList(orderId, LogisticsId string, vendorId int) ([]*model.OrderStatus, error) {
|
||||
sql := `SELECT *
|
||||
FROM order_status t1
|
||||
WHERE t1.vendor_order_id = ? AND t1.ref_vendor_order_id = ? AND t1.vendor_id = ?`
|
||||
sqlParams := []interface{}{
|
||||
LogisticsId,
|
||||
orderId,
|
||||
vendorId,
|
||||
}
|
||||
sql += ` ORDER BY status_time ASC `
|
||||
var result []*model.OrderStatus
|
||||
if err := dao.GetRows(dao.GetDB(), &result, sql, sqlParams...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetOrderStatusList2 查询订单流程 refVendorOrderID 订单Id
|
||||
func GetOrderStatusList2(refVendorOrderID string, wayBillId string, orderType int, vendorID int) (statusList []*model.OrderStatus, err error) {
|
||||
sql := `
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
@@ -216,28 +215,31 @@ func (c *BaseScheduler) CreateWaybill(platformVendorID int, order *model.GoodsOr
|
||||
// }
|
||||
|
||||
storeDetail, _ := dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, order.VendorOrgCode)
|
||||
// 获取门店品牌余额
|
||||
storeAcct, err := cms.GetStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order)) // 获取门店余额
|
||||
// 如果门店没钱,查看品牌,查询门店品牌id
|
||||
result, err := partner.CurStoreAcctManager.GetBrandBalance(storeDetail.BrandID) // 品牌余额
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//result, err := partner.CurStoreAcctManager.GetBrandBalance(storeDetail.BrandID) // 品牌余额
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
var balance int
|
||||
|
||||
// 门店发单,如果是京西门店,直接使用京西余额,非京西门店使用门店余额,余额不足使用品牌余额!
|
||||
if order.CreateDeliveryType == model.YES {
|
||||
if storeDetail.BrandID == scheduler.JXC4B_SHOP || storeDetail.BrandID == scheduler.JXC4B_RAND_JXGY { // 京西品牌,扣门店
|
||||
balance = storeAcct.AccountBalance
|
||||
} else {
|
||||
if storeAcct.AccountBalance >= model.BrandBalanceLimit {
|
||||
balance = storeAcct.AccountBalance
|
||||
} else if storeAcct.AccountBalance < model.BrandBalanceLimit && result >= model.BrandBalanceLimit {
|
||||
balance = result
|
||||
} else {
|
||||
balance = 0
|
||||
}
|
||||
storeAcct, err := cms.GetStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order)) // 获取门店余额
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
balance = storeAcct.AccountBalance
|
||||
//if storeDetail.BrandID == scheduler.JXC4B_SHOP || storeDetail.BrandID == scheduler.JXC4B_RAND_JXGY { // 京西品牌,扣门店
|
||||
// balance = storeAcct.AccountBalance
|
||||
//} else {
|
||||
// if storeAcct.AccountBalance >= model.BrandBalanceLimit {
|
||||
// balance = storeAcct.AccountBalance
|
||||
// } else if storeAcct.AccountBalance < model.BrandBalanceLimit && result >= model.BrandBalanceLimit {
|
||||
// balance = result
|
||||
// } else {
|
||||
// balance = 0
|
||||
// }
|
||||
//}
|
||||
} else {
|
||||
balance, _ = partner.CurStoreAcctManager.GetBrandBalance(storeDetail.BrandID)
|
||||
}
|
||||
@@ -263,7 +265,7 @@ func (c *BaseScheduler) CreateWaybill(platformVendorID int, order *model.GoodsOr
|
||||
|
||||
}
|
||||
} else {
|
||||
err = fmt.Errorf("CreateWaybill failed brand is close orderID: %s, isOpen: %d or store/brand money is enought ", order.VendorOrderID, storeDetail.BrandIsOpen)
|
||||
err = fmt.Errorf("创建运单是门店余额不足十元,无法创建运单")
|
||||
}
|
||||
} else {
|
||||
err = scheduler.ErrDeliverProviderWrong
|
||||
@@ -280,8 +282,9 @@ func (c *BaseScheduler) CancelWaybill(bill *model.Waybill, cancelReasonID int, c
|
||||
if err := handlerInfo.Handler.CancelWaybill(bill, cancelReasonID, cancelReason); err != nil {
|
||||
return err
|
||||
}
|
||||
order, _ := partner.CurOrderManager.LoadOrder(bill.VendorOrderID, bill.OrderVendorID)
|
||||
return orderman.ResetCreateWaybillFee(nil, order)
|
||||
return nil
|
||||
//order, _ := partner.CurOrderManager.LoadOrder(bill.VendorOrderID, bill.OrderVendorID)
|
||||
//return orderman.ResetCreateWaybillFee(nil, order, bill)
|
||||
}, "CancelWaybill bill:%v", bill); err == nil {
|
||||
bill.Status = model.WaybillStatusCanceled
|
||||
bill.DeliveryFlag |= model.WaybillDeliveryFlagMaskActiveCancel
|
||||
|
||||
@@ -43,6 +43,8 @@ func (c *BaseScheduler) CreateWaybillOnProviders(ctx *jxcontext.Context, order *
|
||||
// 创建运单
|
||||
bill, err2 := c.CreateWaybill(courierVendorID, order, maxDeliveryFee)
|
||||
if err = err2; err == nil {
|
||||
bill.DesiredFee += model.WayBillDeliveryMarkUp
|
||||
bill.ActualFee += model.WayBillDeliveryMarkUp
|
||||
bills = append(bills, bill)
|
||||
if createOnlyOne {
|
||||
break
|
||||
@@ -228,7 +230,7 @@ func (c *BaseScheduler) AgreeOrRefuseRefund(ctx *jxcontext.Context, afsOrderID s
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
waybills, _ := dao.GetWaybills(db, order.VendorOrderID)
|
||||
waybills, _ := dao.GetWaybills(db, order.VendorOrderID, nil)
|
||||
//美团的订单如果是同意全部退款,要取消所有三方运单并停止调度
|
||||
if order.VendorID == model.VendorIDMTWM || order.VendorID == model.VendorIDJX || order.VendorID == model.VendorIDEBAI {
|
||||
var (
|
||||
@@ -347,16 +349,27 @@ func (c *BaseScheduler) ConfirmSelfTake(ctx *jxcontext.Context, vendorOrderID st
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *BaseScheduler) SetOrderWaybillTip(ctx *jxcontext.Context, vendorOrderID string, vendorID int, tipFee int64) (errCode string, err error) {
|
||||
if order, err := partner.CurOrderManager.LoadOrder(vendorOrderID, vendorID); err == nil {
|
||||
if errCode, err = c.CheckStoreBalanceWithTip(ctx, order, tipFee); err == nil {
|
||||
err = c.SetOrderWaybillTipByOrder(ctx, order, tipFee)
|
||||
}
|
||||
func (c *BaseScheduler) SetOrderWaybillTip(ctx *jxcontext.Context, vendorOrderID string, vendorID int, tipFee int64, isPay int) (errCode string, err error) {
|
||||
order, err := partner.CurOrderManager.LoadOrder(vendorOrderID, vendorID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
errCode, err = c.CheckStoreBalanceWithTip(ctx, order, tipFee, isPay)
|
||||
if err != nil {
|
||||
return errCode, err
|
||||
}
|
||||
err = c.SetOrderWaybillTipByOrder(ctx, order, tipFee)
|
||||
return errCode, err
|
||||
}
|
||||
|
||||
func (c *BaseScheduler) CheckStoreBalanceWithTip(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee int64) (errCode string, err error) {
|
||||
func (c *BaseScheduler) CheckStoreBalanceWithTip(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee int64, isPay int) (errCode string, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
roundTipFee := tipFee / 100 * 100
|
||||
if roundTipFee != tipFee {
|
||||
return model.ErrCodeOnePayTipFeeMore, fmt.Errorf("小费必须是1元的整数倍")
|
||||
}
|
||||
if order.CreateDeliveryType == model.YES {
|
||||
//加小费只判断余额
|
||||
storeAcct, err := cms.GetStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order))
|
||||
@@ -366,10 +379,32 @@ func (c *BaseScheduler) CheckStoreBalanceWithTip(ctx *jxcontext.Context, order *
|
||||
if tipFee > int64(storeAcct.AccountBalance) {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("门店账户余额不足,不能加小费!")
|
||||
}
|
||||
if tipFee >= 1000 {
|
||||
if tipFee > 1000 {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("小费单次加价金额大于十元")
|
||||
}
|
||||
} else {
|
||||
// 品牌发单
|
||||
storeDetail, err := dao.GetStoreDetail(db, order.JxStoreID, order.VendorID, order.VendorOrgCode)
|
||||
if err != nil || storeDetail == nil {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("根据订单获取门店详情错误:%v", err)
|
||||
}
|
||||
|
||||
brandAcct, err := dao.GetBrandBalance(db, storeDetail.BrandID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if tipFee > int64(brandAcct) {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("品牌账户余额不足,不能加小费!")
|
||||
}
|
||||
if tipFee > 1000 {
|
||||
return model.ErrCodeOnePayTipFeeMore, fmt.Errorf("小费单次加价金额大于十元")
|
||||
}
|
||||
}
|
||||
// 是否确认支付
|
||||
if isPay != model.YES {
|
||||
return model.ErrCodeIsPaySure, fmt.Errorf("此订单已经支付小费[%d]元,本次增加小费[%d]元,总支出小费[%d]元", order.WaybillTipMoney/100, tipFee/100, (order.WaybillTipMoney+tipFee)/100)
|
||||
}
|
||||
|
||||
return errCode, err
|
||||
}
|
||||
|
||||
@@ -379,13 +414,6 @@ func isWaybillCanAddTip(waybill *model.Waybill) (isCan bool) {
|
||||
}
|
||||
|
||||
func (c *BaseScheduler) SetOrderWaybillTipByOrder(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee int64) (err error) {
|
||||
roundTipFee := tipFee / 100 * 100
|
||||
if roundTipFee != tipFee {
|
||||
return fmt.Errorf("小费必须是1元的整数倍")
|
||||
}
|
||||
if order.WaybillTipMoney >= tipFee {
|
||||
return fmt.Errorf("当前小费已经是%s元,想要设置%s元", jxutils.IntPrice2StandardString(order.WaybillTipMoney), jxutils.IntPrice2StandardString(tipFee))
|
||||
}
|
||||
db := dao.GetDB()
|
||||
storeDetail, _ := dao.GetStoreDetail(db, jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, "")
|
||||
flag := false
|
||||
@@ -396,7 +424,11 @@ func (c *BaseScheduler) SetOrderWaybillTipByOrder(ctx *jxcontext.Context, order
|
||||
} else {
|
||||
//加小费成功扣钱
|
||||
if order.CreateDeliveryType == model.YES {
|
||||
if err = partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), 100, partner.StoreAcctTypeExpendCreateWaybillTip, order.VendorOrderID, 0); err == nil {
|
||||
if err = partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(tipFee), partner.StoreAcctTypeExpendCreateWaybillTip, order.VendorOrderID, "", 0); err == nil {
|
||||
flag = true
|
||||
}
|
||||
} else if order.CreateDeliveryType == model.NO {
|
||||
if err = partner.CurStoreAcctManager.InsertBrandBill(ctx, storeDetail.BrandID, int(tipFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeTipFee, order.VendorOrderID, ""); err == nil {
|
||||
flag = true
|
||||
}
|
||||
}
|
||||
@@ -432,7 +464,9 @@ func (c *BaseScheduler) SetOrderWaybillTipByOrder(ctx *jxcontext.Context, order
|
||||
if !flag {
|
||||
//加小费成功扣钱
|
||||
if order.CreateDeliveryType == model.YES {
|
||||
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), 100, partner.StoreAcctTypeExpendCreateWaybillTip, order.VendorOrderID, 0)
|
||||
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(tipFee), partner.StoreAcctTypeExpendCreateWaybillTip, order.VendorOrderID, "", 0)
|
||||
} else if order.CreateDeliveryType == model.NO {
|
||||
partner.CurStoreAcctManager.InsertBrandBill(ctx, storeDetail.BrandID, int(tipFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeTipFee, order.VendorOrderID, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,11 @@ package defsch
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/dadaapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/fnpsapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/uuptapi"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/smsmsg"
|
||||
"math/rand"
|
||||
"strings"
|
||||
@@ -507,20 +512,6 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
||||
savedOrderInfo := s.loadSavedOrderFromMap(model.Waybill2Status(bill), true)
|
||||
order := savedOrderInfo.order
|
||||
|
||||
// 打印通知
|
||||
//netprinter.PrintOrderByOrder(jxcontext.AdminCtx, order, model.PrintTypeWayBill)
|
||||
|
||||
// 获取订单配送平台,如果是美团则需要获取门店配置的配送方式
|
||||
//isBlendWay := false
|
||||
//if bill.OrderVendorID == model.VendorIDMTWM {
|
||||
// mtStoreInfo, err := api.MtwmAPI.PoiGet(utils.Int2Str(order.JxStoreID))
|
||||
// globals.SugarLogger.Debugf("从美团上获取门店失败:%s", err)
|
||||
// isBlendWay = strings.Contains(mtStoreInfo.LogisticsCodes, model.MTWMStorePSWay8)
|
||||
//}
|
||||
//if order.VendorID == model.VendorIDDD {
|
||||
// partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID).GetOrderRider()
|
||||
//}
|
||||
|
||||
// 暂时只处理抖音平台,抖音暂无配送,只要是抖音订单,三方配送压单了,直接通知送出
|
||||
if bill.Status == model.WaybillStatusNew {
|
||||
s.addWaybill2Map(savedOrderInfo, bill)
|
||||
@@ -630,17 +621,23 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
||||
if order.VendorID == model.VendorIDJDShop {
|
||||
s.solutionJdsOrder(bill)
|
||||
}
|
||||
//如果是商城的订单, 骑手取货时,需要发短信提醒
|
||||
//if bill.Status == model.WaybillStatusDelivering && order.VendorID == model.VendorIDJX && order.OrderType == model.OrderTypeNormal {
|
||||
// smsmsg.NotifyJxOrder(order, bill)
|
||||
//}
|
||||
//扣除品牌费用
|
||||
if storeDetail, err2 := dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, ""); err2 == nil {
|
||||
if storeDetail.CreateDeliveryType == model.YES {
|
||||
s.updateStoreAccount(order, bill)
|
||||
}
|
||||
if !model.IsWaybillPlatformOwn(bill) {
|
||||
s.updateBrandAccount(storeDetail, bill)
|
||||
|
||||
// 当运单时三方配送时,美团状态20
|
||||
if bill.WaybillVendorID == model.VendorIDDada || bill.WaybillVendorID == model.VendorIDMTPS || bill.WaybillVendorID == model.VendorIDFengNiao || bill.WaybillVendorID == model.VendorIDUUPT {
|
||||
if (bill.VendorStatus == utils.Int64ToStr(mtpsapi.OrderStatusPickedUp) && bill.OrderVendorID == model.VendorIDMTWM) ||
|
||||
(bill.VendorStatus == utils.Int64ToStr(dadaapi.OrderStatusDelivering) && bill.OrderVendorID == model.VendorIDDada) ||
|
||||
(bill.VendorStatus == utils.Int64ToStr(fnpsapi.OrderStatusArrived) && bill.OrderVendorID == model.VendorIDFengNiao) ||
|
||||
(bill.VendorStatus == uuptapi.StateArrivedStore && bill.OrderVendorID == model.VendorIDUUPT) {
|
||||
if storeDetail, err2 := dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, ""); err2 == nil {
|
||||
if storeDetail.CreateDeliveryType == model.YES {
|
||||
s.updateStoreAccount(order, bill)
|
||||
} else {
|
||||
s.updateBrandAccount(storeDetail, bill)
|
||||
}
|
||||
//if !model.IsWaybillPlatformOwn(bill) {
|
||||
// s.updateBrandAccount(storeDetail, bill)
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -734,9 +731,6 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
||||
if model.IsOrderHaveWaybill(order) {
|
||||
s.updateOrderByBill(order, nil, true)
|
||||
}
|
||||
//if order.VendorID == model.VendorIDMTWM {
|
||||
// order, _ = partner.CurOrderManager.LoadOrder(order.VendorOrderID, order.VendorID)
|
||||
//}
|
||||
// 3方的运单取消才会重新发起创建3方订单,购物平台的运单取消后,它本身还会再创建新运单(NewWaybill事件有相应TIMER)),至少京东是这样的,暂时按京东的行为来
|
||||
// 现在发现饿百取消订单后不会再创建运单了,所以饿百运单取消也允许直接创建三方运单
|
||||
// 之前的条件是order.Status < model.OrderStatusDelivering,但像订单902322817000122确实有在配送中取消状态,改成非订单结束状态都可以
|
||||
@@ -748,21 +742,13 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
||||
//}
|
||||
globals.SugarLogger.Debugf("auto cancelWaybill created second, orderID:%s", order.VendorOrderID)
|
||||
}
|
||||
//if order.Status < model.OrderStatusDelivering {
|
||||
// if order.VendorID == model.VendorIDMTWM && order.DeliveryType == model.OrderDeliveryTypePlatform {
|
||||
// s.CancelOrder(jxcontext.AdminCtx, order, "")
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
// case model.WaybillStatusDelivering:
|
||||
// s.resetTimer(savedOrderInfo, bill, isPending)
|
||||
// if s.isBillCandidate(order, bill) {
|
||||
// // do nothing
|
||||
// } else {
|
||||
// // s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
||||
// globals.SugarLogger.Infof("OnWaybillStatusChanged Delivering order(%d, %s) bill(%d, %s), bill:%v shouldn't get here", order.WaybillVendorID, order.VendorWaybillID, bill.WaybillVendorID, bill.VendorWaybillID, bill)
|
||||
// }
|
||||
|
||||
if err := orderman.ResetCreateWaybillFee(nil, order, bill); err != nil {
|
||||
globals.SugarLogger.Errorf("ResetCreateWaybillFee err : %v", err)
|
||||
}
|
||||
|
||||
case model.WaybillStatusDelivered:
|
||||
s.resetTimer(savedOrderInfo, bill, isPending)
|
||||
s.removeWaybillFromMap(savedOrderInfo, bill.WaybillVendorID)
|
||||
@@ -791,22 +777,18 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
||||
if !isPending {
|
||||
s.notify3rdPartyWaybill(order, bill, false)
|
||||
}
|
||||
// case model.WaybillStatusNeverSend: // 平台不配送,直接创建三方运单
|
||||
// s.resetTimer(savedOrderInfo, bill, isPending)
|
||||
// s.removeWaybillFromMap(savedOrderInfo, bill.WaybillVendorID)
|
||||
// if order.WaybillVendorID == model.VendorIDUnknown {
|
||||
// s.createWaybillOn3rdProviders(savedOrderInfo, 0, nil)
|
||||
// }
|
||||
// 将订单修改为完成状态
|
||||
order.Status = model.OrderStatusFinished
|
||||
order.OrderFinishedAt = time.Now()
|
||||
partner.CurOrderManager.UpdateOrderFields(order, []string{"status", "OrderFinishedAt"})
|
||||
if err := orderman.FinisOrderWaybillFee(nil, order, bill); err != nil {
|
||||
globals.SugarLogger.Debugf("FinisOrderWaybillFee count err : %v", err)
|
||||
}
|
||||
|
||||
default:
|
||||
s.resetTimer(savedOrderInfo, bill, isPending)
|
||||
}
|
||||
// s.updateBillsInfo(savedOrderInfo, bill) // 更新可能的运单状态变化
|
||||
}
|
||||
// }
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -1439,10 +1421,10 @@ func (s *DefScheduler) updateStoreAccount(order *model.GoodsOrder, bill *model.W
|
||||
var diffFee int64
|
||||
if lastFee64 > realDesiredFee {
|
||||
diffFee = lastFee64 - realDesiredFee
|
||||
partner.CurStoreAcctManager.InsertStoreAcctIncomeAndUpdateStoreAcctBalance(jxcontext.AdminCtx, jxutils.GetSaleStoreIDFromOrder(order), int(diffFee), partner.StoreAcctTypeRealFeeIncome, order.VendorOrderID, expend.ID)
|
||||
partner.CurStoreAcctManager.InsertStoreAcctIncomeAndUpdateStoreAcctBalance(jxcontext.AdminCtx, jxutils.GetSaleStoreIDFromOrder(order), int(diffFee), partner.StoreAcctTypeRealFeeIncome, order.VendorOrderID, bill.VendorWaybillID, expend.ID)
|
||||
} else {
|
||||
diffFee = realDesiredFee - lastFee64
|
||||
partner.CurStoreAcctManager.InsertStoreAcctIncomeAndUpdateStoreAcctBalance(jxcontext.AdminCtx, jxutils.GetSaleStoreIDFromOrder(order), int(diffFee), partner.StoreAcctTypeRealFeeExpend, order.VendorOrderID, expend.ID)
|
||||
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(jxcontext.AdminCtx, jxutils.GetSaleStoreIDFromOrder(order), int(diffFee), partner.StoreAcctTypeRealFeeExpend, order.VendorOrderID, "", expend.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1460,6 +1442,10 @@ func (s *DefScheduler) updateBrandAccount(store *dao.StoreDetail, bill *model.Wa
|
||||
}
|
||||
if sum == 0 {
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, int(bill.DesiredFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, bill.VendorOrderID, bill.VendorWaybillID)
|
||||
} else if bill.DesiredFee > int64(sum) {
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, int(bill.DesiredFee-int64(sum)), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, bill.VendorOrderID, bill.VendorWaybillID)
|
||||
} else if bill.DesiredFee < int64(sum) {
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, int(int64(sum)-bill.DesiredFee), model.BrandBillTypeIncome, model.BrandBillFeeTypeDelivery, bill.VendorOrderID, bill.VendorWaybillID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ func (s *DefScheduler) SelfDeliveringAndUpdateStatus(ctx *jxcontext.Context, ven
|
||||
}
|
||||
|
||||
// 上面是真的转自送,支持美团,饿百,京东,如果时抖店,抖店暂时全部是自送的!但是有骑手信息时,就是一个白嫖单子!
|
||||
if (order.VendorID == model.VendorIDDD || order.VendorID == model.VendorIDEBAI) && courierName != "" && courierMobile != "" && err == nil {
|
||||
if courierName != "" && courierMobile != "" && err == nil {
|
||||
timeNow := time.Now()
|
||||
rand.Seed(timeNow.UnixNano())
|
||||
randNumber := rand.Int63n(640)
|
||||
@@ -108,7 +108,7 @@ func (s *DefScheduler) SelfDeliveringAndUpdateStatus(ctx *jxcontext.Context, ven
|
||||
WaybillFinishedAt: utils.DefaultTimeValue,
|
||||
StatusTime: timeNow.Add(randTime), // 下一状态时间
|
||||
OriginalData: "",
|
||||
Remark: "自定义物流单(抖音/饿了么)",
|
||||
Remark: "自定义物流单(全平台刷单)",
|
||||
VendorOrgCode: order.VendorOrgCode,
|
||||
}
|
||||
err = dao.CreateEntity(dao.GetDB(), bill)
|
||||
@@ -177,24 +177,20 @@ func (s *DefScheduler) CreateWaybillOnProviders4SavedOrder(ctx *jxcontext.Contex
|
||||
// 获取门店品牌余额
|
||||
storeAcct, err := cms.GetStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order)) // 获取门店余额
|
||||
|
||||
// 如果门店没钱,查看品牌,查询门店品牌id
|
||||
storeList, err := dao.GetStoreList(dao.GetDB(), []int{jxutils.GetSaleStoreIDFromOrder(order)}, nil, nil, nil, nil, "")
|
||||
if err != nil || len(storeList) != 1 {
|
||||
return nil, fmt.Errorf("门店id:[%d],所属品牌不唯一,或其他查询错误", order.JxStoreID)
|
||||
}
|
||||
result, err := dao.GetBrandBalance(dao.GetDB(), storeList[0].BrandID) // 品牌余额
|
||||
// 门店详细信息
|
||||
storeList, err := dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), savedOrderInfo.order.VendorID, order.VendorOrgCode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//门店发单开始扣钱
|
||||
deliveryFeeMap, _ := s.QueryOrderWaybillFeeInfoEx(ctx, order.VendorOrderID, order.VendorID)
|
||||
// 不管是门店发单还是品牌发单都要扣钱,门店发单扣门店,品牌发单扣品牌
|
||||
if order.CreateDeliveryType == model.YES {
|
||||
deliveryFeeMap, _ := s.QueryOrderWaybillFeeInfoEx(ctx, order.VendorOrderID, order.VendorID)
|
||||
// 运费相等为0或支出大于收入不做,
|
||||
isEqual, isZero, _ := partner.CurStoreAcctManager.CheckStoreAcctExpendExist(order.VendorOrderID)
|
||||
expend, lastFee, _ := partner.CurStoreAcctManager.GetStoreAcctExpendLastCreateWayBillFee(order.VendorOrderID)
|
||||
// 获取平台配送费
|
||||
isEqual, isZero, _ := partner.CurStoreAcctManager.CheckStoreAcctExpendExist(order.VendorOrderID) // 当前订单的支出记录
|
||||
expend, lastFee, _ := partner.CurStoreAcctManager.GetStoreAcctExpendLastCreateWayBillFee(order.VendorOrderID) // 最后一个运单支出记录
|
||||
// 收最贵的一个订单配送费(配送费发送变化,收取最贵的价格)
|
||||
if !isZero && !isEqual {
|
||||
if !isZero && !isEqual { // 满足此条件是,门店发单已经存在此订单的发单记录,且支出记录大于退还记录
|
||||
var newPrice int64
|
||||
if len(courierVendorIDs) == 1 {
|
||||
courierVendorID := courierVendorIDs[0]
|
||||
@@ -205,70 +201,86 @@ func (s *DefScheduler) CreateWaybillOnProviders4SavedOrder(ctx *jxcontext.Contex
|
||||
var maxFee int64
|
||||
for _, v := range deliveryFeeMap {
|
||||
if v.DeliveryFee > maxFee {
|
||||
v.DeliveryFee = maxFee
|
||||
maxFee = v.DeliveryFee
|
||||
}
|
||||
}
|
||||
newPrice = maxFee
|
||||
}
|
||||
// 门店支出运费
|
||||
if storeList[0].BrandID != scheduler.JXC4B_SHOP && storeList[0].BrandID != scheduler.JXC4B_RAND_JXGY { // 非京西品牌,先扣门店在扣品牌
|
||||
// 门店支出运费,门店发单
|
||||
if order.CreateDeliveryType == model.YES {
|
||||
if storeAcct.AccountBalance > int(newPrice) {
|
||||
if int(newPrice) > lastFee {
|
||||
// 门店支出费用
|
||||
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(model.Waybill{}.DesiredFee), partner.StoreAcctTypeExpendCreateWaybill2ndMore, order.VendorOrderID, expend.ID) //int(newPrice)-lastFee
|
||||
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(newPrice)-lastFee, partner.StoreAcctTypeExpendCreateWaybill2ndMore, order.VendorOrderID, "", expend.ID) //int(newPrice)-lastFee
|
||||
}
|
||||
} else if result > int(newPrice) {
|
||||
// 品牌支出费用
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, storeList[0].BrandID, int(model.Waybill{}.DesiredFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, order.VendorOrderID, order.VendorWaybillID)
|
||||
} else {
|
||||
return nil, fmt.Errorf("门店id:[%d],品牌id:[]%d,门店以及门店所属品牌余额不足,无法发单", order.JxStoreID, storeList[0].BrandID)
|
||||
}
|
||||
} else { // 京西品牌
|
||||
} /*else { // 品牌发单,品牌支出运费
|
||||
if storeAcct.AccountBalance > int(newPrice) {
|
||||
if int(newPrice) > lastFee {
|
||||
// 门店支出费用
|
||||
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(model.Waybill{}.DesiredFee), partner.StoreAcctTypeExpendCreateWaybill2ndMore, order.VendorOrderID, expend.ID) //int(newPrice)-lastFee
|
||||
// 品牌支出费用
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, storeList.BrandID, int(newPrice), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, order.VendorOrderID, order.VendorWaybillID)
|
||||
}
|
||||
} else {
|
||||
return nil, fmt.Errorf("门店id:[%d],品牌id:[]%d,门店以及门店所属品牌余额不足,无法发单", order.JxStoreID, storeList[0].BrandID)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
} else {
|
||||
} else { // 新订单的发单记录,门店发单扣门店,品牌发单扣品牌
|
||||
if len(courierVendorIDs) == 1 {
|
||||
courierVendorID := courierVendorIDs[0]
|
||||
if _, ok := deliveryFeeMap[courierVendorID]; ok {
|
||||
if storeList[0].BrandID != scheduler.JXC4B_SHOP && storeList[0].BrandID != scheduler.JXC4B_RAND_JXGY { // 非京西品牌,先扣门店在扣品牌
|
||||
if storeAcct.AccountBalance > int(model.Waybill{}.DesiredFee) {
|
||||
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(model.Waybill{}.DesiredFee), partner.StoreAcctTypeExpendCreateWaybill2ndMore, order.VendorOrderID, expend.ID) //int(newPrice)-lastFee
|
||||
} else if result > int(model.Waybill{}.DesiredFee) {
|
||||
// 品牌支出费用
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, storeList[0].BrandID, int(model.Waybill{}.DesiredFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, order.VendorOrderID, order.VendorWaybillID)
|
||||
} else {
|
||||
return nil, fmt.Errorf("门店id:[%d],品牌id:[]%d,门店以及门店所属品牌余额不足,无法发单", order.JxStoreID, storeList[0].BrandID)
|
||||
}
|
||||
} else { // 京西品牌
|
||||
if storeAcct.AccountBalance > int(model.Waybill{}.DesiredFee) {
|
||||
// 门店支出费用
|
||||
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(model.Waybill{}.DesiredFee), partner.StoreAcctTypeExpendCreateWaybill2ndMore, order.VendorOrderID, expend.ID) //int(newPrice)-lastFee
|
||||
} else {
|
||||
return nil, fmt.Errorf("门店id:[%d],品牌id:[]%d,门店以及门店所属品牌余额不足,无法发单", order.JxStoreID, storeList[0].BrandID)
|
||||
}
|
||||
}
|
||||
//if storeList.BrandID != scheduler.JXC4B_SHOP && storeList.BrandID != scheduler.JXC4B_RAND_JXGY { // 非京西品牌,先扣门店在扣品牌
|
||||
//if storeAcct.AccountBalance > int(model.Waybill{}.DesiredFee) {
|
||||
if order.CreateDeliveryType == model.YES {
|
||||
err = partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(deliveryFeeMap[courierVendorID].DeliveryFee), partner.StoreAcctTypeExpendCreateWaybillEx, order.VendorOrderID, "", 0) //int(newPrice)-lastFee
|
||||
globals.SugarLogger.Debugf("InsertStoreAcctExpendAndUpdateStoreAcctBalance 238 err := %v", err)
|
||||
} /*else {
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, storeList.BrandID, int(bill.DesiredFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, bill.VendorOrderID, bill.VendorWaybillID)
|
||||
}*/
|
||||
//} /*else if result > int(model.Waybill{}.DesiredFee) {
|
||||
// 品牌支出费用
|
||||
// partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, storeList.BrandID, int(model.Waybill{}.DesiredFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, order.VendorOrderID, order.VendorWaybillID)
|
||||
//}*/
|
||||
//} else { // 京西品牌
|
||||
// if storeAcct.AccountBalance > int(model.Waybill{}.DesiredFee) {
|
||||
// // 门店支出费用
|
||||
// partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(model.Waybill{}.DesiredFee), partner.StoreAcctTypeExpendCreateWaybill2ndMore, order.VendorOrderID, expend.ID) //int(newPrice)-lastFee
|
||||
// }
|
||||
//}
|
||||
}
|
||||
} else if len(courierVendorIDs) == 0 {
|
||||
var maxFee int64
|
||||
for _, v := range deliveryFeeMap {
|
||||
if v.DeliveryFee > maxFee {
|
||||
v.DeliveryFee = maxFee
|
||||
maxFee = v.DeliveryFee
|
||||
}
|
||||
}
|
||||
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(model.Waybill{}.DesiredFee), partner.StoreAcctTypeExpendCreateWaybillEx, order.VendorOrderID, 0) //int(maxFee)
|
||||
err = partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(maxFee), partner.StoreAcctTypeExpendCreateWaybillEx, order.VendorOrderID, "", 0) //int(maxFee)
|
||||
globals.SugarLogger.Debugf("InsertStoreAcctExpendAndUpdateStoreAcctBalance 260 err := %v", err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 看看此订单有无发单记录,小费记录
|
||||
// 品牌发单
|
||||
if len(courierVendorIDs) == 1 {
|
||||
courierVendorID := courierVendorIDs[0]
|
||||
if _, ok := deliveryFeeMap[courierVendorID]; ok {
|
||||
err = partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, storeList.BrandID, int(deliveryFeeMap[courierVendorID].DeliveryFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, order.VendorOrderID, order.VendorWaybillID)
|
||||
}
|
||||
} else if len(courierVendorIDs) == 0 {
|
||||
var maxFee int64
|
||||
for _, v := range deliveryFeeMap {
|
||||
if v.DeliveryFee > maxFee {
|
||||
maxFee = v.DeliveryFee
|
||||
}
|
||||
}
|
||||
err = partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, storeList.BrandID, int(maxFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, order.VendorOrderID, order.VendorWaybillID)
|
||||
globals.SugarLogger.Debugf("InsertStoreAcctExpendAndUpdateStoreAcctBalance 260 err := %v", err)
|
||||
}
|
||||
|
||||
}
|
||||
return bills, err
|
||||
|
||||
}
|
||||
|
||||
return bills, err
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
@@ -328,27 +340,54 @@ func (s *DefScheduler) CreateWaybillOnProvidersEx(ctx *jxcontext.Context, vendor
|
||||
}
|
||||
|
||||
func (s *DefScheduler) CheckStoreBalance(ctx *jxcontext.Context, order *model.GoodsOrder, courierVendorIDs []int) (errCode string, err error) {
|
||||
if order.CreateDeliveryType == model.YES {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
deliveryFeeMap, _ := s.QueryOrderWaybillFeeInfoEx(ctx, order.VendorOrderID, order.VendorID)
|
||||
if err != nil {
|
||||
return errCode, fmt.Errorf("获取订单配送费错误[%v]!", err)
|
||||
}
|
||||
|
||||
switch order.CreateDeliveryType {
|
||||
case model.NO: // 品牌发单
|
||||
storeDetail, err := dao.GetStoreDetail(db, jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, "")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
brandAcct, err := dao.GetBrandBalance(db, storeDetail.BrandID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if len(courierVendorIDs) == 1 {
|
||||
courierVendorID := courierVendorIDs[0]
|
||||
if _, ok := deliveryFeeMap[courierVendorID]; ok {
|
||||
if deliveryFeeMap[courierVendorID].DeliveryFee > int64(brandAcct) {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("品牌账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(deliveryFeeMap[courierVendorID].DeliveryFee))
|
||||
}
|
||||
}
|
||||
} else if len(courierVendorIDs) == 0 {
|
||||
var maxFee int64
|
||||
for _, v := range deliveryFeeMap {
|
||||
if v.DeliveryFee > maxFee {
|
||||
v.DeliveryFee = maxFee
|
||||
}
|
||||
}
|
||||
if maxFee > int64(brandAcct) {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("品牌账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(maxFee))
|
||||
}
|
||||
}
|
||||
|
||||
case model.YES: // 门店发单
|
||||
//暂时这么认为,len courierVendorIDs 为1表示是老板或者运营从小程序上点的立即发单,因为小程序上是点哪个发哪个
|
||||
//京西后台则是点一下发3个,len courierVendorIDs 是0
|
||||
//如果是小程序上点哪个扣哪个平台的钱
|
||||
//如果是后台,则选最高的那个扣
|
||||
storeAcct, err := cms.GetStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order)) // 获取门店余额
|
||||
|
||||
// 如果门店没钱,查看品牌,查询门店品牌id
|
||||
storeList, err := dao.GetStoreList(dao.GetDB(), []int{jxutils.GetSaleStoreIDFromOrder(order)}, nil, nil, nil, nil, "")
|
||||
if err != nil || len(storeList) != 1 {
|
||||
return "", fmt.Errorf("门店id:[%d],所属品牌不唯一,或其他查询错误", order.JxStoreID)
|
||||
}
|
||||
result, err := dao.GetBrandBalance(dao.GetDB(), storeList[0].BrandID) // 品牌余额
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
deliveryFeeMap, _ := s.QueryOrderWaybillFeeInfoEx(ctx, order.VendorOrderID, order.VendorID)
|
||||
if err != nil {
|
||||
return errCode, fmt.Errorf("获取账户余额失败!")
|
||||
}
|
||||
//1、先判断是不是第一次发:查询库里是否有这个订单的运费支出记录,再查询是否有相同金额并且类型为回退的收入记录(取消运单退回)
|
||||
//前者有,后者无, 表示已经发过了,暂未取消,若这这次的发单金额小于上次的金额则不进行判断也不多扣钱,若大于则扣除‘这次金额-上次金额’的钱,余额不足问题也根据这个判断
|
||||
//前者有,后者有,表示发过并且取消过了,是多次发,直接扣
|
||||
@@ -356,7 +395,7 @@ func (s *DefScheduler) CheckStoreBalance(ctx *jxcontext.Context, order *model.Go
|
||||
//2、小程序里这次金额用发单平台的金额,后台里这次金额用所有平台最高费用
|
||||
isEqual, isZero, err := partner.CurStoreAcctManager.CheckStoreAcctExpendExist(order.VendorOrderID)
|
||||
//表示前者有,后者无
|
||||
if !isZero && !isEqual {
|
||||
if !isZero && !isEqual { // 当前订单支出费用大于,退还费用
|
||||
var newPrice int64
|
||||
if len(courierVendorIDs) == 1 {
|
||||
courierVendorID := courierVendorIDs[0]
|
||||
@@ -375,28 +414,16 @@ func (s *DefScheduler) CheckStoreBalance(ctx *jxcontext.Context, order *model.Go
|
||||
_, lastFee, _ := partner.CurStoreAcctManager.GetStoreAcctExpendLastCreateWayBillFee(order.VendorOrderID)
|
||||
// 如果门店属于京西菜市,京西果园则只能扣门店的金额
|
||||
if int(newPrice) > lastFee {
|
||||
if storeList[0].BrandID == scheduler.JXC4B_RAND_JXGY || storeList[0].BrandID == scheduler.JXC4B_SHOP { // 订单所属门店属于京西菜市,果园,则不扣品牌只扣门店)(1果园,菜市,7京西超市)
|
||||
if storeAcct.AccountBalance < int(newPrice)-lastFee {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("门店/品牌账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(newPrice-int64(lastFee)))
|
||||
}
|
||||
} else {
|
||||
if storeAcct.AccountBalance < int(newPrice)-lastFee && result < int(newPrice)-lastFee {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("门店/品牌账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(newPrice-int64(lastFee)))
|
||||
}
|
||||
if storeAcct.AccountBalance < int(newPrice)-lastFee /*&& result < int(newPrice)-lastFee*/ {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("门店账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(newPrice-int64(lastFee)))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(courierVendorIDs) == 1 {
|
||||
courierVendorID := courierVendorIDs[0]
|
||||
if _, ok := deliveryFeeMap[courierVendorID]; ok {
|
||||
if storeList[0].BrandID == scheduler.JXC4B_RAND_JXGY || storeList[0].BrandID == scheduler.JXC4B_SHOP { // 订单所属门店属于京西菜市,果园,则不扣品牌只扣门店)(1果园,菜市,7京西超市)
|
||||
if deliveryFeeMap[courierVendorID].DeliveryFee > int64(storeAcct.AccountBalance) {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("门店/品牌账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(partner.MinCreateWaybillBalance))
|
||||
}
|
||||
} else {
|
||||
if deliveryFeeMap[courierVendorID].DeliveryFee > int64(result) && deliveryFeeMap[courierVendorID].DeliveryFee > int64(storeAcct.AccountBalance) {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("门店/品牌 账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(deliveryFeeMap[courierVendorID].DeliveryFee))
|
||||
}
|
||||
if deliveryFeeMap[courierVendorID].DeliveryFee > int64(storeAcct.AccountBalance) {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("门店账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(deliveryFeeMap[courierVendorID].DeliveryFee))
|
||||
}
|
||||
}
|
||||
} else if len(courierVendorIDs) == 0 {
|
||||
@@ -406,18 +433,15 @@ func (s *DefScheduler) CheckStoreBalance(ctx *jxcontext.Context, order *model.Go
|
||||
v.DeliveryFee = maxFee
|
||||
}
|
||||
}
|
||||
if storeList[0].BrandID == scheduler.JXC4B_RAND_JXGY || storeList[0].BrandID == scheduler.JXC4B_SHOP { // 订单所属门店属于京西菜市,果园,则不扣品牌只扣门店)(1果园,菜市,7京西超市)
|
||||
if maxFee > int64(storeAcct.AccountBalance) {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("门店/品牌账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(partner.MinCreateWaybillBalance))
|
||||
}
|
||||
} else {
|
||||
if maxFee > int64(result) && maxFee > int64(storeAcct.AccountBalance) {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("门店/品牌 账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(maxFee))
|
||||
}
|
||||
if maxFee > int64(storeAcct.AccountBalance) {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("门店账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(maxFee))
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
return "", fmt.Errorf("不存在的订单发单类型,检查配置")
|
||||
}
|
||||
|
||||
return errCode, err
|
||||
}
|
||||
|
||||
@@ -500,6 +524,7 @@ func (s *DefScheduler) QueryOrderWaybillFeeInfoEx(ctx *jxcontext.Context, vendor
|
||||
ErrStr: err.Error(),
|
||||
}
|
||||
} else {
|
||||
feeInfo.DeliveryFee += model.WayBillDeliveryMarkUp // 加收两毛
|
||||
feeInfo.TimeoutSecond = timeoutSecond
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -21,6 +21,7 @@ const (
|
||||
const (
|
||||
JXC4B_RAND_JXGY = 1 // 京西菜市和果园品牌id
|
||||
JXC4B_SHOP = 7 // 京西超市
|
||||
JXC4B_ZHIGONG = 8 // 京西直供
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -1328,19 +1328,19 @@ func updateOrCreateSkuVendorCategoryMap(db *dao.DaoDB, ctx *jxcontext.Context, n
|
||||
if payload["descImg"] != nil {
|
||||
imgs = append(imgs, payload["descImg"].(string))
|
||||
}
|
||||
if payload["img"] != "" {
|
||||
if payload["img"] != nil {
|
||||
imgs = append(imgs, payload["descImg"].(string))
|
||||
}
|
||||
if payload["img2"] != "" {
|
||||
if payload["img2"] != nil {
|
||||
imgs = append(imgs, payload["img2"].(string))
|
||||
}
|
||||
if payload["img3"] != "" {
|
||||
if payload["img3"] != nil {
|
||||
imgs = append(imgs, payload["img3"].(string))
|
||||
}
|
||||
if payload["img4"] != "" {
|
||||
if payload["img4"] != nil {
|
||||
imgs = append(imgs, payload["img4"].(string))
|
||||
}
|
||||
if payload["img5"] != "" {
|
||||
if payload["img5"] != nil {
|
||||
imgs = append(imgs, payload["img5"].(string))
|
||||
}
|
||||
ddCategoryID = getCategoryByImg(imgs...)
|
||||
|
||||
@@ -1856,7 +1856,6 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
|
||||
|
||||
// 更新商品
|
||||
if isSyncStoreMapSku {
|
||||
globals.SugarLogger.Debugf("修改门店调价包是同步门店商品价格=============: %v", err)
|
||||
singleStoreHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
||||
task := tasksch.NewParallelTask("修改门店调价包的时候,同时同步门店商品", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
@@ -4586,14 +4585,6 @@ func GetStoreAcctBalance(ctx *jxcontext.Context, storeID int) (storeAcct *model.
|
||||
}, err
|
||||
}
|
||||
|
||||
// func SendVendorStoreStatusChanged(ctx *jxcontext.Context) (err error) {
|
||||
// var (
|
||||
// db = dao.GetDB()
|
||||
// )
|
||||
// dao.GetStoresMapList(db, []int{model.VendorIDJD, model.VendorIDMTWM, model.VendorIDEBAI}, nil, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", "")
|
||||
// return err
|
||||
// }
|
||||
|
||||
func RefreshStoreBind(ctx *jxcontext.Context) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
|
||||
@@ -23,7 +23,7 @@ func init() {
|
||||
partner.InitStoreAcctManager(FixedStoreAcctManager)
|
||||
}
|
||||
|
||||
func InsertStoreAcctIncome(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error) {
|
||||
func InsertStoreAcctIncome(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID, vendorWaybillId string, expendID int) (err error) {
|
||||
var (
|
||||
userID, userName string
|
||||
goodsVendorOrderID string
|
||||
@@ -44,11 +44,12 @@ func InsertStoreAcctIncome(ctx *jxcontext.Context, storeID, price, acctType int,
|
||||
}
|
||||
}
|
||||
storeAcctIncome := &model.StoreAcctIncome{
|
||||
StoreID: storeID,
|
||||
IncomePrice: price,
|
||||
Type: acctType,
|
||||
UserID: userID,
|
||||
VendorOrderID: goodsVendorOrderID,
|
||||
StoreID: storeID,
|
||||
IncomePrice: price,
|
||||
Type: acctType,
|
||||
UserID: userID,
|
||||
VendorOrderID: goodsVendorOrderID,
|
||||
VendorWaybillID: vendorWaybillId,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(storeAcctIncome, userName)
|
||||
if expendID != 0 {
|
||||
@@ -58,7 +59,7 @@ func InsertStoreAcctIncome(ctx *jxcontext.Context, storeID, price, acctType int,
|
||||
return err
|
||||
}
|
||||
|
||||
func InsertStoreAcctExpend(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error) {
|
||||
func InsertStoreAcctExpend(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID, vendorWaybillId string, expendID int) (err error) {
|
||||
var (
|
||||
userID, userName string
|
||||
db = dao.GetDB()
|
||||
@@ -76,11 +77,12 @@ func InsertStoreAcctExpend(ctx *jxcontext.Context, storeID, price, acctType int,
|
||||
}
|
||||
}
|
||||
storeAcctExpend := &model.StoreAcctExpend{
|
||||
StoreID: storeID,
|
||||
ExpendPrice: price,
|
||||
Type: acctType,
|
||||
UserID: userID,
|
||||
VendorOrderID: vendorOrderID,
|
||||
StoreID: storeID,
|
||||
ExpendPrice: price,
|
||||
Type: acctType,
|
||||
UserID: userID,
|
||||
VendorOrderID: vendorOrderID,
|
||||
VendorWaybillID: vendorWaybillId,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(storeAcctExpend, userName)
|
||||
if expendID != 0 {
|
||||
@@ -132,18 +134,18 @@ func (s *StoreAcctManager) UpdateStoreAcctBalance(ctx *jxcontext.Context, storeI
|
||||
}
|
||||
|
||||
// 门店到账(老版本,修改门店的交易记录)
|
||||
func (s *StoreAcctManager) InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error) {
|
||||
func (s *StoreAcctManager) InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID, vendorWaybillID string, expendID int) (err error) {
|
||||
utils.CallFuncAsync(func() {
|
||||
if err = InsertStoreAcctExpend(ctx, storeID, price, acctType, vendorOrderID, expendID); err == nil {
|
||||
if err = InsertStoreAcctExpend(ctx, storeID, price, acctType, vendorOrderID, vendorWaybillID, expendID); err == nil {
|
||||
s.UpdateStoreAcctBalance(ctx, storeID, price, false)
|
||||
}
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *StoreAcctManager) InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error) {
|
||||
func (s *StoreAcctManager) InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID, vendorWaybillID string, expendID int) (err error) {
|
||||
utils.CallFuncAsync(func() {
|
||||
if err = InsertStoreAcctIncome(ctx, storeID, price, acctType, vendorOrderID, expendID); err == nil {
|
||||
if err = InsertStoreAcctIncome(ctx, storeID, price, acctType, vendorOrderID, vendorWaybillID, expendID); err == nil {
|
||||
s.UpdateStoreAcctBalance(ctx, storeID, price, true)
|
||||
}
|
||||
})
|
||||
@@ -156,9 +158,9 @@ func (s *StoreAcctManager) CheckStoreAcctExpendExist(vendorOrderID string) (isEq
|
||||
expends, incomes int
|
||||
db = dao.GetDB()
|
||||
)
|
||||
// 发单扣除的临时运费
|
||||
expends, err = dao.GetStoreAcctExpendTotal(db, 0, []int{partner.StoreAcctTypeExpendCreateWaybillEx, partner.StoreAcctTypeRealFeeExpend}, vendorOrderID, utils.ZeroTimeValue, utils.ZeroTimeValue)
|
||||
// 真实运费 < 临时运费, 临时运费-真实运费的值
|
||||
// 当前订单的支出金额(临时运费+真实运费)[小费] partner.StoreAcctTypeExpendCreateWaybillDeductFee 违约金不参与计算,本来就要扣除
|
||||
expends, err = dao.GetStoreAcctExpendTotal(db, 0, []int{partner.StoreAcctTypeExpendCreateWaybillEx, partner.StoreAcctTypeExpendCreateWaybillTip, partner.StoreAcctTypeExpendCreateWaybill2ndMore, partner.StoreAcctTypeRealFeeExpend}, vendorOrderID, utils.ZeroTimeValue, utils.ZeroTimeValue)
|
||||
// 当前订单的退费金额()
|
||||
incomes, err = dao.GetStoreAcctIncomeTotal(db, 0, []int{partner.StoreAcctTypeRealFeeIncome, partner.StoreAcctTypeIncomeCancelTemp, partner.StoreAcctTypeIncomeCancelReal}, vendorOrderID, utils.ZeroTimeValue, utils.ZeroTimeValue)
|
||||
if expends != incomes {
|
||||
if expends > incomes {
|
||||
|
||||
@@ -412,7 +412,7 @@ func CreateUser(user *model.User, creatorName string) (err error) {
|
||||
}
|
||||
//支付宝注册电话需要解密
|
||||
if user.GetMobile() != "" && user.GetName() != "" && user.GetID2() != "" {
|
||||
if user.LastLoginType != "" && user.LastLoginType == alipay.AuthType {
|
||||
if user.LastLoginType == alipay.AuthType {
|
||||
mobile := &alipayapi.KeyMobile{}
|
||||
data, _ := base64.StdEncoding.DecodeString(user.GetMobile())
|
||||
key, _ := base64.StdEncoding.DecodeString(alipay.AuthKey)
|
||||
|
||||
@@ -200,18 +200,18 @@ func Init() {
|
||||
orderman.UpdateTiktokShopTotalMoney()
|
||||
}, []string{
|
||||
"03:35:00",
|
||||
"09:35:00",
|
||||
})
|
||||
|
||||
// 每分钟轮询一次,推送抖店骑手信息
|
||||
// 每分钟轮询一次,推送骑手信息
|
||||
ScheduleTimerFuncByInterval(func() {
|
||||
delivery.UpdateFakeWayBillToTiktok()
|
||||
}, 10*time.Second, 5*time.Second)
|
||||
|
||||
// 抖音自动刷单
|
||||
// (自动发单拣货,设置骑手)
|
||||
ScheduleTimerFuncByInterval(func() {
|
||||
if beego.BConfig.RunMode != "jxgy" {
|
||||
auto_delivery.AutoSettingFakeDelivery()
|
||||
}
|
||||
auto_delivery.Init() // 初始化骑手列表
|
||||
auto_delivery.AutoSettingFakeDelivery()
|
||||
}, 10*time.Second, 3*time.Minute)
|
||||
|
||||
// 定时任务更新负责人信息
|
||||
@@ -594,8 +594,8 @@ func syncStoreSku() {
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
}
|
||||
|
||||
var storeIds = []int{
|
||||
668802, 668787, 668785, 668777, 668769, 668776, 668770, 668760, 668758, 668756, 668748, 668727, 668723, 300372, 668715, 668717, 668707, 668667, 668668, 800306, 668628, 668681, 668673, 668544, 668619, 668614, 668600, 102217, 667405, 100988, 668353, 103022, 668283, 667208, 668266, 102101, 100610, 103201, 103459, 667154, 102691, 666747, 103417, 666744, 666864, 102186, 667271, 101750, 101031, 667452, 666942, 666927, 100068, 668339, 668306, 668310, 667352, 102544, 667014, 102280, 667134, 102945, 103062, 102443, 668218, 666913, 102742, 668360, 102851, 668580, 667252, 666746, 100455, 667037, 667317, 667473, 666816, 103063, 666800, 668210, 103079, 668200, 668176, 667462, 102426, 667116, 668309, 100193, 666828, 666944, 102852, 666900, 668521, 668373, 102596, 668444, 667071, 668264, 668395, 668090, 102172, 102790, 101935, 667480, 102479, 103197, 102703, 668386, 668229, 666948, 101008, 668249, 102374, 667464, 668468, 102490, 666756, 102976, 667467, 666707, 668270, 667429, 103098, 668135, 668523, 666907, 668407, 668358, 668385, 101134, 100887, 668568, 668003, 101763, 100829, 667476, 101078, 668099, 668503, 666807, 100167, 100433, 668107, 667262, 100849, 102771, 667173, 666847, 667485, 102821, 666955, 101107, 667229, 102950, 103435, 102497, 666916, 668163, 668061, 102147, 668248, 667066, 102853, 667944, 100002, 102865, 668219, 100184, 666840, 667057, 668202, 102223, 667101, 667128, 101110, 668511, 103151, 667093, 668154, 666905, 668268, 666929, 102935, 102074, 668174, 668217, 102350, 666940, 102980, 668117, 668384, 100067, 101916, 102987, 667250, 668570, 667466, 101099, 667082, 100229, 667553, 100215, 667991, 100217, 103073, 103074, 103037, 668180, 668583, 668462, 667891, 666811, 666736, 668173, 100267, 102962, 102752, 668284, 667296, 668175, 667806, 103103, 103084, 668453, 102970, 103184, 668548, 101036, 668182, 668157, 668257, 668166, 668543, 668170, 668071, 667744, 102925, 100115, 668093, 667745, 668164, 668156, 667743, 668165, 103408, 103038, 667268, 667094, 667321, 100726, 102333, 666742, 101775, 100028, 668304, 667305, 101942, 668575, 101755, 103425, 102833, 100699, 103190, 666711, 668396, 100334, 102533, 100336, 101995, 102320, 101842, 102519, 101999, 102433, 100920, 102594, 102951, 668506, 666667, 102963, 300034, 667212, 100236, 101909, 668541, 102857, 668417, 102955, 103031, 668545, 666790, 100328}
|
||||
//var storeIds = []int{
|
||||
// 668802, 668787, 668785, 668777, 668769, 668776, 668770, 668760, 668758, 668756, 668748, 668727, 668723, 300372, 668715, 668717, 668707, 668667, 668668, 800306, 668628, 668681, 668673, 668544, 668619, 668614, 668600, 102217, 667405, 100988, 668353, 103022, 668283, 667208, 668266, 102101, 100610, 103201, 103459, 667154, 102691, 666747, 103417, 666744, 666864, 102186, 667271, 101750, 101031, 667452, 666942, 666927, 100068, 668339, 668306, 668310, 667352, 102544, 667014, 102280, 667134, 102945, 103062, 102443, 668218, 666913, 102742, 668360, 102851, 668580, 667252, 666746, 100455, 667037, 667317, 667473, 666816, 103063, 666800, 668210, 103079, 668200, 668176, 667462, 102426, 667116, 668309, 100193, 666828, 666944, 102852, 666900, 668521, 668373, 102596, 668444, 667071, 668264, 668395, 668090, 102172, 102790, 101935, 667480, 102479, 103197, 102703, 668386, 668229, 666948, 101008, 668249, 102374, 667464, 668468, 102490, 666756, 102976, 667467, 666707, 668270, 667429, 103098, 668135, 668523, 666907, 668407, 668358, 668385, 101134, 100887, 668568, 668003, 101763, 100829, 667476, 101078, 668099, 668503, 666807, 100167, 100433, 668107, 667262, 100849, 102771, 667173, 666847, 667485, 102821, 666955, 101107, 667229, 102950, 103435, 102497, 666916, 668163, 668061, 102147, 668248, 667066, 102853, 667944, 100002, 102865, 668219, 100184, 666840, 667057, 668202, 102223, 667101, 667128, 101110, 668511, 103151, 667093, 668154, 666905, 668268, 666929, 102935, 102074, 668174, 668217, 102350, 666940, 102980, 668117, 668384, 100067, 101916, 102987, 667250, 668570, 667466, 101099, 667082, 100229, 667553, 100215, 667991, 100217, 103073, 103074, 103037, 668180, 668583, 668462, 667891, 666811, 666736, 668173, 100267, 102962, 102752, 668284, 667296, 668175, 667806, 103103, 103084, 668453, 102970, 103184, 668548, 101036, 668182, 668157, 668257, 668166, 668543, 668170, 668071, 667744, 102925, 100115, 668093, 667745, 668164, 668156, 667743, 668165, 103408, 103038, 667268, 667094, 667321, 100726, 102333, 666742, 101775, 100028, 668304, 667305, 101942, 668575, 101755, 103425, 102833, 100699, 103190, 666711, 668396, 100334, 102533, 100336, 101995, 102320, 101842, 102519, 101999, 102433, 100920, 102594, 102951, 668506, 666667, 102963, 300034, 667212, 100236, 101909, 668541, 102857, 668417, 102955, 103031, 668545, 666790, 100328}
|
||||
|
||||
func syncStoreSkuTiktok() {
|
||||
//syncFlag := 0 | model.SyncFlagSaleMask
|
||||
@@ -610,7 +610,7 @@ func syncStoreSkuTiktok() {
|
||||
if beego.BConfig.RunMode != "jxgy" {
|
||||
errList.AddErr(cms.DeleteSkuNameExPrefixOverdue(db))
|
||||
errList.AddErr(cms.SetMultiStoreSkuSyncModifyStatus(db, partner.GetMultiStoreVendorIDs()))
|
||||
_, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, []int{model.VendorIDDD}, storeIds, false, nil, nil, syncFlag, true, true)
|
||||
_, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, []int{model.VendorIDDD}, nil, false, nil, nil, syncFlag, true, true)
|
||||
errList.AddErr(err)
|
||||
}
|
||||
case 1:
|
||||
|
||||
@@ -126,9 +126,20 @@ func NotifyPickOrder(order *model.GoodsOrder) (err error) {
|
||||
}
|
||||
updateSth := func(order *model.GoodsOrder, store *dao.StoreDetail, feeType int) (err error) {
|
||||
order.NotifyType = int(store.SMSNotify)
|
||||
err = partner.CurOrderManager.UpdateOrderFields(order, []string{"NotifyType"})
|
||||
partner.CurOrderManager.UpdateOrderFields(order, []string{"NotifyType"})
|
||||
//品牌余额, 一条5分
|
||||
err = partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, 5, model.BrandBillTypeExpend, feeType, order.VendorOrderID, "")
|
||||
//if order.CreateDeliveryType == model.YES { // 门店发单
|
||||
noticeType := 0
|
||||
switch feeType {
|
||||
case model.BrandBillFeeTypeSms:
|
||||
noticeType = partner.StoreAcctTypeExpendTextMessageNotify
|
||||
case model.BrandBillFeeTypeVoice:
|
||||
noticeType = partner.StoreAcctTypeExpendVoiceMessageNotify
|
||||
}
|
||||
err = partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(jxcontext.AdminCtx, store.ID, 5, noticeType, order.VendorOrderID, "", 0)
|
||||
/*} else if order.CreateDeliveryType == model.NO { // 品牌发单
|
||||
err = partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, 5, model.BrandBillTypeExpend, feeType, order.VendorOrderID, "")
|
||||
}*/
|
||||
return err
|
||||
}
|
||||
balance, _ := partner.CurStoreAcctManager.GetBrandBalance(store.BrandID)
|
||||
|
||||
@@ -511,8 +511,7 @@ func SendMessage(t *BaseTask) {
|
||||
}
|
||||
|
||||
if err := ddmsg.SendUserMessage(dingdingapi.MsgTyeText, authInfo.UserID, "异步任务完成", content); err != nil {
|
||||
err2 := enterprise_msg.SendUserMessage(authInfo.Mobile, "异步任务完成", "", content)
|
||||
globals.SugarLogger.Errorf("==============errr ddd %v", err2)
|
||||
enterprise_msg.SendUserMessage(authInfo.Mobile, "异步任务完成", "", content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,8 @@ type GoodsOrderExt struct {
|
||||
OperatorPhone3 string `orm:"size(16)" json:"operatorPhone3"` // 饿百运营人电话
|
||||
OperatorName3 string `orm:"size(32)" json:"operatorName3"` // 饿百运营人组(角色)
|
||||
|
||||
VendorPayType string `json:"vendorPayType"` // 支付方式,当订单来源小程序时通过支付方式区分订单来源(w06微信/tt抖音/ks快手/支付宝)
|
||||
VendorPayType string `json:"vendorPayType"` // 支付方式,当订单来源小程序时通过支付方式区分订单来源(w06微信/tt抖音/ks快手/支付宝)
|
||||
LiquidatedDamages int64 `json:"liquidated_damages"` // 违约金
|
||||
}
|
||||
|
||||
type OrderSkuExt struct {
|
||||
|
||||
@@ -58,9 +58,10 @@ const (
|
||||
VendorIDDDH5MicroApp = 311 // 钉钉H5微应用
|
||||
VendorIDDDMobileQRCode = 312 // 钉钉移动接入应用(登录)
|
||||
|
||||
VendorIDAutonavi = 321 // 高德导航
|
||||
VendorIDQiNiuCloud = 323 // 七牛云
|
||||
VendorIDShowAPI = 325 // 万维易源
|
||||
VendorIDAutonavi = 321 // 高德导航
|
||||
VendorIDQiNiuCloud = 323 // 七牛云
|
||||
VendorIDShowAPI = 325 // 万维易源
|
||||
WayBillDeliveryMarkUp = 20 // 运单加价两毛钱
|
||||
|
||||
// 美团配送门店配送方式
|
||||
MTWMStorePSWay1 = "1003" //美团跑腿(众包)
|
||||
|
||||
@@ -448,13 +448,11 @@ type DeliveryFee struct {
|
||||
// GetPlatformDesiredFee 统计平台的订单的配送费信息
|
||||
func GetPlatformDesiredFee(db *DaoDB, storeIDs []int, finishedAtBegin, finishedAtEnd time.Time) (fee []*DeliveryFee, err error) {
|
||||
sql := `
|
||||
SELECT sum(b.actual_fee) actual_fee,b.order_vendor_id vendor_id FROM goods_order t2
|
||||
RIGHT JOIN waybill b ON t2.vendor_order_id = b.vendor_order_id AND b.status IN (?,?) AND b.vendor_order_id <> b.vendor_waybill_id
|
||||
SELECT sum(b.desired_fee) actual_fee,b.order_vendor_id vendor_id FROM goods_order t2
|
||||
RIGHT JOIN waybill b ON t2.vendor_order_id = b.vendor_order_id AND b.vendor_order_id <> b.vendor_waybill_id
|
||||
WHERE t2.order_finished_at >= ? AND t2.order_finished_at <= ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
model.WaybillStatusDelivered,
|
||||
110,
|
||||
finishedAtBegin,
|
||||
finishedAtEnd,
|
||||
}
|
||||
@@ -1030,7 +1028,6 @@ func GetOrders(db *DaoDB, ids []int64, isIncludeSku, isIncludeFake bool, fromDat
|
||||
if len(statuss) > 0 {
|
||||
sqlWhere += " AND t1.status IN (" + GenQuestionMarks(len(statuss)) + ")"
|
||||
sqlParams = append(sqlParams, statuss)
|
||||
//globals.SugarLogger.Debugf("sqlParams statuss===========%d", statuss)
|
||||
}
|
||||
}
|
||||
if params["lockStatuss"] != nil {
|
||||
@@ -1466,13 +1463,24 @@ func GetOrdersForJxPay(db *DaoDB, finishTimeBegin, finishTimeEnd time.Time) (goo
|
||||
return goods, err
|
||||
}
|
||||
|
||||
func GetWaybills(db *DaoDB, vendorOrderID string) (waybills []*model.Waybill, err error) {
|
||||
// UpdateWaybillActualFee 修改运单实际支付价格
|
||||
func UpdateWaybillActualFee(db *DaoDB, vendorWaybillId, vendorOrderId string, actualFee, desiredFee int64) error {
|
||||
sql := ` UPDATE waybill SET actual_fee = ? ,desired_fee = ? WHERE vendor_order_id = ? AND vendor_waybill_id = ?`
|
||||
_, err := ExecuteSQL(db, sql, []interface{}{actualFee, desiredFee, vendorOrderId, vendorWaybillId}...)
|
||||
return err
|
||||
}
|
||||
|
||||
func GetWaybills(db *DaoDB, vendorOrderID string, vendors []int64) (waybills []*model.Waybill, err error) {
|
||||
sql := ` SELECT *
|
||||
FROM waybill
|
||||
WHERE vendor_order_id = ? ORDER BY waybill_created_at asc
|
||||
WHERE vendor_order_id = ?
|
||||
`
|
||||
|
||||
if len(vendors) > model.NO {
|
||||
sql += " AND waybill_vendor_id IN (" + GenQuestionMarks(len(vendors)) + ")"
|
||||
}
|
||||
sql += ` ORDER BY waybill_created_at asc`
|
||||
sqlParams := []interface{}{vendorOrderID}
|
||||
sqlParams = append(sqlParams, vendors)
|
||||
err = GetRows(db, &waybills, sql, sqlParams)
|
||||
return waybills, err
|
||||
}
|
||||
@@ -1895,9 +1903,9 @@ func GetOrderStoreIDs(db *DaoDB, beginAt, endAt time.Time, vendorID int) (storeI
|
||||
}
|
||||
|
||||
// GetOrderListByStoreList 根据门店id获取正在刷单的门店商品
|
||||
func GetOrderListByStoreList(db *DaoDB, storeId []int64) (order []*model.GoodsOrder, err error) {
|
||||
sql := `SELECT * FROM goods_order g WHERE g.order_created_at >= ? AND g.order_created_at <= ? AND g.jx_store_id IN (` + GenQuestionMarks(len(storeId)) + `)` + `AND g.vendor_id IN (` + GenQuestionMarks(2) + `)` + `AND g.status < ?`
|
||||
sqlParam := []interface{}{time.Now().AddDate(0, 0, -5), time.Now().AddDate(0, 0, 1), storeId, []int{model.VendorIDDD, model.VendorIDEBAI}, model.OrderStatusDelivering}
|
||||
func GetOrderListByStoreList(db *DaoDB, storeId []int64, vendorId int) (order []*model.GoodsOrder, err error) {
|
||||
sql := `SELECT * FROM goods_order g WHERE g.order_created_at >= ? AND g.order_created_at <= ? AND g.jx_store_id IN (` + GenQuestionMarks(len(storeId)) + `)` + ` AND g.vendor_id = ? ` + `AND g.status < ?`
|
||||
sqlParam := []interface{}{time.Now().AddDate(0, 0, -5), time.Now().AddDate(0, 0, 1), storeId, vendorId, model.OrderStatusDelivering}
|
||||
|
||||
if err := GetRows(db, &order, sql, sqlParam...); err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -41,6 +41,20 @@ func GetPlacesByCond(db *DaoDB, enableCond int) (placeList []*model.Place, err e
|
||||
return placeList, err
|
||||
}
|
||||
|
||||
// GetParentCodeByCode 根据城市code获取省份code
|
||||
func GetParentCodeByCode(db *DaoDB, code int) (*model.Place, error) {
|
||||
sql := `
|
||||
SELECT p1.* FROM place p1
|
||||
INNER JOIN place p2 On p1.code = p2.parent_code
|
||||
WHERE p2.code = ? `
|
||||
|
||||
place := &model.Place{}
|
||||
if err := GetRow(db, place, sql, []interface{}{code}...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return place, nil
|
||||
}
|
||||
|
||||
func GetPlaceByName(db *DaoDB, name string, level int, parentCode int) (place *model.Place, err error) {
|
||||
if db == nil {
|
||||
db = GetDB()
|
||||
|
||||
@@ -29,7 +29,7 @@ type StoreDetail struct {
|
||||
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
|
||||
PricePercentagePackStr string `orm:"size(4096)" json:"-"` //
|
||||
PricePercentagePackObj model.PricePercentagePack `orm:"-" json:"-"`
|
||||
CreateDeliveryType int `orm:"default(0)" json:"createDeliveryType"` //默认0系统发单,1为门店发单
|
||||
CreateDeliveryType int `orm:"default(0)" json:"createDeliveryType"` //默认0系统(品牌)发单,1为门店发单
|
||||
|
||||
FreightDeductionPackStr string `orm:"size(4096)" json:"-"` //
|
||||
FreightDeductionPackObj *model.FreightDeductionPack `orm:"-" json:"-"`
|
||||
@@ -1162,11 +1162,11 @@ func GetStoreAcctExpendTotal(db *DaoDB, storeID int, expendTypes []int, vendorOr
|
||||
|
||||
type GetStoreAcctExpendLastCreateWayBillFeeResult struct {
|
||||
ID int `orm:"column(id)" json:"id"`
|
||||
ExpID int `orm:"column(exp_id)" json:"expID"` //少扣的钱
|
||||
IncID int `orm:"column(inc_id)" json:"incID"` //多扣的钱
|
||||
ExpendPrice int `json:"expendPrice"`
|
||||
MulitExpendPrice int `json:"mulitExpendPrice"`
|
||||
MulitIncomePrice int `json:"mulitIncomePrice"`
|
||||
ExpID int `orm:"column(exp_id)" json:"expID"` // 支出记录id(金额补充)
|
||||
IncID int `orm:"column(inc_id)" json:"incID"` // 退费记录id(金额退款)
|
||||
ExpendPrice int `json:"expendPrice"` // 运单支出金额
|
||||
MulitExpendPrice int `json:"mulitExpendPrice"` // 运单补充金额
|
||||
MulitIncomePrice int `json:"mulitIncomePrice"` // 运单退还金额
|
||||
}
|
||||
|
||||
func GetStoreAcctExpendLastCreateWayBillFee(db *DaoDB, vendorOrderID string) (expend *GetStoreAcctExpendLastCreateWayBillFeeResult, lastFee int, err error) {
|
||||
@@ -1180,7 +1180,7 @@ func GetStoreAcctExpendLastCreateWayBillFee(db *DaoDB, vendorOrderID string) (ex
|
||||
AND a.type = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
20,
|
||||
20, // partner.StoreAcctTypeExpendCreateWaybillEx 零食运费
|
||||
}
|
||||
if vendorOrderID != "" {
|
||||
sql += " AND a.vendor_order_id = ?"
|
||||
@@ -1397,6 +1397,34 @@ func GetBrandBalance(db *DaoDB, brandID int) (result int, err error) {
|
||||
return balance.Balance, err
|
||||
}
|
||||
|
||||
// GetBrandBillOrderExpend 获取订单品牌支出记录
|
||||
func GetBrandBillOrderExpend(db *DaoDB, brandId int, vendorOrderID string) (int, error) {
|
||||
var Price = &struct {
|
||||
Price int
|
||||
}{}
|
||||
|
||||
sql := `SELECT IFNULL(SUM(price),0) price FROM brand_bill
|
||||
WHERE brand_id = ? AND bill_type = ? AND vendor_order_id = ? AND fee_type IN (?,?,?) `
|
||||
sqlParam := []interface{}{brandId, model.BrandBillTypeExpend, vendorOrderID, model.BrandBillFeeTypeDelivery, model.BrandBillFeeTypeTipFee, model.BrandBillFeeTypeDeductFee}
|
||||
|
||||
err := GetRow(db, &Price, sql, sqlParam)
|
||||
return Price.Price, err
|
||||
}
|
||||
|
||||
// GetBrandBillOrderIncome 获取品牌订单的退还记录
|
||||
func GetBrandBillOrderIncome(db *DaoDB, brandId int, vendorOrderID string) (int, error) {
|
||||
var Price = &struct {
|
||||
Price int
|
||||
}{}
|
||||
|
||||
sql := `SELECT IFNULL(SUM(price),0) price FROM brand_bill
|
||||
WHERE brand_id = ? AND bill_type = ? AND vendor_order_id = ? AND fee_type IN (?,?,?) `
|
||||
sqlParam := []interface{}{brandId, model.BrandBillTypeIncome, vendorOrderID, model.BrandBillFeeTypeDelivery, model.BrandBillFeeTypeTipFee, model.BrandBillFeeTypeDeductFee}
|
||||
|
||||
err := GetRow(db, &Price, sql, sqlParam)
|
||||
return Price.Price, err
|
||||
}
|
||||
|
||||
func GetBrandBill(db *DaoDB, brandID int, vendorOrderID string, billType, feeType int, vendorWaybillOrderID string) (result []*model.BrandBill, err error) {
|
||||
sql := `
|
||||
SELECT *
|
||||
|
||||
@@ -20,6 +20,9 @@ const (
|
||||
|
||||
ErrCodeAccountBalanceNotEnough = "-201" //余额不足
|
||||
ErrCodeNotAuthBindWeixin = "-202" //没有绑定微信认证方式
|
||||
|
||||
ErrCodeOnePayTipFeeMore = "10001" // 单次支付金额太多
|
||||
ErrCodeIsPaySure = "10000" // 是否确认支付
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -234,7 +234,7 @@ type Waybill struct {
|
||||
Status int `json:"status"` // 参见WaybillStatus*相关的常量定义
|
||||
VendorStatus string `orm:"size(255)" json:"-"`
|
||||
ActualFee int64 `json:"actualFee"` // 实际要支付给快递公司的费用
|
||||
DesiredFee int64 `json:"desiredFee"` // 运单总费用
|
||||
DesiredFee int64 `json:"desiredFee"` // 运单总费用(原价+两毛)统计使用
|
||||
TipFee int64 `json:"tipFee"` // 运单小费,不含在上两项中
|
||||
DuplicatedCount int `json:"-"` // 重复新订单消息数,这个一般不是由于消息重发造成的(消息重发由OrderStatus过滤),一般是业务逻辑造成的
|
||||
DeliveryFlag int8 `json:"deliveryFlag"`
|
||||
|
||||
@@ -29,6 +29,8 @@ const (
|
||||
BrandBillFeeTypeVoice = 4 //语音费用
|
||||
BrandBillFeeTypeDelivery = 5 //三方配送费
|
||||
BrandBillFeeTypeSecretNumber = 6 //隐私号电话
|
||||
BrandBillFeeTypeTipFee = 7 //小费
|
||||
BrandBillFeeTypeDeductFee = 8 //取消三方配送违约金
|
||||
|
||||
BrandOpenMTPS = 1 //品牌开关标志, 美团配送
|
||||
BrandOpenDaDa = 2 //达达
|
||||
@@ -471,55 +473,46 @@ func (*StoreSub) TableUnique() [][]string {
|
||||
type StoreMap 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"`
|
||||
Status int `json:"status"` // 取值同Store.Status
|
||||
IsOnline int `json:"isOnline"` //上下线状态, -1是下线,1是上线
|
||||
StoreName string `orm:"size(255)" json:"storeName"` // 平台门店的名字,由平台到京西
|
||||
VendorStoreName string `orm:"size(255)" json:"vendorStoreName"` //平台门店名,由京西到平台
|
||||
VendorPayPercentage int `json:"vendorPayPercentage"` //平台结算比例
|
||||
|
||||
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
|
||||
PricePercentagePack string `orm:"size(32)" json:"pricePercentagePack"` //
|
||||
FreightDeductionPack string `orm:"size(32)" json:"freightDeductionPack"` //
|
||||
|
||||
AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货
|
||||
DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型
|
||||
DeliveryFeeDeductionSill int `json:"deliveryFeeDeductionSill"` //在vendorID=14,存储满 x 包邮金额
|
||||
DeliveryFeeDeductionFee int `json:"deliveryFeeDeductionFee"` //在vendorID=14,存储打包费
|
||||
DeliveryCompetition int8 `orm:"default(1)" json:"deliveryCompetition"` // 是否支持配送竞争
|
||||
CreateDeliveryType int `orm:"default(0)" json:"createDeliveryType"` //默认0系统发单,1为门店发单
|
||||
IsService int `orm:"default(0)" json:"isService"` // 默认0非服务商,1服务商
|
||||
|
||||
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
|
||||
IsSync int8 `orm:"default(1)" json:"isSync"` // 是否同步
|
||||
SyncRule int8 `orm:"default(0)" json:"syncRule"` //目前用于京东商城晚上的同步规则,0表示关闭,1表示小同步,2表示大同步
|
||||
FakeOpenStart int16 `orm:"default(0)" json:"fakeOpenStart"` // 假开店开始
|
||||
FakeOpenStop int16 `orm:"default(0)" json:"fakeOpenStop"` // 假开店结束
|
||||
JdStoreLevel string `orm:"size(32)" json:"jdStoreLevel"` //京东门店等级
|
||||
JdsStreetCode int `orm:"default(0)" json:"jdsStreetCode"` //京东商城直辖市街道code
|
||||
JdsStreetName string `orm:"size(32)" json:"jdsStreetName"` //京东商城直辖市街道
|
||||
|
||||
IsOrder int `orm:"default(0)" json:"isOrder"` //是否是下预订单门店
|
||||
IsSysCat int `orm:"default(0)" json:"isSysCat"` //是否使用京西分类
|
||||
IsSupplyGoods int `orm:"default(0)" json:"isSupplyGoods"` // 是否是货源门店
|
||||
|
||||
YbAppID string `orm:"column(yb_app_id);size(255)" json:"ybAppID"`
|
||||
YbAppKey string `orm:"size(255)" json:"ybAppKey"`
|
||||
YbStorePrefix string `orm:"size(255)" json:"ybStorePrefix"` //在vendorID=14,存储抖店门店起送金额 单位分
|
||||
|
||||
MtwmToken string `orm:"size(512)" json:"mtwmToken"` //美团外卖商超token,有效期30天,每20天刷一次
|
||||
MtwmRefreshToken string `orm:"size(255)" json:"mtwmRefreshToken"` //美团外卖商超refreshToken
|
||||
EbaiSupplierID string `orm:"column(ebai_supplier_id)" json:"ebaiSupplierID"` //饿百供应商ID
|
||||
|
||||
BussinessStatus int `orm:"-" json:"bussinessStatus"`
|
||||
|
||||
VendorAccount string `orm:"size(255)" json:"vendorAccount"` //商户在平台上的账号(授权用
|
||||
VendorPasswaord string `orm:"size(255)" json:"vendorPasswaord"` //商户在平台上的密码( aes cbc base64后的
|
||||
AuditStatus int `json:"auditStatus"` //审核状态(授权状态
|
||||
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"`
|
||||
Status int `json:"status"` // 取值同Store.Status
|
||||
IsOnline int `json:"isOnline"` //上下线状态, -1是下线,1是上线
|
||||
StoreName string `orm:"size(255)" json:"storeName"` // 平台门店的名字,由平台到京西
|
||||
VendorStoreName string `orm:"size(255)" json:"vendorStoreName"` //平台门店名,由京西到平台
|
||||
VendorPayPercentage int `json:"vendorPayPercentage"` //平台结算比例
|
||||
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
|
||||
PricePercentagePack string `orm:"size(32)" json:"pricePercentagePack"` //
|
||||
FreightDeductionPack string `orm:"size(32)" json:"freightDeductionPack"` //
|
||||
AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货
|
||||
DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型
|
||||
DeliveryFeeDeductionSill int `json:"deliveryFeeDeductionSill"` //在vendorID=14,存储满 x 包邮金额
|
||||
DeliveryFeeDeductionFee int `json:"deliveryFeeDeductionFee"` //在vendorID=14,存储打包费
|
||||
DeliveryCompetition int8 `orm:"default(1)" json:"deliveryCompetition"` // 是否支持配送竞争
|
||||
CreateDeliveryType int `orm:"default(0)" json:"createDeliveryType"` //默认0系统发单,1为门店发单
|
||||
IsService int `orm:"default(0)" json:"isService"` // 默认0非服务商,1服务商
|
||||
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
|
||||
IsSync int8 `orm:"default(1)" json:"isSync"` // 是否同步
|
||||
SyncRule int8 `orm:"default(0)" json:"syncRule"` //目前用于京东商城晚上的同步规则,0表示关闭,1表示小同步,2表示大同步
|
||||
FakeOpenStart int16 `orm:"default(0)" json:"fakeOpenStart"` // 假开店开始
|
||||
FakeOpenStop int16 `orm:"default(0)" json:"fakeOpenStop"` // 假开店结束
|
||||
JdStoreLevel string `orm:"size(32)" json:"jdStoreLevel"` //京东门店等级
|
||||
JdsStreetCode int `orm:"default(0)" json:"jdsStreetCode"` //京东商城直辖市街道code
|
||||
JdsStreetName string `orm:"size(32)" json:"jdsStreetName"` //京东商城直辖市街道
|
||||
IsOrder int `orm:"default(0)" json:"isOrder"` //是否是下预订单门店
|
||||
IsSysCat int `orm:"default(0)" json:"isSysCat"` //是否使用京西分类
|
||||
IsSupplyGoods int `orm:"default(0)" json:"isSupplyGoods"` // 是否是货源门店
|
||||
YbAppID string `orm:"column(yb_app_id);size(255)" json:"ybAppID"`
|
||||
YbAppKey string `orm:"size(255)" json:"ybAppKey"`
|
||||
YbStorePrefix string `orm:"size(255)" json:"ybStorePrefix"` //在vendorID=14,存储抖店门店起送金额 单位分
|
||||
MtwmToken string `orm:"size(512)" json:"mtwmToken"` //美团外卖商超token,有效期30天,每20天刷一次
|
||||
MtwmRefreshToken string `orm:"size(255)" json:"mtwmRefreshToken"` //美团外卖商超refreshToken
|
||||
EbaiSupplierID string `orm:"column(ebai_supplier_id)" json:"ebaiSupplierID"` //饿百供应商ID
|
||||
BussinessStatus int `orm:"-" json:"bussinessStatus"`
|
||||
VendorAccount string `orm:"size(255)" json:"vendorAccount"` //商户在平台上的账号(授权用
|
||||
VendorPasswaord string `orm:"size(255)" json:"vendorPasswaord"` //商户在平台上的密码( aes cbc base64后的
|
||||
AuditStatus int `json:"auditStatus"` //审核状态(授权状态
|
||||
}
|
||||
|
||||
func (*StoreMap) TableUnique() [][]string {
|
||||
@@ -904,12 +897,13 @@ func (*BrandStore) TableUnique() [][]string {
|
||||
type StoreAcctIncome struct {
|
||||
ModelIDCUL
|
||||
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"` //门店ID
|
||||
VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"`
|
||||
UserID string `orm:"column(user_id)" json:"userID"` //用户ID (谁消费的)
|
||||
ExpID int `orm:"column(exp_id)" json:"expID"` //用于关联多退少补的金额是对应哪一笔收入(支出)
|
||||
Type int `json:"type"` //收入类型
|
||||
IncomePrice int `json:"incomePrice"` //收入金额
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"` //门店ID
|
||||
VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"`
|
||||
VendorWaybillID string `orm:"column(vendor_waybill_id);size(48)" json:"vendorWaybillID"` // 运单id
|
||||
UserID string `orm:"column(user_id)" json:"userID"` //用户ID (谁消费的)
|
||||
ExpID int `orm:"column(exp_id)" json:"expID"` //用于关联多退少补的金额是对应哪一笔收入(支出)
|
||||
Type int `json:"type"` //收入类型
|
||||
IncomePrice int `json:"incomePrice"` //收入金额
|
||||
}
|
||||
|
||||
func (v *StoreAcctIncome) TableIndex() [][]string {
|
||||
@@ -923,12 +917,13 @@ func (v *StoreAcctIncome) TableIndex() [][]string {
|
||||
type StoreAcctExpend struct {
|
||||
ModelIDCUL
|
||||
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"` //门店ID
|
||||
VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"`
|
||||
UserID string `orm:"column(user_id)" json:"userID"` //用户ID (谁消费的)
|
||||
ExpID int `orm:"column(exp_id)" json:"expID"` //用于关联多退少补的金额是对应哪一笔收入(支出)
|
||||
Type int `json:"type"` //支出类型
|
||||
ExpendPrice int `json:"expendPrice"` //支出金额
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"` //门店ID
|
||||
VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"` // 订单id
|
||||
VendorWaybillID string `orm:"column(vendor_waybill_id);size(48)" json:"vendorWaybillID"` // 运单id
|
||||
UserID string `orm:"column(user_id)" json:"userID"` //用户ID (谁消费的)
|
||||
ExpID int `orm:"column(exp_id)" json:"expID"` //用于关联多退少补的金额是对应哪一笔收入(支出)
|
||||
Type int `json:"type"` //支出类型
|
||||
ExpendPrice int `json:"expendPrice"` //支出金额
|
||||
}
|
||||
|
||||
func (v *StoreAcctExpend) TableIndex() [][]string {
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/dadaapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -281,7 +282,7 @@ func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInf
|
||||
if result, err = api.DadaAPI.QueryDeliverFee(billParams); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(result.Fee)
|
||||
deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(result.DeliverFee) // jxutils.StandardPrice2Int(result.Fee)
|
||||
deliveryFeeInfo.RefDeliveryFee = deliveryFeeInfo.DeliveryFee
|
||||
}
|
||||
return deliveryFeeInfo, err
|
||||
@@ -357,6 +358,7 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
}
|
||||
// 重新发送订单
|
||||
result, err = api.DadaAPI.ReaddOrder(billParams)
|
||||
globals.SugarLogger.Debugf("重新发送订单多次发单======== := %s", utils.Format4Output(result, false))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -366,6 +368,7 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
if result, err = api.DadaAPI.QueryDeliverFee(billParams); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
globals.SugarLogger.Debugf("查询达达订单费用(第一次发单)======== := %s", utils.Format4Output(result, false))
|
||||
// 阀值警报
|
||||
if err = delivery.CallCreateWaybillPolicy(jxutils.StandardPrice2Int(result.Fee), maxDeliveryFee, order, model.VendorIDDada); err != nil {
|
||||
return nil, err
|
||||
@@ -374,6 +377,7 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
if err = api.DadaAPI.AddOrderAfterQuery(result.DeliveryNo); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
globals.SugarLogger.Debugf("重新发送订单======== := %s", utils.Format4Output(result, false))
|
||||
}
|
||||
if result == nil {
|
||||
return nil, errors.New("达达配送,平台调用错误,无订单数据返回")
|
||||
@@ -383,8 +387,8 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
VendorOrderID: order.VendorOrderID,
|
||||
OrderVendorID: order.VendorID,
|
||||
WaybillVendorID: model.VendorIDDada,
|
||||
DesiredFee: jxutils.StandardPrice2Int(result.Fee),
|
||||
ActualFee: jxutils.StandardPrice2Int(result.Fee),
|
||||
DesiredFee: jxutils.StandardPrice2Int(result.DeliverFee),
|
||||
ActualFee: jxutils.StandardPrice2Int(result.DeliverFee),
|
||||
}
|
||||
delivery.OnWaybillCreated(bill)
|
||||
return bill, err
|
||||
@@ -540,3 +544,41 @@ func (c *DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeiso
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetDeliverLiquidatedDamages 获取达达平台扣除配送费
|
||||
// 待接单,待取货(小于一分钟,大于十五分钟)不扣钱
|
||||
// 待取货1-15分钟内取消扣两元
|
||||
func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error) {
|
||||
dadaOrder, err := api.DadaAPI.QueryOrderInfo(orderId)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// 未接单不扣款
|
||||
if dadaOrder.AcceptTime == "" {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// 有了接单时间,订单变成了待取货
|
||||
if dadaOrder.AcceptTime != "" && dadaOrder.FetchTime == "" {
|
||||
nowTime := time.Now().Unix()
|
||||
fetchTime := utils.Str2Time(dadaOrder.AcceptTime).Unix()
|
||||
timeDiffer := nowTime - fetchTime
|
||||
if timeDiffer > 15*60 || timeDiffer < 60 {
|
||||
return 0, nil
|
||||
}
|
||||
return 200, nil
|
||||
}
|
||||
|
||||
// fetchTime 已经有时间了,代表已经取货.次数取消扣除此订单全部金额
|
||||
// 达达存在多个订单的运单违约金额统计在一起的情况
|
||||
if dadaOrder.FetchTime != "" {
|
||||
bill, err := partner.CurOrderManager.LoadWaybill(deliverId, model.VendorIDDada)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return bill.DesiredFee, nil
|
||||
}
|
||||
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -69,10 +69,14 @@ func (c *DeliveryHandler) CancelWaybill(bill *model.Waybill, cancelReasonID int,
|
||||
}
|
||||
parameter.PartnerOrderCode = bill.VendorOrderID
|
||||
if err = api.FnAPI.CancelOrder(parameter); err != nil {
|
||||
globals.SugarLogger.Debugf("============err := %v ", err)
|
||||
if strings.Contains(err.Error(), "运单暂未生成") {
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
bill.Status = model.WaybillStatusCanceled
|
||||
bill.Remark = cancelReason
|
||||
@@ -114,6 +118,7 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
ReceiverPrimaryPhone: order.ConsigneeMobile,
|
||||
OutShopCode: utils.Int2Str(order.JxStoreID),
|
||||
ChainStoreId: "",
|
||||
SerialNumber: fmt.Sprintf("%s #%d", model.VendorChineseNames[order.VendorID], order.OrderSeq),
|
||||
}
|
||||
// 重量超标减少配送费
|
||||
weight := 4.9500
|
||||
@@ -145,13 +150,15 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
}
|
||||
|
||||
// 查询订单获取配送费
|
||||
desireFee, actualFee := GetDesiredFee(order.VendorOrderID)
|
||||
bill = &model.Waybill{
|
||||
VendorOrderID: order.VendorOrderID,
|
||||
OrderVendorID: order.VendorID,
|
||||
VendorWaybillID: fnOrderId,
|
||||
VendorWaybillID2: order.VendorOrderID,
|
||||
WaybillVendorID: model.VendorIDFengNiao,
|
||||
DesiredFee: GetDesiredFee(order.VendorOrderID),
|
||||
DesiredFee: desireFee,
|
||||
ActualFee: actualFee,
|
||||
}
|
||||
delivery.OnWaybillCreated(bill)
|
||||
return bill, err
|
||||
@@ -192,17 +199,28 @@ func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInf
|
||||
preCreateOrder.GoodsItemList = goodsList
|
||||
|
||||
deliveryFeeInfo = &partner.WaybillFeeInfo{}
|
||||
deliveryFeeInfo.RefDeliveryFee, deliveryFeeInfo.RefAddFee, err = api.FnAPI.PreCreateByShopFn(preCreateOrder)
|
||||
deliveryFeeInfo.RefDeliveryFee, deliveryFeeInfo.RefAddFee, err = api.FnAPI.PreCreateByShopFn(preCreateOrder) //
|
||||
deliveryFeeInfo.DeliveryFee = deliveryFeeInfo.RefDeliveryFee
|
||||
return deliveryFeeInfo, err
|
||||
}
|
||||
|
||||
// 订单状态
|
||||
func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify) (resp *fnpsapi.CallbackResponse) {
|
||||
func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify, resultParam *fnpsapi.ShortStatus) (resp *fnpsapi.CallbackResponse) {
|
||||
cc := &fnpsapi.OrderCallbackParam{}
|
||||
if err := utils.Map2StructByJson(msg.Param, cc, true); err != nil {
|
||||
return fnpsapi.Err2CallbackResponse(err, "")
|
||||
}
|
||||
var good *model.GoodsOrder
|
||||
sql := `SELECT * FROM goods_order WHERE vendor_order_id = ? ORDER BY order_created_at DESC LIMIT 1 OFFSET 0`
|
||||
sqlParams := []interface{}{cc.PartnerOrderCode}
|
||||
dao.GetRow(dao.GetDB(), &good, sql, sqlParams)
|
||||
if good == nil || good.VendorOrderID == "" {
|
||||
_, err := fnpsapi.HttpToGuoYuanFN(utils.Struct2MapByJson(resultParam), "order")
|
||||
if err != nil {
|
||||
return fnpsapi.Err2CallbackResponse(err, "")
|
||||
}
|
||||
return fnpsapi.Err2CallbackResponse(nil, "")
|
||||
}
|
||||
|
||||
order := &model.Waybill{
|
||||
VendorWaybillID: utils.Int64ToStr(cc.OrderId),
|
||||
@@ -218,24 +236,19 @@ func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify) (resp *fnpsapi.CallbackRespon
|
||||
order.StatusTime = time.Now()
|
||||
}
|
||||
order.VendorOrderID, order.OrderVendorID = jxutils.SplitUniversalOrderID(cc.PartnerOrderCode)
|
||||
|
||||
var good *model.GoodsOrder
|
||||
sql := `SELECT * FROM goods_order WHERE vendor_order_id = ? ORDER BY order_created_at DESC LIMIT 1 OFFSET 0`
|
||||
sqlParams := []interface{}{cc.PartnerOrderCode}
|
||||
dao.GetRow(dao.GetDB(), &good, sql, sqlParams)
|
||||
order.OrderVendorID = good.VendorID
|
||||
|
||||
orderStatus := utils.Str2Int64(order.VendorStatus)
|
||||
switch orderStatus {
|
||||
case fnpsapi.OrderStatusAcceptCreate, fnpsapi.OrderStatusAccept: // 0 创建订单
|
||||
order.DesiredFee = GetDesiredFee(order.VendorOrderID)
|
||||
order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID)
|
||||
order.Status = model.WaybillStatusNew //5 带调度
|
||||
case fnpsapi.OrderStatusAssigned: //20分配骑手
|
||||
order.DesiredFee = GetDesiredFee(order.VendorOrderID)
|
||||
//order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID)
|
||||
order.Status = model.WaybillStatusCourierAssigned //12
|
||||
order.Remark = order.CourierName + "," + order.CourierMobile
|
||||
case fnpsapi.OrderStatusArrived: // 80 到店
|
||||
order.DesiredFee = GetDesiredFee(order.VendorOrderID)
|
||||
//order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID)
|
||||
order.Status = model.WaybillStatusCourierArrived
|
||||
case fnpsapi.OrderStatusDelivering: // 2 配送中
|
||||
order.Status = model.WaybillStatusDelivering
|
||||
@@ -319,11 +332,11 @@ func (c *DeliveryHandler) OnWaybillExcept(msg *fnpsapi.AbnormalReportNotify) (re
|
||||
}
|
||||
|
||||
// 查询订单配送费
|
||||
func GetDesiredFee(vendorOrderID string) (desiredFee int64) {
|
||||
func GetDesiredFee(vendorOrderID string) (desiredFee, acuteFee int64) {
|
||||
if result, err := api.FnAPI.QueryOrder(vendorOrderID); err == nil {
|
||||
return result.OrderActualAmountCent
|
||||
return result.OrderTotalAmountCent + int64(utils.WayBillDeliveryMarkUp), result.OrderActualAmountCent
|
||||
}
|
||||
return desiredFee
|
||||
return desiredFee, acuteFee
|
||||
}
|
||||
|
||||
// 获取骑手信息
|
||||
@@ -380,3 +393,36 @@ func (c *DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeiso
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetDeliverLiquidatedDamages 获取运单取消违约金
|
||||
// 蜂鸟:骑手接单后-取餐之前,每单扣除2元,超过20分钟不扣款
|
||||
func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error) {
|
||||
// 获取订单状态
|
||||
order, err := api.FnAPI.QueryOrder(orderId)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// 已经分配骑手,且超过十五分钟,不扣款
|
||||
if len(order.EventLogDetails) != model.NO {
|
||||
for i := len(order.EventLogDetails) - 1; i >= 0; i-- {
|
||||
switch order.EventLogDetails[i].OrderStatus {
|
||||
case fnpsapi.OrderStatusDelivered, fnpsapi.OrderStatusArrived, fnpsapi.OrderStatusDelivering: // 送达,到店,配送中 取消订单全额扣款
|
||||
return order.OrderTotalAmountCent, nil
|
||||
case fnpsapi.OrderStatusAcceptCacle, fnpsapi.OrderStatusException: // 取消和异常状态,跳过查看上一状态
|
||||
continue
|
||||
case fnpsapi.OrderStatusAcceptCreate, fnpsapi.OrderStatusAccept: // 生成运单和系统接单取消不扣除费用
|
||||
return 0, nil
|
||||
case fnpsapi.OrderStatusAssigned:
|
||||
if time.Now().UnixNano()/1e6-order.EventLogDetails[i].OccurTime > fnpsapi.WayBillPressureOrderTime {
|
||||
return 0, nil
|
||||
} else {
|
||||
return 200, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -107,3 +107,6 @@ func (c *DeliveryHandler) ComplaintRider(bill *model.Waybill, resonID int, reson
|
||||
func (c *DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeisongId string) (rider *mtpsapi.RiderInfo, err error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
@@ -92,6 +93,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m
|
||||
return mtpsapi.Err2CallbackResponse(err, fmt.Sprintf("%s", "获取订单状态错误"))
|
||||
}
|
||||
order.DesiredFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["delivery_fee"]) * 100)
|
||||
order.ActualFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["pay_amount"]) * 100)
|
||||
order.Status = model.WaybillStatusNew
|
||||
case mtpsapi.OrderStatusAccepted: // 已接单
|
||||
data, err := api.MtpsAPI.QueryOrderStatus(msg.DeliveryID, msg.MtPeisongID)
|
||||
@@ -99,6 +101,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m
|
||||
return mtpsapi.Err2CallbackResponse(err, fmt.Sprintf("%s", "获取订单状态错误"))
|
||||
}
|
||||
order.DesiredFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["delivery_fee"]) * 100)
|
||||
order.ActualFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["pay_amount"]) * 100)
|
||||
order.Status = model.WaybillStatusCourierAssigned
|
||||
order.Remark = order.CourierName + "," + order.CourierMobile
|
||||
case mtpsapi.OrderStatusPickedUp: // 已取货
|
||||
@@ -483,3 +486,36 @@ func (c *DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeiso
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error) {
|
||||
statusList, err := orderman.FixedOrderManager.GetWayBillStatusList(orderId, deliverId, model.VendorIDMTPS)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// 已经分配骑手,且超过十五分钟,不扣款
|
||||
if len(statusList) != model.NO {
|
||||
for i := len(statusList) - 1; i >= 0; i-- {
|
||||
switch statusList[i].VendorStatus {
|
||||
case utils.Int2Str(mtpsapi.OrderStatusWaitingForSchedule): // 待调度
|
||||
return 0, nil
|
||||
case utils.Int2Str(mtpsapi.OrderStatusCanceled): // 取消不管
|
||||
continue
|
||||
case utils.Int2Str(mtpsapi.OrderStatusDeliverred): // 送达
|
||||
continue
|
||||
case utils.Int2Str(mtpsapi.OrderStatusAccepted): // 接单
|
||||
// 接单取消扣凉快
|
||||
return 200, nil
|
||||
case utils.Int2Str(mtpsapi.OrderStatusPickedUp): // 取货
|
||||
bill, err := partner.CurOrderManager.LoadWaybill(deliverId, model.VendorIDMTPS)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return bill.DesiredFee, nil
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package delivery
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
@@ -100,7 +101,7 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
|
||||
}
|
||||
|
||||
if orderId == "" { // 订单id为空是,是定时轮询操作,不做此状态
|
||||
waybillList, _ := dao.GetWaybills(dao.GetDB(), v.VendorOrderID)
|
||||
waybillList, _ := dao.GetWaybills(dao.GetDB(), v.VendorOrderID, nil)
|
||||
if len(waybillList) > 0 && waybillList[0].Status > model.WaybillStatusEndBegin {
|
||||
globals.SugarLogger.Debugf("订单物流状态结束,不在推送订单状态:orderID[%s],wayBillId[%s]", v.VendorOrderID, waybillList[0].VendorWaybillID)
|
||||
continue
|
||||
@@ -207,6 +208,8 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
|
||||
continue
|
||||
case model.VendorIDDD: // 抖店小时达
|
||||
continue
|
||||
case model.VendorIDJX: // 京西平台
|
||||
continue
|
||||
default:
|
||||
globals.SugarLogger.Errorf("Order source error, non system order: %s", v.VendorOrderID)
|
||||
continue
|
||||
@@ -277,6 +280,14 @@ func UpdateOrder2Complete() {
|
||||
}
|
||||
|
||||
func makeRiderInfo(fakeWayBill *model.Waybill, riderInfo *mtpsapi.RiderInfo) {
|
||||
order, _ := partner.CurOrderManager.LoadOrder(fakeWayBill.VendorOrderID, fakeWayBill.OrderVendorID)
|
||||
storeId := 0
|
||||
if order.StoreID != 0 {
|
||||
storeId = order.StoreID
|
||||
} else {
|
||||
storeId = order.JxStoreID
|
||||
}
|
||||
storeDetail, _ := dao.GetStoreDetail(dao.GetDB(), storeId, order.VendorID, order.VendorOrgCode)
|
||||
switch fakeWayBill.Status {
|
||||
case 5: // 呼叫骑手
|
||||
riderInfo.LogisticsContext = "呼叫骑手,新建运单"
|
||||
@@ -290,8 +301,10 @@ func makeRiderInfo(fakeWayBill *model.Waybill, riderInfo *mtpsapi.RiderInfo) {
|
||||
fakeWayBill.VendorStatus = utils.Int64ToStr(model.WaybillStatusCourierAssigned)
|
||||
case 12: // 骑手接单
|
||||
riderInfo.LogisticsContext = model.RiderWaitGetGoods
|
||||
riderInfo.LogisticsStatus = 12
|
||||
riderInfo.LogisticsStatus = 10
|
||||
riderInfo.OpCode = tiktok_api.TiktokLogisticsORDERRECEIVED
|
||||
riderInfo.Latitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lat))
|
||||
riderInfo.Longitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lng))
|
||||
// 下一状态以及推送时间
|
||||
fakeWayBill.Status = model.WaybillStatusCourierArrived
|
||||
fakeWayBill.VendorStatus = utils.Int64ToStr(model.WaybillStatusCourierArrived)
|
||||
@@ -299,6 +312,8 @@ func makeRiderInfo(fakeWayBill *model.Waybill, riderInfo *mtpsapi.RiderInfo) {
|
||||
riderInfo.LogisticsContext = model.RiderToStore
|
||||
riderInfo.LogisticsStatus = 15
|
||||
riderInfo.OpCode = tiktok_api.TiktokLogisticsRIDERARRIVED
|
||||
riderInfo.Latitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lat))
|
||||
riderInfo.Longitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lng))
|
||||
// 下一状态以及推送时间
|
||||
fakeWayBill.Status = model.WaybillStatusDelivering
|
||||
fakeWayBill.VendorStatus = utils.Int64ToStr(model.WaybillStatusDelivering)
|
||||
@@ -306,6 +321,8 @@ func makeRiderInfo(fakeWayBill *model.Waybill, riderInfo *mtpsapi.RiderInfo) {
|
||||
riderInfo.LogisticsContext = model.RiderGetOrderDelivering
|
||||
riderInfo.LogisticsStatus = 20
|
||||
riderInfo.OpCode = tiktok_api.TiktokLogisticsRIDERPICKUP
|
||||
riderInfo.Latitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lat))
|
||||
riderInfo.Longitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lng))
|
||||
// 下一状态以及推送时间
|
||||
fakeWayBill.Status = model.WaybillStatusDelivered
|
||||
fakeWayBill.VendorStatus = utils.Int64ToStr(model.WaybillStatusDelivered)
|
||||
@@ -313,6 +330,8 @@ func makeRiderInfo(fakeWayBill *model.Waybill, riderInfo *mtpsapi.RiderInfo) {
|
||||
riderInfo.LogisticsContext = model.RiderGetOrderDelivered
|
||||
riderInfo.LogisticsStatus = 40
|
||||
riderInfo.OpCode = tiktok_api.TiktokLogisticsDELIVERED
|
||||
riderInfo.Latitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(order.ConsigneeLat))
|
||||
riderInfo.Longitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(order.ConsigneeLng))
|
||||
// 下一状态以及推送时间
|
||||
fakeWayBill.Status = model.WaybillStatusFailed
|
||||
fakeWayBill.VendorStatus = utils.Int64ToStr(model.WaybillStatusFailed)
|
||||
@@ -322,7 +341,7 @@ func makeRiderInfo(fakeWayBill *model.Waybill, riderInfo *mtpsapi.RiderInfo) {
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateFakeWayBillToTiktok 轮询更新假订单到抖音
|
||||
// UpdateFakeWayBillToTiktok 轮询更新假订单到抖音(抖音/美团/饿百)
|
||||
func UpdateFakeWayBillToTiktok() {
|
||||
scheduleTimer, _ := rand.Int(rand.Reader, big.NewInt(1000))
|
||||
randTimeSchedule := scheduleTimer.Int64()
|
||||
@@ -354,6 +373,7 @@ func UpdateFakeWayBillToTiktok() {
|
||||
LogisticsStatus: fakeWayBill[i].Status,
|
||||
}
|
||||
|
||||
// 设置骑手和下一状态时间
|
||||
makeRiderInfo(fakeWayBill[i], riderInfo)
|
||||
|
||||
if riderInfo.LogisticsContext != model.RiderGetOrderDeliverFailed && riderInfo.LogisticsContext != model.RiderGetOrderDeliverOther && riderInfo.LogisticsContext != model.RiderWaitRider {
|
||||
@@ -398,7 +418,7 @@ func UpdateFakeWayBillToTiktok() {
|
||||
globals.SugarLogger.Debugf("UPDATA goods_order Err :%s", err.Error())
|
||||
}
|
||||
// 饿百订单推送订单送达
|
||||
if fakeWayBill[i].OrderVendorID == model.VendorIDEBAI {
|
||||
if fakeWayBill[i].OrderVendorID == model.VendorIDEBAI || fakeWayBill[i].OrderVendorID == model.VendorIDMTWM {
|
||||
if err := handler.Swtich2SelfDelivered(order, "JingXiAdmin"); err != nil {
|
||||
globals.SugarLogger.Errorf("Swtich2SelfDelivered err := %v", err)
|
||||
}
|
||||
|
||||
@@ -198,8 +198,22 @@ func (d DeliveryHandler) ComplaintRider(bill *model.Waybill, resonID int, resonC
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetDeliverLiquidatedDamages 获取取消运单违约金
|
||||
func (d DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error) {
|
||||
waybill, err := dao.GetWaybills(dao.GetDB(), orderId, []int64{model.VendorIDSFPS})
|
||||
if len(waybill) == 0 || err != nil {
|
||||
return 0, err
|
||||
}
|
||||
deductionFee, err := api.SfPsAPI.PreCancelOrder(waybill[0].VendorWaybillID)
|
||||
if deductionFee == 0 || err != nil {
|
||||
return 0, err
|
||||
}
|
||||
money = jxutils.StandardPrice2Int(deductionFee)
|
||||
return money, nil
|
||||
}
|
||||
|
||||
func (d DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeisongId string) (rider *mtpsapi.RiderInfo, err error) {
|
||||
order, err := dao.GetWaybills(dao.GetDB(), orderId)
|
||||
order, err := dao.GetWaybills(dao.GetDB(), orderId, []int64{model.VendorIDSFPS})
|
||||
if len(order) == 0 || err != nil {
|
||||
return nil, errors.New("顺丰 订单id无效,请检查")
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee i
|
||||
VendorWaybillID: orderCode,
|
||||
VendorWaybillID2: originID,
|
||||
WaybillVendorID: model.VendorIDUUPT,
|
||||
DesiredFee: jxutils.StandardPrice2Int(utils.Str2Float64(price.NeedPayMoney)),
|
||||
DesiredFee: jxutils.StandardPrice2Int(utils.Str2Float64(price.TotalMoney)),
|
||||
}
|
||||
}
|
||||
delivery.OnWaybillCreated(bill)
|
||||
@@ -192,7 +192,8 @@ func (d DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo
|
||||
return nil, err
|
||||
} else {
|
||||
deliveryFeeInfo = &partner.WaybillFeeInfo{}
|
||||
deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(utils.Str2Float64(orderPrice.NeedPayMoney))
|
||||
// deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(utils.Str2Float64(orderPrice.NeedPayMoney)) 优惠后金额
|
||||
deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(utils.Str2Float64(orderPrice.TotalMoney)) // 原始金额
|
||||
}
|
||||
return deliveryFeeInfo, err
|
||||
}
|
||||
@@ -240,6 +241,10 @@ func (d DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeison
|
||||
return param, nil
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error) {
|
||||
return api.UuAPI.GetOrderLiquidatedDamages(deliverId, orderId)
|
||||
}
|
||||
|
||||
//辅助函数
|
||||
func getOrderPrice(order *model.GoodsOrder) (orderPrice *uuptapi.GetOrderPriceResp, err error) {
|
||||
store, err := dao.GetStoreDetail(dao.GetDB(), getReallyStoreID(order.StoreID, order.JxStoreID), 0, "")
|
||||
@@ -304,28 +309,39 @@ func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResp
|
||||
dao.GetRow(dao.GetDB(), &good, sql, sqlParams)
|
||||
param.OrderVendorID = good.VendorID
|
||||
//查询运单价格
|
||||
if uuPrice, err := api.UuAPI.GetOrderDetail(req.OrderCode); err != nil {
|
||||
uuPrice, err := api.UuAPI.GetOrderDetail(req.OrderCode)
|
||||
if err != nil {
|
||||
reallyPrice = 0
|
||||
} else {
|
||||
reallyPrice = int64((utils.Str2Float64(uuPrice.OrderPrice) - utils.Str2Float64(uuPrice.PriceOff)) * 100)
|
||||
reallyPrice = int64(utils.Str2Float64(uuPrice.OrderPrice) * 100)
|
||||
}
|
||||
actualFee := int64((utils.Str2Float64(uuPrice.OrderPrice)-utils.Str2Float64(uuPrice.PriceOff))*100) - int64(utils.WayBillDeliveryMarkUp)
|
||||
switch req.State {
|
||||
case uuptapi.StateConfirmSuccess:
|
||||
param.Status = model.WaybillStatusNew //5 待调度
|
||||
param.DesiredFee = reallyPrice
|
||||
param.ActualFee = actualFee
|
||||
case uuptapi.StateRMGrabsOrder:
|
||||
param.Status = model.WaybillStatusCourierAssigned
|
||||
param.Remark = req.DriverName + "," + req.DriverMobile
|
||||
param.DesiredFee = reallyPrice
|
||||
param.ActualFee = actualFee
|
||||
case uuptapi.StateArrivedStore:
|
||||
param.Status = model.WaybillStatusCourierArrived
|
||||
param.DesiredFee = reallyPrice
|
||||
case uuptapi.StatePickUp, uuptapi.StateArrivedDestination:
|
||||
param.Status = model.WaybillStatusDelivering
|
||||
param.ActualFee = actualFee
|
||||
case uuptapi.StatePickUp:
|
||||
param.Status = model.WaybillStatusUuPickUp
|
||||
param.DesiredFee = reallyPrice
|
||||
param.ActualFee = actualFee
|
||||
case uuptapi.StateArrivedDestination:
|
||||
param.Status = model.WaybillStatusUuArrivedDestination
|
||||
param.DesiredFee = reallyPrice
|
||||
param.ActualFee = actualFee
|
||||
case uuptapi.StateReceiverGetGoods:
|
||||
param.Status = model.WaybillStatusDelivered
|
||||
param.DesiredFee = reallyPrice
|
||||
param.ActualFee = actualFee
|
||||
case uuptapi.StateOrderCancel:
|
||||
param.Status = model.WaybillStatusCanceled
|
||||
default:
|
||||
@@ -355,9 +371,12 @@ func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResp
|
||||
case uuptapi.StateArrivedStore: //骑手到店
|
||||
result.LogisticsStatus = model.WaybillStatusCourierArrived
|
||||
result.LogisticsContext = model.RiderToStore
|
||||
case uuptapi.StatePickUp, uuptapi.StateArrivedDestination: //已取件
|
||||
result.LogisticsStatus = model.WaybillStatusDelivering
|
||||
case uuptapi.StatePickUp: //已取件
|
||||
result.LogisticsStatus = model.WaybillStatusUuPickUp
|
||||
result.LogisticsContext = model.RiderPickUp
|
||||
case uuptapi.StateArrivedDestination: //到达取件人地址处
|
||||
result.LogisticsStatus = model.WaybillStatusUuArrivedDestination
|
||||
result.LogisticsContext = model.RiderArrivedDestination
|
||||
case uuptapi.StateReceiverGetGoods: //取件人收货
|
||||
result.LogisticsStatus = model.WaybillStatusDelivered
|
||||
result.LogisticsContext = model.RiderGetOrderDelivered
|
||||
|
||||
@@ -18,10 +18,10 @@ const (
|
||||
type WaybillFeeInfo struct {
|
||||
ErrCode int `json:"errCode"`
|
||||
ErrStr string `json:"errStr"`
|
||||
RefDeliveryFee int64 `json:"refDeliveryFee"` // 无用,待删除
|
||||
RefAddFee int64 `json:"refAddFee"` // 无用,待删除
|
||||
DeliveryFee int64 `json:"deliveryFee"`
|
||||
TimeoutSecond int `json:"timeoutSecond"` // 系统会自动发运单的倒计时
|
||||
RefDeliveryFee int64 `json:"refDeliveryFee"` // 优惠后
|
||||
RefAddFee int64 `json:"refAddFee"` // 原始配送费
|
||||
DeliveryFee int64 `json:"deliveryFee"` // 优惠后
|
||||
TimeoutSecond int `json:"timeoutSecond"` // 系统会自动发运单的倒计时
|
||||
Waybill *model.Waybill `json:"waybill"`
|
||||
}
|
||||
|
||||
@@ -40,8 +40,16 @@ type IDeliveryPlatformHandler interface {
|
||||
GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo *WaybillFeeInfo, err error)
|
||||
//投诉骑手
|
||||
ComplaintRider(bill *model.Waybill, resonID int, resonContent string) (err error)
|
||||
// 获取骑手信息
|
||||
// GetRiderInfo 获取骑手信息
|
||||
GetRiderInfo(orderId string, deliveryId int64, mtPeisongId string) (rider *mtpsapi.RiderInfo, err error)
|
||||
// 三方配送时,呼叫骑手在取消.可能存在违约赔付!获取每单的违约金额!
|
||||
// 蜂鸟:骑手接单后-取餐之前,每单扣除2元,超过20分钟不扣款
|
||||
// 达达:骑手接单后-到店之前,接单1-15分钟内,扣款2元,超过不扣款
|
||||
// uu :接单后超过一定时间取消会产生违约金,取消后扣除费用退回剩余订单金额
|
||||
// 美团配送: 暂无
|
||||
|
||||
// GetDeliverLiquidatedDamages 获取配送单的违约金:京西订单id:orderId,配送方id:deliverId
|
||||
GetDeliverLiquidatedDamages(orderId string, deliverId string) (money int64, err error)
|
||||
}
|
||||
|
||||
type IDeliveryUpdateStoreHandler interface {
|
||||
|
||||
@@ -13,10 +13,13 @@ const (
|
||||
StoreAcctTypeIncomeCancelReal = 19 //运单取消,回退的真实运费
|
||||
|
||||
//账户支出类型
|
||||
StoreAcctTypeExpendCreateWaybillEx = 20 //发单扣除的临时运费
|
||||
StoreAcctTypeExpendCreateWaybillTip = 21 //手动加小费扣除
|
||||
StoreAcctTypeExpendCreateWaybill2ndMore = 22 //第二次发运单,并且比上次需要更多钱扣的差价
|
||||
StoreAcctTypeRealFeeExpend = 25 //真实运费 > 临时运费, 真实运费的值 - 临时运费的值
|
||||
StoreAcctTypeExpendCreateWaybillEx = 20 //发单扣除的临时运费
|
||||
StoreAcctTypeExpendCreateWaybillTip = 21 //手动加小费扣除
|
||||
StoreAcctTypeExpendCreateWaybill2ndMore = 22 //第二次发运单,并且比上次需要更多钱扣的差价
|
||||
StoreAcctTypeExpendCreateWaybillDeductFee = 23 //运单取消的违约金
|
||||
StoreAcctTypeExpendTextMessageNotify = 24 //短信通知扣费
|
||||
StoreAcctTypeExpendVoiceMessageNotify = 26 //电话通知扣费
|
||||
StoreAcctTypeRealFeeExpend = 25 //真实运费 > 临时运费, 真实运费的值 - 临时运费的值
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -38,8 +41,8 @@ type IStoreAcctManager interface {
|
||||
//InsertStoreAcctExpend(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error)
|
||||
//更新门店账户
|
||||
UpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price int, isIncome bool) (err error)
|
||||
InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error)
|
||||
InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error)
|
||||
InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID, vendorWaybillID string, expendID int) (err error)
|
||||
InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID, vendOrderID string, expendID int) (err error)
|
||||
CheckStoreAcctExpendExist(vendorOrderID string) (isEqual, isZero bool, err error)
|
||||
GetStoreAcctExpendLastCreateWayBillFee(vendorOrderID string) (expend *dao.GetStoreAcctExpendLastCreateWayBillFeeResult, lastFee int, err error)
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@ import (
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
@@ -114,7 +112,7 @@ func WriteMessage() {
|
||||
clientInfo := <-ToClientChan
|
||||
//广播发送通知所有京西客户端
|
||||
i++
|
||||
fmt.Printf("WriteMessage clientInfo=%s i=%d\n", utils.Format4Output(clientInfo, false), i)
|
||||
//fmt.Printf("WriteMessage clientInfo=%s i=%d\n", utils.Format4Output(clientInfo, false), i)
|
||||
if Manager.AllClient() != nil {
|
||||
for _, conn := range Manager.AllClient() {
|
||||
if conn.ClientType == ClientTypeJx { //只发送给京西
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/kuaishou_mini"
|
||||
beego "github.com/astaxie/beego/server/web"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -39,24 +40,29 @@ func pay4OrderByKs(ctx *jxcontext.Context, order *model.GoodsOrder, vendorPayTyp
|
||||
}
|
||||
|
||||
param := &kuaishou_mini.PreCreateOrderReq{
|
||||
OutOrderNo: utils.Int64ToStr(GenPayOrderID(order)),
|
||||
OpenId: authBindList[0].AuthID,
|
||||
TotalAmount: order.ActualPayPrice,
|
||||
Subject: "蔬菜水果日用品",
|
||||
Detail: getOrderBriefKs(order),
|
||||
TypeDetail: 1832, // 蔬菜:费率2%,水果:1833%2
|
||||
ExpireTime: 60 * 10,
|
||||
Sign: "",
|
||||
Attach: "",
|
||||
NotifyUrl: "http://callback.jxc4.com/kuaishou/KuaiShouCallback",
|
||||
GoodsId: "",
|
||||
GoodsDetailUrl: "",
|
||||
MultiCopiesGoodsInfo: "",
|
||||
CancelOrder: 0,
|
||||
OutOrderNo: utils.Int64ToStr(GenPayOrderID(order)),
|
||||
OpenId: authBindList[0].AuthID,
|
||||
TotalAmount: order.ActualPayPrice,
|
||||
Subject: "蔬菜水果日用品",
|
||||
Detail: getOrderBriefKs(order),
|
||||
TypeDetail: 1832, // 蔬菜:费率2%,水果:1833%2
|
||||
ExpireTime: 60 * 10,
|
||||
Sign: "",
|
||||
//Attach: "",
|
||||
//GoodsId: "",
|
||||
//GoodsDetailUrl: "",
|
||||
//MultiCopiesGoodsInfo: "",
|
||||
CancelOrder: 0,
|
||||
}
|
||||
|
||||
if beego.BConfig.RunMode == "jxgy" {
|
||||
param.NotifyUrl = "https://callback-jxgy.jxc4.com/kuaishou/kuaiShouCallback"
|
||||
} else {
|
||||
param.NotifyUrl = "https://callback.jxc4.com/kuaishou/kuaiShouCallback"
|
||||
}
|
||||
// 预下单
|
||||
prePayInfo, err := api.KuaiShouApi.PreCreateOrder(param)
|
||||
globals.SugarLogger.Debugf("=======err : %v", err)
|
||||
if err == nil {
|
||||
orderPay = &model.OrderPay{
|
||||
PayOrderID: order.VendorOrderID, // 抖音订单id
|
||||
|
||||
@@ -324,7 +324,7 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType
|
||||
//if subAppID == tiktok.TiktokAppId || subAppID == tiktok.TiktokJXDJAppID {
|
||||
// subAppID = model.JXC4AppId // 京西商城
|
||||
//}
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID, ""); err == nil && orderPay != nil {
|
||||
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
@@ -351,7 +351,7 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType
|
||||
ActualPayPrice: priceDefendOrders[0].ActualPayPrice,
|
||||
VendorID: model.VendorIDJX,
|
||||
}
|
||||
if orderPay, err = pay4OrderByTL(ctx, order2, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
|
||||
if orderPay, err = pay4OrderByTL(ctx, order2, payType, vendorPayType, subAppID, ""); err == nil && orderPay != nil {
|
||||
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
@@ -359,7 +359,7 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType
|
||||
return orderPay, err
|
||||
}
|
||||
|
||||
func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType int, vendorPayType, subAppID string) (orderPay *model.OrderPay, err error) {
|
||||
func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType int, vendorPayType, subAppID, code string) (orderPay *model.OrderPay, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
order *model.GoodsOrder
|
||||
@@ -383,7 +383,7 @@ func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType
|
||||
ActualPayPrice: int64(discountCard.Price),
|
||||
VendorID: model.VendorIDJX,
|
||||
}
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID, code); err == nil && orderPay != nil {
|
||||
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
@@ -406,7 +406,7 @@ func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType
|
||||
dao.UpdateEntity(db, userMemberOrigin, "EndAt")
|
||||
}
|
||||
}
|
||||
case model.PayTypeTL_StoreAcctPay:
|
||||
case model.PayTypeTL_StoreAcctPay: // 门店账户充值
|
||||
storeOrder := &model.StoreAcctOrder{
|
||||
VendorOrderID: vendorOrderID,
|
||||
}
|
||||
@@ -416,13 +416,13 @@ func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType
|
||||
ActualPayPrice: int64(storeOrder.ActualPayPrice),
|
||||
VendorID: model.VendorIDJX,
|
||||
}
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID, code); err == nil && orderPay != nil {
|
||||
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
}
|
||||
case model.PayTypeTL_BrandBillCharge:
|
||||
brandOrder := &model.BrandOrder{
|
||||
case model.PayTypeTL_BrandBillCharge: // 品牌账户充值
|
||||
brandOrder := &model.StoreAcctOrder{
|
||||
VendorOrderID: vendorOrderID,
|
||||
}
|
||||
if err = dao.GetEntity(db, brandOrder, "VendorOrderID"); err == nil && brandOrder.ID != 0 {
|
||||
@@ -431,7 +431,7 @@ func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType
|
||||
ActualPayPrice: int64(brandOrder.ActualPayPrice),
|
||||
VendorID: model.VendorIDJX,
|
||||
}
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID, code); err == nil && orderPay != nil {
|
||||
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
@@ -546,9 +546,11 @@ func GetAvailableDeliverTime(ctx *jxcontext.Context, storeID int) (deliverTimerL
|
||||
|
||||
func OnPayFinished(orderPay *model.OrderPay) (err error) {
|
||||
// 查询订单是购物订单还是充值订单
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
order, err := partner.CurOrderManager.LoadOrder(orderPay.VendorOrderID, orderPay.VendorID)
|
||||
if err == nil {
|
||||
db := dao.GetDB()
|
||||
dao.UpdateEntity(db, orderPay)
|
||||
if count, err2 := dao.GetJxOrderCount(db, jxutils.GetSaleStoreIDFromOrder(order), order.VendorOrderID, order.OrderCreatedAt); err2 == nil {
|
||||
order.OrderSeq = count + 1
|
||||
@@ -584,44 +586,42 @@ func OnPayFinished(orderPay *model.OrderPay) (err error) {
|
||||
} else {
|
||||
switch orderPay.PayType {
|
||||
case model.PayTypeTL_DiscountCard:
|
||||
userMembers, _ := dao.GetUserMember(dao.GetDB(), "", orderPay.VendorOrderID, "", model.VendorIDJX, model.MemberTypeDiscountCard, model.NO)
|
||||
userMembers, _ := dao.GetUserMember(db, "", orderPay.VendorOrderID, "", model.VendorIDJX, model.MemberTypeDiscountCard, model.NO)
|
||||
if len(userMembers) > 0 {
|
||||
userMembers[0].IsPay = model.YES
|
||||
dao.UpdateEntity(dao.GetDB(), userMembers[0], "IsPay")
|
||||
dao.UpdateEntity(db, userMembers[0], "IsPay")
|
||||
err = nil
|
||||
}
|
||||
case model.PayTypeTL_StoreAcctPay: //门店账户充值完成后直接入账
|
||||
storeOrder := &model.StoreAcctOrder{
|
||||
VendorOrderID: orderPay.VendorOrderID,
|
||||
}
|
||||
if err = dao.GetEntity(dao.GetDB(), storeOrder, "VendorOrderID"); err == nil && storeOrder.ID != 0 {
|
||||
if err = dao.GetEntity(db, storeOrder, "VendorOrderID"); err == nil && storeOrder.ID != 0 {
|
||||
storeOrder.OrderFinishedAt = time.Now()
|
||||
storeOrder.Status = model.OrderStatusFinished
|
||||
if _, err = dao.UpdateEntity(dao.GetDB(), storeOrder, "OrderFinishedAt", "Status"); err == nil {
|
||||
// 获取门店的品牌ID
|
||||
storeBrandId, err := GetStoreAcctOrderByVendorId(orderPay.VendorOrderID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, storeBrandId, storeOrder.ActualPayPrice, model.BrandBillFeeTypeSys, model.BrandBillFeeTypeSys, "", "")
|
||||
_, err = dao.UpdateEntity(db, storeOrder, "OrderFinishedAt", "Status")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
partner.CurStoreAcctManager.InsertStoreAcctIncomeAndUpdateStoreAcctBalance(jxcontext.AdminCtx, storeOrder.StoreID, storeOrder.ActualPayPrice, partner.StoreAcctTypeIncomePay, storeOrder.VendorOrderID, "", 0)
|
||||
}
|
||||
case model.PayTypeTL_BrandBillCharge:
|
||||
brandOrder := &model.BrandOrder{
|
||||
case model.PayTypeTL_BrandBillCharge: // 品牌充值入账
|
||||
brandOrder := &model.StoreAcctOrder{
|
||||
VendorOrderID: orderPay.VendorOrderID,
|
||||
}
|
||||
if err = dao.GetEntity(dao.GetDB(), brandOrder, "VendorOrderID"); err == nil && brandOrder.ID != 0 {
|
||||
if err = dao.GetEntity(db, brandOrder, "VendorOrderID"); err == nil && brandOrder.ID != 0 {
|
||||
brandOrder.OrderFinishedAt = time.Now()
|
||||
brandOrder.Status = model.OrderStatusFinished
|
||||
if _, err = dao.UpdateEntity(dao.GetDB(), brandOrder, "OrderFinishedAt", "Status"); err == nil {
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, brandOrder.BrandID, brandOrder.ActualPayPrice, model.BrandBillTypeIncome, model.BrandBillFeeTypeCharge, orderPay.VendorOrderID, "")
|
||||
if _, err = dao.UpdateEntity(db, brandOrder, "OrderFinishedAt", "Status"); err == nil {
|
||||
store, _ := dao.GetStoreDetail(db, brandOrder.StoreID, 0, "")
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, brandOrder.ActualPayPrice, model.BrandBillTypeIncome, model.BrandBillFeeTypeCharge, orderPay.VendorOrderID, "")
|
||||
}
|
||||
}
|
||||
default:
|
||||
priceDefendOrders, _ := dao.GetPriceDefendOrder(dao.GetDB(), orderPay.VendorOrderID, nil, nil, []int{jxutils.GetDefendPriceIssue()}, 0, -1, -1, 0, "", utils.ZeroTimeValue, utils.ZeroTimeValue, false)
|
||||
priceDefendOrders, _ := dao.GetPriceDefendOrder(db, orderPay.VendorOrderID, nil, nil, []int{jxutils.GetDefendPriceIssue()}, 0, -1, -1, 0, "", utils.ZeroTimeValue, utils.ZeroTimeValue, false)
|
||||
if len(priceDefendOrders) > 0 {
|
||||
priceDefendOrders[0].IsPay = model.YES
|
||||
dao.UpdateEntity(dao.GetDB(), priceDefendOrders[0], "IsPay")
|
||||
dao.UpdateEntity(db, priceDefendOrders[0], "IsPay")
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
@@ -1823,7 +1823,7 @@ func RefreshAllMatterOrderStatus(ctx *jxcontext.Context) (err error) {
|
||||
}()
|
||||
vv.Status = model.OrderStatusFinished
|
||||
dao.UpdateEntity(db, vv, "Status")
|
||||
waybills, err := dao.GetWaybills(db, vv.VendorOrderID)
|
||||
waybills, err := dao.GetWaybills(db, vv.VendorOrderID, nil)
|
||||
if err == nil && len(waybills) > 0 {
|
||||
waybills[0].Status = model.WaybillStatusDelivered
|
||||
dao.UpdateEntity(db, waybills[0], "Status")
|
||||
@@ -1939,7 +1939,7 @@ func updateMatterOrderStatus(db *dao.DaoDB, order *model.GoodsOrder, queryOrderS
|
||||
}()
|
||||
order.Status = model.OrderStatusFinished
|
||||
dao.UpdateEntity(db, order, "Status")
|
||||
waybills, err := dao.GetWaybills(db, order.VendorOrderID)
|
||||
waybills, err := dao.GetWaybills(db, order.VendorOrderID, nil)
|
||||
if err == nil && len(waybills) > 0 {
|
||||
waybills[0].Status = model.WaybillStatusDelivered
|
||||
dao.UpdateEntity(db, waybills[0], "Status")
|
||||
@@ -1977,7 +1977,7 @@ func updateJdWayBillInfo(db *dao.DaoDB, order *model.GoodsOrder, getTrackMessage
|
||||
break
|
||||
}
|
||||
}
|
||||
waybills, err = dao.GetWaybills(db, order.VendorOrderID)
|
||||
waybills, err = dao.GetWaybills(db, order.VendorOrderID, nil)
|
||||
if len(waybills) > 0 {
|
||||
waybills[0].VendorWaybillID = waybillCode
|
||||
waybills[0].CourierName = cName
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int, vendorPayType, subAppID string) (orderPay *model.OrderPay, err error) {
|
||||
func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int, vendorPayType, subAppID, code string) (orderPay *model.OrderPay, err error) {
|
||||
// if order.FromStoreID != 0 {
|
||||
// result, _ := orderman.GetMatterStoreOrderCount(nil, order.FromStoreID)
|
||||
// if !result.Flag {
|
||||
@@ -45,6 +45,14 @@ func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int,
|
||||
if err == nil && authInfo.GetAuthType() == weixin.AuthTypeMini && authInfo.GetAuthTypeID() == subAppID {
|
||||
param.Acct = authInfo.GetAuthID()
|
||||
}
|
||||
if code != "" {
|
||||
appAuth := strings.Split(code, "_")
|
||||
sessionInfo, err := weixin.GetAPI(appAuth[0]).SNSCode2Session(appAuth[1])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
param.Acct = sessionInfo.OpenID
|
||||
}
|
||||
}
|
||||
if vendorPayType == tonglianpayapi.PayTypeZfbJS || vendorPayType == tonglianpayapi.PayTypeZfbApp {
|
||||
if authInfo, err := ctx.GetV2AuthInfo(); err == nil {
|
||||
@@ -64,6 +72,8 @@ func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int,
|
||||
err = api.TLpayAPI.CreateH5UnitorderOrder(param2)
|
||||
} else {
|
||||
result, err := api.TLpayAPI.CreateUnitorderOrder(param)
|
||||
globals.SugarLogger.Debugf("===============result: %s", utils.Format4Output(result, false))
|
||||
globals.SugarLogger.Debugf("===============result: %s", utils.Format4Output(err, false))
|
||||
if err == nil {
|
||||
var result2 tonglianpayapi.PayInfo
|
||||
json.Unmarshal([]byte(result.PayInfo), &result2)
|
||||
|
||||
Reference in New Issue
Block a user