|
@@ -39,7 +39,7 @@ func (o *Order) GetNum() int {
|
|
|
return count
|
|
|
}
|
|
|
|
|
|
-func (o *Order) GetAmount(openId string) (Wallet, error) {
|
|
|
+func (o *Order) GetAmount() (Wallet, error) {
|
|
|
var wallet Wallet
|
|
|
|
|
|
//历史总收益: 0,1,2,3,5 求和
|
|
@@ -49,32 +49,32 @@ func (o *Order) GetAmount(openId string) (Wallet, error) {
|
|
|
//可体现金额:5求和-已体现金额
|
|
|
//已体现金额:提现记录求和
|
|
|
//历史总收益
|
|
|
- err := orm.Eloquent.Select("SUM(promotion_amount) as total_amount").Where("order_status in (0,1,2,3,5) and open_id = ? ", openId).Table(o.TableName()).First(&wallet).Error
|
|
|
+ err := orm.Eloquent.Select("SUM(promotion_amount) as total_amount").Where("order_status in (0,1,2,3,5) and p_id = ? ", o.PID).Table(o.TableName()).First(&wallet).Error
|
|
|
|
|
|
if err != nil {
|
|
|
return wallet, err
|
|
|
}
|
|
|
//今日收益
|
|
|
- err = orm.Eloquent.Select("SUM(promotion_amount) as today_amount").Where("order_status in (0,1,2,3) and open_id = ? and DATE(order_group_success_time) = curdate() ", openId).Table(o.TableName()).First(&wallet).Error
|
|
|
+ err = orm.Eloquent.Select("SUM(promotion_amount) as today_amount").Where("order_status in (0,1,2,3) and p_id = ? and DATE(order_group_success_time) = curdate() ", o.PID).Table(o.TableName()).First(&wallet).Error
|
|
|
|
|
|
if err != nil {
|
|
|
return wallet, err
|
|
|
}
|
|
|
//昨日收益
|
|
|
- err = orm.Eloquent.Select("SUM(promotion_amount) as yesterday_amount").Where("order_status in (0,1,2,3) and open_id = ? and DATE(order_group_success_time) = date_sub(curdate(),interval 1 day) ", openId).Table(o.TableName()).First(&wallet).Error
|
|
|
+ err = orm.Eloquent.Select("SUM(promotion_amount) as yesterday_amount").Where("order_status in (0,1,2,3) and p_id = ? and DATE(order_group_success_time) = date_sub(curdate(),interval 1 day) ", o.PID).Table(o.TableName()).First(&wallet).Error
|
|
|
|
|
|
if err != nil {
|
|
|
return wallet, err
|
|
|
}
|
|
|
//近30日收益
|
|
|
- err = orm.Eloquent.Select("SUM(promotion_amount) as lately_amount").Where("order_status in (0,1,2,3) and open_id = ? and DATE(order_group_success_time) >= date_sub(curdate(),interval 30 day) ", openId).Table(o.TableName()).First(&wallet).Error
|
|
|
+ err = orm.Eloquent.Select("SUM(promotion_amount) as lately_amount").Where("order_status in (0,1,2,3) and p_id = ? and DATE(order_group_success_time) >= date_sub(curdate(),interval 30 day) ", o.PID).Table(o.TableName()).First(&wallet).Error
|
|
|
|
|
|
if err != nil {
|
|
|
return wallet, err
|
|
|
}
|
|
|
|
|
|
//上个月结算收益
|
|
|
- err = orm.Eloquent.Select("SUM(promotion_amount) as available_amount").Where("order_status = 5 and open_id = ? and DATE(order_group_success_time) >= date_sub(date_sub(date_format(now(),'%y-%m-%d'),interval extract(day from now()) day),interval 0 month) ", openId).Table(o.TableName()).First(&wallet).Error
|
|
|
+ err = orm.Eloquent.Select("SUM(promotion_amount) as available_amount").Where("order_status = 5 and p_id = ? and DATE(order_group_success_time) >= date_sub(date_sub(date_format(now(),'%y-%m-%d'),interval extract(day from now()) day),interval 0 month) ", o.PID).Table(o.TableName()).First(&wallet).Error
|
|
|
|
|
|
if err != nil {
|
|
|
return wallet, err
|