| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510 |
- <?php
- namespace pt\controllers;
- use biz\sj\services\MerchantExtendService;
- use biz\sj\services\MerchantService;
- use bizGhs\custom\classes\CustomClass;
- use bizGhs\order\classes\OrderClass;
- use bizGhs\shop\classes\ShopAdminClass;
- use bizGhs\shop\classes\ShopClass;
- use bizHd\message\services\InformAdminService;
- use bizHd\order\services\OrderService;
- use bizHd\saas\classes\ApplyClass;
- use bizHd\user\services\UserService;
- use bizHd\wx\classes\WxOpenClass;
- use bizHd\wx\services\WxOpenService;
- use common\components\dateUtil;
- use common\components\dict;
- use common\components\mapUtil;
- use Overtrue\Pinyin\Pinyin;
- use Yii;
- use common\components\wxUtil;
- use common\components\miniUtil;
- use bizHd\order\classes\OrderClass as HdOrderClass;
- class TestController extends PublicController
- {
- //收入
- public function actionIncome()
- {
- echo "<pre>";
- $searchTime = 'thisMonth';
- $startTime = $get['startTime'] ?? '';
- $endTime = $get['endTime'] ?? '';
- $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
- $start = $period['startTime'];
- $end = $period['endTime'];
- $currentStartDate = date('Y-m-d', strtotime($start));
- $currentEndDate = date('Y-m-d', strtotime($end));
- $currentStartTime = $currentStartDate . ' 00:00:00';
- $currentEndTime = $currentEndDate . ' 23:59:59';
- $mainId = 4836;
- $pfIncome = 0;
- $pfSendCost = 0;
- $where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
- $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
- $ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
- if (!empty($ghsOrderList)) {
- foreach ($ghsOrderList as $ghsKey => $ghsOrder) {
- $actPrice = $ghsOrder['actPrice'] ?? 0;
- $sendCost = $ghsOrder['sendCost'] ?? 0;
- $pfIncome = bcadd($pfIncome, $actPrice, 2);
- $pfSendCost = bcadd($pfSendCost, $sendCost, 2);
- }
- }
- echo $pfIncome . "<br />";
- //零售开单
- $lsIncome = 0;
- $lsSendCost = 0;
- $lsServiceFee = 0;
- $hdWhere = ['mainId' => $mainId, 'status' => ['in', [HdOrderClass::ORDER_STATUS_UN_SEND, HdOrderClass::ORDER_STATUS_SENDING, HdOrderClass::ORDER_STATUS_COMPLETE]]];
- $hdWhere['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
- $hdOrderList = HdOrderClass::getAllByCondition($hdWhere, null, '*');
- foreach ($hdOrderList as $hdKey => $hdOrder) {
- $actPrice = $hdOrder['mainPay'] ?? 0;
- $serviceFee = $hdOrder['serviceFee'] ?? 0;
- $sendCost = $hdOrder['sendCost'] ?? 0;
- $lsIncome = bcadd($actPrice, $lsIncome, 2);
- //退款取消的先不计算成本
- if ($actPrice > 0) {
- $lsSendCost = bcadd($lsSendCost, $sendCost, 2);
- $lsServiceFee = bcadd($lsServiceFee, $serviceFee, 2);
- }
- }
- echo " <br />零售收入:".$lsIncome."<br />";
- $shopId = 4892;
- $shop = ShopClass::getById($shopId, true);
- $mainId = $shop->mainId ?? 0;
- //批发开单 pf 零售开单 ls 批发结账 pfJz 零售尾款 lsWk
- $searchTime = 'thisMonth';
- $startTime = $get['startTime'] ?? '';
- $endTime = $get['endTime'] ?? '';
- $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
- $start = $period['startTime'];
- $end = $period['endTime'];
- $currentStartDate = date('Y-m-d', strtotime($start));
- $currentEndDate = date('Y-m-d', strtotime($end));
- $currentStartTime = $currentStartDate . ' 00:00:00';
- $currentEndTime = $currentEndDate . ' 23:59:59';
- $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId, 'isPt' => 0], null, '*', 'id', true);
- $kf = [];
- if (!empty($staffList)) {
- foreach ($staffList as $staff) {
- $name = $staff->name ?? '';
- $staffId = $staff->id ?? 0;
- $kf[$staffId]['name'] = $name;
- $kf[$staffId]['key'] = $staffId;
- $kf[$staffId]['num'] = 0;
- $kf[$staffId]['amount'] = 0;
- $kf[$staffId]['itemList']['pf'] = ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0];
- $kf[$staffId]['itemList']['ls'] = ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0];
- $kf[$staffId]['itemList']['pfJz'] = ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0];
- $kf[$staffId]['itemList']['lsWk'] = ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0];
- }
- }
- $incomeList = [
- //系统收入
- 'system' => [
- 'amount' => 0,
- 'num' => 0,
- 'name' => '系统收款',
- 'category' => [
- 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
- 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
- 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
- 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
- ],
- ],
- 'kfWx' => [
- 'amount' => 0,
- 'num' => 0,
- 'name' => '员工收款',
- 'class' => $kf,
- 'category' => [
- 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
- 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
- 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
- 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
- ]
- ],
- 'debt' => [
- 'amount' => 0,
- 'num' => 0,
- 'name' => '欠款',
- 'category' => [
- 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
- 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
- ],
- ],
- 'debtClear' => [
- 'amount' => 0,
- 'num' => 0,
- 'name' => '已结欠款',
- 'category' => [
- 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
- 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
- ],
- ],
- 'cash' => [
- 'amount' => 0,
- 'name' => '现金',
- 'num' => 0,
- 'category' => [
- 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
- 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
- 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
- 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
- ],
- ],
- 'aliPay' => [
- 'amount' => 0,
- 'num' => 0,
- 'name' => '支付宝',
- 'category' => [
- 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
- 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
- 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
- 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
- ],
- ],
- 'bankCard' => [
- 'amount' => 0,
- 'name' => '银行卡',
- 'num' => 0,
- 'category' => [
- 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
- 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
- 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
- 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
- ],
- ],
- 'mt' => ['amount' => 0, 'num' => 0, 'name' => '美团'],
- 'other' => [
- 'amount' => 0,
- 'num' => 0,
- 'name' => '其它',
- 'category' => [
- 'pf' => ['name' => '批发', 'key' => 'pf', 'num' => 0, 'amount' => 0],
- 'ls' => ['name' => '零售', 'key' => 'ls', 'num' => 0, 'amount' => 0],
- 'pfJz' => ['name' => '批发结账', 'key' => 'pfJz', 'num' => 0, 'amount' => 0],
- 'lsWk' => ['name' => '零售尾款', 'key' => 'lsWk', 'num' => 0, 'amount' => 0],
- ],
- ],
- ];
- $incomeList = [];
- //批发开单
- $where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
- $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
- $ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
- $ghsTotal = 0;
- $defaultTotal = 0;
- if (!empty($ghsOrderList)) {
- foreach ($ghsOrderList as $ghsKey => $ghsOrder) {
- $payWay = $ghsOrder['payWay'] ?? 0;
- $actPrice = $ghsOrder['actPrice'] ?? 0;
- $ghsTotal = bcadd($ghsTotal, $actPrice, 2);
- $getStaffId = $ghsOrder['getStaffId'] ?? 0;
- $debtPrice = $ghsOrder['debtPrice'] ?? 0;
- $remainDebtPrice = $ghsOrder['remainDebtPrice'] ?? 0;
- $onlinePay = $ghsOrder['onlinePay'] ?? dict::getDict('onlinePay', 'not');
- if ($debtPrice > 0) {
- if ($remainDebtPrice > 0) {
- $incomeList['debt']['amount'] = bcadd($incomeList['debt']['amount'], $actPrice, 2);
- $incomeList['debt']['num'] = bcadd($incomeList['debt']['num'], 1);
- $incomeList['debt']['category']['pf']['amount'] = bcadd($incomeList['debt']['category']['pf']['amount'], $actPrice, 2);
- $incomeList['debt']['category']['pf']['num'] = bcadd($incomeList['debt']['category']['pf']['num'], 1);
- } else {
- $incomeList['debtClear']['amount'] = bcadd($incomeList['debtClear']['amount'], $actPrice, 2);
- $incomeList['debtClear']['num'] = bcadd($incomeList['debtClear']['num'], 1);
- $incomeList['debtClear']['category']['pf']['amount'] = bcadd($incomeList['debtClear']['category']['pf']['amount'], $actPrice, 2);
- $incomeList['debtClear']['category']['pf']['num'] = bcadd($incomeList['debtClear']['category']['pf']['num'], 1);
- }
- } else {
- if ($onlinePay == dict::getDict('onlinePay', 'yes')) {
- //使用在线支付
- $incomeList['system']['amount'] = bcadd($incomeList['system']['amount'], $actPrice, 2);
- $incomeList['system']['num'] = bcadd($incomeList['system']['num'], 1);
- $incomeList['system']['category']['pf']['amount'] = bcadd($incomeList['system']['category']['pf']['amount'], $actPrice, 2);
- $incomeList['system']['category']['pf']['num'] = bcadd($incomeList['system']['category']['pf']['num'], 1);
- } else {
- //使用非在线支付
- switch ($payWay) {
- case dict::getDict('payWay', 'wxPay'):
- //员工微信总共收了多少笔多少钱
- $incomeList['kfWx']['amount'] = bcadd($incomeList['kfWx']['amount'], $actPrice, 2);
- $incomeList['kfWx']['num'] = bcadd($incomeList['kfWx']['num'], 1);
- //批发开单、零售开单、批发结账、零售尾款各收了多少现金
- $incomeList['kfWx']['category']['pf']['amount'] = bcadd($incomeList['kfWx']['category']['pf']['amount'], $actPrice, 2);
- $incomeList['kfWx']['category']['pf']['num'] = bcadd($incomeList['kfWx']['category']['pf']['num'], 1);
- //每个客服总共收了多少笔多少钱
- if (isset($incomeList['kfWx']['class'][$getStaffId])) {
- $incomeList['kfWx']['class'][$getStaffId]['amount'] = floatval(bcadd($incomeList['kfWx']['class'][$getStaffId]['amount'], $actPrice, 2));
- $incomeList['kfWx']['class'][$getStaffId]['num'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['num'], 1);
- }
- //每个客服收的明细
- if (isset($incomeList['kfWx']['class'][$getStaffId]['itemList']['pf'])) {
- $incomeList['kfWx']['class'][$getStaffId]['itemList']['pf']['amount'] = floatval(bcadd($incomeList['kfWx']['class'][$getStaffId]['itemList']['pf']['amount'], $actPrice, 2));
- $incomeList['kfWx']['class'][$getStaffId]['itemList']['pf']['num'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['itemList']['pf']['num'], 1);
- }
- break;
- case dict::getDict('payWay', 'alipay'):
- $incomeList['aliPay']['amount'] = bcadd($incomeList['aliPay']['amount'], $actPrice, 2);
- $incomeList['aliPay']['num'] = bcadd($incomeList['aliPay']['num'], 1);
- $incomeList['aliPay']['category']['pf']['amount'] = bcadd($incomeList['aliPay']['category']['pf']['amount'], $actPrice, 2);
- $incomeList['aliPay']['category']['pf']['num'] = bcadd($incomeList['aliPay']['category']['pf']['num'], 1);
- break;
- case dict::getDict('payWay', 'cash'):
- $incomeList['cash']['amount'] = bcadd($incomeList['cash']['amount'], $actPrice, 2);
- $incomeList['cash']['num'] = bcadd($incomeList['cash']['num'], 1);
- $incomeList['cash']['category']['pf']['amount'] = bcadd($incomeList['cash']['category']['pf']['amount'], $actPrice, 2);
- $incomeList['cash']['category']['pf']['num'] = bcadd($incomeList['cash']['category']['pf']['num'], 1);
- break;
- case dict::getDict('payWay', 'bankCard'):
- $incomeList['bankCard']['amount'] = bcadd($incomeList['bankCard']['amount'], $actPrice, 2);
- $incomeList['bankCard']['num'] = bcadd($incomeList['bankCard']['num'], 1);
- $incomeList['bankCard']['category']['pf']['amount'] = bcadd($incomeList['bankCard']['category']['pf']['amount'], $actPrice, 2);
- $incomeList['bankCard']['category']['pf']['num'] = bcadd($incomeList['bankCard']['category']['pf']['num'], 1);
- break;
- case dict::getDict('payWay', 'unknown'):
- $incomeList['other']['amount'] = bcadd($incomeList['other']['amount'], $actPrice, 2);
- $incomeList['other']['num'] = bcadd($incomeList['other']['num'], 1);
- $incomeList['other']['category']['pf']['amount'] = bcadd($incomeList['other']['category']['pf']['amount'], $actPrice, 2);
- $incomeList['other']['category']['pf']['num'] = bcadd($incomeList['other']['category']['pf']['num'], 1);
- break;
- default:
- $defaultTotal = bcadd($defaultTotal, $actPrice, 2);
- }
- }
- }
- }
- }
- $total = 0;
- foreach ($incomeList as $i) {
- $current = $i['amount'] ?? 0;
- $total = bcadd($current, $total, 2);
- }
- echo 'default:'.$defaultTotal.'<br />';
- echo 'ghsTotal:' . $ghsTotal . '<br />';
- echo 'total:' . $total . '<br />';
- print_r($incomeList);
- $incomeList = [];
- //零售开单
- $hdWhere = ['mainId' => $mainId, 'status' => ['in', [HdOrderClass::ORDER_STATUS_UN_SEND, HdOrderClass::ORDER_STATUS_SENDING, HdOrderClass::ORDER_STATUS_COMPLETE]]];
- $hdWhere['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
- $hdOrderList = HdOrderClass::getAllByCondition($hdWhere, null, '*');
- foreach ($hdOrderList as $hdKey => $hdOrder) {
- $payWay = $hdOrder['payWay'] ?? 0;
- $mainPay = $hdOrder['mainPay'] ?? 0;
- $cash = $hdOrder['cash'] ?? 0;
- $actPrice = $hdOrder['actPrice'] ?? 0;
- $getStaffId = $hdOrder['getStaffId'] ?? 0;
- $debtPrice = $hdOrder['debtPrice'] ?? 0;
- $remainDebtPrice = $hdOrder['remainDebtPrice'] ?? 0;
- $onlinePay = $hdOrder['onlinePay'] ?? 0;
- $fromType = $hdOrder['fromType'] ?? 0;
- if ($onlinePay == dict::getDict('onlinePay', 'yes')) {
- //使用在线支付
- $incomeList['system']['amount'] = bcadd($incomeList['system']['amount'], $mainPay, 2);
- $incomeList['system']['num'] = bcadd($incomeList['system']['num'], 1);
- $incomeList['system']['category']['ls']['amount'] = bcadd($incomeList['system']['category']['ls']['amount'], $mainPay, 2);
- $incomeList['system']['category']['ls']['num'] = bcadd($incomeList['system']['category']['ls']['num'], 1);
- if ($cash > 0) {
- $incomeList['cash']['amount'] = bcadd($incomeList['cash']['amount'], $cash, 2);
- $incomeList['cash']['num'] = bcadd($incomeList['cash']['num'], 1);
- $incomeList['cash']['category']['ls']['amount'] = bcadd($incomeList['cash']['category']['ls']['amount'], $cash, 2);
- $incomeList['cash']['category']['ls']['num'] = bcadd($incomeList['cash']['category']['ls']['num'], 1);
- }
- } else {
- if ($fromType == dict::getDict('fromType', 'mt')) {
- //美团!!!
- $incomeList['mt']['amount'] = bcadd($incomeList['mt']['amount'], $actPrice, 2);
- $incomeList['mt']['num'] = bcadd($incomeList['mt']['num'], 1);
- } else {
- //非美团!!!
- if ($debtPrice > 0) {
- if ($remainDebtPrice > 0) {
- $incomeList['debt']['amount'] = bcadd($incomeList['debt']['amount'], $debtPrice, 2);
- $incomeList['debt']['num'] = bcadd($incomeList['debt']['num'], 1);
- $incomeList['debt']['category']['ls']['amount'] = bcadd($incomeList['debt']['category']['ls']['amount'], $debtPrice, 2);
- $incomeList['debt']['category']['ls']['num'] = bcadd($incomeList['debt']['category']['ls']['num'], 1);
- } else {
- $incomeList['debtClear']['amount'] = bcadd($incomeList['debtClear']['amount'], $debtPrice, 2);
- $incomeList['debtClear']['num'] = bcadd($incomeList['debtClear']['num'], 1);
- $incomeList['debtClear']['category']['ls']['amount'] = bcadd($incomeList['debtClear']['category']['ls']['amount'], $debtPrice, 2);
- $incomeList['debtClear']['category']['ls']['num'] = bcadd($incomeList['debtClear']['category']['ls']['num'], 1);
- }
- }
- //付订金的情况!!
- $currentAmount = $debtPrice > 0 ? bcsub($actPrice, $debtPrice, 2) : $actPrice;
- //使用非在线支付
- switch ($payWay) {
- case dict::getDict('payWay', 'wxPay'):
- //员工微信总共收了多少笔多少钱
- $incomeList['kfWx']['amount'] = bcadd($incomeList['kfWx']['amount'], $currentAmount, 2);
- $incomeList['kfWx']['num'] = bcadd($incomeList['kfWx']['num'], 1);
- //批发开单、零售开单、批发结账、零售尾款各收了多少现金
- $incomeList['kfWx']['category']['ls']['amount'] = bcadd($incomeList['kfWx']['category']['ls']['amount'], $currentAmount, 2);
- $incomeList['kfWx']['category']['ls']['num'] = bcadd($incomeList['kfWx']['category']['ls']['num'], 1);
- //客1 客2 客3各收了多少钱
- if (isset($incomeList['kfWx']['class'][$getStaffId])) {
- $incomeList['kfWx']['class'][$getStaffId]['amount'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['amount'], $currentAmount, 2);
- $incomeList['kfWx']['class'][$getStaffId]['num'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['num'], 1);
- }
- //每个客服收的明细
- if (isset($incomeList['kfWx']['class'][$getStaffId]['itemList']['ls'])) {
- $incomeList['kfWx']['class'][$getStaffId]['itemList']['ls']['amount'] = floatval(bcadd($incomeList['kfWx']['class'][$getStaffId]['itemList']['ls']['amount'], $actPrice, 2));
- $incomeList['kfWx']['class'][$getStaffId]['itemList']['ls']['num'] = bcadd($incomeList['kfWx']['class'][$getStaffId]['itemList']['ls']['num'], 1);
- }
- break;
- case dict::getDict('payWay', 'alipay'):
- $incomeList['aliPay']['amount'] = bcadd($incomeList['aliPay']['amount'], $currentAmount, 2);
- $incomeList['aliPay']['num'] = bcadd($incomeList['aliPay']['num'], 1);
- $incomeList['aliPay']['category']['ls']['amount'] = bcadd($incomeList['aliPay']['category']['ls']['amount'], $currentAmount, 2);
- $incomeList['aliPay']['category']['ls']['num'] = bcadd($incomeList['aliPay']['category']['ls']['num'], 1);
- break;
- case dict::getDict('payWay', 'cash'):
- $incomeList['cash']['amount'] = bcadd($incomeList['cash']['amount'], $currentAmount, 2);
- $incomeList['cash']['num'] = bcadd($incomeList['cash']['num'], 1);
- $incomeList['cash']['category']['ls']['amount'] = bcadd($incomeList['cash']['category']['ls']['amount'], $currentAmount, 2);
- $incomeList['cash']['category']['ls']['num'] = bcadd($incomeList['cash']['category']['ls']['num'], 1);
- break;
- case dict::getDict('payWay', 'bankCard'):
- $incomeList['bankCard']['amount'] = bcadd($incomeList['aliPay']['amount'], $currentAmount, 2);
- $incomeList['bankCard']['num'] = bcadd($incomeList['aliPay']['num'], 1);
- $incomeList['bankCard']['category']['ls']['amount'] = bcadd($incomeList['bankCard']['category']['ls']['amount'], $currentAmount, 2);
- $incomeList['bankCard']['category']['ls']['num'] = bcadd($incomeList['bankCard']['category']['ls']['num'], 1);
- break;
- case dict::getDict('payWay', 'unknown'):
- $incomeList['other']['amount'] = bcadd($incomeList['aliPay']['amount'], $currentAmount, 2);
- $incomeList['other']['num'] = bcadd($incomeList['aliPay']['num'], 1);
- $incomeList['other']['category']['ls']['amount'] = bcadd($incomeList['other']['category']['ls']['amount'], $currentAmount, 2);
- $incomeList['other']['category']['ls']['num'] = bcadd($incomeList['other']['category']['ls']['num'], 1);
- break;
- default:
- }
- }
- }
- }
- $total = 0;
- foreach ($incomeList as $i) {
- $current = $i['amount'] ?? 0;
- $total = bcadd($current, $total, 2);
- }
- echo '<br /> lsTotal:'.$total.' <br />';
- print_r($incomeList);
- die;
- }
- //即时配送
- public function actionGetBindAccount()
- {
- $merchant = WxOpenClass::getGhsWxInfo();
- $isOpen = 2;
- $r = miniUtil::getBindAccount($merchant, $isOpen);
- dd($r);
- }
- public function actionDada()
- {
- //https://github.com/wanDoubleMing/dada_openapi_php
- //初始化一个配置文件
- $dada = Yii::getAlias("@vendor/dada/");
- require_once $dada . 'api/addOrderApi.php';
- require_once $dada . 'client/dadaRequestClient.php';
- require_once $dada . 'client/dadaResponse.php';
- require_once $dada . 'config/config.php';
- require_once $dada . 'model/orderModel.php';
- // isOnline 判断是否是测试环境,会有不同的域名等
- $isOnline = false;
- //商户id
- $sourceId = 73753;
- $shopNo = 11047059;
- // 初始化一个config
- $config = new \Config($sourceId, $isOnline);
- //3.domain文件新建一个model,并初始化
- $orderModel = new \OrderModel();
- $orderModel->setShopNo($shopNo);
- $orderModel->setOriginId('2020043017180001');
- $orderModel->setCityCode('021');
- $orderModel->setCargoPrice(10);
- $orderModel->setIsPrepay(0);
- $orderModel->setReceiverName('测试达达');
- $orderModel->setReceiverAddress('上海市崇明岛');
- $orderModel->setReceiverLat(31.63);
- $orderModel->setReceiverLng(121.41);
- $orderModel->setReceiverPhone('15280215347');
- $orderModel->setCallback('https://api.saas.huaml.com/express/callback');
- // api主要有2个参数,一个是url, 一个是业务参数
- $addOrderApi = new \AddOrderApi(json_encode($orderModel));
- //5.初始化客户端,并调用rpc
- $dada_client = new \DadaRequestClient($config, $addOrderApi);
- $resp = $dada_client->makeRequest();
- echo json_encode($resp);
- }
- public function actionRabbit()
- {
- $orderId = 214752;
- $order = OrderService::getById($orderId);
- $sjId = $order['sjId'];
- $openMerchant = WxOpenService::getWxInfo();
- $merchant = MerchantService::getMerchantById($sjId);
- $shopId = $merchant['defaultShopId'];
- $params = ['sourceType' => $order['sourceType'], 'miniAppId' => $openMerchant['miniAppId'], 'orderId' => $orderId];
- $type = 'income';
- InformAdminService::addInform($shopId, $type, $params);
- }
- //添加优惠券 ssh 2020.5.5
- public function actionAddCoupon()
- {
- $merchant = MerchantService::getMerchantById(12358);
- $user = UserService::getById(12543444);
- UserService::focus($user, $merchant);
- }
- public function actionGetUnionId()
- {
- $merchant = MerchantService::getMerchantById(12358);
- $extend = MerchantExtendService::getBySjId(12358);
- $mcId = $extend['wxPayMerchantId'];
- $orderId = '200512145420123581254345688252';
- miniUtil::getPaidUnionId($merchant, 'o-hXO4qOzIVbUNVucoFzEiArOz5k', $mcId, $orderId, 0);
- }
- public function actionCalc()
- {
- $dis = mapUtil::calculateDistance('116.308479', '39.983171', '116.328479', '39.973171');
- echo $dis;
- }
- }
|