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