| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <?php
- namespace hd\controllers;
- use bizHd\distribution\classes\DistributionRuleClass;
- use bizHd\distribution\classes\DistributionUserClass;
- use bizHd\distribution\classes\DistributionFlowClass;
- use bizHd\distribution\classes\DistributionOrderClass;
- use bizHd\distribution\classes\DistributionReportClass;
- use Yii;
- use common\components\util;
- /**
- * 分销(hdApp 门店设置-分销规则 / 客户详情-分销统计)
- */
- class DistributionController extends BaseController
- {
- /**
- * 获取当前门店分销规则
- */
- public function actionGetRule()
- {
- try {
- $data = DistributionRuleClass::getRule($this->shopId, $this->mainId);
- util::success($data);
- } catch (\Exception $e) {
- util::fail($e->getMessage());
- }
- }
- /**
- * 保存分销规则
- */
- public function actionSaveRule()
- {
- $post = Yii::$app->request->post();
- try {
- DistributionRuleClass::saveRule($this->shopId, $this->mainId, $post);
- util::complete('保存成功');
- } catch (\Exception $e) {
- util::fail($e->getMessage());
- }
- }
- /**
- * 客户分销统计(客户详情页)
- */
- public function actionGetUserStat()
- {
- $customId = (int)Yii::$app->request->get('customId', 0);
- try {
- $data = DistributionUserClass::getUserStat($this->shopId, $customId);
- util::success($data);
- } catch (\Exception $e) {
- util::fail($e->getMessage());
- }
- }
- /**
- * 客户分红变动明细(xhDistributionFlow)
- * customId=0 且 scope=shop 时查门店全部流水
- */
- public function actionGetFlowList()
- {
- $customId = (int)Yii::$app->request->get('customId', 0);
- $scope = trim(Yii::$app->request->get('scope', ''));
- if ($scope === 'shop') {
- $customId = 0;
- }
- try {
- $data = DistributionFlowClass::getFlowList($this->shopId, $customId);
- util::success($data);
- } catch (\Exception $e) {
- util::fail($e->getMessage());
- }
- }
- /**
- * 拉新客户列表(xhDistributionUser)
- */
- public function actionGetInviteList()
- {
- $customId = (int)Yii::$app->request->get('customId', 0);
- try {
- $data = DistributionUserClass::getInviteList($this->shopId, $customId);
- util::success($data);
- } catch (\Exception $e) {
- util::fail($e->getMessage());
- }
- }
- /**
- * 下线贡献分红明细(xhDistributionOrder)
- * distId/customId 可选;scope=shop 时查门店全部订单
- */
- public function actionGetContribOrderList()
- {
- $scope = trim(Yii::$app->request->get('scope', ''));
- $distId = (int)Yii::$app->request->get('distId', 0);
- if ($distId <= 0) {
- $distId = (int)Yii::$app->request->get('customId', 0);
- }
- if ($scope === 'shop') {
- $distId = 0;
- }
- $buyerId = (int)Yii::$app->request->get('buyerId', 0);
- try {
- $data = DistributionOrderClass::getContribOrderList($this->shopId, $distId, $buyerId);
- util::success($data);
- } catch (\Exception $e) {
- util::fail($e->getMessage());
- }
- }
- /**
- * 门店分销报表汇总
- */
- public function actionGetReportStat()
- {
- try {
- $data = DistributionReportClass::getReportStat($this->shopId);
- util::success($data);
- } catch (\Exception $e) {
- util::fail($e->getMessage());
- }
- }
- /**
- * 门店获佣人数明细
- */
- public function actionGetShopDistList()
- {
- try {
- $data = DistributionUserClass::getShopDistList($this->shopId);
- util::success($data);
- } catch (\Exception $e) {
- util::fail($e->getMessage());
- }
- }
- /**
- * 门店拉新明细
- */
- public function actionGetShopInviteList()
- {
- try {
- $data = DistributionUserClass::getShopInviteList($this->shopId);
- util::success($data);
- } catch (\Exception $e) {
- util::fail($e->getMessage());
- }
- }
- }
|