select t1.fbillnum,
       t1.fname,--姓名
       t1.fphonenumber,--客户手机
       t1.fcommunity,--小区名称
       t1.fnumber,--幢/单元/室
       t1.frenovationplandate, --计划装修时间
       t1.fbirthdate,--生日
       t1.fwechatno,--微信号
       t1.fdate,--下单日期
       t1.fwaiter,--接待员
       t3.fwaiter      as ffirstwaiter,--首次接待员
       t1.finstalldate,--安装日期
       sum(t4.famount) as fprodtotalamount,--商品合计金额
       t1.forderamount,--成交金额
       t1.fdepositamount,--定金
       t1.freceivablesamount,--应收款
       t1.freceivedamount,--已收尾款
       t1.createby,--创建人
       t1.createdate,--创建时间
       t1.changedate, --更新时间
       t1.fstatus,--订单状态
       t1.fnotes,--订单备注
       t1.fispayout,--是否已结清
       t1.fisstockout,--是否已出库
       t1.siteid,--企业ID
       t1.tagentsid,--经销商ID
       t1.tstoreid,--门店Id
       t1.tcustomerid,--客户档案ID
       t1.tcustomer_receptid,--销售记录ID
       t5.fsignetvalue1,
       t5.fsignetvalue2
from tcustomer_reception t1
         left join tcustomer t3
                   on t1.siteid = t3.siteid and t1.tagentsid = t3.tagentsid and t1.tcustomerid = t3.tcustomerid
         left join tcustomer_order t4
                   on t1.siteid = t4.siteid and t1.tagentsid = t4.tagentsid and t1.tcustomerid = t4.tcustomerid and
                      t1.tcustomer_receptid = t4.tcustomer_receptid
         left join tagents t5 on t1.siteid = t5.siteid and t1.tagentsid = t5.tagentsid
where t1.siteid =$siteid$ and t1.tagentsid=$tagentsid$ and t1.tcustomer_receptid=$tcustomer_receptid$
group by
    t1.fbillnum,
    t1.fname,--姓名
    t1.fphonenumber,--客户手机
    t1.fcommunity,--小区名称
    t1.fnumber,--幢/单元/室
    t1.frenovationplandate, --计划装修时间
    t1.fbirthdate,--生日
    t1.fwechatno,--微信号
    t1.fdate,--下单日期
    t1.fwaiter,--接待员
    t3.fwaiter,--首次接待员
    t1.finstalldate,--安装日期
    t1.forderamount,--成交金额
    t1.fdepositamount,--定金
    t1.freceivablesamount,--应收款
    t1.freceivedamount,--已收尾款
    t1.createby,--创建人
    t1.createdate,--创建时间
    t1.changedate, --更新时间
    t1.fstatus,--订单状态
    t1.fnotes,
    t1.fispayout,--是否已结清
    t1.fisstockout,--是否已出库
    t1.siteid,--企业ID
    t1.tagentsid,--经销商ID
    t1.tstoreid,--门店Id
    t1.tcustomerid,--客户档案ID
    t1.tcustomer_receptid,--销售记录ID
    t5.fsignetvalue1,
    t5.fsignetvalue2