This commit is contained in:
richboo111
2023-05-25 09:52:40 +08:00
46 changed files with 1050 additions and 558 deletions

View File

@@ -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 {

View File

@@ -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" //美团跑腿(众包)

View File

@@ -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

View File

@@ -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()

View File

@@ -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 *

View File

@@ -20,6 +20,9 @@ const (
ErrCodeAccountBalanceNotEnough = "-201" //余额不足
ErrCodeNotAuthBindWeixin = "-202" //没有绑定微信认证方式
ErrCodeOnePayTipFeeMore = "10001" // 单次支付金额太多
ErrCodeIsPaySure = "10000" // 是否确认支付
)
var (

View File

@@ -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"`

View File

@@ -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 {