fix: 修复佣金明细列表多表 JOIN 时 shop_id 字段歧义问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m24s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m24s
ListByShopID 使用 tb_commission_record.shop_id 限定表名, 避免与 JOIN 的 tb_order/tb_iot_card/tb_device 表中同名字段冲突, 解决 SQLSTATE 42702 ambiguous column reference 错误。 Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -74,7 +74,9 @@ func (s *CommissionRecordStore) ListByShopID(ctx context.Context, opts *store.Qu
|
||||
Joins("LEFT JOIN tb_order o ON tb_commission_record.order_id = o.id AND o.deleted_at IS NULL").
|
||||
Joins("LEFT JOIN tb_iot_card ic ON tb_commission_record.iot_card_id = ic.id AND ic.deleted_at IS NULL").
|
||||
Joins("LEFT JOIN tb_device d ON tb_commission_record.device_id = d.id AND d.deleted_at IS NULL")
|
||||
query = middleware.ApplyShopFilter(ctx, query)
|
||||
if shopIDs := middleware.GetSubordinateShopIDs(ctx); len(shopIDs) > 0 {
|
||||
query = query.Where("tb_commission_record.shop_id IN ?", shopIDs)
|
||||
}
|
||||
|
||||
if filters != nil {
|
||||
if filters.ShopID > 0 {
|
||||
|
||||
Reference in New Issue
Block a user