TestController.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <?php
  2. namespace pt\controllers;
  3. use biz\sj\services\MerchantExtendService;
  4. use biz\sj\services\MerchantService;
  5. use bizGhs\custom\classes\CustomClass;
  6. use bizGhs\order\classes\OrderClass;
  7. use bizGhs\shop\classes\ShopAdminClass;
  8. use bizGhs\shop\classes\ShopClass;
  9. use bizHd\message\services\InformAdminService;
  10. use bizHd\order\services\OrderService;
  11. use bizHd\saas\classes\ApplyClass;
  12. use bizHd\user\services\UserService;
  13. use bizHd\wx\classes\WxOpenClass;
  14. use bizHd\wx\services\WxOpenService;
  15. use common\components\dateUtil;
  16. use common\components\dict;
  17. use common\components\mapUtil;
  18. use Overtrue\Pinyin\Pinyin;
  19. use Yii;
  20. use common\components\wxUtil;
  21. use common\components\miniUtil;
  22. use bizHd\order\classes\OrderClass as HdOrderClass;
  23. class TestController extends PublicController
  24. {
  25. //收入
  26. public function actionIncome()
  27. {
  28. $searchTime = 'thisMonth';
  29. $startTime = $get['startTime'] ?? '';
  30. $endTime = $get['endTime'] ?? '';
  31. $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
  32. $start = $period['startTime'];
  33. $end = $period['endTime'];
  34. $currentStartDate = date('Y-m-d', strtotime($start));
  35. $currentEndDate = date('Y-m-d', strtotime($end));
  36. $currentStartTime = $currentStartDate . ' 00:00:00';
  37. $currentEndTime = $currentEndDate . ' 23:59:59';
  38. $mainId = 4836;
  39. $pfIncome = 0;
  40. $pfSendCost = 0;
  41. $where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
  42. $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
  43. print_r($where);
  44. $ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
  45. if (!empty($ghsOrderList)) {
  46. foreach ($ghsOrderList as $ghsKey => $ghsOrder) {
  47. $actPrice = $ghsOrder['actPrice'] ?? 0;
  48. $sendCost = $ghsOrder['sendCost'] ?? 0;
  49. $pfIncome = bcadd($pfIncome, $actPrice, 2);
  50. $pfSendCost = bcadd($pfSendCost, $sendCost, 2);
  51. }
  52. }
  53. echo ' ' . $pfIncome . ' ';
  54. echo "==================";
  55. //零售开单
  56. $lsIncome = 0;
  57. $lsSendCost = 0;
  58. $lsServiceFee = 0;
  59. $hdWhere = ['mainId' => $mainId, 'status' => ['in', [HdOrderClass::ORDER_STATUS_UN_SEND, HdOrderClass::ORDER_STATUS_SENDING, HdOrderClass::ORDER_STATUS_COMPLETE]]];
  60. $hdWhere['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
  61. $hdOrderList = HdOrderClass::getAllByCondition($hdWhere, null, '*');
  62. foreach ($hdOrderList as $hdKey => $hdOrder) {
  63. $actPrice = $hdOrder['mainPay'] ?? 0;
  64. $serviceFee = $hdOrder['serviceFee'] ?? 0;
  65. $sendCost = $hdOrder['sendCost'] ?? 0;
  66. $lsIncome = bcadd($actPrice, $lsIncome, 2);
  67. //退款取消的先不计算成本
  68. if ($actPrice > 0) {
  69. $lsSendCost = bcadd($lsSendCost, $sendCost, 2);
  70. $lsServiceFee = bcadd($lsServiceFee, $serviceFee, 2);
  71. }
  72. }
  73. echo ' 零售收入:'.$lsIncome.' ';
  74. $shopId = 4892;
  75. $shop = ShopClass::getById($shopId, true);
  76. $mainId = $shop->mainId ?? 0;
  77. //批发开单 pf 零售开单 ls 批发结账 pfJz 零售尾款 lsWk
  78. $searchTime = 'thisMonth';
  79. $startTime = $get['startTime'] ?? '';
  80. $endTime = $get['endTime'] ?? '';
  81. $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
  82. $start = $period['startTime'];
  83. $end = $period['endTime'];
  84. $currentStartDate = date('Y-m-d', strtotime($start));
  85. $currentEndDate = date('Y-m-d', strtotime($end));
  86. $currentStartTime = $currentStartDate . ' 00:00:00';
  87. $currentEndTime = $currentEndDate . ' 23:59:59';
  88. $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId, 'isPt' => 0], null, '*', 'id', true);
  89. $kf = [];
  90. if (!empty($staffList)) {
  91. foreach ($staffList as $staff) {
  92. $name = $staff->name ?? '';
  93. $staffId = $staff->id ?? 0;
  94. $kf[$staffId]['name'] = $name;
  95. $kf[$staffId]['key'] = $staffId;
  96. $kf[$staffId]['num'] = 0;
  97. $kf[$staffId]['amount'] = 0;
  98. $kf[$staffId]['itemList']['pf'] = ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0];
  99. $kf[$staffId]['itemList']['ls'] = ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0];
  100. $kf[$staffId]['itemList']['pfJz'] = ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0];
  101. $kf[$staffId]['itemList']['lsWk'] = ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0];
  102. }
  103. }
  104. $incomeList = [
  105. //系统收入
  106. 'system' => [
  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. 'kfWx' => [
  118. 'amount' => 0,
  119. 'num' => 0,
  120. 'name' => '员工收款',
  121. 'class' => $kf,
  122. 'category' => [
  123. 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
  124. 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
  125. 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
  126. 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
  127. ]
  128. ],
  129. 'debt' => [
  130. 'amount' => 0,
  131. 'num' => 0,
  132. 'name' => '欠款',
  133. 'category' => [
  134. 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
  135. 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
  136. ],
  137. ],
  138. 'debtClear' => [
  139. 'amount' => 0,
  140. 'num' => 0,
  141. 'name' => '已结欠款',
  142. 'category' => [
  143. 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
  144. 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
  145. ],
  146. ],
  147. 'cash' => [
  148. 'amount' => 0,
  149. 'name' => '现金',
  150. 'num' => 0,
  151. 'category' => [
  152. 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
  153. 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
  154. 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
  155. 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
  156. ],
  157. ],
  158. 'aliPay' => [
  159. 'amount' => 0,
  160. 'num' => 0,
  161. 'name' => '支付宝',
  162. 'category' => [
  163. 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
  164. 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
  165. 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
  166. 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
  167. ],
  168. ],
  169. 'bankCard' => [
  170. 'amount' => 0,
  171. 'name' => '银行卡',
  172. 'num' => 0,
  173. 'category' => [
  174. 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
  175. 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
  176. 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
  177. 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
  178. ],
  179. ],
  180. 'mt' => ['amount' => 0, 'num' => 0, 'name' => '美团'],
  181. 'other' => [
  182. 'amount' => 0,
  183. 'num' => 0,
  184. 'name' => '其它',
  185. 'category' => [
  186. 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
  187. 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
  188. 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
  189. 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
  190. ],
  191. ],
  192. ];
  193. $incomeList = [];
  194. //批发开单
  195. $where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
  196. $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
  197. print_r($where);
  198. $ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
  199. $ghsTotal = 0;
  200. $defaultTotal = 0;
  201. if (!empty($ghsOrderList)) {
  202. foreach ($ghsOrderList as $ghsKey => $ghsOrder) {
  203. $payWay = $ghsOrder['payWay'] ?? 0;
  204. $actPrice = $ghsOrder['actPrice'] ?? 0;
  205. $ghsTotal = bcadd($ghsTotal, $actPrice, 2);
  206. $getStaffId = $ghsOrder['getStaffId'] ?? 0;
  207. $debtPrice = $ghsOrder['debtPrice'] ?? 0;
  208. $remainDebtPrice = $ghsOrder['remainDebtPrice'] ?? 0;
  209. $onlinePay = $ghsOrder['onlinePay'] ?? dict::getDict('onlinePay', 'not');
  210. if ($debtPrice > 0) {
  211. if ($remainDebtPrice > 0) {
  212. $incomeList['debt']['amount'] = bcadd($incomeList['debt']['amount'], $actPrice, 2);
  213. $incomeList['debt']['num'] = bcadd($incomeList['debt']['num'], 1);
  214. $incomeList['debt']['category']['pf']['amount'] = bcadd($incomeList['debt']['category']['pf']['amount'], $actPrice, 2);
  215. $incomeList['debt']['category']['pf']['num'] = bcadd($incomeList['debt']['category']['pf']['num'], 1);
  216. } else {
  217. $incomeList['debtClear']['amount'] = bcadd($incomeList['debtClear']['amount'], $actPrice, 2);
  218. $incomeList['debtClear']['num'] = bcadd($incomeList['debtClear']['num'], 1);
  219. $incomeList['debtClear']['category']['pf']['amount'] = bcadd($incomeList['debtClear']['category']['pf']['amount'], $actPrice, 2);
  220. $incomeList['debtClear']['category']['pf']['num'] = bcadd($incomeList['debtClear']['category']['pf']['num'], 1);
  221. }
  222. } else {
  223. if ($onlinePay == dict::getDict('onlinePay', 'yes')) {
  224. //使用在线支付
  225. $incomeList['system']['amount'] = bcadd($incomeList['system']['amount'], $actPrice, 2);
  226. $incomeList['system']['num'] = bcadd($incomeList['system']['num'], 1);
  227. $incomeList['system']['category']['pf']['amount'] = bcadd($incomeList['system']['category']['pf']['amount'], $actPrice, 2);
  228. $incomeList['system']['category']['pf']['num'] = bcadd($incomeList['system']['category']['pf']['num'], 1);
  229. } else {
  230. //使用非在线支付
  231. switch ($payWay) {
  232. case dict::getDict('payWay', 'wxPay'):
  233. //员工微信总共收了多少笔多少钱
  234. $incomeList['kfWx']['amount'] = bcadd($incomeList['kfWx']['amount'], $actPrice, 2);
  235. $incomeList['kfWx']['num'] = bcadd($incomeList['kfWx']['num'], 1);
  236. //批发开单、零售开单、批发结账、零售尾款各收了多少现金
  237. $incomeList['kfWx']['category']['pf']['amount'] = bcadd($incomeList['kfWx']['category']['pf']['amount'], $actPrice, 2);
  238. $incomeList['kfWx']['category']['pf']['num'] = bcadd($incomeList['kfWx']['category']['pf']['num'], 1);
  239. //每个客服总共收了多少笔多少钱
  240. if (isset($incomeList['kfWx']['class'][$getStaffId])) {
  241. $incomeList['kfWx']['class'][$getStaffId]['amount'] = floatval(bcadd($incomeList['kfWx']['class'][$getStaffId]['amount'], $actPrice, 2));
  242. $incomeList['kfWx']['class'][$getStaffId]['num'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['num'], 1);
  243. }
  244. //每个客服收的明细
  245. if (isset($incomeList['kfWx']['class'][$getStaffId]['itemList']['pf'])) {
  246. $incomeList['kfWx']['class'][$getStaffId]['itemList']['pf']['amount'] = floatval(bcadd($incomeList['kfWx']['class'][$getStaffId]['itemList']['pf']['amount'], $actPrice, 2));
  247. $incomeList['kfWx']['class'][$getStaffId]['itemList']['pf']['num'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['itemList']['pf']['num'], 1);
  248. }
  249. break;
  250. case dict::getDict('payWay', 'alipay'):
  251. $incomeList['aliPay']['amount'] = bcadd($incomeList['aliPay']['amount'], $actPrice, 2);
  252. $incomeList['aliPay']['num'] = bcadd($incomeList['aliPay']['num'], 1);
  253. $incomeList['aliPay']['category']['pf']['amount'] = bcadd($incomeList['aliPay']['category']['pf']['amount'], $actPrice, 2);
  254. $incomeList['aliPay']['category']['pf']['num'] = bcadd($incomeList['aliPay']['category']['pf']['num'], 1);
  255. break;
  256. case dict::getDict('payWay', 'cash'):
  257. $incomeList['cash']['amount'] = bcadd($incomeList['cash']['amount'], $actPrice, 2);
  258. $incomeList['cash']['num'] = bcadd($incomeList['cash']['num'], 1);
  259. $incomeList['cash']['category']['pf']['amount'] = bcadd($incomeList['cash']['category']['pf']['amount'], $actPrice, 2);
  260. $incomeList['cash']['category']['pf']['num'] = bcadd($incomeList['cash']['category']['pf']['num'], 1);
  261. break;
  262. case dict::getDict('payWay', 'bankCard'):
  263. $incomeList['bankCard']['amount'] = bcadd($incomeList['bankCard']['amount'], $actPrice, 2);
  264. $incomeList['bankCard']['num'] = bcadd($incomeList['bankCard']['num'], 1);
  265. $incomeList['bankCard']['category']['pf']['amount'] = bcadd($incomeList['bankCard']['category']['pf']['amount'], $actPrice, 2);
  266. $incomeList['bankCard']['category']['pf']['num'] = bcadd($incomeList['bankCard']['category']['pf']['num'], 1);
  267. break;
  268. case dict::getDict('payWay', 'unknown'):
  269. $incomeList['other']['amount'] = bcadd($incomeList['other']['amount'], $actPrice, 2);
  270. $incomeList['other']['num'] = bcadd($incomeList['other']['num'], 1);
  271. $incomeList['other']['category']['pf']['amount'] = bcadd($incomeList['other']['category']['pf']['amount'], $actPrice, 2);
  272. $incomeList['other']['category']['pf']['num'] = bcadd($incomeList['other']['category']['pf']['num'], 1);
  273. break;
  274. default:
  275. $defaultTotal = bcadd($defaultTotal, $actPrice, 2);
  276. }
  277. }
  278. }
  279. }
  280. }
  281. $total = 0;
  282. foreach ($incomeList as $i) {
  283. $current = $i['amount'] ?? 0;
  284. $total = bcadd($current, $total, 2);
  285. }
  286. echo ' default:'.$defaultTotal.' ';
  287. echo ' ghsTotal:' . $ghsTotal . ' ';
  288. echo ' total:' . $total . ' ';
  289. print_r($incomeList);
  290. $incomeList = [];
  291. //零售开单
  292. $hdWhere = ['mainId' => $mainId, 'status' => ['in', [HdOrderClass::ORDER_STATUS_UN_SEND, HdOrderClass::ORDER_STATUS_SENDING, HdOrderClass::ORDER_STATUS_COMPLETE]]];
  293. $hdWhere['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
  294. $hdOrderList = HdOrderClass::getAllByCondition($hdWhere, null, '*');
  295. foreach ($hdOrderList as $hdKey => $hdOrder) {
  296. $payWay = $hdOrder['payWay'] ?? 0;
  297. $mainPay = $hdOrder['mainPay'] ?? 0;
  298. $cash = $hdOrder['cash'] ?? 0;
  299. $actPrice = $hdOrder['actPrice'] ?? 0;
  300. $getStaffId = $hdOrder['getStaffId'] ?? 0;
  301. $debtPrice = $hdOrder['debtPrice'] ?? 0;
  302. $remainDebtPrice = $hdOrder['remainDebtPrice'] ?? 0;
  303. $onlinePay = $hdOrder['onlinePay'] ?? 0;
  304. $fromType = $hdOrder['fromType'] ?? 0;
  305. if ($onlinePay == dict::getDict('onlinePay', 'yes')) {
  306. //使用在线支付
  307. $incomeList['system']['amount'] = bcadd($incomeList['system']['amount'], $mainPay, 2);
  308. $incomeList['system']['num'] = bcadd($incomeList['system']['num'], 1);
  309. $incomeList['system']['category']['ls']['amount'] = bcadd($incomeList['system']['category']['ls']['amount'], $mainPay, 2);
  310. $incomeList['system']['category']['ls']['num'] = bcadd($incomeList['system']['category']['ls']['num'], 1);
  311. if ($cash > 0) {
  312. $incomeList['cash']['amount'] = bcadd($incomeList['cash']['amount'], $cash, 2);
  313. $incomeList['cash']['num'] = bcadd($incomeList['cash']['num'], 1);
  314. $incomeList['cash']['category']['ls']['amount'] = bcadd($incomeList['cash']['category']['ls']['amount'], $cash, 2);
  315. $incomeList['cash']['category']['ls']['num'] = bcadd($incomeList['cash']['category']['ls']['num'], 1);
  316. }
  317. } else {
  318. if ($fromType == dict::getDict('fromType', 'mt')) {
  319. //美团!!!
  320. $incomeList['mt']['amount'] = bcadd($incomeList['mt']['amount'], $actPrice, 2);
  321. $incomeList['mt']['num'] = bcadd($incomeList['mt']['num'], 1);
  322. } else {
  323. //非美团!!!
  324. if ($debtPrice > 0) {
  325. if ($remainDebtPrice > 0) {
  326. $incomeList['debt']['amount'] = bcadd($incomeList['debt']['amount'], $debtPrice, 2);
  327. $incomeList['debt']['num'] = bcadd($incomeList['debt']['num'], 1);
  328. $incomeList['debt']['category']['ls']['amount'] = bcadd($incomeList['debt']['category']['ls']['amount'], $debtPrice, 2);
  329. $incomeList['debt']['category']['ls']['num'] = bcadd($incomeList['debt']['category']['ls']['num'], 1);
  330. } else {
  331. $incomeList['debtClear']['amount'] = bcadd($incomeList['debtClear']['amount'], $debtPrice, 2);
  332. $incomeList['debtClear']['num'] = bcadd($incomeList['debtClear']['num'], 1);
  333. $incomeList['debtClear']['category']['ls']['amount'] = bcadd($incomeList['debtClear']['category']['ls']['amount'], $debtPrice, 2);
  334. $incomeList['debtClear']['category']['ls']['num'] = bcadd($incomeList['debtClear']['category']['ls']['num'], 1);
  335. }
  336. }
  337. //付订金的情况!!
  338. $currentAmount = $debtPrice > 0 ? bcsub($actPrice, $debtPrice, 2) : $actPrice;
  339. //使用非在线支付
  340. switch ($payWay) {
  341. case dict::getDict('payWay', 'wxPay'):
  342. //员工微信总共收了多少笔多少钱
  343. $incomeList['kfWx']['amount'] = bcadd($incomeList['kfWx']['amount'], $currentAmount, 2);
  344. $incomeList['kfWx']['num'] = bcadd($incomeList['kfWx']['num'], 1);
  345. //批发开单、零售开单、批发结账、零售尾款各收了多少现金
  346. $incomeList['kfWx']['category']['ls']['amount'] = bcadd($incomeList['kfWx']['category']['ls']['amount'], $currentAmount, 2);
  347. $incomeList['kfWx']['category']['ls']['num'] = bcadd($incomeList['kfWx']['category']['ls']['num'], 1);
  348. //客1 客2 客3各收了多少钱
  349. if (isset($incomeList['kfWx']['class'][$getStaffId])) {
  350. $incomeList['kfWx']['class'][$getStaffId]['amount'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['amount'], $currentAmount, 2);
  351. $incomeList['kfWx']['class'][$getStaffId]['num'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['num'], 1);
  352. }
  353. //每个客服收的明细
  354. if (isset($incomeList['kfWx']['class'][$getStaffId]['itemList']['ls'])) {
  355. $incomeList['kfWx']['class'][$getStaffId]['itemList']['ls']['amount'] = floatval(bcadd($incomeList['kfWx']['class'][$getStaffId]['itemList']['ls']['amount'], $actPrice, 2));
  356. $incomeList['kfWx']['class'][$getStaffId]['itemList']['ls']['num'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['itemList']['ls']['num'], 1);
  357. }
  358. break;
  359. case dict::getDict('payWay', 'alipay'):
  360. $incomeList['aliPay']['amount'] = bcadd($incomeList['aliPay']['amount'], $currentAmount, 2);
  361. $incomeList['aliPay']['num'] = bcadd($incomeList['aliPay']['num'], 1);
  362. $incomeList['aliPay']['category']['ls']['amount'] = bcadd($incomeList['aliPay']['category']['ls']['amount'], $currentAmount, 2);
  363. $incomeList['aliPay']['category']['ls']['num'] = bcadd($incomeList['aliPay']['category']['ls']['num'], 1);
  364. break;
  365. case dict::getDict('payWay', 'cash'):
  366. $incomeList['cash']['amount'] = bcadd($incomeList['cash']['amount'], $currentAmount, 2);
  367. $incomeList['cash']['num'] = bcadd($incomeList['cash']['num'], 1);
  368. $incomeList['cash']['category']['ls']['amount'] = bcadd($incomeList['cash']['category']['ls']['amount'], $currentAmount, 2);
  369. $incomeList['cash']['category']['ls']['num'] = bcadd($incomeList['cash']['category']['ls']['num'], 1);
  370. break;
  371. case dict::getDict('payWay', 'bankCard'):
  372. $incomeList['bankCard']['amount'] = bcadd($incomeList['aliPay']['amount'], $currentAmount, 2);
  373. $incomeList['bankCard']['num'] = bcadd($incomeList['aliPay']['num'], 1);
  374. $incomeList['bankCard']['category']['ls']['amount'] = bcadd($incomeList['bankCard']['category']['ls']['amount'], $currentAmount, 2);
  375. $incomeList['bankCard']['category']['ls']['num'] = bcadd($incomeList['bankCard']['category']['ls']['num'], 1);
  376. break;
  377. case dict::getDict('payWay', 'unknown'):
  378. $incomeList['other']['amount'] = bcadd($incomeList['aliPay']['amount'], $currentAmount, 2);
  379. $incomeList['other']['num'] = bcadd($incomeList['aliPay']['num'], 1);
  380. $incomeList['other']['category']['ls']['amount'] = bcadd($incomeList['other']['category']['ls']['amount'], $currentAmount, 2);
  381. $incomeList['other']['category']['ls']['num'] = bcadd($incomeList['other']['category']['ls']['num'], 1);
  382. break;
  383. default:
  384. }
  385. }
  386. }
  387. }
  388. $total = 0;
  389. foreach ($incomeList as $i) {
  390. $current = $i['amount'] ?? 0;
  391. $total = bcadd($current, $total, 2);
  392. }
  393. echo ' lsTotal:'.$total.' ';
  394. print_r($incomeList);
  395. die;
  396. }
  397. //即时配送
  398. public function actionGetBindAccount()
  399. {
  400. $merchant = WxOpenClass::getGhsWxInfo();
  401. $isOpen = 2;
  402. $r = miniUtil::getBindAccount($merchant, $isOpen);
  403. dd($r);
  404. }
  405. public function actionDada()
  406. {
  407. //https://github.com/wanDoubleMing/dada_openapi_php
  408. //初始化一个配置文件
  409. $dada = Yii::getAlias("@vendor/dada/");
  410. require_once $dada . 'api/addOrderApi.php';
  411. require_once $dada . 'client/dadaRequestClient.php';
  412. require_once $dada . 'client/dadaResponse.php';
  413. require_once $dada . 'config/config.php';
  414. require_once $dada . 'model/orderModel.php';
  415. // isOnline 判断是否是测试环境,会有不同的域名等
  416. $isOnline = false;
  417. //商户id
  418. $sourceId = 73753;
  419. $shopNo = 11047059;
  420. // 初始化一个config
  421. $config = new \Config($sourceId, $isOnline);
  422. //3.domain文件新建一个model,并初始化
  423. $orderModel = new \OrderModel();
  424. $orderModel->setShopNo($shopNo);
  425. $orderModel->setOriginId('2020043017180001');
  426. $orderModel->setCityCode('021');
  427. $orderModel->setCargoPrice(10);
  428. $orderModel->setIsPrepay(0);
  429. $orderModel->setReceiverName('测试达达');
  430. $orderModel->setReceiverAddress('上海市崇明岛');
  431. $orderModel->setReceiverLat(31.63);
  432. $orderModel->setReceiverLng(121.41);
  433. $orderModel->setReceiverPhone('15280215347');
  434. $orderModel->setCallback('https://api.saas.huaml.com/express/callback');
  435. // api主要有2个参数,一个是url, 一个是业务参数
  436. $addOrderApi = new \AddOrderApi(json_encode($orderModel));
  437. //5.初始化客户端,并调用rpc
  438. $dada_client = new \DadaRequestClient($config, $addOrderApi);
  439. $resp = $dada_client->makeRequest();
  440. echo json_encode($resp);
  441. }
  442. public function actionRabbit()
  443. {
  444. $orderId = 214752;
  445. $order = OrderService::getById($orderId);
  446. $sjId = $order['sjId'];
  447. $openMerchant = WxOpenService::getWxInfo();
  448. $merchant = MerchantService::getMerchantById($sjId);
  449. $shopId = $merchant['defaultShopId'];
  450. $params = ['sourceType' => $order['sourceType'], 'miniAppId' => $openMerchant['miniAppId'], 'orderId' => $orderId];
  451. $type = 'income';
  452. InformAdminService::addInform($shopId, $type, $params);
  453. }
  454. //添加优惠券 ssh 2020.5.5
  455. public function actionAddCoupon()
  456. {
  457. $merchant = MerchantService::getMerchantById(12358);
  458. $user = UserService::getById(12543444);
  459. UserService::focus($user, $merchant);
  460. }
  461. public function actionGetUnionId()
  462. {
  463. $merchant = MerchantService::getMerchantById(12358);
  464. $extend = MerchantExtendService::getBySjId(12358);
  465. $mcId = $extend['wxPayMerchantId'];
  466. $orderId = '200512145420123581254345688252';
  467. miniUtil::getPaidUnionId($merchant, 'o-hXO4qOzIVbUNVucoFzEiArOz5k', $mcId, $orderId, 0);
  468. }
  469. public function actionCalc()
  470. {
  471. $dis = mapUtil::calculateDistance('116.308479', '39.983171', '116.328479', '39.973171');
  472. echo $dis;
  473. }
  474. }