TestController.php 28 KB

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