| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670 |
- <?php
- namespace addons\HiGo\api\modules\v1\controllers;
- use addons\HiGo\common\enums\HiGoEnum;
- use addons\HiGo\common\logic\HiBeiLogic;
- use addons\HiGo\common\logic\RewardLogic;
- use addons\HiGo\common\models\HigoWallet;
- use addons\HiGo\common\models\HigoWalletFreezeLog;
- use addons\HiGo\common\models\HigoWalletLog;
- use addons\Mch\common\models\Mch;
- use addons\Store\common\models\Store;
- use Yii;
- use api\controllers\OnAuthController;
- use common\enums\AddonsEnum;
- use common\enums\StatusEnum;
- use common\helpers\ApiCode;
- use common\models\mall\MallAddons;
- use common\models\order\Order;
- /**
- *
- *
- * Class UserController
- * @package addons\HiGo\api\modules\v1\controllers
- */
- class UserController extends OnAuthController
- {
- public $modelClass = '';
- /**
- * 不用进行登录验证的方法
- *
- * 例如: ['index', 'update', 'create', 'view', 'delete']
- * 默认全部需要验证
- *
- * @var array
- */
- protected $authOptional = [];
- /**
- * @Description: 会员/商户嗨贝概况
- * @Author: qi
- * @DateTime 2022-11-16 16:41:36
- * @return mixed
- */
- public function actionUserCenter()
- {
- if (!Yii::$app->request->isGet) {
- return $this->error('请求方式非法');
- }
- $params = Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['type'], 'required'],
- ['type', 'in', 'range' => [1, 2]], //1-普通会员,2-商家
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $higo_wallet = HigoWallet::getOne([['mall_id' => $this->mall_id], ['user_id' => $this->user_id], ['status' => StatusEnum::ENABLED]], true);
- $basic = Yii::$app->services->setting->addons->get($this->mall_id, HiGoEnum::ADDONS_NAME, 'basic');
- $protocol = Yii::$app->services->setting->addons->get($this->mall_id, HiGoEnum::ADDONS_NAME, 'protocol');
- $airdrop_income = HigoWalletLog::find()
- ->where([
- 'and', ['mall_id' => $this->mall_id], ['wallet_type' => HiGoEnum::WALLET_TYPE_HI_BEI], ['status' => StatusEnum::ENABLED], ['user_id' => $this->user_id], ['from_type' => HiGoEnum::FROM_TYPE_AIRDROP]
- ])->sum('change_num');
- $consumption_income = HigoWalletLog::find()
- ->where([
- 'and', ['mall_id' => $this->mall_id], ['wallet_type' => HiGoEnum::WALLET_TYPE_HI_BEI], ['status' => StatusEnum::ENABLED], ['user_id' => $this->user_id], ['from_type' => HiGoEnum::FROM_TYPE_ORDER_GOODS]
- ])->sum('change_num');
- $cumulative_income = HigoWalletLog::find()
- ->where([
- 'and', ['mall_id' => $this->mall_id], ['wallet_type' => HiGoEnum::WALLET_TYPE_HI_BEI], ['status' => StatusEnum::ENABLED], ['user_id' => $this->user_id], ['change_type' => 'add']
- ])->sum('change_num');
- $value_cumulative_income = HigoWalletLog::find()
- ->where([
- 'and', ['mall_id' => $this->mall_id], ['wallet_type' => HiGoEnum::WALLET_TYPE_HI_VALUE], ['status' => StatusEnum::ENABLED], ['user_id' => $this->user_id], ['change_type' => 'add']
- ])->andWhere(['!=','from_type',HiGoEnum::FROM_TYPE_REPURCHASE_ACTIVE])->sum('change_num');
- $today_earnings = HigoWalletLog::find()
- ->where([
- 'and', ['mall_id' => $this->mall_id], ['wallet_type' => HiGoEnum::WALLET_TYPE_HI_BEI], ['status' => StatusEnum::ENABLED], ['user_id' => $this->user_id], ['change_type' => 'add'],
- ['>=', 'created_at', strtotime(date('Y-m-d'))], ['<=', 'created_at', strtotime(date('Y-m-d 23:59:59'))]
- ])->sum('change_num');
- $recharge = Yii::$app->services->setting->addons->get($this->mall_id, HiGoEnum::ADDONS_NAME, 'recharge');
- $withdraw = Yii::$app->services->setting->addons->get($this->mall_id, HiGoEnum::ADDONS_NAME, 'withdraw');
- $cash_status = $withdraw['cash_status'] ? json_decode($withdraw['cash_status'], true) : 0;
- $cash_status = is_array($cash_status) ? ($cash_status['value'] ?? 0) : $cash_status;
- //嗨呗现在价值
- $now_price = HiBeiLogic::getNowPrice($this->mall_id);
- $data = [
- 'hi_bei' => $higo_wallet['hi_bei'] ?? 0,
- 'hi_bei_name' => $basic['hi_bei_name'] ?? '嗨贝',
- 'hi_value' => $higo_wallet['hi_value'] ?? 0,
- 'hi_value_name' => $basic['hi_value_name'] ?? '嗨值',
- 'airdrop_income' => $airdrop_income ?? 0, //空投收益
- 'cumulative_income' => $cumulative_income ?? 0, //累计收益
- 'today_earnings' => $today_earnings ?? 0, //今日收益
- 'value_cumulative_income' => $value_cumulative_income ?? 0, //嗨值累计收益
- 'consumption_income' => $consumption_income ?? 0, //消费收益
- 'nav_text' => $basic['hi_bei_name'] ?? '嗨贝',
- 'member_notice' => $protocol['member_notice'] ?? '',
- 'enable_recharge' => $recharge['enable'] ?? 0,
- 'enable_withdraw' => $cash_status,
- 'freeze_hi_bei' => $higo_wallet['freeze_hi_bei'] ?? 0,
- 'freeze_hi_value' => $higo_wallet['freeze_hi_value'] ?? 0,
- 'enable_transfer' => $basic['hi_bei_transfer_enable'] ?? 0,
- 'hi_bei_now_price' => $now_price
- ];
- $is_mch = 0;
- if ($params['type'] == 2) {
- $data['reward_details'] = '0.00';
- $data['reward_hi_bei'] = '0.00';
- if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_STORE)) {
- $store = Store::findOne(['mall_id' => $this->mall_id, 'user_id' => $this->user_id, 'status' => StatusEnum::ENABLED]);
- if ($store) $is_mch = 1;
- }
- if ($is_mch == 0 && MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_MCH)) {
- $mch = Mch::findOne(['mall_id' => $this->mall_id, 'user_id' => $this->user_id, 'status' => StatusEnum::ENABLED]);
- if ($mch) $is_mch = 1;
- }
- }
- $data['is_mch'] = $is_mch;
- return $this->success(ApiCode::CODE_SUCCESS_TITLE, $data);
- }
- /**
- * @Description: 会员/商户嗨贝明细
- * @Author: qi
- * @DateTime 2022-11-16 16:40:18
- * @return mixed
- */
- public function actionUserLog()
- {
- if (!Yii::$app->request->isGet) {
- return $this->error('请求方式非法');
- }
- $params = Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['type'], 'required'],
- ['type', 'in', 'range' => [1, 2]],
- ['page', 'integer']
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $param = [
- 'where' => [
- ['mall_id' => $this->mall_id],
- ['user_id' => $this->user_id],
- ['wallet_type' => HiGoEnum::WALLET_TYPE_HI_BEI],
- ['>=', 'status', 1]
- ],
- 'select' => 'id,change_type,change_num,after_num,desc,created_at,from_type',
- 'page' => $params['page'] ?? 1,
- 'order' => 'id DESC'
- ];
- $list = HigoWalletLog::listPage($param);
- if ($list === false) {
- return $this->error(HigoWalletLog::getStaticError());
- }
- $from_type_map = HiGoEnum::getFromTypeMap($this->mall_id);
- foreach ($list['list'] as &$item) {
- $item['from_type_text'] = $from_type_map[$item['from_type']] ?? '';
- $item['created_at'] = date('Y-m-d H:i:s', $item['created_at']);
- }
- unset($item);
- return $this->success(ApiCode::CODE_SUCCESS_TITLE, $list);
- }
- /**
- * @Description: 会员/商户嗨贝记录
- * @Author: qi
- * @DateTime 2022-11-16 16:40:18
- * @return mixed
- */
- public function actionHiBeiLog()
- {
- if (!Yii::$app->request->isGet) {
- return $this->error('请求方式非法');
- }
- $params = Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['type', 'from'], 'required'],
- ['type', 'in', 'range' => [1, 2]],
- ['page', 'integer'],
- ['from', 'in', 'range' => [1, 2]]
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $where = [];
- switch ($params['from']) {
- case 1: //空投收益
- $where = [['from_type' => HiGoEnum::FROM_TYPE_AIRDROP]];
- break;
- case 2: //今日收益
- $where = [
- ['>=', 'created_at', strtotime(date('Y-m-d 00:00:00'))],
- ['<=', 'created_at', strtotime(date('Y-m-d 23:59:59'))],
- ];
- break;
- default:
- break;
- }
- $param = [
- 'where' => array_merge([
- ['mall_id' => $this->mall_id],
- ['user_id' => $this->user_id],
- ['wallet_type' => HiGoEnum::WALLET_TYPE_HI_BEI],
- ['>=', 'status', 1],
- ], $where),
- 'select' => 'id,change_type,change_num,after_num,desc,created_at,from_type',
- 'page' => $params['page'] ?? 1,
- 'order' => 'id DESC'
- ];
- $list = HigoWalletLog::listPage($param);
- if ($list === false) {
- return $this->error(HigoWalletLog::getStaticError());
- }
- $from_type_map = HiGoEnum::getFromTypeMap($this->mall_id);
- $wallet_text = HiGoEnum::getHigoWalletText($this->mall_id);
- foreach ($list['list'] as &$item) {
- $item['from_type_text'] = $from_type_map[$item['from_type']] ?? '';
- $item['created_at'] = date('Y-m-d H:i:s', $item['created_at']);
- $item['desc'] = str_replace('嗨贝',$wallet_text[HiGoEnum::WALLET_TYPE_HI_BEI],$item['desc']);
- }
- unset($item);
- return $this->success(ApiCode::CODE_SUCCESS_TITLE, $list);
- }
- /**
- * @Description: 会员/商户嗨贝记录
- * @Author: qi
- * @DateTime 2022-11-16 16:40:18
- * @return mixed
- */
- public function actionTotalHiBeiLog()
- {
- if (!Yii::$app->request->isGet) {
- return $this->error('请求方式非法');
- }
- $params = Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['date'], 'string'],
- ['page', 'integer'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- if (isset($params['date'])) {
- $year = substr($params['date'], 0, 4);
- $month = substr($params['date'], 5);
- } else {
- $year = date('Y');
- $month = date('m');
- }
- $day = date('t', strtotime($year . '-' . $month));
- $param = [
- 'where' => [
- ['mall_id' => $this->mall_id],
- ['user_id' => $this->user_id],
- ['wallet_type' => HiGoEnum::WALLET_TYPE_HI_BEI],
- ['>=', 'status', 1],
- ['>=', 'created_at', strtotime($year . '-' . $month)],
- ['<=', 'created_at', mktime(23, 59, 59, $month, $day, $year)]
- ],
- 'select' => 'id,change_type,change_num,after_num,desc,created_at,from_type',
- 'page' => $params['page'] ?? 1,
- ];
- $list = HigoWalletLog::listPage($param);
- if ($list === false) {
- return $this->error(HigoWalletLog::getStaticError());
- }
- $where = $param['where'];
- $where[] = ['change_type' => 'add'];
- $where[0] = 'and';
- $total_profit = HigoWalletLog::find()->where($where)->sum('change_num');
- $total_profit = $total_profit ?? 0;
- $from_type_map = HiGoEnum::getFromTypeMap($this->mall_id);
- $wallet_text = HiGoEnum::getHigoWalletText($this->mall_id);
- foreach ($list['list'] as &$item) {
- $item['from_type_text'] = $from_type_map[$item['from_type']] ?? '';
- $item['created_at'] = date('Y-m-d H:i:s', $item['created_at']);
- $item['desc'] = str_replace('嗨贝',$wallet_text[HiGoEnum::WALLET_TYPE_HI_BEI],$item['desc']);
- }
- unset($item);
- $list['total_profit'] = $total_profit;
- return $this->success(ApiCode::CODE_SUCCESS_TITLE, $list);
- }
- /**
- * @Description: 会员/商户嗨值记录
- * @Author: qi
- * @DateTime 2022-11-16 16:40:18
- * @return mixed
- */
- public function actionHiValueLog()
- {
- if (!Yii::$app->request->isGet) {
- return $this->error('请求方式非法');
- }
- $params = Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['type', 'from'], 'required'],
- ['type', 'in', 'range' => [1, 2]],
- ['page', 'integer'],
- ['from', 'in', 'range' => [0, 1, 2]]
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $where = [];
- switch ($params['from']) {
- case 0: //累计收益
- break;
- case 1: //消费收益
- $where = [['from_type' => HiGoEnum::FROM_TYPE_ORDER_GOODS]];
- break;
- case 2: //今日收益
- $where = [
- ['>=', 'created_at', strtotime(date('Y-m-d 00:00:00'))],
- ['<=', 'created_at', strtotime(date('Y-m-d 23:59:59'))],
- ];
- break;
- default:
- break;
- }
- $param = [
- 'where' => array_merge([
- ['mall_id' => $this->mall_id],
- ['user_id' => $this->user_id],
- ['wallet_type' => HiGoEnum::WALLET_TYPE_HI_VALUE],
- ['>=', 'status', 1],
- ], $where),
- 'select' => 'id,change_type,change_num,after_num,desc,created_at,from_type',
- 'page' => $params['page'] ?? 1,
- 'order' => 'id desc'
- ];
- $list = HigoWalletLog::listPage($param);
- if ($list === false) {
- return $this->error(HigoWalletLog::getStaticError());
- }
- $from_type_map = HiGoEnum::getFromTypeMap($this->mall_id);
- $wallet_text = HiGoEnum::getHigoWalletText($this->mall_id);
- foreach ($list['list'] as &$item) {
- $item['from_type_text'] = $from_type_map[$item['from_type']] ?? '';
- $item['created_at'] = date('Y-m-d H:i:s', $item['created_at']);
- $item['desc'] = str_replace('嗨值',$wallet_text[HiGoEnum::WALLET_TYPE_HI_VALUE],$item['desc']);
- }
- unset($item);
- return $this->success(ApiCode::CODE_SUCCESS_TITLE, $list);
- }
- /**
- * @Description: 商家打赏: 展示
- * @Author: qi
- * @DateTime 2022-11-18 16:43:10
- * @return mixed
- */
- public function actionMchRewardShow()
- {
- if (!Yii::$app->request->isGet) {
- return $this->error('请求方式非法');
- }
- if (!$this->checkIsMch()) return $this->error('请求非法');
- $higo_wallet = HigoWallet::getOne([['mall_id' => $this->mall_id, 'user_id' => $this->user_id, 'status' => StatusEnum::ENABLED]], true);
- $basic = Yii::$app->services->setting->addons->get($this->mall_id, HiGoEnum::ADDONS_NAME, 'basic');
- $protocol = Yii::$app->services->setting->addons->get($this->mall_id, HiGoEnum::ADDONS_NAME, 'protocol');
- $data = [
- 'reward_rules' => $protocol['reward_rules'] ?? '',
- 'merchant_profit_multiple' => $basic['merchant_profit_multiple'] ?? 0,
- 'hi_bei' => $higo_wallet['hi_bei'] ?? 0,
- 'hi_bei_name' => $basic['hi_bei_name'] ?? '嗨贝',
- 'hi_value' => $higo_wallet['hi_value'] ?? 0,
- 'hi_value_name' => $basic['hi_value_name'] ?? '嗨值',
- ];
- return $this->success(ApiCode::CODE_SUCCESS_TITLE, $data);
- }
- /**
- * @Description: 商家打赏:输入订单号验证
- * @Author: qi
- * @DateTime 2022-11-18 16:43:10
- * @return mixed
- */
- public function actionMchRewardCheck()
- {
- if (!Yii::$app->request->isPost) {
- return $this->error('请求方式非法');
- }
- $mch = $this->checkIsMch();
- if (!$mch) return $this->error('请求非法');
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['order_no'], 'required'],
- ]);
- //这里会传type = 2 ? 什么时候等于1【门店,多商户都是 2】
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- // to do
- $basic = Yii::$app->services->setting->addons->get($this->mall_id, HiGoEnum::ADDONS_NAME, 'basic');
- if ($basic['mode_reward_method']) return $this->error('不支持商家打赏');
- $reward = RewardLogic::getOrderMerchantReward($params['order_no'], $mch);
- if (!$reward) return $this->error(RewardLogic::getStaticError());
- $data = [
- 'available_hi_bei' => $reward['hi_bei'],
- 'available_hi_value' => $reward['hi_value'],
- 'amount_consumption' => $reward['pay_money'],
- 'order_no' => $params['order_no'],
- ];
- return $this->success(ApiCode::CODE_SUCCESS_TITLE, $data);
- }
- /**
- * @Description: 商家打赏
- * @Author: qi
- * @DateTime 2022-11-18 16:43:10
- * @return mixed
- */
- public function actionMchReward()
- {
- if (!Yii::$app->request->isPost) {
- return $this->error('请求方式非法');
- }
- $mch = $this->checkIsMch();
- if (!$mch) return $this->error('请求非法');
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['order_no'], 'required'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $basic = Yii::$app->services->setting->addons->get($this->mall_id, HiGoEnum::ADDONS_NAME, 'basic');
- if ($basic['mode_reward_method']) return $this->error('不支持商家打赏');
- $order = [];
- $mch_id = 0;
- $mch_name = '';
- if(isset($mch['store'])){
- $mch_id = $mch['store']['mch_id'];
- $mch_name = $mch['store']['mch_name'];
- $order = Order::findOne(['order_no' => $params['order_no'],'store_id' => $mch_id,'pay_status' => 1,'status' => StatusEnum::ENABLED]);
- }
- if(!$order && isset($mch['mch'])){
- $mch_id = $mch['mch']['mch_id'];
- $mch_name = $mch['mch']['mch_name'];
- $order = Order::findOne(['order_no' => $params['order_no'],'mch_id' => $mch_id,'pay_status' => 1,'status' => StatusEnum::ENABLED]);
- }
- if(!$order) return $this->error('订单不存在');
- $res = RewardLogic::doMerchantReward($params['order_no'], $mch_id, $this->user_id, $mch_name);
- if (!$res) return $this->error(RewardLogic::getStaticError());
- return $this->success('打赏成功');
- }
- /**
- * @Description: 打赏记录
- * @Author: qi
- * @DateTime 2022-11-18 17:23:58
- * @return mixed
- */
- public function actionMchRewardList()
- {
- if (!Yii::$app->request->isGet) {
- return $this->error('请求方式非法');
- }
- $params = Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['wallet_type'], 'required'],
- [['page'], 'integer'],
- ['wallet_type', 'in', 'range' => [HiGoEnum::WALLET_TYPE_HI_VALUE, HiGoEnum::WALLET_TYPE_HI_BEI]],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $param = [
- 'where' => [
- ['mall_id' => $this->mall_id],
- ['user_id' => $this->user_id],
- ['wallet_type' => $params['wallet_type']],
- ['from_type' => HiGoEnum::FROM_TYPE_MERCHANT_REWARD],
- ['>=', 'status', 1],
- ],
- 'select' => 'id,change_type,change_num,after_num,desc,created_at,source_table_id',
- 'page' => $params['page'] ?? 1,
- ];
- $list = HigoWalletLog::listPage($param);
- if ($list === false) {
- return $this->error(HigoWalletLog::getStaticError());
- }
- $basic = Yii::$app->services->setting->addons->get($this->mall_id, HiGoEnum::ADDONS_NAME, 'basic');
- $name = $basic[$params['wallet_type'] . '_name'] ?? ($params['wallet_type'] == HiGoEnum::WALLET_TYPE_HI_VALUE ? '嗨值' : '嗨贝');
- $souce_ids = array_column($list['list'], 'source_table_id');
- $order_list = Order::lists([
- 'where' => [['id' => $souce_ids], ['mall_id' => $this->mall_id]],
- 'with' => [
- 'detail' => function ($query) {
- $query->select('id, goods_id, order_id, goods_name, price, pic_url');
- }
- ],
- 'select' => 'id, mall_id, order_no',
- 'index' => 'id'
- ], true);
- foreach ($list['list'] as &$item) {
- $item['order_no'] = isset($order_list[$item['source_table_id']]) ? $order_list[$item['source_table_id']]['order_no'] : '';
- $item['pic_url'] = isset($order_list[$item['source_table_id']]) ? $order_list[$item['source_table_id']]['detail'][0]['pic_url'] : '';
- $item['price'] = isset($order_list[$item['source_table_id']]) ? $order_list[$item['source_table_id']]['detail'][0]['price'] : '';
- $item['goods_name'] = isset($order_list[$item['source_table_id']]) ? $order_list[$item['source_table_id']]['detail'][0]['goods_name'] : '';
- $item['created_at'] = date('Y-m-d H:i:s', $item['created_at']);
- $item['reward_method'] = $name;
- }
- unset($item);
- return $this->success(ApiCode::CODE_SUCCESS_TITLE, $list);
- }
- /**
- * 检测是否商家身份
- */
- private function checkIsMch()
- {
- $mch_list = [];
- $mch_info = [];
- if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_STORE)) {
- $store = Store::findOne(['mall_id' => $this->mall_id, 'user_id' => $this->user_id, 'status' => StatusEnum::ENABLED]);
- if ($store) {
- $mch_info['mch_id'] = $store['id'];
- $mch_info['mch_name'] = $store['store_name'];
- $mch_list['store'] = $mch_info;
- }
- }
- if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_MCH)) {
- $mch = Mch::findOne(['mall_id' => $this->mall_id, 'user_id' => $this->user_id, 'status' => StatusEnum::ENABLED]);
- if ($mch) {
- $mch_info['mch_id'] = $mch['id'];
- $mch_info['mch_name'] = $mch['store_name'];
- $mch_list['mch'] = $mch_info;
- }
- }
- // return $mch_info;
- return $mch_list;
- }
- /**
- * @Description: 会员/商户嗨值冻结记录
- * @Author: qi
- * @DateTime 2022-12-01 14:42:18
- * @return mixed
- */
- public function actionHiValueFreezeLog()
- {
- if (!Yii::$app->request->isGet) {
- return $this->error('请求方式非法');
- }
- $params = Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- // [['type', 'from'], 'required'],
- // ['type', 'in', 'range' => [1, 2]],
- ['page', 'integer'],
- // ['from', 'in', 'range' => [0, 1, 2]]
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $where = [];
- $param = [
- 'where' => array_merge([
- ['mall_id' => $this->mall_id],
- ['user_id' => $this->user_id],
- ['wallet_type' => HiGoEnum::WALLET_TYPE_HI_VALUE],
- ['>=', 'status', 0],
- ], $where),
- 'select' => 'id,change_type,change_num,after_num,desc,created_at,from_type,status',
- 'page' => $params['page'] ?? 1,
- ];
- $list = HigoWalletFreezeLog::listPage($param);
- if ($list === false) {
- return $this->error(HigoWalletLog::getStaticError());
- }
- $from_type_map = HiGoEnum::getFreezeFromTypeMap();
- foreach ($list['list'] as &$item) {
- $item['from_type_text'] = $from_type_map[$item['from_type']] ?? '';
- $item['created_at'] = date('Y-m-d H:i:s', $item['created_at']);
- $item['status_msg'] = $item['status'] > 0 ? '已解冻' : '冻结中';
- }
- unset($item);
- return $this->success(ApiCode::CODE_SUCCESS_TITLE, $list);
- }
- /**
- * 模糊查询商家订单号
- * @return mixed|void
- */
- public function actionMchSearchOrder()
- {
- if (!Yii::$app->request->isPost) {
- return $this->error('请求方式非法');
- }
- $mch = $this->checkIsMch();
- if (!$mch) return $this->error('请求非法');
- $param = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($param, [
- [['order_no'], 'required'],
- [['order_no'], 'string'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params[] = ['like', 'order_no', $param['order_no']];
- $params[] = ['=', 'mall_id', $this->mall_id];
- $params[] = ['=', 'pay_status', 1];
- $params[] = ['=', 'status', StatusEnum::ENABLED];
- $store_id = isset($mch['store']) ? $mch['store']['mch_id'] : 0;
- $mch_id = isset($mch['mch']) ? $mch['mch']['mch_id'] : 0;
- if($store_id > 0 && $mch_id > 0 ){
- $params[] = ['or', ['=', 'store_id', $store_id], ['=', 'mch_id', $mch_id]];
- }else{
- $params[] = ['and', ['=', 'store_id', $store_id], ['=', 'mch_id', $mch_id]];
- }
- $params = [
- 'select' => 'id,order_no,user_id',
- 'where' => $params,
- 'order' => 'id desc',
- 'page' => 1,
- 'limit' => 10,
- ];
- $list = Order::listPage($params, false, true);
- return $this->success(ApiCode::CODE_SUCCESS_TITLE, $list);
- }
- }
|