# `viw_accproductstoreinvoicesalesman`（视图）


- **是否可更新：** NO
- **定义者：** `xlyprint@%`

## 字段

| # | 名称 | 类型 | 可空 |
|---|---|---|---|
| 1 | `sId` | `varchar(63)` | YES |
| 2 | `sSlaveId` | `varchar(63)` | YES |
| 3 | `sSalesManId` | `varchar(100)` | YES |
| 4 | `sConfirmMonth` | `varchar(100)` | NO |
| 5 | `dAllCostMoney` | `decimal(45,6)` | YES |
| 6 | `dProductNoTaxMoney` | `decimal(44,10)` | YES |
| 7 | `dProductMoney` | `decimal(44,10)` | YES |
| 8 | `dProfitMoney` | `decimal(50,10)` | YES |
| 9 | `dCustomerRate` | `decimal(52,2)` | YES |
| 10 | `dCustomerallRate` | `decimal(52,2)` | YES |
| 11 | `dReceiptRate` | `decimal(43,2)` | YES |

## 定义

```sql
select concat(date_format(now(),'%Y%m%d%H%i%s'),ceiling(((rand() * 9000000) + 1000000)),ceiling(((rand() * 9000000000) + 1000000000))) AS `sId`,concat(date_format(now(),'%Y%m%d%H%i%s'),ceiling(((rand() * 9000000) + 1000000)),ceiling(((rand() * 9000000000) + 1000000000))) AS `sSlaveId`,`c`.`sSalesManId` AS `sSalesManId`,`a`.`sConfirmMonth` AS `sConfirmMonth`,(sum((ifnull(`a`.`dCostMoney`,0) + ifnull(`a`.`dFreight`,0))) / 10000) AS `dAllCostMoney`,(sum(ifnull(`a`.`dProductNoTaxMoney`,0)) / 10000) AS `dProductNoTaxMoney`,(sum(ifnull(`a`.`dProductMoney`,0)) / 10000) AS `dProductMoney`,((sum(ifnull(`a`.`dProductNoTaxMoney`,0)) - sum((ifnull(`a`.`dCostMoney`,0) + ifnull(`a`.`dFreight`,0)))) / 10000) AS `dProfitMoney`,round((((sum(ifnull(`a`.`dProductNoTaxMoney`,0)) - sum((ifnull(`a`.`dCostMoney`,0) + ifnull(`a`.`dFreight`,0)))) / (select sum(((ifnull(`b`.`dProductNoTaxMoney`,0) - ifnull(`b`.`dCostMoney`,0)) - ifnull(`b`.`dFreight`,0))) from `xlyweberp_saas_ai`.`accproductstore` `b` where ((`b`.`bConfirm` = 1) and (`b`.`sFormId` = '15780358080007074056281633539000') and (`b`.`sConfirmMonth` = `a`.`sConfirmMonth`)))) * 100),2) AS `dCustomerRate`,round((((sum(ifnull(`a`.`dProductNoTaxMoney`,0)) - sum((ifnull(`a`.`dCostMoney`,0) + ifnull(`a`.`dFreight`,0)))) / sum(ifnull(`a`.`dProductNoTaxMoney`,0))) * 100),2) AS `dCustomerallRate`,round((sum(ifnull(`a`.`dProductNoTaxMoney`,0)) / (select sum(ifnull(`b`.`dProductNoTaxMoney`,0)) from `xlyweberp_saas_ai`.`accproductstore` `b` where ((`b`.`bConfirm` = 1) and (`b`.`sFormId` = '15780358080007074056281633539000') and (`b`.`sConfirmMonth` = `a`.`sConfirmMonth`)))),2) AS `dReceiptRate` from ((`xlyweberp_saas_ai`.`accproductstore` `a` left join `xlyweberp_saas_ai`.`eleproduct` `b` on((`a`.`sProductId` = `b`.`sId`))) left join `xlyweberp_saas_ai`.`elecustomer` `c` on((`b`.`sCustomerId` = `c`.`sId`))) where ((`a`.`bConfirm` = 1) and (`a`.`sFormId` = '15780358080007074056281633539000')) group by `c`.`sSalesManId`,`a`.`sConfirmMonth`
```

## 说明

_暂无人工说明。_
