Przeglądaj źródła

订单时间搜索

shish 5 lat temu
rodzic
commit
ffa2adcc38

+ 47 - 56
app/ghs/controllers/ConsoleController.php

@@ -8,66 +8,57 @@ use biz\stat\services\StatIncomeService;
 use biz\stat\services\StatOrderService;
 use biz\stat\services\StatUserService;
 use biz\stat\services\StatVisitService;
+use common\components\constant;
 use Yii;
 use common\components\util;
 
 class ConsoleController extends BaseController
 {
+	
+	//概况 shish 2019.12.19
+	public function actionProfile()
+	{
+		$asset = MerchantAssetService::getByMerchantId($this->sjId);
+		$notice = [
+			//['title' => '您还有10天试用期结束 ', 'action' => '立即续费', 'clickHint' => '请在手机上进行续费', 'url' => 'http://www.test.com'],
+		];
+		//今天访客数
+		$todayVisit = StatVisitService::getTodayVisitNum($this->sjId);
+		//今天客户与粉丝数
+		$userData = StatUserService::getTodayNum($this->sjId);
+		$todayFansNum = isset($userData['riseFansNum']) ? $userData['riseFansNum'] : 0;
+		$todayUserNum = isset($userData['riseUserNum']) ? $userData['riseUserNum'] : 0;
+		//今天订单数
+		$orderData = StatOrderService::getTodayNum($this->sjId);
+		$todayOrder = isset($orderData['riseNum']) ? $orderData['riseNum'] : 0;
+		//今天收入
+		$incomeData = StatIncomeService::getTodayNum($this->sjId);
+		$todayIncome = isset($incomeData['amount']) ? $incomeData['amount'] : 0;
+		$todayData = ['visit' => $todayVisit, 'fans' => $todayFansNum, 'user' => $todayUserNum, 'income' => $todayIncome, 'order' => $todayOrder, 'expend' => 399];
+		
+		$mainMenu = [
+			['name' => '开单', 'img' => 'https://img.huaml.com/retail/admin/tab-icon-6.png', 'page' => '/pageA/merchant/getList'],
+			['name' => '采购', 'img' => 'https://img.huaml.com/retail/admin/tab-icon-6.png', 'page' => '/pageA/merchant/getList'],
+		];
+		$menu = [
+			['name' => '库存预警', 'img' => 'https://img.huaml.com/retail/admin/tab-icon-6.png', 'page' => '/pageA/merchant/getList'],
+			['name' => '改价', 'img' => 'https://img.huaml.com/retail/admin/tab-icon-6.png', 'page' => '/pageA/merchant/getList'],
+			['name' => '全部', 'img' => 'https://img.huaml.com/retail/admin/tab-icon-6.png', 'page' => '/pageA/merchant/getList'],
+		];
+		util::success([
+			'asset' => $asset,
+			'notice' => $notice,
+			'todayData' => $todayData,
+			'mainMenu' => $mainMenu,
+			'menu' => $menu,
+		]);
+	}
 
-    //概况 shish 2019.12.19
-    public function actionProfile()
-    {
-        $asset = MerchantAssetService::getByMerchantId($this->sjId);
-        $notice = [
-            //['title' => '您还有10天试用期结束 ', 'action' => '立即续费', 'clickHint' => '请在手机上进行续费', 'url' => 'http://www.test.com'],
-        ];
-        //今天访客数
-        $todayVisit = StatVisitService::getTodayVisitNum($this->sjId);
-        //今天客户与粉丝数
-        $userData = StatUserService::getTodayNum($this->sjId);
-        $todayFansNum = isset($userData['riseFansNum']) ? $userData['riseFansNum'] : 0;
-        $todayUserNum = isset($userData['riseUserNum']) ? $userData['riseUserNum'] : 0;
-        //今天订单数
-        $orderData = StatOrderService::getTodayNum($this->sjId);
-        $todayOrder = isset($orderData['riseNum']) ? $orderData['riseNum'] : 0;
-        //今天收入
-        $incomeData = StatIncomeService::getTodayNum($this->sjId);
-        $todayIncome = isset($incomeData['amount']) ? $incomeData['amount'] : 0;
-        $todayData = ['visit' => $todayVisit, 'fans' => $todayFansNum, 'user' => $todayUserNum, 'income' => $todayIncome, 'order' => $todayOrder, 'expend' => 399];
-
-        $mainMenu = [
-            ['name' => '开单', 'img' => 'https://img.huaml.com/retail/admin/tab-icon-6.png', 'page' => '/pageA/merchant/getList'],
-            ['name' => '采购', 'img' => 'https://img.huaml.com/retail/admin/tab-icon-6.png', 'page' => '/pageA/merchant/getList'],
-        ];
-        $menu = [
-            ['name' => '库存预警', 'img' => 'https://img.huaml.com/retail/admin/tab-icon-6.png', 'page' => '/pageA/merchant/getList'],
-            ['name' => '改价', 'img' => 'https://img.huaml.com/retail/admin/tab-icon-6.png', 'page' => '/pageA/merchant/getList'],
-            ['name' => '全部', 'img' => 'https://img.huaml.com/retail/admin/tab-icon-6.png', 'page' => '/pageA/merchant/getList'],
-        ];
-        util::success([
-            'asset' => $asset,
-            'notice' => $notice,
-            'todayData' => $todayData,
-            'mainMenu' => $mainMenu,
-            'menu' => $menu,
-        ]);
-    }
-
-    //常用初始化
-    public function actionInit()
-    {
-        $constant = [
-            //默认的日期搜索选项
-            'defaultDateSearchOption' => [
-                ['name' => '昨天', 'value' => 1, 'type' => 'fixed'],
-                ['name' => '今天', 'value' => 2, 'type' => 'fixed'],
-                ['name' => '本月', 'value' => 3, 'type' => 'fixed'],
-                ['name' => '上月', 'value' => 4, 'type' => 'fixed'],
-                ['name' => '今年', 'value' => 5, 'type' => 'fixed'],
-                ['name' => '自定义', 'value' => 6, 'type' => 'custom'],
-            ],
-        ];
-        util::success(['constant' => $constant]);
-    }
-
+	//常用初始化
+	public function actionInit()
+	{
+		$constant = constant::data();
+		util::success(['constant' => $constant]);
+	}
+	
 }

+ 451 - 442
app/ghs/controllers/OrderController.php

@@ -16,6 +16,7 @@ use biz\saas\services\RegionService;
 use biz\user\services\UserService;
 use bizGhs\product\classes\ProductClass;
 use common\components\configDict;
+use common\components\dateUtil;
 use common\components\httpUtil;
 use common\services\xhPayToolService;
 use Yii;
@@ -24,133 +25,141 @@ use common\components\stringUtil;
 
 class OrderController extends BaseController
 {
-
-    public $guestAccessAction = ['create-order', 'order-relate', 'fast-pay'];
-
-    //订单列表 shish 2021.1.20
-    public function actionList()
-    {
-        $get = Yii::$app->request->get();
-        $status = $get['status'] ?? 0;
-        if (!empty($status)) {
-            $where['status'] = $status;
-        }
-        $where['merchantId'] = $this->sjId;
-        if (isset($get['shopId'])) {
-            $shopId = $get['shopId'] ?? 0;
-            if (!empty($shopId)) {
-                $where['shopId'] = $this->shopId;
-            }
-        } else {
-            $where['shopId'] = $this->shopId;
-        }
-        $data = OrderClass::getOrderList($where);
-        util::success($data);
-    }
-
-    //商城下单操作 shish 2021.1.14
-    public function actionCreateOrder()
-    {
-        $post = Yii::$app->request->post();
-        $adminId = $this->adminId;
-        $shopId = $this->shopId;
-        $customId = $post['customId'] ?? 0;
-        if (!empty($shopId)) {
-            //供货商 员工 开单
-            $post['customId'] = $customId;
-            $post['adminId'] = $adminId;
-            $post['shopId'] = $shopId;
-        } else {
-            //供货商 商城 客户 开单
-            $post['adminId'] = $adminId;
-            $shopId = $post['shopId'] ?? 0;
-            if (empty($shopId)) {
-                util::fail('请选择供货商');
-            }
-            $post['shopId'] = $shopId;
-            $shop = ShopClass::getById($shopId);
-            if (empty($shop)) {
-                util::fail('没有找到供货商');
-            }
-        }
-
-        $post['payWay'] = $this->isWx == true ? 0 : 1;
-        $post['merchantId'] = $this->sjId;
-        $post['fromType'] = 1;//商城
-        $post['prePrice'] = 0.01;
-        $post['actPrice'] = 0.01;
-        $post['sendSide'] = $post['sendSide'] ?? 0;
-
-        $productJson = $post['product'] ?? '';
-        if (empty($productJson)) {
-            util::fail('请选择花材');
-        }
-        $productList = json_decode($productJson, true);
-        if (empty($productList)) {
-            util::fail('请选择花材');
-        }
-        $orderSn = '';
-        $id = 0;
-        $connection = Yii::$app->db;//事务处理
-        $transaction = $connection->beginTransaction();
-        try {
-            //判断花材有效性
-            ProductClass::valid($productList, $this->shopId);
-            $post['product'] = $productList;
-            $order = OrderClass::addOrder($post);
-            $orderSn = $order['orderSn'] ?? '';
-            $id = $order['id'] ?? 0;
-            $transaction->commit();
-        } catch (\Exception $e) {
-            $transaction->rollBack();
-            Yii::info("下单报错:" . $e->getMessage());
-            util::fail('下单失败');
-        }
-
-        util::success([
-            'orderId' => $id,
-            'orderSn' => $orderSn,
-            'totalPrice' => 0.01,
-            'sendType' => '快递送',
-            'sendTime' => '15:00',
-            'qrCode' => Yii::$app->params['imgHost'] . '/hhb_small.png',
-        ]);
-    }
-
-    //延期支付 shish 2021.1.19
-    public function actionDebt()
-    {
-        $get = Yii::$app->request->get();
-        util::complete();
-    }
-
-    //已经支付
-    public function actionHasPay()
-    {
-        $get = Yii::$app->request->get();
-        util::complete();
-    }
-
-    //获取商城下单要用的微信支付和小程序支付参数 shish 2019.21.3
-    public function actionWxPay()
-    {
-        ini_set('date.timezone', 'Asia/Shanghai');
-        $post = Yii::$app->request->post();
-        $couponId = $post['couponId'] ?? 0;
-        $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
-        $order = OrderClass::getByOrderSn($orderSn);
-        if (empty($order)) {
-            util::fail('订单号无效');
-        }
-        $id = $order['id'];
-
-        //支付前验证订单有效性
-        if (isset($order['adminId']) == false || $order['adminId'] != $this->adminId) {
-            util::fail('没有权限操作');
-        }
-
-        $name = $order['orderName'] ?? '购买商品';
-        $totalFee = $order['actPrice'];
+	
+	public $guestAccessAction = ['create-order', 'order-relate', 'fast-pay'];
+	
+	//订单列表 shish 2021.1.20
+	public function actionList()
+	{
+		$get = Yii::$app->request->get();
+		$status = $get['status'] ?? 0;
+		if (!empty($status)) {
+			$where['status'] = $status;
+		}
+		$where['merchantId'] = $this->sjId;
+		if (isset($get['shopId'])) {
+			$shopId = $get['shopId'] ?? 0;
+			if (!empty($shopId)) {
+				$where['shopId'] = $this->shopId;
+			}
+		} else {
+			$where['shopId'] = $this->shopId;
+		}
+		$searchTime = $get['searchTime'] ?? '';
+		if (!empty($searchTime)) {
+			$startTime = $get['startTime'] ?? '';
+			$endTime = $get['endTime'] ?? '';
+			$period = dateUtil::formatTime($searchTime, $startTime, $endTime);
+			$where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
+		}
+
+		$data = OrderClass::getOrderList($where);
+		util::success($data);
+	}
+	
+	//商城下单操作 shish 2021.1.14
+	public function actionCreateOrder()
+	{
+		$post = Yii::$app->request->post();
+		$adminId = $this->adminId;
+		$shopId = $this->shopId;
+		$customId = $post['customId'] ?? 0;
+		if (!empty($shopId)) {
+			//供货商 员工 开单
+			$post['customId'] = $customId;
+			$post['adminId'] = $adminId;
+			$post['shopId'] = $shopId;
+		} else {
+			//供货商 商城 客户 开单
+			$post['adminId'] = $adminId;
+			$shopId = $post['shopId'] ?? 0;
+			if (empty($shopId)) {
+				util::fail('请选择供货商');
+			}
+			$post['shopId'] = $shopId;
+			$shop = ShopClass::getById($shopId);
+			if (empty($shop)) {
+				util::fail('没有找到供货商');
+			}
+		}
+		
+		$post['payWay'] = $this->isWx == true ? 0 : 1;
+		$post['merchantId'] = $this->sjId;
+		$post['fromType'] = 1;//商城
+		$post['prePrice'] = 0.01;
+		$post['actPrice'] = 0.01;
+		$post['sendSide'] = $post['sendSide'] ?? 0;
+		
+		$productJson = $post['product'] ?? '';
+		if (empty($productJson)) {
+			util::fail('请选择花材');
+		}
+		$productList = json_decode($productJson, true);
+		if (empty($productList)) {
+			util::fail('请选择花材');
+		}
+		$orderSn = '';
+		$id = 0;
+		$connection = Yii::$app->db;//事务处理
+		$transaction = $connection->beginTransaction();
+		try {
+			//判断花材有效性
+			ProductClass::valid($productList, $this->shopId);
+			$post['product'] = $productList;
+			$order = OrderClass::addOrder($post);
+			$orderSn = $order['orderSn'] ?? '';
+			$id = $order['id'] ?? 0;
+			$transaction->commit();
+		} catch (\Exception $e) {
+			$transaction->rollBack();
+			Yii::info("下单报错:" . $e->getMessage());
+			util::fail('下单失败');
+		}
+		
+		util::success([
+			'orderId' => $id,
+			'orderSn' => $orderSn,
+			'totalPrice' => 0.01,
+			'sendType' => '快递送',
+			'sendTime' => '15:00',
+			'qrCode' => Yii::$app->params['imgHost'] . '/hhb_small.png',
+		]);
+	}
+	
+	//延期支付 shish 2021.1.19
+	public function actionDebt()
+	{
+		$get = Yii::$app->request->get();
+		util::complete();
+	}
+	
+	//已经支付
+	public function actionHasPay()
+	{
+		$get = Yii::$app->request->get();
+		util::complete();
+	}
+	
+	//获取商城下单要用的微信支付和小程序支付参数 shish 2019.21.3
+	public function actionWxPay()
+	{
+		ini_set('date.timezone', 'Asia/Shanghai');
+		$post = Yii::$app->request->post();
+		$couponId = $post['couponId'] ?? 0;
+		$orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
+		$order = OrderClass::getByOrderSn($orderSn);
+		if (empty($order)) {
+			util::fail('订单号无效');
+		}
+		$id = $order['id'];
+		
+		//支付前验证订单有效性
+		if (isset($order['adminId']) == false || $order['adminId'] != $this->adminId) {
+			util::fail('没有权限操作');
+		}
+		
+		$name = $order['orderName'] ?? '购买商品';
+		$totalFee = $order['actPrice'];
 
 
 //        if (httpUtil::isMiniProgram()) {
@@ -158,323 +167,323 @@ class OrderController extends BaseController
 //        } else {
 //            $openId = $this->admin['openId'];
 //        }
-
-        //强制使用小程序的miniOpenId
-        $openId = $this->admin['miniOpenId'];
-
-        $typeList = configDict::getConfig('capitalType');
-        $capitalType = $typeList['xhGhsOrder']['id'];
-        //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
-        $wxPayType = 0;
-        if (httpUtil::isMiniProgram()) {
-            $wxPayType = 1;
-        }
-        $attach = "couponId=" . $couponId . "&capitalType=" . $capitalType . '&wxPayType=' . $wxPayType;
-        //订单30分钟后过期
-        $now = time();
-        $expireTime = $now + 1800;
-
-        $wx = Yii::getAlias("@vendor/weixin");
-        require_once($wx . '/lib/WxPay.Api.php');
-        require_once($wx . '/example/WxPay.JsApiPay.php');
-        $input = new \WxPayUnifiedOrder();
-        $input->SetBody($name);
-        $input->SetOut_trade_no($orderSn);
-        $input->SetTotal_fee($totalFee * 100);
-        $input->SetTime_start(date("YmdHis", $now));
-        $input->SetAttach($attach);//将流水类型、代金劵等传给微信再回传
-        $input->SetTime_expire(date("YmdHis", $expireTime));
-        $input->SetNotify_url(Yii::$app->params['ghsHost'] . '/notice/wx-callback/');
-        $input->SetTrade_type("JSAPI");
-
-        //花卉宝代为申请的微信支付
-        //$merchantExtend = $this->sjExtend;
-        $merchantExtend = WxOpenClass::getGhsWxInfo();
-        if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) {
-            $input->SetSub_openid($openId);
-        } else {
-            $input->SetOpenid($openId);
-        }
+		
+		//强制使用小程序的miniOpenId
+		$openId = $this->admin['miniOpenId'];
+		
+		$typeList = configDict::getConfig('capitalType');
+		$capitalType = $typeList['xhGhsOrder']['id'];
+		//流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
+		$wxPayType = 0;
+		if (httpUtil::isMiniProgram()) {
+			$wxPayType = 1;
+		}
+		$attach = "couponId=" . $couponId . "&capitalType=" . $capitalType . '&wxPayType=' . $wxPayType;
+		//订单30分钟后过期
+		$now = time();
+		$expireTime = $now + 1800;
+		
+		$wx = Yii::getAlias("@vendor/weixin");
+		require_once($wx . '/lib/WxPay.Api.php');
+		require_once($wx . '/example/WxPay.JsApiPay.php');
+		$input = new \WxPayUnifiedOrder();
+		$input->SetBody($name);
+		$input->SetOut_trade_no($orderSn);
+		$input->SetTotal_fee($totalFee * 100);
+		$input->SetTime_start(date("YmdHis", $now));
+		$input->SetAttach($attach);//将流水类型、代金劵等传给微信再回传
+		$input->SetTime_expire(date("YmdHis", $expireTime));
+		$input->SetNotify_url(Yii::$app->params['ghsHost'] . '/notice/wx-callback/');
+		$input->SetTrade_type("JSAPI");
+		
+		//花卉宝代为申请的微信支付
+		//$merchantExtend = $this->sjExtend;
+		$merchantExtend = WxOpenClass::getGhsWxInfo();
+		if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) {
+			$input->SetSub_openid($openId);
+		} else {
+			$input->SetOpenid($openId);
+		}
 
 //        if (httpUtil::isMiniProgram()) {
 //            $merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
 //        }
-
-        //强制使用小程序的miniAppId
-        $merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
-
-        $wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend);
-        $tools = new \JsApiPay();
-        $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
-        $newParams = json_decode($jsApiParameters, true);
-        //微信不能修改价格
-        $current = date("Y-m-d H:i:s");
-        $updateData = ['deadline' => $current, 'modPrice' => 0];
-        OrderClass::updateById($id, $updateData);
-        util::success($newParams);
-    }
-
-    //获取订单详情 shish 2021.1.21
-    public function actionDetail()
-    {
-        $get = Yii::$app->request->get();
-        $id = $get['id'] ?? 0;
-        $info = OrderClass::getOrderInfo($id, true, true, true, true, false);
-        OrderClass::valid($info, $this->shopId);
-        util::success($info);
-    }
-
-    //自取和免发货流程处理 shish 2021.1.22
-    public function actionWithoutSend()
-    {
-        $get = Yii::$app->request->get();
-        $id = $get['id'] ?? 0;
-        $info = OrderClass::getOrderInfo($id);
-        OrderClass::valid($info, $this->shopId);
-        OrderClass::withoutSend($info);
-        util::complete();
-    }
-
-    //本店送 shish 2021.1.24
-    public function actionSelfSend()
-    {
-        $get = Yii::$app->request->get();
-        $id = isset($get['id']) ? $get['id'] : 0;
-        $info = OrderClass::getOrderInfo($id);
-        OrderClass::valid($info, $this->shopId);
-        OrderClass::selfSend($info);
-        util::complete();
-    }
-
-    //运费计算 shish 2021.1.24
-    public function actionFreight()
-    {
-        util::success(['sndCost' => 20]);
-    }
-
-    //发快递和第三方配送 shish 2021.1.24
-    public function actionThirdSend()
-    {
-        $respond = [
-            'sendSide' => '达达',
-            'distance' => 5.5,
-            'sendCost' => 20,
-            'status' => 1,
-            'tip' => 5,
-        ];
-        util::success($respond);
-    }
-
-    //确认送达 shish 2021.1.24
-    public function actionReach()
-    {
-        $get = Yii::$app->request->get();
-        $id = isset($get['id']) ? $get['id'] : 0;
-        $info = OrderClass::getOrderInfo($id);
-        OrderClass::valid($info, $this->shopId);
-        util::complete();
-    }
-
-    //快捷付款订单
-    public function actionFastPay()
-    {
-        ini_set('date.timezone', 'Asia/Shanghai');
-        $post = Yii::$app->request->post();
-        $payWay = isset($post['payWay']) ? $post['payWay'] : 0;
-        $post['shopId'] = 2;
-        //默认门店订单
-        $store = isset($post['store']) ? $post['store'] : 1;
-        $post['store'] = $store;
-        $fromType = $post['fromType'] ?? 1;
-        $post['userId'] = $this->adminId;
-        $admin = $this->admin;
-        $post['bookName'] = isset($admin['adminName']) ? $admin['adminName'] : '';
-        $bookMobile = isset($post['bookMobile']) && !empty($post['bookMobile']) && stringUtil::isMobile($post['bookMobile']) ? $post['bookMobile'] : '';
-        $bookMobile = empty($bookMobile) && isset($admin['mobile']) && !empty($admin['mobile']) ? $admin['mobile'] : $bookMobile;
-        $post['bookMobile'] = $bookMobile;
-        $prePrice = round($post['prePrice'], 2);
-        $couponId = isset($post['couponId']) ? $post['couponId'] : 0;
-        $sourceType = 0;
-        $discountData = OrderService::getDiscountPrice(['price' => $prePrice, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->adminId]);
-        $actPrice = $discountData['price'];
-        $post['discountType'] = $discountData['discountType'];
-        $post['discountAmount'] = $discountData['discountAmount'];
-        $post['actPrice'] = $actPrice;
-        $post['payStyle'] = 0;
-        $post['merchantId'] = $this->sjId;
-        $now = time();
-        //订单5分钟后过期
-        $expireTime = $now + 300;
-        $post['createTime'] = date("Y-m-d H:i:s", $now);
-        $post['deadline'] = $expireTime;
-        if ($actPrice <= 0) {
-            util::fail('请填写正确的金额');
-        }
-        //微信支付订单提交不能修改价格
-        $post['modPrice'] = $this->isWx ? 0 : 1;
-        $post['sourceType'] = $sourceType;
-        $post['goodsNum'] = 1;
-        $post['fromType'] = $fromType;
-        $post['product'] = [];
-        $order = OrderClass::addOrder($post);
-        $id = $order['id'];
-        $orderSn = $order['orderSn'];
-        $merchantId = $this->sjId;
-        if ($payWay == 0) {
-            $id = $order['id'];
-            $name = '购买商品';
-            $totalFee = $actPrice;
-            $admin = AdminClass::getAdminById($this->adminId);
-            $openId = isset($admin['openId']) ? $admin['openId'] : 0;
-            if (httpUtil::isMiniProgram()) {
-                //小程序使用miniOpenId
-                $openId = $admin['miniOpenId'];
-            } else {
-                //util::fail('仅支持小程序支付');
-                $openId = $admin['miniOpenId'];
-            }
-            $typeList = configDict::getConfig('capitalType');
-            $capitalType = $typeList['xhGhsOrder']['id'];
-            //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
-            $wxPayType = 0;
-            if (httpUtil::isMiniProgram()) {
-                $wxPayType = 1;
-            }
-            $attach = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&wxPayType=' . $wxPayType;
-            $wx = Yii::getAlias("@vendor/weixin");
-            require_once($wx . '/lib/WxPay.Api.php');
-            require_once($wx . '/example/WxPay.JsApiPay.php');
-            $input = new \WxPayUnifiedOrder();
-            $input->SetBody($name);
-            $input->SetOut_trade_no($orderSn);
-            $input->SetTotal_fee($totalFee * 100);
-            $input->SetTime_start(date("YmdHis", $now));
-            $input->SetAttach($attach);
-            //设置订单有效期5分钟
-            $input->SetTime_expire(date("YmdHis", $expireTime));
-            $input->SetNotify_url(Yii::$app->params['ghsHost'] . '/notice/wx-callback/');
-            $input->SetTrade_type("JSAPI");
-
-            //花卉宝代为申请的微信支付
-            //$merchantExtend = $this->sjExtend;
-            $merchantExtend = WxOpenClass::getGhsWxInfo();
-            if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) {
-                $input->SetSub_openid($openId);
-            } else {
-                $input->SetOpenid($openId);
-            }
-            //小程序使用miniAppId
-            if (httpUtil::isMiniProgram()) {
-                $merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
-            }
-            //强制使用小程序的appId
-            $merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
-            Yii::info('支付发起使用小程序信息' . json_encode($merchantExtend));
-            $wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend);
-            $tools = new \JsApiPay();
-            $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
-            $newParams = json_decode($jsApiParameters, true);
-            $newParams['orderId'] = $id;
-            util::success($newParams);
-        } elseif ($payWay == 1) {
-            $extend = MerchantExtendService::getByMerchantId($merchantId);
-            if (isset($extend['alipayInit']) == false || $extend['alipayInit'] == 0) {
-                util::fail('支付宝付款即将开通...');
-            }
-            $config = [
-                //应用ID,您的APPID。
-                'app_id' => $extend['alipayPId'],
-                //商户私钥,您的原始格式RSA私钥
-                'merchant_private_key' => $extend['alipayKey'],
-                //异步通知地址
-                'notify_url' => Yii::$app->params['ghsHost'] . "/notice/alipay-callback",
-                //同步跳转
-                'return_url' => "",
-                //编码格式
-                'charset' => "UTF-8",
-                //签名方式
-                'sign_type' => "RSA2",
-                //支付宝网关
-                'gatewayUrl' => "https://openapi.alipay.com/gateway.do",
-                //支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
-                'alipay_public_key' => $extend['alipayPublicKey'],
-            ];
-
-            Yii::info(json_encode($config) . ' aplipay config');
-
-            $alipayWap = Yii::getAlias("@vendor/alipayWap");
-            require_once($alipayWap . '/wappay/service/AlipayTradeService.php');
-            require_once($alipayWap . '/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php');
-
-            $totalFee = $order['actPrice'];
-            $out_trade_no = $orderSn;//商户订单号,商户网站订单系统中唯一订单号,必填
-            $subject = '购买商品';//订单名称,必填
-            $total_amount = $totalFee;//付款金额,必填
-            $body = '';//商品描述,可空
-            $timeout_express = "1m";//超时时间
-
-            $typeList = configDict::getConfig('capitalType');
-            $capitalType = $typeList['xhGhsOrder']['id'];
-            $passbackParams = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&merchantId=' . $merchantId;//将流水类型、优惠卷传过去
-            $passbackParams = urlencode($passbackParams);
-
-            $payRequestBuilder = new \AlipayTradeWapPayContentBuilder();
-            $payRequestBuilder->setBody($body);
-            $payRequestBuilder->setSubject($subject);
-            $payRequestBuilder->setOutTradeNo($out_trade_no);
-            $payRequestBuilder->setTotalAmount($total_amount);
-            $payRequestBuilder->setTimeExpress($timeout_express);
-            //在异步通知时将该参数原样返回
-            $payRequestBuilder->setPassbackParams($passbackParams);
-            //同步通知
-            $returnUrl = Yii::$app->params['mallDomain'] . "/#/pages/callback/success?account={$merchantId}&shopId={$shopId}&orderSn={$orderSn}&totalPrice={$totalFee}&pageStatus=3&payDiscountPrice=0&payDiscountType=0";
-            //异步通知
-            $notifyUrl = Yii::$app->params['ghsHost'] . "/notice/alipay-callback";
-            $payResponse = new \AlipayTradeService($config);
-            $result = $payResponse->wapPay($payRequestBuilder, $returnUrl, $notifyUrl);
-            //直接将支付宝的html返回给前端
-            echo $result;
-        } elseif ($payWay == 2) {
-            //余额支付,验证支付密码是否正确
-            $payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0;
-            $typeList = configDict::getConfig('capitalType');
-            $capitalType = $typeList['xhGhsOrder']['id'];
-            $callbackParams = [];
-            $respond = xhPayToolService::balancePay($callbackParams, $orderSn, $actPrice, $capitalType, $couponId);
-            $balance = isset($respond['balance']) ? $respond['balance'] : 0;
-            util::success(['discountAmount' => $discountData['discountAmount'], 'discountType' => $discountData['discountType'], 'orderSn' => $orderSn, 'orderId' => $id, 'balance' => $balance]);
-        } else {
-            util::fail('无效的支付方式');
-        }
-    }
-
-    //下单要用到的相关信息 shish 2019.12.6
-    public function actionOrderRelate()
-    {
-        $regionTree = RegionService::tree();
-        $shop = ShopService::getDefaultShop($this->sj);
-        $freight = ['first' => 5, 'add' => 2];
-        $mapKey = 'OFWBZ-2NTHP-EHNDD-LKWQY-GANM7-PXBJH';
-        $out = ['freight' => $freight, 'shop' => $shop, 'region' => $regionTree, 'txMapKey' => $mapKey, 'merchant' => $this->sj];
-        util::success($out);
-    }
-
-    //客户欠款的订单 shish 2021.2.4
-    public function actionDebtList()
-    {
-        $id = Yii::$app->request->get('id', 0);
-        $info = CustomClass::getCustom($id);
-        CustomClass::valid($info, $this->sjId);
-        $where = ['customId' => $id, 'debt' => 1];
-        $list = OrderService::getDebtOrderList($where);
-        util::success($list);
-    }
-
-    //收款 shish 2021.2.4
-    public function actionClearDebt()
-    {
-        $ids = Yii::$app->request->post('id');
-        util::complete();
-    }
-
+		
+		//强制使用小程序的miniAppId
+		$merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
+		
+		$wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend);
+		$tools = new \JsApiPay();
+		$jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
+		$newParams = json_decode($jsApiParameters, true);
+		//微信不能修改价格
+		$current = date("Y-m-d H:i:s");
+		$updateData = ['deadline' => $current, 'modPrice' => 0];
+		OrderClass::updateById($id, $updateData);
+		util::success($newParams);
+	}
+	
+	//获取订单详情 shish 2021.1.21
+	public function actionDetail()
+	{
+		$get = Yii::$app->request->get();
+		$id = $get['id'] ?? 0;
+		$info = OrderClass::getOrderInfo($id, true, true, true, true, false);
+		OrderClass::valid($info, $this->shopId);
+		util::success($info);
+	}
+	
+	//自取和免发货流程处理 shish 2021.1.22
+	public function actionWithoutSend()
+	{
+		$get = Yii::$app->request->get();
+		$id = $get['id'] ?? 0;
+		$info = OrderClass::getOrderInfo($id);
+		OrderClass::valid($info, $this->shopId);
+		OrderClass::withoutSend($info);
+		util::complete();
+	}
+	
+	//本店送 shish 2021.1.24
+	public function actionSelfSend()
+	{
+		$get = Yii::$app->request->get();
+		$id = isset($get['id']) ? $get['id'] : 0;
+		$info = OrderClass::getOrderInfo($id);
+		OrderClass::valid($info, $this->shopId);
+		OrderClass::selfSend($info);
+		util::complete();
+	}
+	
+	//运费计算 shish 2021.1.24
+	public function actionFreight()
+	{
+		util::success(['sndCost' => 20]);
+	}
+	
+	//发快递和第三方配送 shish 2021.1.24
+	public function actionThirdSend()
+	{
+		$respond = [
+			'sendSide' => '达达',
+			'distance' => 5.5,
+			'sendCost' => 20,
+			'status' => 1,
+			'tip' => 5,
+		];
+		util::success($respond);
+	}
+	
+	//确认送达 shish 2021.1.24
+	public function actionReach()
+	{
+		$get = Yii::$app->request->get();
+		$id = isset($get['id']) ? $get['id'] : 0;
+		$info = OrderClass::getOrderInfo($id);
+		OrderClass::valid($info, $this->shopId);
+		util::complete();
+	}
+	
+	//快捷付款订单
+	public function actionFastPay()
+	{
+		ini_set('date.timezone', 'Asia/Shanghai');
+		$post = Yii::$app->request->post();
+		$payWay = isset($post['payWay']) ? $post['payWay'] : 0;
+		$post['shopId'] = 2;
+		//默认门店订单
+		$store = isset($post['store']) ? $post['store'] : 1;
+		$post['store'] = $store;
+		$fromType = $post['fromType'] ?? 1;
+		$post['userId'] = $this->adminId;
+		$admin = $this->admin;
+		$post['bookName'] = isset($admin['adminName']) ? $admin['adminName'] : '';
+		$bookMobile = isset($post['bookMobile']) && !empty($post['bookMobile']) && stringUtil::isMobile($post['bookMobile']) ? $post['bookMobile'] : '';
+		$bookMobile = empty($bookMobile) && isset($admin['mobile']) && !empty($admin['mobile']) ? $admin['mobile'] : $bookMobile;
+		$post['bookMobile'] = $bookMobile;
+		$prePrice = round($post['prePrice'], 2);
+		$couponId = isset($post['couponId']) ? $post['couponId'] : 0;
+		$sourceType = 0;
+		$discountData = OrderService::getDiscountPrice(['price' => $prePrice, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->adminId]);
+		$actPrice = $discountData['price'];
+		$post['discountType'] = $discountData['discountType'];
+		$post['discountAmount'] = $discountData['discountAmount'];
+		$post['actPrice'] = $actPrice;
+		$post['payStyle'] = 0;
+		$post['merchantId'] = $this->sjId;
+		$now = time();
+		//订单5分钟后过期
+		$expireTime = $now + 300;
+		$post['createTime'] = date("Y-m-d H:i:s", $now);
+		$post['deadline'] = $expireTime;
+		if ($actPrice <= 0) {
+			util::fail('请填写正确的金额');
+		}
+		//微信支付订单提交不能修改价格
+		$post['modPrice'] = $this->isWx ? 0 : 1;
+		$post['sourceType'] = $sourceType;
+		$post['goodsNum'] = 1;
+		$post['fromType'] = $fromType;
+		$post['product'] = [];
+		$order = OrderClass::addOrder($post);
+		$id = $order['id'];
+		$orderSn = $order['orderSn'];
+		$merchantId = $this->sjId;
+		if ($payWay == 0) {
+			$id = $order['id'];
+			$name = '购买商品';
+			$totalFee = $actPrice;
+			$admin = AdminClass::getAdminById($this->adminId);
+			$openId = isset($admin['openId']) ? $admin['openId'] : 0;
+			if (httpUtil::isMiniProgram()) {
+				//小程序使用miniOpenId
+				$openId = $admin['miniOpenId'];
+			} else {
+				//util::fail('仅支持小程序支付');
+				$openId = $admin['miniOpenId'];
+			}
+			$typeList = configDict::getConfig('capitalType');
+			$capitalType = $typeList['xhGhsOrder']['id'];
+			//流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
+			$wxPayType = 0;
+			if (httpUtil::isMiniProgram()) {
+				$wxPayType = 1;
+			}
+			$attach = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&wxPayType=' . $wxPayType;
+			$wx = Yii::getAlias("@vendor/weixin");
+			require_once($wx . '/lib/WxPay.Api.php');
+			require_once($wx . '/example/WxPay.JsApiPay.php');
+			$input = new \WxPayUnifiedOrder();
+			$input->SetBody($name);
+			$input->SetOut_trade_no($orderSn);
+			$input->SetTotal_fee($totalFee * 100);
+			$input->SetTime_start(date("YmdHis", $now));
+			$input->SetAttach($attach);
+			//设置订单有效期5分钟
+			$input->SetTime_expire(date("YmdHis", $expireTime));
+			$input->SetNotify_url(Yii::$app->params['ghsHost'] . '/notice/wx-callback/');
+			$input->SetTrade_type("JSAPI");
+			
+			//花卉宝代为申请的微信支付
+			//$merchantExtend = $this->sjExtend;
+			$merchantExtend = WxOpenClass::getGhsWxInfo();
+			if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) {
+				$input->SetSub_openid($openId);
+			} else {
+				$input->SetOpenid($openId);
+			}
+			//小程序使用miniAppId
+			if (httpUtil::isMiniProgram()) {
+				$merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
+			}
+			//强制使用小程序的appId
+			$merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
+			Yii::info('支付发起使用小程序信息' . json_encode($merchantExtend));
+			$wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend);
+			$tools = new \JsApiPay();
+			$jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
+			$newParams = json_decode($jsApiParameters, true);
+			$newParams['orderId'] = $id;
+			util::success($newParams);
+		} elseif ($payWay == 1) {
+			$extend = MerchantExtendService::getByMerchantId($merchantId);
+			if (isset($extend['alipayInit']) == false || $extend['alipayInit'] == 0) {
+				util::fail('支付宝付款即将开通...');
+			}
+			$config = [
+				//应用ID,您的APPID。
+				'app_id' => $extend['alipayPId'],
+				//商户私钥,您的原始格式RSA私钥
+				'merchant_private_key' => $extend['alipayKey'],
+				//异步通知地址
+				'notify_url' => Yii::$app->params['ghsHost'] . "/notice/alipay-callback",
+				//同步跳转
+				'return_url' => "",
+				//编码格式
+				'charset' => "UTF-8",
+				//签名方式
+				'sign_type' => "RSA2",
+				//支付宝网关
+				'gatewayUrl' => "https://openapi.alipay.com/gateway.do",
+				//支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
+				'alipay_public_key' => $extend['alipayPublicKey'],
+			];
+			
+			Yii::info(json_encode($config) . ' aplipay config');
+			
+			$alipayWap = Yii::getAlias("@vendor/alipayWap");
+			require_once($alipayWap . '/wappay/service/AlipayTradeService.php');
+			require_once($alipayWap . '/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php');
+			
+			$totalFee = $order['actPrice'];
+			$out_trade_no = $orderSn;//商户订单号,商户网站订单系统中唯一订单号,必填
+			$subject = '购买商品';//订单名称,必填
+			$total_amount = $totalFee;//付款金额,必填
+			$body = '';//商品描述,可空
+			$timeout_express = "1m";//超时时间
+			
+			$typeList = configDict::getConfig('capitalType');
+			$capitalType = $typeList['xhGhsOrder']['id'];
+			$passbackParams = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&merchantId=' . $merchantId;//将流水类型、优惠卷传过去
+			$passbackParams = urlencode($passbackParams);
+			
+			$payRequestBuilder = new \AlipayTradeWapPayContentBuilder();
+			$payRequestBuilder->setBody($body);
+			$payRequestBuilder->setSubject($subject);
+			$payRequestBuilder->setOutTradeNo($out_trade_no);
+			$payRequestBuilder->setTotalAmount($total_amount);
+			$payRequestBuilder->setTimeExpress($timeout_express);
+			//在异步通知时将该参数原样返回
+			$payRequestBuilder->setPassbackParams($passbackParams);
+			//同步通知
+			$returnUrl = Yii::$app->params['mallDomain'] . "/#/pages/callback/success?account={$merchantId}&shopId={$shopId}&orderSn={$orderSn}&totalPrice={$totalFee}&pageStatus=3&payDiscountPrice=0&payDiscountType=0";
+			//异步通知
+			$notifyUrl = Yii::$app->params['ghsHost'] . "/notice/alipay-callback";
+			$payResponse = new \AlipayTradeService($config);
+			$result = $payResponse->wapPay($payRequestBuilder, $returnUrl, $notifyUrl);
+			//直接将支付宝的html返回给前端
+			echo $result;
+		} elseif ($payWay == 2) {
+			//余额支付,验证支付密码是否正确
+			$payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0;
+			$typeList = configDict::getConfig('capitalType');
+			$capitalType = $typeList['xhGhsOrder']['id'];
+			$callbackParams = [];
+			$respond = xhPayToolService::balancePay($callbackParams, $orderSn, $actPrice, $capitalType, $couponId);
+			$balance = isset($respond['balance']) ? $respond['balance'] : 0;
+			util::success(['discountAmount' => $discountData['discountAmount'], 'discountType' => $discountData['discountType'], 'orderSn' => $orderSn, 'orderId' => $id, 'balance' => $balance]);
+		} else {
+			util::fail('无效的支付方式');
+		}
+	}
+	
+	//下单要用到的相关信息 shish 2019.12.6
+	public function actionOrderRelate()
+	{
+		$regionTree = RegionService::tree();
+		$shop = ShopService::getDefaultShop($this->sj);
+		$freight = ['first' => 5, 'add' => 2];
+		$mapKey = 'OFWBZ-2NTHP-EHNDD-LKWQY-GANM7-PXBJH';
+		$out = ['freight' => $freight, 'shop' => $shop, 'region' => $regionTree, 'txMapKey' => $mapKey, 'merchant' => $this->sj];
+		util::success($out);
+	}
+	
+	//客户欠款的订单 shish 2021.2.4
+	public function actionDebtList()
+	{
+		$id = Yii::$app->request->get('id', 0);
+		$info = CustomClass::getCustom($id);
+		CustomClass::valid($info, $this->sjId);
+		$where = ['customId' => $id, 'debt' => 1];
+		$list = OrderService::getDebtOrderList($where);
+		util::success($list);
+	}
+	
+	//收款 shish 2021.2.4
+	public function actionClearDebt()
+	{
+		$ids = Yii::$app->request->post('id');
+		util::complete();
+	}
+	
 }

+ 57 - 66
app/shop/controllers/ConsoleController.php

@@ -8,75 +8,66 @@ use biz\stat\services\StatIncomeService;
 use biz\stat\services\StatOrderService;
 use biz\stat\services\StatUserService;
 use biz\stat\services\StatVisitService;
+use common\components\constant;
 use Yii;
 use common\components\util;
 
 class ConsoleController extends BaseController
 {
-
-    //概况 shish 2019.12.19
-    public function actionProfile()
-    {
-        $asset = MerchantAssetService::getByMerchantId($this->sjId);
-        $notice = [
-            ['title' => '您的试用期还有7天,点击免费续期1年 ', 'action' => '详情', 'clickHint' => '请在手机上进行续费', 'url' => 'http://www.test.com', 'page' => 'page/notice/recharge'],
-        ];
-        //今天访客数
-        $todayVisit = StatVisitService::getTodayVisitNum($this->sjId);
-        //今天客户与粉丝数
-        $userData = StatUserService::getTodayNum($this->sjId);
-        $todayFansNum = isset($userData['riseFansNum']) ? $userData['riseFansNum'] : 0;
-        $todayUserNum = isset($userData['riseUserNum']) ? $userData['riseUserNum'] : 0;
-        //今天订单数
-        $orderData = StatOrderService::getTodayNum($this->sjId);
-        $todayOrder = isset($orderData['riseNum']) ? $orderData['riseNum'] : 0;
-        //今天收入
-        $incomeData = StatIncomeService::getTodayNum($this->sjId);
-        $todayIncome = isset($incomeData['amount']) ? $incomeData['amount'] : 0;
-        $todayData = ['visit' => $todayVisit, 'fans' => $todayFansNum, 'user' => $todayUserNum, 'income' => $todayIncome, 'order' => $todayOrder];
-
-        //当月的收入
-        $currentMonthIncome = StatIncomeMonthService::getCurrentMonthIncome($this->sjId);
-        //上个月收入
-        $previousMonthIncome = StatIncomeMonthService::getPreviousMonthIncome($this->sjId);
-        //最近7天收入变化趋势
-        $latestIncome = StatIncomeService::getLatestSevenDay($this->sjId);
-        $incomeStat = [
-            'month' => $currentMonthIncome,
-            'week' => 999,
-            'previousMonth' => $previousMonthIncome,
-            'list' => $latestIncome,
-        ];
-        $visitStat = [
-            'month' => 1999,
-            'week' => 999,
-            'list' => ['7.1' => 100, '7.2' => 200, '7.3' => 300, '7.4' => 400, '7.5' => 500],
-        ];
-        util::success([
-            'asset' => $asset,
-            'notice' => $notice,
-            'todayData' => $todayData,
-            'admin' => ['avatar' => 'http://a.huahb.com/images/avatar.jpg'],
-            'visitStat' => $visitStat,
-            'incomeStat' => $incomeStat,
-        ]);
-    }
-
-    //常用初始化
-    public function actionInit()
-    {
-        $constant = [
-            //默认的日期搜索选项
-            'defaultDateSearchOption' => [
-                ['name' => '昨天', 'value' => 1, 'type' => 'fixed'],
-                ['name' => '今天', 'value' => 2, 'type' => 'fixed'],
-                ['name' => '本月', 'value' => 3, 'type' => 'fixed'],
-                ['name' => '上月', 'value' => 4, 'type' => 'fixed'],
-                ['name' => '今年', 'value' => 5, 'type' => 'fixed'],
-                ['name' => '自定义', 'value' => 6, 'type' => 'custom'],
-            ],
-        ];
-        util::success(['constant' => $constant]);
-    }
-
+	
+	//概况 shish 2019.12.19
+	public function actionProfile()
+	{
+		$asset = MerchantAssetService::getByMerchantId($this->sjId);
+		$notice = [
+			['title' => '您的试用期还有7天,点击免费续期1年 ', 'action' => '详情', 'clickHint' => '请在手机上进行续费', 'url' => 'http://www.test.com', 'page' => 'page/notice/recharge'],
+		];
+		//今天访客数
+		$todayVisit = StatVisitService::getTodayVisitNum($this->sjId);
+		//今天客户与粉丝数
+		$userData = StatUserService::getTodayNum($this->sjId);
+		$todayFansNum = isset($userData['riseFansNum']) ? $userData['riseFansNum'] : 0;
+		$todayUserNum = isset($userData['riseUserNum']) ? $userData['riseUserNum'] : 0;
+		//今天订单数
+		$orderData = StatOrderService::getTodayNum($this->sjId);
+		$todayOrder = isset($orderData['riseNum']) ? $orderData['riseNum'] : 0;
+		//今天收入
+		$incomeData = StatIncomeService::getTodayNum($this->sjId);
+		$todayIncome = isset($incomeData['amount']) ? $incomeData['amount'] : 0;
+		$todayData = ['visit' => $todayVisit, 'fans' => $todayFansNum, 'user' => $todayUserNum, 'income' => $todayIncome, 'order' => $todayOrder];
+		
+		//当月的收入
+		$currentMonthIncome = StatIncomeMonthService::getCurrentMonthIncome($this->sjId);
+		//上个月收入
+		$previousMonthIncome = StatIncomeMonthService::getPreviousMonthIncome($this->sjId);
+		//最近7天收入变化趋势
+		$latestIncome = StatIncomeService::getLatestSevenDay($this->sjId);
+		$incomeStat = [
+			'month' => $currentMonthIncome,
+			'week' => 999,
+			'previousMonth' => $previousMonthIncome,
+			'list' => $latestIncome,
+		];
+		$visitStat = [
+			'month' => 1999,
+			'week' => 999,
+			'list' => ['7.1' => 100, '7.2' => 200, '7.3' => 300, '7.4' => 400, '7.5' => 500],
+		];
+		util::success([
+			'asset' => $asset,
+			'notice' => $notice,
+			'todayData' => $todayData,
+			'admin' => ['avatar' => 'http://a.huahb.com/images/avatar.jpg'],
+			'visitStat' => $visitStat,
+			'incomeStat' => $incomeStat,
+		]);
+	}
+	
+	//常用初始化
+	public function actionInit()
+	{
+		$constant = constant::data();
+		util::success(['constant' => $constant]);
+	}
+	
 }

+ 12 - 5
app/shop/controllers/OrderController.php

@@ -158,31 +158,31 @@ class OrderController extends BaseController
 			if (empty($product)) {
 				util::fail('请选择花材');
 			}
-            $actPrice = 0;
+			$actPrice = 0;
 			$orderProduct = [];
 			foreach ($product as $key => $val) {
 				$productId = $val['productId'];
 				$bigNum = $val['bigNum'];
 				$smallNum = $val['smallNum'];
-                $actPrice += 2;
+				$actPrice += 2;
 				$orderProduct[] = [
 					'productId' => $productId,
 					'bigNum' => $bigNum,
 					'smallNum' => $smallNum,
 				];
 			}
-
+			
 			$post['prePrice'] = $actPrice;
 			$post['actPrice'] = $actPrice;
 			$order = OrderClass::addOrder($post);
 			$orderId = $order['id'];
 			$orderSn = $order['orderSn'];
-
+			
 			foreach ($orderProduct as $key => $val) {
 				$val['orderSn'] = $orderSn;
 				OrderItemClass::add($val);
 			}
-
+			
 		}
 		util::success(['orderSn' => $orderSn, 'totalPrice' => $actPrice, 'couponId' => $couponId, 'orderId' => $orderId]);
 	}
@@ -535,6 +535,13 @@ class OrderController extends BaseController
 				$where['id'] = $search;
 			}
 		}
+		$searchTime = $get['searchTime'] ?? '';
+		if (!empty($searchTime)) {
+			$startTime = $get['startTime'] ?? '';
+			$endTime = $get['endTime'] ?? '';
+			$period = dateUtil::formatTime($searchTime, $startTime, $endTime);
+			$where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
+		}
 		$list = OrderService::getOrderList($where);
 		$list['asset'] = MerchantAssetService::getByMerchantId($this->sjId);
 		util::success($list);

+ 27 - 0
common/components/constant.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace common\components;
+
+/**
+ * 常量配置
+ */
+class constant
+{
+
+	public static function data()
+	{
+		$arr = [
+			//默认的日期搜索选项
+			'dateDefaultOption' => [
+				['name' => '昨天', 'value' => 'yesterday'],
+				['name' => '今天', 'value' => 'today',],
+				['name' => '本月', 'value' => 'thisMonth',],
+				['name' => '上月', 'value' => 'lastMonth',],
+				['name' => '今年', 'value' => 'thisYear',],
+				['name' => '自定义', 'value' => 'custom',],
+			],
+		];
+		return $arr;
+	}
+
+}

+ 65 - 2
common/components/dateUtil.php

@@ -7,6 +7,69 @@ use Yii;
 class dateUtil
 {
 	
+	//日期时间转换 shish 2021.3.4
+	public static function formatTime($searchTime, $startTime, $endTime)
+	{
+		switch ($searchTime) {
+			case 'yesterday':
+				//昨天
+				$startTime = date("Y-m-d 00:00:00", strtotime("-1 day"));
+				$endTime = date("Y-m-d 23:59:59", strtotime("-1 day"));
+				break;
+			case 'today':
+				//今天
+				$startTime = date("Y-m-d 00:00:00");
+				$endTime = date("Y-m-d 23:59:59");
+				break;
+			case 'thisMonth':
+				//本月
+				$startTime = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), 1, date("Y")));
+				$endTime = date("Y-m-d H:i:s", mktime(23, 59, 59, date("m"), date("t"), date("Y")));
+				break;
+			case 'lastMonth':
+				//上个月
+				$start = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m") - 1, 1, date("Y")));
+				$endTime = date("Y-m-d H:i:s", mktime(23, 59, 59, date("m"), 0, date("Y")));
+				break;
+			case 'thisYear':
+				//今年
+				$startTime = date("Y-m-d H:i:s", mktime(0, 0, 0, 1, 1, date("Y")));
+				$endTime = date("Y-m-d H:i:s", mktime(23, 59, 59, 1, 0, date("Y", strtotime('+1 year'))));
+				break;
+			case 'lastWeek':
+				//上周
+				$start = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), date("d") - date("w") + 1 - 7, date("Y")));
+				$endTime = date("Y-m-d H:i:s", mktime(23, 59, 59, date("m"), date("d") - date("w") + 7 - 7, date("Y")));
+				break;
+			case 'thisWeek':
+				//本周
+				$start = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), date("d") - date("w") + 1, date("Y")));
+				$endTime = date("Y-m-d H:i:s", mktime(23, 59, 59, date("m"), date("d") - date("w") + 7, date("Y")));
+				break;
+			case 'thisSeason':
+				//本季度
+				//本季度未最后一月天数
+				$getMonthDays = date("t", mktime(0, 0, 0, date('n') + (date('n') - 1) % 3, 1, date("Y")));
+				$start = date('Y-m-d H:i:s', mktime(0, 0, 0, date('n') - (date('n') - 1) % 3, 1, date('Y')));
+				$endTime = date('Y-m-d H:i:s', mktime(23, 59, 59, date('n') + (date('n') - 1) % 3, $getMonthDays, date('Y')));
+				break;
+			case 'custom':
+				//自定义
+				if (empty($startTime)) {
+					util::fail('请选择开始时间');
+				}
+				if (empty($endTime)) {
+					util::fail('请选择结束时间');
+				}
+				break;
+			default:
+				//今天
+				$startTime = date("Y-m-d 00:00:00");
+				$endTime = date("Y-m-d 23:59:59");
+		}
+		return ['startTime' => $startTime, 'endTime' => $endTime];
+	}
+	
 	//获取日期 shish 2019.9.16
 	public static function getDate($type = 0)
 	{
@@ -61,7 +124,7 @@ class dateUtil
 		}
 		return [$start, $end];
 	}
-
+	
 	//获取开始的月份 shish 2019.12.31
 	public static function getStartMonth($num)
 	{
@@ -72,5 +135,5 @@ class dateUtil
 		}
 		return $start;
 	}
-
+	
 }

+ 5 - 0
sql.sql

@@ -1364,3 +1364,8 @@ ALTER TABLE xhGhsOrder ADD hasItem TINYINT NOT NULL DEFAULT 1 COMMENT '1订单
 ==linqh 2021-03-02
 ALTER TABLE `xhItem`
 ADD COLUMN `inTurn`  int(11) NOT NULL DEFAULT 0 COMMENT '排序,数字越大越靠前' AFTER `unitAddPrice`;
+
+=====
+== shish 2021-3-4
+ALTER TABLE xhOrder DROP COLUMN `addTime`;
+ALTER TABLE xhOrder ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `createTime`;