|
@@ -141,7 +141,7 @@ func (self *Order) TableName() string {
|
|
|
return orders_tablename
|
|
return orders_tablename
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//创建订单
|
|
|
|
|
|
|
+// 创建订单
|
|
|
func (self *Order) Create(wxUserId, uId, count, totalPrice, buyPrice int64, source string) *Order {
|
|
func (self *Order) Create(wxUserId, uId, count, totalPrice, buyPrice int64, source string) *Order {
|
|
|
var oId string
|
|
var oId string
|
|
|
oId = createOrderId(ORDER_ID_PREFIX_EX)
|
|
oId = createOrderId(ORDER_ID_PREFIX_EX)
|
|
@@ -165,7 +165,7 @@ func (self *Order) Create(wxUserId, uId, count, totalPrice, buyPrice int64, sour
|
|
|
return order
|
|
return order
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//新创建订单
|
|
|
|
|
|
|
+// 新创建订单
|
|
|
func (self *Order) CreateNew(wxUserId, uId, totalPrice, freight, orderType, depart int64, source string) *Order {
|
|
func (self *Order) CreateNew(wxUserId, uId, totalPrice, freight, orderType, depart int64, source string) *Order {
|
|
|
var oId string
|
|
var oId string
|
|
|
oId = createOrderId(ORDER_ID_PREFIX_EX)
|
|
oId = createOrderId(ORDER_ID_PREFIX_EX)
|
|
@@ -256,7 +256,7 @@ func (self *Order) Delete() error {
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//生成订单ID
|
|
|
|
|
|
|
+// 生成订单ID
|
|
|
func createOrderId(prefix string) string {
|
|
func createOrderId(prefix string) string {
|
|
|
n := time.Now().Format("20060102")
|
|
n := time.Now().Format("20060102")
|
|
|
u := uuid.NewV4().String()
|
|
u := uuid.NewV4().String()
|
|
@@ -266,7 +266,7 @@ func createOrderId(prefix string) string {
|
|
|
return oId
|
|
return oId
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//某个收货时间段的已完成订单
|
|
|
|
|
|
|
+// 某个收货时间段的已完成订单
|
|
|
func GetFinishedOrdersByRTime(from, to time.Time) (orders []*Order) {
|
|
func GetFinishedOrdersByRTime(from, to time.Time) (orders []*Order) {
|
|
|
order := new(Order)
|
|
order := new(Order)
|
|
|
qs := orm.NewOrm().QueryTable(order)
|
|
qs := orm.NewOrm().QueryTable(order)
|
|
@@ -281,7 +281,7 @@ func GetFinishedOrdersByRTime(from, to time.Time) (orders []*Order) {
|
|
|
return orders
|
|
return orders
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//获取某种类型订单总数
|
|
|
|
|
|
|
+// 获取某种类型订单总数
|
|
|
func GetOrdersCountByOTypeAndWxUId(gId, oType, wxUId int64) int64 {
|
|
func GetOrdersCountByOTypeAndWxUId(gId, oType, wxUId int64) int64 {
|
|
|
order := new(Order)
|
|
order := new(Order)
|
|
|
qs := orm.NewOrm().QueryTable(order)
|
|
qs := orm.NewOrm().QueryTable(order)
|
|
@@ -293,7 +293,7 @@ func GetOrdersCountByOTypeAndWxUId(gId, oType, wxUId int64) int64 {
|
|
|
return count
|
|
return count
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//获取某种类型订单
|
|
|
|
|
|
|
+// 获取某种类型订单
|
|
|
func GetOrdersByOTypeAndWxUId(gId, oType, wxUId, page, perPage int64) (orders []*Order) {
|
|
func GetOrdersByOTypeAndWxUId(gId, oType, wxUId, page, perPage int64) (orders []*Order) {
|
|
|
order := new(Order)
|
|
order := new(Order)
|
|
|
qs := orm.NewOrm().QueryTable(order)
|
|
qs := orm.NewOrm().QueryTable(order)
|
|
@@ -310,7 +310,7 @@ func GetOrdersByOTypeAndWxUId(gId, oType, wxUId, page, perPage int64) (orders []
|
|
|
return orders
|
|
return orders
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//获取用户订单列表
|
|
|
|
|
|
|
+// 获取用户订单列表
|
|
|
func GetUserOrders(wxUId int64, status string, page, perPage int) (orders []*Order) {
|
|
func GetUserOrders(wxUId int64, status string, page, perPage int) (orders []*Order) {
|
|
|
order := new(Order)
|
|
order := new(Order)
|
|
|
qs := orm.NewOrm().QueryTable(order)
|
|
qs := orm.NewOrm().QueryTable(order)
|
|
@@ -332,7 +332,7 @@ func GetUserOrders(wxUId int64, status string, page, perPage int) (orders []*Ord
|
|
|
return orders
|
|
return orders
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//获取用户订单列表
|
|
|
|
|
|
|
+// 获取用户订单列表
|
|
|
func GetUserSaleOrders() (orders []*Order) {
|
|
func GetUserSaleOrders() (orders []*Order) {
|
|
|
// order := new(Order)
|
|
// order := new(Order)
|
|
|
// qs := orm.NewOrm().QueryTable(order)
|
|
// qs := orm.NewOrm().QueryTable(order)
|
|
@@ -358,7 +358,7 @@ func GetUserSaleOrders() (orders []*Order) {
|
|
|
return orders
|
|
return orders
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//获取用户订单列表
|
|
|
|
|
|
|
+// 获取用户订单列表
|
|
|
func GetWxUserOrders(wxUId int64) (orders []*Order) {
|
|
func GetWxUserOrders(wxUId int64) (orders []*Order) {
|
|
|
|
|
|
|
|
sql := `
|
|
sql := `
|
|
@@ -378,7 +378,7 @@ func GetWxUserOrders(wxUId int64) (orders []*Order) {
|
|
|
return orders
|
|
return orders
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//获取用户订单列表-总数
|
|
|
|
|
|
|
+// 获取用户订单列表-总数
|
|
|
func GetUserOrdersCount(wxUId int64, status string) int64 {
|
|
func GetUserOrdersCount(wxUId int64, status string) int64 {
|
|
|
order := new(Order)
|
|
order := new(Order)
|
|
|
qs := orm.NewOrm().QueryTable(order)
|
|
qs := orm.NewOrm().QueryTable(order)
|
|
@@ -390,7 +390,7 @@ func GetUserOrdersCount(wxUId int64, status string) int64 {
|
|
|
return count
|
|
return count
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//获取某个商品已售总数
|
|
|
|
|
|
|
+// 获取某个商品已售总数
|
|
|
func GetSoldCountByPId(pId int64, useCache bool) int64 {
|
|
func GetSoldCountByPId(pId int64, useCache bool) int64 {
|
|
|
k := fmt.Sprintf("order_model.GetSoldCountByPId(%d)", pId)
|
|
k := fmt.Sprintf("order_model.GetSoldCountByPId(%d)", pId)
|
|
|
if useCache {
|
|
if useCache {
|
|
@@ -416,7 +416,7 @@ func GetSoldCountByPId(pId int64, useCache bool) int64 {
|
|
|
return ret.Count
|
|
return ret.Count
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//获取用户订单列表-总数
|
|
|
|
|
|
|
+// 获取用户订单列表-总数
|
|
|
func GetMerchantOrdersCount(merchantId, queryPaiedStart, queryPaiedEnd int64, receiveStart, receiveEnd int64,
|
|
func GetMerchantOrdersCount(merchantId, queryPaiedStart, queryPaiedEnd int64, receiveStart, receiveEnd int64,
|
|
|
status, contact, productIds, tel, orderType, orderId, province, city, district string) int64 {
|
|
status, contact, productIds, tel, orderType, orderId, province, city, district string) int64 {
|
|
|
|
|
|
|
@@ -511,7 +511,7 @@ func GetMerchantOrdersCount(merchantId, queryPaiedStart, queryPaiedEnd int64, re
|
|
|
return ret.Count
|
|
return ret.Count
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//查找已发货但发货时间为空的订单
|
|
|
|
|
|
|
+// 查找已发货但发货时间为空的订单
|
|
|
func GetOrdersByDispatchStatusAndDispatchTimeIsNull() (orders []*Order) {
|
|
func GetOrdersByDispatchStatusAndDispatchTimeIsNull() (orders []*Order) {
|
|
|
|
|
|
|
|
sql := `
|
|
sql := `
|
|
@@ -532,7 +532,7 @@ func GetOrdersByDispatchStatusAndDispatchTimeIsNull() (orders []*Order) {
|
|
|
return orders
|
|
return orders
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//查找距离发货时间满7天的订单
|
|
|
|
|
|
|
+// 查找距离发货时间满7天的订单
|
|
|
func GetSevenDaysFullOrdersByDispatchTime() (orders []*Order) {
|
|
func GetSevenDaysFullOrdersByDispatchTime() (orders []*Order) {
|
|
|
|
|
|
|
|
sql := `
|
|
sql := `
|
|
@@ -553,7 +553,7 @@ func GetSevenDaysFullOrdersByDispatchTime() (orders []*Order) {
|
|
|
return orders
|
|
return orders
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//查找未支付订单
|
|
|
|
|
|
|
+// 查找未支付订单
|
|
|
func GetUnpayOrders() (orders []*Order) {
|
|
func GetUnpayOrders() (orders []*Order) {
|
|
|
|
|
|
|
|
sql := `
|
|
sql := `
|
|
@@ -597,7 +597,7 @@ func GetOrderByOrderRemark(remark string, useCache bool) (item *Order) {
|
|
|
return item
|
|
return item
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//查询用户购买某个商品的订单总数
|
|
|
|
|
|
|
+// 查询用户购买某个商品的订单总数
|
|
|
func GetOrderCountByPIdAndWxUId(pId, wxUId int64) int64 {
|
|
func GetOrderCountByPIdAndWxUId(pId, wxUId int64) int64 {
|
|
|
|
|
|
|
|
sql := `
|
|
sql := `
|
|
@@ -625,7 +625,7 @@ func GetOrderCountByPIdAndWxUId(pId, wxUId int64) int64 {
|
|
|
return ret.Count
|
|
return ret.Count
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//获取商品销售专题的商品销售数量
|
|
|
|
|
|
|
+// 获取商品销售专题的商品销售数量
|
|
|
func GetSoldCountByPIdAndSId(pId, sId int64, useCache bool) int64 {
|
|
func GetSoldCountByPIdAndSId(pId, sId int64, useCache bool) int64 {
|
|
|
k := fmt.Sprintf("order_model.GetSoldCountByPIdAndSId(%d, %d)", pId, sId)
|
|
k := fmt.Sprintf("order_model.GetSoldCountByPIdAndSId(%d, %d)", pId, sId)
|
|
|
if useCache {
|
|
if useCache {
|
|
@@ -650,7 +650,7 @@ func GetSoldCountByPIdAndSId(pId, sId int64, useCache bool) int64 {
|
|
|
return ret.Count
|
|
return ret.Count
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//获取商品销售专题的订单
|
|
|
|
|
|
|
+// 获取商品销售专题的订单
|
|
|
func GetPrizeSubjectOrdersBySbjId(subjectId int64) (list []*Order) {
|
|
func GetPrizeSubjectOrdersBySbjId(subjectId int64) (list []*Order) {
|
|
|
|
|
|
|
|
sql := `
|
|
sql := `
|
|
@@ -700,7 +700,7 @@ func GetTypeSaleFinishedOrders() (orders []*Order) {
|
|
|
return orders
|
|
return orders
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//获取某用户微信支付过的订单
|
|
|
|
|
|
|
+// 获取某用户微信支付过的订单
|
|
|
func GetPaiedOrderByWxUIdAndPayWayLimitOne(wxUserId int64, payWay string, useCache bool) (item *Order) {
|
|
func GetPaiedOrderByWxUIdAndPayWayLimitOne(wxUserId int64, payWay string, useCache bool) (item *Order) {
|
|
|
|
|
|
|
|
k := fmt.Sprintf("order_model.GetPaiedOrderByWxUIdAndPayWayLimitOne(%d, %s)", wxUserId, payWay)
|
|
k := fmt.Sprintf("order_model.GetPaiedOrderByWxUIdAndPayWayLimitOne(%d, %s)", wxUserId, payWay)
|
|
@@ -732,7 +732,7 @@ func GetPaiedOrderByWxUIdAndPayWayLimitOne(wxUserId int64, payWay string, useCac
|
|
|
return item
|
|
return item
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//更新商品已售数量
|
|
|
|
|
|
|
+// 更新商品已售数量
|
|
|
func UpdateSaleNums(saleProducts map[int64]int64) bool {
|
|
func UpdateSaleNums(saleProducts map[int64]int64) bool {
|
|
|
|
|
|
|
|
for pId, nums := range saleProducts {
|
|
for pId, nums := range saleProducts {
|
|
@@ -897,7 +897,7 @@ func GetDistrictOrderSum(tcBl int64, tcArea string) int64 {
|
|
|
return ret.Count
|
|
return ret.Count
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//根据用户快递单号和Tkey得到物流信息查询的密钥
|
|
|
|
|
|
|
+// 根据用户快递单号和Tkey得到物流信息查询的密钥
|
|
|
func GenExpressPassword(expressNo string) string {
|
|
func GenExpressPassword(expressNo string) string {
|
|
|
md5CtxUsn := md5.New()
|
|
md5CtxUsn := md5.New()
|
|
|
md5CtxUsn.Write([]byte(ZT_PASSWORD))
|
|
md5CtxUsn.Write([]byte(ZT_PASSWORD))
|