TestController.php 28 KB

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