StatKdClass.php 30 KB

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