StatKdClass.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <?php
  2. namespace bizGhs\stat\classes;
  3. use biz\shop\classes\ShopAdminClass;
  4. use bizGhs\order\classes\OrderClass;
  5. use bizGhs\order\classes\OrderItemClass;
  6. use bizGhs\order\classes\StockOutOrderClass;
  7. use bizHd\order\classes\SettleClass;
  8. use common\components\dateUtil;
  9. use common\components\dict;
  10. use bizHd\order\classes\OrderClass as HdOrderClass;
  11. use bizGhs\clear\classes\ClearClass;
  12. use bizGhs\base\classes\BaseClass;
  13. use common\components\noticeUtil;
  14. use Yii;
  15. class StatKdClass extends BaseClass
  16. {
  17. public static $baseFile = '\bizGhs\stat\models\StatKd';
  18. //当天各渠道收入 ssh 20220723
  19. public static function eachChannelIncome($mainId, $shop, $contain = 1)
  20. {
  21. $ghsShopId = $shop->id ?? 0;
  22. $lsShopId = $shop->lsShopId ?? 0;
  23. //批发开单 pf 零售开单 ls 批发结账 pfJz 零售尾款 lsWk
  24. $get = Yii::$app->request->get();
  25. $searchTime = isset($get['searchTime']) && !empty($get['searchTime']) ? $get['searchTime'] : 'today';
  26. $startTime = $get['startTime'] ?? '';
  27. $endTime = $get['endTime'] ?? '';
  28. $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
  29. $start = $period['startTime'];
  30. $end = $period['endTime'];
  31. $currentStartDate = date('Y-m-d', strtotime($start));
  32. $currentEndDate = date('Y-m-d', strtotime($end));
  33. $currentStartTime = $currentStartDate . ' 00:00:00';
  34. $currentEndTime = $currentEndDate . ' 23:59:59';
  35. $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId, 'isPt' => 0], null, '*', 'id', true);
  36. $kf = [];
  37. if (!empty($staffList)) {
  38. foreach ($staffList as $staff) {
  39. $name = $staff->name ?? '';
  40. $staffId = $staff->id ?? 0;
  41. $kf[$staffId]['name'] = $name;
  42. $kf[$staffId]['key'] = $staffId;
  43. $kf[$staffId]['num'] = 0;
  44. $kf[$staffId]['amount'] = 0;
  45. $kf[$staffId]['itemList']['pf'] = ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0];
  46. $kf[$staffId]['itemList']['ls'] = ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0];
  47. $kf[$staffId]['itemList']['pfJz'] = ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0];
  48. $kf[$staffId]['itemList']['lsWk'] = ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0];
  49. }
  50. }
  51. $incomeList = [
  52. //系统收入
  53. 'system' => [
  54. 'amount' => 0,
  55. 'num' => 0,
  56. 'name' => '系统收款',
  57. 'category' => [
  58. 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
  59. 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
  60. 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
  61. 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
  62. ],
  63. ],
  64. 'kfWx' => [
  65. 'amount' => 0,
  66. 'num' => 0,
  67. 'name' => '线下微信',
  68. 'class' => $kf,
  69. 'category' => [
  70. 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
  71. 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
  72. 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
  73. 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
  74. ]
  75. ],
  76. 'debt' => [
  77. 'amount' => 0,
  78. 'num' => 0,
  79. 'name' => '挂账(未结)',
  80. 'category' => [
  81. 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
  82. 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
  83. ],
  84. ],
  85. 'debtClear' => [
  86. 'amount' => 0,
  87. 'num' => 0,
  88. 'name' => '挂账(已结)',
  89. 'category' => [
  90. 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
  91. 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
  92. ],
  93. ],
  94. 'balancePay' => [
  95. 'amount' => 0,
  96. 'name' => '余额支付',
  97. 'num' => 0,
  98. 'category' => [
  99. 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
  100. 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
  101. 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
  102. 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
  103. ],
  104. ],
  105. 'cash' => [
  106. 'amount' => 0,
  107. 'name' => '现金',
  108. 'num' => 0,
  109. 'category' => [
  110. 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
  111. 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
  112. 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
  113. 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
  114. ],
  115. ],
  116. 'aliPay' => [
  117. 'amount' => 0,
  118. 'num' => 0,
  119. 'name' => '线下支付宝',
  120. 'category' => [
  121. 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
  122. 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
  123. 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
  124. 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
  125. ],
  126. ],
  127. 'bankCard' => [
  128. 'amount' => 0,
  129. 'name' => '银行卡',
  130. 'num' => 0,
  131. 'category' => [
  132. 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
  133. 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
  134. 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
  135. 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
  136. ],
  137. ],
  138. 'mt' => ['amount' => 0, 'num' => 0, 'name' => '美团'],
  139. 'other' => [
  140. 'amount' => 0,
  141. 'num' => 0,
  142. 'name' => '其它',
  143. 'category' => [
  144. 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
  145. 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
  146. 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
  147. 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
  148. ],
  149. ],
  150. ];
  151. $staffAmountList = [];
  152. //批发开单
  153. $where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
  154. $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
  155. $ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
  156. if (!empty($ghsOrderList)) {
  157. foreach ($ghsOrderList as $ghsKey => $ghsOrder) {
  158. $payWay = $ghsOrder['payWay'] ?? 0;
  159. $actPrice = $ghsOrder['actPrice'] ?? 0;
  160. $getStaffId = $ghsOrder['getStaffId'] ?? 0;
  161. $debtPrice = $ghsOrder['debtPrice'] ?? 0;
  162. $remainDebtPrice = $ghsOrder['remainDebtPrice'] ?? 0;
  163. $onlinePay = $ghsOrder['onlinePay'] ?? dict::getDict('onlinePay', 'not');
  164. $status = $ghsOrder['status'] ?? 0;
  165. $book = $ghsOrder['book'] ?? 0;
  166. $staffId = $ghsOrder['shopAdminId'] ?? 0;
  167. $staffName = $ghsOrder['shopAdminName'] ?? '';
  168. if ($staffId == 0) {
  169. $staffName = '系统';
  170. }
  171. if ($status == 0 || $status == 5) {
  172. continue;
  173. }
  174. if ($book == 1 && $status == 2) {
  175. continue;
  176. }
  177. //ssh 冲销单功能:金额(actPrice为负数)正常混入各渠道抵扣;但冲销单本质是售后调整,
  178. //不算一笔正常收款,所有"笔数(num)"统计都要排除冲销单,用 $numDelta 代替固定的 1
  179. $forward = $ghsOrder['forward'] ?? 0;
  180. $numDelta = ($forward == 1) ? 0 : 1;
  181. if (isset($staffAmountList[$staffId])) {
  182. $staffAmountList[$staffId]['num'] = bcadd($staffAmountList[$staffId]['num'], $numDelta);
  183. $staffAmountList[$staffId]['amount'] = bcadd($staffAmountList[$staffId]['amount'], $actPrice, 2);
  184. } else {
  185. $staffAmountList[$staffId] = ['num' => $numDelta, 'amount' => $actPrice, 'staffName' => $staffName, 'staffId' => $staffId];
  186. }
  187. if ($debtPrice > 0) {
  188. if ($remainDebtPrice > 0) {
  189. $incomeList['debt']['amount'] = bcadd($incomeList['debt']['amount'], $actPrice, 2);
  190. $incomeList['debt']['num'] = bcadd($incomeList['debt']['num'], $numDelta);
  191. $incomeList['debt']['category']['pf']['amount'] = bcadd($incomeList['debt']['category']['pf']['amount'], $actPrice, 2);
  192. $incomeList['debt']['category']['pf']['num'] = bcadd($incomeList['debt']['category']['pf']['num'], $numDelta);
  193. } else {
  194. $incomeList['debtClear']['amount'] = bcadd($incomeList['debtClear']['amount'], $actPrice, 2);
  195. $incomeList['debtClear']['num'] = bcadd($incomeList['debtClear']['num'], $numDelta);
  196. $incomeList['debtClear']['category']['pf']['amount'] = bcadd($incomeList['debtClear']['category']['pf']['amount'], $actPrice, 2);
  197. $incomeList['debtClear']['category']['pf']['num'] = bcadd($incomeList['debtClear']['category']['pf']['num'], $numDelta);
  198. }
  199. } else {
  200. if ($onlinePay == dict::getDict('onlinePay', 'yes')) {
  201. //使用在线支付
  202. $incomeList['system']['amount'] = bcadd($incomeList['system']['amount'], $actPrice, 2);
  203. $incomeList['system']['num'] = bcadd($incomeList['system']['num'], $numDelta);
  204. $incomeList['system']['category']['pf']['amount'] = bcadd($incomeList['system']['category']['pf']['amount'], $actPrice, 2);
  205. $incomeList['system']['category']['pf']['num'] = bcadd($incomeList['system']['category']['pf']['num'], $numDelta);
  206. } else {
  207. //使用非在线支付
  208. switch ($payWay) {
  209. case dict::getDict('payWay', 'wxPay'):
  210. //员工微信总共收了多少笔多少钱
  211. $incomeList['kfWx']['amount'] = bcadd($incomeList['kfWx']['amount'], $actPrice, 2);
  212. $incomeList['kfWx']['num'] = bcadd($incomeList['kfWx']['num'], $numDelta);
  213. //批发开单、零售开单、批发结账、零售尾款各收了多少现金
  214. $incomeList['kfWx']['category']['pf']['amount'] = bcadd($incomeList['kfWx']['category']['pf']['amount'], $actPrice, 2);
  215. $incomeList['kfWx']['category']['pf']['num'] = bcadd($incomeList['kfWx']['category']['pf']['num'], $numDelta);
  216. //每个客服总共收了多少笔多少钱
  217. if (isset($incomeList['kfWx']['class'][$getStaffId])) {
  218. $incomeList['kfWx']['class'][$getStaffId]['amount'] = floatval(bcadd($incomeList['kfWx']['class'][$getStaffId]['amount'], $actPrice, 2));
  219. $incomeList['kfWx']['class'][$getStaffId]['num'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['num'], $numDelta);
  220. }
  221. //每个客服收的明细
  222. if (isset($incomeList['kfWx']['class'][$getStaffId]['itemList']['pf'])) {
  223. $incomeList['kfWx']['class'][$getStaffId]['itemList']['pf']['amount'] = floatval(bcadd($incomeList['kfWx']['class'][$getStaffId]['itemList']['pf']['amount'], $actPrice, 2));
  224. $incomeList['kfWx']['class'][$getStaffId]['itemList']['pf']['num'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['itemList']['pf']['num'], $numDelta);
  225. }
  226. break;
  227. case dict::getDict('payWay', 'alipay'):
  228. $incomeList['aliPay']['amount'] = bcadd($incomeList['aliPay']['amount'], $actPrice, 2);
  229. $incomeList['aliPay']['num'] = bcadd($incomeList['aliPay']['num'], $numDelta);
  230. $incomeList['aliPay']['category']['pf']['amount'] = bcadd($incomeList['aliPay']['category']['pf']['amount'], $actPrice, 2);
  231. $incomeList['aliPay']['category']['pf']['num'] = bcadd($incomeList['aliPay']['category']['pf']['num'], $numDelta);
  232. break;
  233. case dict::getDict('payWay', 'cash'):
  234. $incomeList['cash']['amount'] = bcadd($incomeList['cash']['amount'], $actPrice, 2);
  235. $incomeList['cash']['num'] = bcadd($incomeList['cash']['num'], $numDelta);
  236. $incomeList['cash']['category']['pf']['amount'] = bcadd($incomeList['cash']['category']['pf']['amount'], $actPrice, 2);
  237. $incomeList['cash']['category']['pf']['num'] = bcadd($incomeList['cash']['category']['pf']['num'], $numDelta);
  238. break;
  239. case dict::getDict('payWay', 'balancePay'):
  240. $incomeList['balancePay']['amount'] = bcadd($incomeList['balancePay']['amount'], $actPrice, 2);
  241. $incomeList['balancePay']['num'] = bcadd($incomeList['balancePay']['num'], $numDelta);
  242. $incomeList['balancePay']['category']['pf']['amount'] = bcadd($incomeList['balancePay']['category']['pf']['amount'], $actPrice, 2);
  243. $incomeList['balancePay']['category']['pf']['num'] = bcadd($incomeList['balancePay']['category']['pf']['num'], $numDelta);
  244. break;
  245. case dict::getDict('payWay', 'bankCard'):
  246. $incomeList['bankCard']['amount'] = bcadd($incomeList['bankCard']['amount'], $actPrice, 2);
  247. $incomeList['bankCard']['num'] = bcadd($incomeList['bankCard']['num'], $numDelta);
  248. $incomeList['bankCard']['category']['pf']['amount'] = bcadd($incomeList['bankCard']['category']['pf']['amount'], $actPrice, 2);
  249. $incomeList['bankCard']['category']['pf']['num'] = bcadd($incomeList['bankCard']['category']['pf']['num'], $numDelta);
  250. break;
  251. case dict::getDict('payWay', 'unknown'):
  252. $incomeList['other']['amount'] = bcadd($incomeList['other']['amount'], $actPrice, 2);
  253. $incomeList['other']['num'] = bcadd($incomeList['other']['num'], $numDelta);
  254. $incomeList['other']['category']['pf']['amount'] = bcadd($incomeList['other']['category']['pf']['amount'], $actPrice, 2);
  255. $incomeList['other']['category']['pf']['num'] = bcadd($incomeList['other']['category']['pf']['num'], $numDelta);
  256. break;
  257. default:
  258. }
  259. }
  260. }
  261. }
  262. }
  263. //零售开单
  264. $payCodeIncome = 0;
  265. $lsAfterSale = 0;
  266. $hdWhere = ['mainId' => $mainId, 'status' => ['in', [HdOrderClass::ORDER_STATUS_UN_SEND, HdOrderClass::ORDER_STATUS_SENDING, HdOrderClass::ORDER_STATUS_COMPLETE]]];
  267. $hdWhere['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
  268. $hdOrderList = HdOrderClass::getAllByCondition($hdWhere, null, '*');
  269. foreach ($hdOrderList as $hdKey => $hdOrder) {
  270. $payWay = $hdOrder['payWay'] ?? 0;
  271. $mainPay = $hdOrder['mainPay'] ?? 0;
  272. $cash = $hdOrder['cash'] ?? 0;
  273. $actPrice = $hdOrder['mainPay'] ?? 0;
  274. $getStaffId = $hdOrder['getStaffId'] ?? 0;
  275. $debtPrice = $hdOrder['debtPrice'] ?? 0;
  276. $remainDebtPrice = $hdOrder['remainDebtPrice'] ?? 0;
  277. $onlinePay = $hdOrder['onlinePay'] ?? 0;
  278. $fromType = $hdOrder['fromType'] ?? 0;
  279. $staffId = $hdOrder['shopAdminId'] ?? 0;
  280. $staffName = $hdOrder['shopAdminName'] ?? '';
  281. $repeat = $hdOrder['repeat'] ?? 0;
  282. $forward = $hdOrder['forward'] ?? 0;
  283. $tkPrice = $hdOrder['tkPrice'] ?? 0;
  284. $mainPay = bcsub($mainPay, $tkPrice, 2);
  285. if ($forward == 1) {
  286. //售后付款属于支出
  287. $lsAfterSale = bcadd($lsAfterSale, $mainPay, 2);
  288. continue;
  289. }
  290. $currentAmount = 0;
  291. if ($onlinePay == dict::getDict('onlinePay', 'yes')) {
  292. $incomeList['system']['amount'] = bcadd($incomeList['system']['amount'], $mainPay, 2);
  293. $incomeList['system']['num'] = bcadd($incomeList['system']['num'], 1);
  294. $incomeList['system']['category']['ls']['amount'] = bcadd($incomeList['system']['category']['ls']['amount'], $mainPay, 2);
  295. $incomeList['system']['category']['ls']['num'] = bcadd($incomeList['system']['category']['ls']['num'], 1);
  296. if ($repeat == 1) {
  297. $payCodeIncome = bcadd($payCodeIncome, $mainPay, 2);
  298. }
  299. if ($cash > 0) {
  300. $incomeList['cash']['amount'] = bcadd($incomeList['cash']['amount'], $cash, 2);
  301. $incomeList['cash']['num'] = bcadd($incomeList['cash']['num'], 1);
  302. $incomeList['cash']['category']['ls']['amount'] = bcadd($incomeList['cash']['category']['ls']['amount'], $cash, 2);
  303. $incomeList['cash']['category']['ls']['num'] = bcadd($incomeList['cash']['category']['ls']['num'], 1);
  304. }
  305. $currentAmount = bcadd($mainPay, $cash, 2);
  306. } else {
  307. if ($fromType == dict::getDict('fromType', 'mt')) {
  308. //美团!!!
  309. $incomeList['mt']['amount'] = bcadd($incomeList['mt']['amount'], $actPrice, 2);
  310. $incomeList['mt']['num'] = bcadd($incomeList['mt']['num'], 1);
  311. } else {
  312. if ($debtPrice > 0) {
  313. if ($remainDebtPrice > 0) {
  314. $incomeList['debt']['amount'] = bcadd($incomeList['debt']['amount'], $remainDebtPrice, 2);
  315. $incomeList['debt']['num'] = bcadd($incomeList['debt']['num'], 1);
  316. $incomeList['debt']['category']['ls']['amount'] = bcadd($incomeList['debt']['category']['ls']['amount'], $remainDebtPrice, 2);
  317. $incomeList['debt']['category']['ls']['num'] = bcadd($incomeList['debt']['category']['ls']['num'], 1);
  318. }
  319. $clearDebt = bcsub($debtPrice, $remainDebtPrice, 2);
  320. if ($clearDebt > 0) {
  321. $incomeList['debtClear']['amount'] = bcadd($incomeList['debtClear']['amount'], $clearDebt, 2);
  322. $incomeList['debtClear']['num'] = bcadd($incomeList['debtClear']['num'], 1);
  323. $incomeList['debtClear']['category']['ls']['amount'] = bcadd($incomeList['debtClear']['category']['ls']['amount'], $clearDebt, 2);
  324. $incomeList['debtClear']['category']['ls']['num'] = bcadd($incomeList['debtClear']['category']['ls']['num'], 1);
  325. }
  326. $currentAmount = bcadd($remainDebtPrice, $clearDebt, 2);
  327. } else {
  328. $currentAmount = $mainPay;
  329. }
  330. if ($currentAmount > 0) {
  331. //使用非在线支付
  332. switch ($payWay) {
  333. case dict::getDict('payWay', 'wxPay'):
  334. //员工微信总共收了多少笔多少钱
  335. $incomeList['kfWx']['amount'] = bcadd($incomeList['kfWx']['amount'], $currentAmount, 2);
  336. $incomeList['kfWx']['num'] = bcadd($incomeList['kfWx']['num'], 1);
  337. //批发开单、零售开单、批发结账、零售尾款各收了多少现金
  338. $incomeList['kfWx']['category']['ls']['amount'] = bcadd($incomeList['kfWx']['category']['ls']['amount'], $currentAmount, 2);
  339. $incomeList['kfWx']['category']['ls']['num'] = bcadd($incomeList['kfWx']['category']['ls']['num'], 1);
  340. //客1 客2 客3各收了多少钱
  341. if (isset($incomeList['kfWx']['class'][$getStaffId])) {
  342. $incomeList['kfWx']['class'][$getStaffId]['amount'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['amount'], $currentAmount, 2);
  343. $incomeList['kfWx']['class'][$getStaffId]['num'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['num'], 1);
  344. }
  345. //每个客服收的明细
  346. if (isset($incomeList['kfWx']['class'][$getStaffId]['itemList']['ls'])) {
  347. $incomeList['kfWx']['class'][$getStaffId]['itemList']['ls']['amount'] = floatval(bcadd($incomeList['kfWx']['class'][$getStaffId]['itemList']['ls']['amount'], $actPrice, 2));
  348. $incomeList['kfWx']['class'][$getStaffId]['itemList']['ls']['num'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['itemList']['ls']['num'], 1);
  349. }
  350. break;
  351. case dict::getDict('payWay', 'alipay'):
  352. $incomeList['aliPay']['amount'] = bcadd($incomeList['aliPay']['amount'], $currentAmount, 2);
  353. $incomeList['aliPay']['num'] = bcadd($incomeList['aliPay']['num'], 1);
  354. $incomeList['aliPay']['category']['ls']['amount'] = bcadd($incomeList['aliPay']['category']['ls']['amount'], $currentAmount, 2);
  355. $incomeList['aliPay']['category']['ls']['num'] = bcadd($incomeList['aliPay']['category']['ls']['num'], 1);
  356. break;
  357. case dict::getDict('payWay', 'cash'):
  358. $incomeList['cash']['amount'] = bcadd($incomeList['cash']['amount'], $currentAmount, 2);
  359. $incomeList['cash']['num'] = bcadd($incomeList['cash']['num'], 1);
  360. $incomeList['cash']['category']['ls']['amount'] = bcadd($incomeList['cash']['category']['ls']['amount'], $currentAmount, 2);
  361. $incomeList['cash']['category']['ls']['num'] = bcadd($incomeList['cash']['category']['ls']['num'], 1);
  362. break;
  363. case dict::getDict('payWay', 'balancePay'):
  364. $incomeList['balancePay']['amount'] = bcadd($incomeList['balancePay']['amount'], $currentAmount, 2);
  365. $incomeList['balancePay']['num'] = bcadd($incomeList['balancePay']['num'], 1);
  366. $incomeList['balancePay']['category']['ls']['amount'] = bcadd($incomeList['balancePay']['category']['ls']['amount'], $currentAmount, 2);
  367. $incomeList['balancePay']['category']['ls']['num'] = bcadd($incomeList['balancePay']['category']['ls']['num'], 1);
  368. break;
  369. case dict::getDict('payWay', 'bankCard'):
  370. $incomeList['bankCard']['amount'] = bcadd($incomeList['bankCard']['amount'], $currentAmount, 2);
  371. $incomeList['bankCard']['num'] = bcadd($incomeList['bankCard']['num'], 1);
  372. $incomeList['bankCard']['category']['ls']['amount'] = bcadd($incomeList['bankCard']['category']['ls']['amount'], $currentAmount, 2);
  373. $incomeList['bankCard']['category']['ls']['num'] = bcadd($incomeList['bankCard']['category']['ls']['num'], 1);
  374. break;
  375. case dict::getDict('payWay', 'unknown'):
  376. $incomeList['other']['amount'] = bcadd($incomeList['other']['amount'], $currentAmount, 2);
  377. $incomeList['other']['num'] = bcadd($incomeList['other']['num'], 1);
  378. $incomeList['other']['category']['ls']['amount'] = bcadd($incomeList['other']['category']['ls']['amount'], $currentAmount, 2);
  379. $incomeList['other']['category']['ls']['num'] = bcadd($incomeList['other']['category']['ls']['num'], 1);
  380. break;
  381. default:
  382. }
  383. }
  384. }
  385. }
  386. //员工业绩
  387. if (isset($staffAmountList[$staffId])) {
  388. $staffAmountList[$staffId]['num'] = bcadd($staffAmountList[$staffId]['num'], 1);
  389. $staffAmountList[$staffId]['amount'] = bcadd($staffAmountList[$staffId]['amount'], $currentAmount, 2);
  390. } else {
  391. $staffAmountList[$staffId] = ['num' => 1, 'amount' => $currentAmount, 'staffName' => $staffName];
  392. }
  393. }
  394. return ['incomeList' => $incomeList, 'staffAmountList' => $staffAmountList, 'payCodeIncome' => $payCodeIncome, 'lsAfterSale' => $lsAfterSale];
  395. }
  396. }