| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- <?php
- namespace ghs\controllers;
- use biz\shop\classes\ShopClass;
- use biz\stat\classes\StatCgClass;
- use bizGhs\product\classes\ProductClass;
- use bizGhs\shop\classes\ShopAdminClass;
- use bizHd\stat\classes\StatIncomeClass;
- use bizHd\stat\classes\StatOrderClass;
- use bizHd\wx\classes\WxOpenClass;
- use common\components\dict;
- use common\components\imgUtil;
- use common\components\miniUtil;
- use common\components\stringUtil;
- use common\components\util;
- use Yii;
- use GatewayClient\Gateway;
- class MainController extends BaseController
- {
- public $guestAccess = ['my'];
- //修改运费标准 ssh 20230406
- public function actionModifyFreight()
- {
- $post = Yii::$app->request->post();
- $main = $this->main;
- $baseFee = $post['baseFee'] ?? 5.5;
- $shortDistanceFee = $post['shortDistanceFee'] ?? 2;
- $longDistanceFee = $post['longDistanceFee'] ?? 2;
- $smallWeightFee = $post['smallWeightFee'] ?? 6;
- $bigWeightFee = $post['bigWeightFee'] ?? 10;
- $onePeriodFee = $post['onePeriodFee'] ?? 4;
- $twoPeriodFee = $post['twoPeriodFee'] ?? 1;
- $threePeriodFee = $post['threePeriodFee'] ?? 2;
- $lsFee = $post['lsFee'] ?? 0;
- $main->baseFee = $baseFee;
- $main->shortDistanceFee = $shortDistanceFee;
- $main->longDistanceFee = $longDistanceFee;
- $main->smallWeightFee = $smallWeightFee;
- $main->bigWeightFee = $bigWeightFee;
- $main->onePeriodFee = $onePeriodFee;
- $main->twoPeriodFee = $twoPeriodFee;
- $main->threePeriodFee = $threePeriodFee;
- $main->lsFee = $lsFee;
- $main->save();
- util::complete();
- }
- //main信息 ssh 20230406
- public function actionInfo()
- {
- $main = $this->main;
- util::success(['info' => $main]);
- }
- //采购商城海报 ssh 20230217
- public function actionGetMallPoster()
- {
- $merchant = WxOpenClass::getWxInfo();
- $page = 'pagesPurchase/ghsProduct';
- $ptStyle = dict::getDict('ptStyle', 'hd');
- //scene不能超过32个字条,这些进行缩写:sId = shopId gId = ghsShopAdminId
- $scene = "sId={$this->shopId}&id=0&gId=" . $this->shopAdminId;
- $imgUrl = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $ptStyle);
- $titleBase64 = stringUtil::ossBase64('扫码买花');
- $prefix = imgUtil::getPrefix();
- $url = $prefix . 'shop/miniCodeBg.jpg?x-oss-process=image';
- $goodsMiniCodeBase64 = stringUtil::ossBase64($imgUrl);
- $url .= '/watermark,image_' . $goodsMiniCodeBase64 . ',g_north,x_0,y_40';
- $url .= '/watermark,text_' . $titleBase64 . ',g_north,x_0,y_530,size_50';
- $respond = ['imgUrl' => $url];
- util::success($respond);
- }
- public function actionDemo()
- {
- return $this->renderPartial('demo');
- }
- public function actionIndex()
- {
- return $this->renderPartial('index');
- }
- //新客户 ssh 2019.12.29
- public function actionVisit()
- {
- $data = json_encode(array(
- 'type' => 'msg',
- 'msg' => 'aaaa',
- ));
- $id = 'merchantConsole_' . $this->sjId;
- $online = Gateway::getClientIdByUid($id);
- if ($online) {
- //直接发送
- Gateway::sendToUid($id, json_encode($data));
- } else {
- //保存
- }
- }
- //新订单 ssh 2019.12.29
- public function actionOrder()
- {
- $data = json_encode(array(
- 'type' => 'msg',
- 'msg' => 'aaaa',
- ));
- $id = 'merchantConsole_' . $this->sjId;
- $online = Gateway::getClientIdByUid($id);
- if ($online) {
- //直接发送
- Gateway::sendToUid($id, json_encode($data));
- } else {
- //保存
- }
- }
- //经营概况 ssh 2021.1.27
- public function actionProfile()
- {
- //余额
- $shopInfo = ShopClass::getById($this->shopId);
- //库存情况
- $stockInfo = ProductClass::getProductStockByShopId($this->sjId, $this->shopId);
- //今日销售金额
- $today = StatIncomeClass::getAmountToday($this->shopId);
- //近七天销售金额
- $latestSeven = StatIncomeClass::getAmountWeek($this->shopId);
- //30天销售金额
- $latestThirty = StatIncomeClass::getAmountThirty($this->shopId);
- $base = [
- 'balance' => $shopInfo['balance'],
- 'mayGathering' => $shopInfo['mayGathering'] ?? 0.00,
- 'mayPay' => $shopInfo['mayPay'] ?? 0.00,
- 'stockCost' => $stockInfo['stockCost'],
- 'stockNum' => 0,
- 'stockBigNum' => $stockInfo['stockBigNum'],
- 'stockSmallNum' => $stockInfo['stockSmallNum'],
- 'stockWarning' => $stockInfo['stockWarning'],
- 'today' => $today,
- 'todayCompareYesterday' => 0,
- 'latestSeven' => $latestSeven,
- 'latestSevenSameTerm' => 0,
- 'latestThirty' => $latestThirty,
- 'latestThirtySameTerm' => 0,
- ];
- //今日订单数
- $saleNum = StatOrderClass::getRiseNumToday($this->shopId);
- //今日销售金额
- $saleAmount = $today;
- //昨日订单数
- $ySaleNum = StatOrderClass::getRiseNumYesterday($this->shopId);
- //昨日销售金额
- $ySaleAmount = StatIncomeClass::getAmountYesterday($this->shopId);
- //7天订单数
- $sevenSaleNum = StatOrderClass::getRiseNumWeek($this->shopId);
- //7天销售金额
- $sevenSaleAmount = $latestSeven;
- //30天订单数
- $thirtySaleNum = StatOrderClass::getRiseNumThirty($this->shopId);
- //30天销售金额
- $thirtySaleAmount = $latestThirty;
- //今日采购
- $todayCg = StatCgClass::getTodayCg($this->shop);
- //昨日采购
- $yesCg = StatCgClass::getYesterdayCg($this->shop);
- //7日采购
- $sevenCg = StatCgClass::getSevenCg($this->shop);
- //30日采购
- $thirtyCg = StatCgClass::getThirtyCg($this->shop);
- $more = [
- 'today' => [
- 'income' => 0,
- 'expend' => 0,
- 'saleNum' => $saleNum,
- 'saleAmount' => $saleAmount,
- 'purchaseNum' => $todayCg['num'] ?? 0,
- 'purchaseAmount' => $todayCg['amount'] ?? 0.00,
- ],
- 'yesterday' => [
- 'income' => 0,
- 'expend' => 0,
- 'saleNum' => $ySaleNum,
- 'saleAmount' => $ySaleAmount,
- 'purchaseNum' => $yesCg['num'] ?? 0,
- 'purchaseAmount' => $yesCg['amount'] ?? 0.00,
- ],
- 'latestSeven' => [
- 'income' => 0,
- 'expend' => 0,
- 'saleNum' => $sevenSaleNum,
- 'saleAmount' => $sevenSaleAmount,
- 'purchaseNum' => $sevenCg['num'] ?? 0,
- 'purchaseAmount' => $sevenCg['amount'] ?? 0.00,
- ],
- 'latestThirty' => [
- 'income' => 0,
- 'expend' => 0,
- 'saleNum' => $thirtySaleNum,
- 'saleAmount' => $thirtySaleAmount,
- 'purchaseNum' => $thirtyCg['num'] ?? 0,
- 'purchaseAmount' => $thirtyCg['amount'] ?? 0.00,
- ],
- ];
- util::success(['base' => $base, 'more' => $more]);
- }
- //我的 ssh 2021.1.30
- public function actionMy()
- {
- $lookMoney = ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop);
- $shop = $this->shop ?? null;
- $main = $this->main ?? null;
- $balance = $main->balance ?? 0.00;
- $txBalance = $main->txBalance ?? 0.00;
- $money = $main->money ?? 0;
- $cashAccount = $main->cashAccount ?? '';
- $sj = isset($this->sj) && !empty($this->sj) ? $this->sj->attributes : [];
- $shopImg = imgUtil::groupImg('');
- if (!empty($shop)) {
- $shopImg = imgUtil::groupImg($shop->avatar);
- }
- $smallShopImg = $shopImg . "?x-oss-process=image/resize,m_fill,h_180,w_180";
- $deadline = $sj['deadline'] ?? '';
- $relation = isset($this->shopAdmin) && !empty($this->shopAdmin) ? $this->shopAdmin->attributes : [];
- $adminName = $relation['name'] ?? '';
- $shopAdminId = $relation['id'] ?? 0;
- $mobile = $relation['mobile'] ?? '';
- $sjName = $sj['name'] ?? '';
- $shopName = $shop->shopName ?? '';
- $data = [
- 'balance' => $balance,
- 'txBalance' => $txBalance,
- 'deadline' => $deadline,
- 'adminName' => $adminName,
- 'adminMobile' => $mobile,
- 'sjName' => $sjName,
- 'shopName' => $shopName,
- 'shopImg' => $shopImg,
- 'smallShopImg' => $smallShopImg,
- 'cashAccount' => $cashAccount,
- 'shopAdminId' => $shopAdminId,
- 'shopId' => $this->shopId,
- 'sjId' => $this->sjId,
- 'adminId' => $this->adminId,
- 'money' => $money,
- 'shopInfo' => $shop,
- 'lookMoney' => $lookMoney,
- 'fast1' => '17189513228',
- 'fast2' => '15280215347',
- ];
- util::success($data);
- }
- }
|