|
|
@@ -84,55 +84,57 @@ var ORDER_TYPE_CN_TEXT = map[int64]string{
|
|
|
}
|
|
|
|
|
|
type Order struct {
|
|
|
- Id int64 `orm:"column(id);pk" json:"id"` // int(11)
|
|
|
- OrderId string `orm:"column(order_id)" json:"order_id"` // varchar(255)
|
|
|
- OrderType int64 `orm:"column(order_type)" json:"order_type"`
|
|
|
- WxUserId int64 `orm:"column(wx_user_id)" json:"wx_user_id"`
|
|
|
- UserId int64 `orm:"column(user_id)" json:"user_id"` // int(11)
|
|
|
- TotalPrice int64 `orm:"column(total_price)" json:"total_price"` // int(11)
|
|
|
- PaiedPrice int64 `orm:"column(paied_price);null" json:"paied_price"` // int(11)
|
|
|
- CouponPrice int64 `orm:"column(coupon_price);null" json:"coupon_price"` // int(11)
|
|
|
- CentPrice int64 `orm:"column(cent_price);null" json:"cent_price"` // int(11)
|
|
|
- BuyPrice int64 `orm:"column(buy_price);null" json:"-"` // int(11)
|
|
|
- Count int64 `orm:"column(count);null" json:"count"` // int(11)
|
|
|
- PaiedAt int64 `orm:"column(paied_at);null" json:"paied_at"` // int(11)
|
|
|
- TradeNo string `orm:"column(trade_no);null" json:"trade_no"` // varchar(255)
|
|
|
- Status string `orm:"column(status);null" json:"status"` // varchar(255)
|
|
|
- StatusCn string `orm:"-" json:"status_cn"` // varchar(255)
|
|
|
- PayWay string `orm:"column(pay_way);null" json:"pay_way"` // varchar(255)
|
|
|
- Source string `orm:"column(source);null" json:"source"` // varchar(255)
|
|
|
- Tel string `orm:"column(tel);null" json:"tel"` // varchar(255)
|
|
|
- Address string `orm:"column(address);null" json:"address"` // varchar(255)
|
|
|
- Contact string `orm:"column(contact);null" json:"contact"` // varchar(255)
|
|
|
- ExpressCompany string `orm:"column(express_company);null" json:"express_company"` // varchar(255)
|
|
|
- ExpressOrderNo string `orm:"column(express_order_no);null" json:"express_order_no"` // varchar(255)
|
|
|
- Remark string `orm:"column(remark);null" json:"remark"` // varchar(255)
|
|
|
- OrderRemark string `orm:"column(order_remark);null" json:"-"` // varchar(255)
|
|
|
- ExpressCode string `orm:"column(express_code);null" json:"express_code"` // varchar(255)
|
|
|
- Sign string `orm:"-" json:"sign"` // varchar(255)
|
|
|
- CTime int64 `orm:"-" json:"ctime"` // int(11)
|
|
|
- DTime int64 `orm:"-" json:"dtime"` // int(11)
|
|
|
- Freight int64 `orm:"column(freight);null" json:"freight"` // int(11)
|
|
|
- Depart int64 `orm:"column(depart)" json:"-"` // datetime
|
|
|
- Pv int64 `orm:"column(pv)" json:"pv"` // varchar(255)
|
|
|
- PickWay int64 `orm:"column(pick_way)" json:"pick_way"` // 物流方式
|
|
|
- PickDept int64 `orm:"column(pick_dept)" json:"pick_dept"` // 自提部门
|
|
|
- AddressId int64 `orm:"column(address_id)" json:"address_id"` // 地址ID
|
|
|
- DispatchTime time.Time `orm:"column(dispatch_time);null;type(datetime)" json:"dispatch_time"`
|
|
|
- ReceiveTime time.Time `orm:"column(receive_time);null;type(datetime)" json:"receive_time"`
|
|
|
- PaiedTime time.Time `orm:"column(paied_time);null;type(datetime)" json:"paied_time"` // int(11)
|
|
|
- HasCommission bool `orm:"has_commission" json:"-"`
|
|
|
- CreatedAt time.Time `orm:"column(created_at);null;auto_now_add;type(datetime)" json:"-"` // datetime
|
|
|
- UpdatedAt time.Time `orm:"column(updated_at);null;auto_now;type(datetime)" json:"-"` // datetime
|
|
|
- Promotions string `orm:"column(promotions);null" json:"-"` // varchar(255)
|
|
|
- SpecialPro bool `orm:"-" json:"special_promotion"` // int(11)
|
|
|
- ShutWechat bool `orm:"-" json:"shut_wechat"` // int(11)
|
|
|
- PaiedSilver int64 `orm:"column(paied_silver)" json:"paied_silver"` // int(11)
|
|
|
- TotalSilver int64 `orm:"column(total_silver)" json:"total_silver"` // int(11)
|
|
|
- DisAmount int64 `orm:"column(dis_amount)" json:"dis_amount"` // 折扣
|
|
|
- PaiedCash int64 `orm:"column(paied_cash);null" json:"paied_cash"` // int(11)
|
|
|
- WxUser *user_model.WxUser `orm:"-" json:"wx_user"`
|
|
|
- ProductList []*OrderDetail `orm:"-" json:"product_list"` // varchar(255)
|
|
|
+ Id int64 `orm:"column(id);pk" json:"id"` // int(11)
|
|
|
+ OrderId string `orm:"column(order_id)" json:"order_id"` // varchar(255)
|
|
|
+ OrderType int64 `orm:"column(order_type)" json:"order_type"`
|
|
|
+ WxUserId int64 `orm:"column(wx_user_id)" json:"wx_user_id"`
|
|
|
+ UserId int64 `orm:"column(user_id)" json:"user_id"` // int(11)
|
|
|
+ TotalPrice int64 `orm:"column(total_price)" json:"total_price"` // int(11)
|
|
|
+ PaiedPrice int64 `orm:"column(paied_price);null" json:"paied_price"` // int(11)
|
|
|
+ CouponPrice int64 `orm:"column(coupon_price);null" json:"coupon_price"` // int(11)
|
|
|
+ CentPrice int64 `orm:"column(cent_price);null" json:"cent_price"` // int(11)
|
|
|
+ BuyPrice int64 `orm:"column(buy_price);null" json:"-"` // int(11)
|
|
|
+ Count int64 `orm:"column(count);null" json:"count"` // int(11)
|
|
|
+ PaiedAt int64 `orm:"column(paied_at);null" json:"paied_at"` // int(11)
|
|
|
+ TradeNo string `orm:"column(trade_no);null" json:"trade_no"` // varchar(255)
|
|
|
+ Status string `orm:"column(status);null" json:"status"` // varchar(255)
|
|
|
+ StatusCn string `orm:"-" json:"status_cn"` // varchar(255)
|
|
|
+ PayWay string `orm:"column(pay_way);null" json:"pay_way"` // varchar(255)
|
|
|
+ Source string `orm:"column(source);null" json:"source"` // varchar(255)
|
|
|
+ Tel string `orm:"column(tel);null" json:"tel"` // varchar(255)
|
|
|
+ Address string `orm:"column(address);null" json:"address"` // varchar(255)
|
|
|
+ Contact string `orm:"column(contact);null" json:"contact"` // varchar(255)
|
|
|
+ ExpressCompany string `orm:"column(express_company);null" json:"express_company"` // varchar(255)
|
|
|
+ ExpressOrderNo string `orm:"column(express_order_no);null" json:"express_order_no"` // varchar(255)
|
|
|
+ Remark string `orm:"column(remark);null" json:"remark"` // varchar(255)
|
|
|
+ OrderRemark string `orm:"column(order_remark);null" json:"-"` // varchar(255)
|
|
|
+ ExpressCode string `orm:"column(express_code);null" json:"express_code"` // varchar(255)
|
|
|
+ Sign string `orm:"-" json:"sign"` // varchar(255)
|
|
|
+ CTime int64 `orm:"-" json:"ctime"` // int(11)
|
|
|
+ DTime int64 `orm:"-" json:"dtime"` // int(11)
|
|
|
+ Freight int64 `orm:"column(freight);null" json:"freight"` // int(11)
|
|
|
+ Depart int64 `orm:"column(depart)" json:"-"` // datetime
|
|
|
+ Pv int64 `orm:"column(pv)" json:"pv"` // varchar(255)
|
|
|
+ PickWay int64 `orm:"column(pick_way)" json:"pick_way"` // 物流方式
|
|
|
+ PickDept int64 `orm:"column(pick_dept)" json:"pick_dept"` // 自提部门
|
|
|
+ AddressId int64 `orm:"column(address_id)" json:"address_id"` // 地址ID
|
|
|
+ DispatchTime time.Time `orm:"column(dispatch_time);null;type(datetime)" json:"dispatch_time"`
|
|
|
+ ReceiveTime time.Time `orm:"column(receive_time);null;type(datetime)" json:"receive_time"`
|
|
|
+ PaiedTime time.Time `orm:"column(paied_time);null;type(datetime)" json:"paied_time"` // int(11)
|
|
|
+ HasCommission bool `orm:"has_commission" json:"-"`
|
|
|
+ CreatedAt time.Time `orm:"column(created_at);null;auto_now_add;type(datetime)" json:"-"` // datetime
|
|
|
+ UpdatedAt time.Time `orm:"column(updated_at);null;auto_now;type(datetime)" json:"-"` // datetime
|
|
|
+ Promotions string `orm:"column(promotions);null" json:"-"` // varchar(255)
|
|
|
+ SpecialPro bool `orm:"-" json:"special_promotion"` // int(11)
|
|
|
+ ShutWechat bool `orm:"-" json:"shut_wechat"` // int(11)
|
|
|
+ PaiedSilver int64 `orm:"column(paied_silver)" json:"paied_silver"` // int(11)
|
|
|
+ TotalSilver int64 `orm:"column(total_silver)" json:"total_silver"` // int(11)
|
|
|
+ DisAmount int64 `orm:"column(dis_amount)" json:"dis_amount"` // 折扣
|
|
|
+ PaiedCash int64 `orm:"column(paied_cash);null" json:"paied_cash"` // int(11)
|
|
|
+ NormalPromotions string `orm:"column(normal_promotions);null" json:"-"` // varchar(255)
|
|
|
+ NotPromotionAmount string `orm:"column(not_promotion_amount);null" json:"-"` // varchar(255)
|
|
|
+ WxUser *user_model.WxUser `orm:"-" json:"wx_user"`
|
|
|
+ ProductList []*OrderDetail `orm:"-" json:"product_list"` // varchar(255)
|
|
|
}
|
|
|
|
|
|
func (self *Order) TableName() string {
|
|
|
@@ -909,3 +911,50 @@ func GenExpressPassword(expressNo string) string {
|
|
|
|
|
|
return md5PwdTkey[0:12]
|
|
|
}
|
|
|
+
|
|
|
+func GetNotInvovedAmount(promotionId int64, orderId string) int64 {
|
|
|
+
|
|
|
+ type PromotionPds struct {
|
|
|
+ ProductId int64 `orm:"column(product_id)"`
|
|
|
+ Nums int64 `orm:"column(nums)"`
|
|
|
+ }
|
|
|
+
|
|
|
+ sql := `
|
|
|
+ SELECT
|
|
|
+ op.product_id,
|
|
|
+ IF(od.nums IS NULL, 0, od.nums) AS nums
|
|
|
+ FROM
|
|
|
+ products_promotions AS op
|
|
|
+ LEFT JOIN
|
|
|
+ order_details AS od ON od.product_id = op.product_id AND od.order_no =?
|
|
|
+ WHERE
|
|
|
+ op.promotion_id = ?;
|
|
|
+ AND IF(od.nums IS NULL, 0, od.nums) > 0;
|
|
|
+ `
|
|
|
+
|
|
|
+ var results []PromotionPds
|
|
|
+ db := orm.NewOrm()
|
|
|
+ _, err := db.Raw(sql, promotionId, orderId).QueryRows(&results)
|
|
|
+ if err != nil {
|
|
|
+ beego.BeeLogger.Debug("GetNotInvovedAmount err=%s", err)
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ total := int64(0)
|
|
|
+ for _, item := range results {
|
|
|
+ item_pd := product_model.GetProductById(item.ProductId, true)
|
|
|
+ total += item.Nums * item_pd.Price
|
|
|
+ }
|
|
|
+
|
|
|
+ return total
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateOrderPromotions 更新 normal_promotions字段
|
|
|
+func UpdateOrderPromotions(promotions, noInvovedAmount, orderId string) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ //更新wx_users会员关系
|
|
|
+ sql := `
|
|
|
+ update orders set normal_promotions=? ,not_promotion_amount=? where order_id=?
|
|
|
+ `
|
|
|
+ o.Raw(sql, promotions, noInvovedAmount, orderId).Exec()
|
|
|
+
|
|
|
+}
|