| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581 |
- <?php
- namespace addons\Store\api\modules\v1\controllers;
- use addons\Store\common\enums\StoreEnum;
- use addons\Store\common\models\Store;
- use addons\Store\common\models\StoreBank;
- use addons\Store\common\models\StoreCommission;
- use addons\Store\common\models\StoreOrder;
- use addons\Store\common\models\StoreOrderCredit;
- use addons\Store\common\models\StoreRefundAddress;
- use addons\Store\common\models\StoreSettings;
- use addons\Store\common\models\StoreWithdrawLog;
- use api\controllers\OnAuthController;
- use common\enums\ExpressEnum;
- use common\enums\MarketingTypeEnum;
- use common\enums\OrderStatusEnum;
- use common\enums\PayTypeEnum;
- use common\enums\RefundStatusEnum;
- use common\enums\RefundTypeEnum;
- use common\enums\ShippingTypeEnum;
- use common\enums\StatusEnum;
- use common\models\goods\Goods;
- use common\models\order\Order;
- use common\models\order\OrderAction;
- use common\models\order\OrderExpress;
- use common\models\order\OrderRefund;
- use common\models\user\User;
- use common\enums\ApiStatusEnum;
- use common\globals\GlobalInvoke;
- use common\enums\WithdrawWayEnum;
- use common\models\common\PlatformSetting;
- use Yii;
- use yii\helpers\Json;
- /**
- * 门店卖家
- * Class SellerController
- * @package api\modules\order\controllers
- */
- class SellerController extends OnAuthController
- {
- public $modelClass = '';
- /**
- * 不用进行登录验证的方法
- *
- * 例如: ['index', 'update', 'create', 'view', 'delete']
- * 默认全部需要验证
- *
- * @var array
- */
- protected $authOptional = [];
- protected $store_id = 0;
- public function beforeAction($action)
- {
- parent::beforeAction($action);
- //检测门店身份
- $store = Store::find()
- ->where(['mall_id' => $this->mall_id, 'user_id' => $this->user_id, 'status' => StatusEnum::ENABLED])
- ->one();
- if (empty($store)) {
- \Yii::$app->response->data = ['code' => 1, 'msg' => '您非门店身份'];
- \Yii::$app->response->send();
- return;
- }
- $this->store_id = $store->id;
- return $action;
- }
- /**
- * 门店订单列表
- * @return void
- */
- public function actionOrderList()
- {
- $param = \Yii::$app->request->get();
- $order_status_list = OrderStatusEnum::getMap();
- $payment_type_list = PayTypeEnum::getMap();
- $shipping_type_list = ShippingTypeEnum::getMap();
- $rules = [
- [['order_status'], 'in', 'range' => array_keys($order_status_list)],
- //[['payment_type'], 'in', 'range' => array_keys($payment_type_list)],
- //[['shipping_type'], 'in', 'range' => array_keys($shipping_type_list)],
- //[['start', 'end'], 'datetime', 'format' => 'php:Y-m-d H:i:s'],
- //[['order_no', 'mobile', 'order_id'], 'safe'],
- [['keyword','type'], 'string'],
- // ['mobile', 'match', 'pattern' => '/^1\d{10}$/', 'message' => '请输入正确的手机号码'],
- ];
- $res = Yii::$app->services->validate->validate($param, $rules);
- if (!$res) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $where[] = ['mall_id' => $this->mall_id];
- $where[] = ['store_id' => $this->store_id];
- if (isset($param['order_status']) && $param['order_status'] != 999) {
- $where[] = ['order_status' => $param['order_status']];
- }
- if (isset($param['keyword']) && $param['keyword']) {
- switch (trim($param['type'])){
- case 'order_no':
- $where[] = ['order_no' => $param['keyword']];
- break;
- case 'mobile':
- $where[] = ['mobile' => $param['keyword']];
- break;
- case 'express':
- $express = OrderExpress::findOne(['express_no' => $param['keyword']]);
- if($express){
- $order = Order::findOne(['id' => $express->order_id,'mall_id' => $this->mall_id,'store_id' => $this->store_id]);
- $order && $where[] = ['order_no' => $order->order_no];
- }
- break;
- }
- }
- $where[] = ['=', 'supplier_type', 0];
- $where[] = ['>=', 'status', StatusEnum::DISABLED];
- $with = ['base_user', 'detail'];
- $order = "id desc";
- $params = compact('where', 'with', 'order');
- $page_data = StoreOrder::listPage($params, false, true);
- if ($page_data === false) return $this->error(Goods::getStaticError());
- $compact_params = array_keys($page_data);
- extract($page_data);
- //订单数量:未付款,待发货,待收货
- $stat = StoreOrder::find()->select('count(id) as num ,order_status')->where(['mall_id' => $this->mall_id, 'store_id' => $this->store_id
- ])->groupBy('order_status')->asArray()->all();
- $stat = array_column($stat, 'num', 'order_status');
- //$stat_tab = [];
- $stat_tab[] = [
- 'order_status' => 999,
- 'num' => 0 ,
- 'order_status_text' => '全部'
- ];
- foreach ($order_status_list as $key => $value) {
- if (!in_array($key, [OrderStatusEnum::NOT_PAY, OrderStatusEnum::PAY, OrderStatusEnum::SHIPMENTS])) continue;
- $stat_tab[] = [
- 'order_status' => $key,
- 'num' => $stat[$key] ?? 0,
- 'order_status_text' => $value
- ];
- }
- return $this->success('操作成功', compact($compact_params, 'order_status_list', 'payment_type_list', 'shipping_type_list', 'export_list', 'marketing_type_map','stat_tab'));
- }
- /**
- * 售后订单列表
- * @return void
- */
- public function actionRefundList()
- {
- $param = Yii::$app->request->get();
- $refund_status_list = RefundStatusEnum::getMap();
- $refund_type_list = RefundTypeEnum::getMap();
- $rules = [
- [['keyword'], 'string'],
- [['keyword', 'refund_status'], 'safe'],
- ];
- $res = Yii::$app->services->validate->validate($param, $rules);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $where = [['mall_id' => $this->mall_id]];
- $where[] = ['=', 'store_id', $this->store_id];
- $where[] = ['=', 'status', StatusEnum::ENABLED];
- if (isset($param['keyword']) && $param['keyword']) {
- //关键词 订单号:st202212161912558027820701
- if (substr($param['keyword'], 0, 2) == 'st') {
- //商城订单号搜索,查询对应订单id
- $search_order = OrderRefund::getOidByOrderNo($this->mall_id, $param['order_no']);
- if ($search_order) {
- $where[] = ['in', 'order_id', $search_order];
- }
- } else {
- preg_match('/^1\d{10}$/', $param['keyword'], $match);
- if ($match) {
- $where[] = OrderRefund::searchByKeyword($this->mall_id, 'mobile', $param['keyword']);
- } else {
- //快递单号查询不了
- }
- }
- }
- if (isset($param['refund_status']) && $param['refund_status'] != 999 ) {
- if($param['refund_status'] == RefundStatusEnum::HANDEL){
- //售后中
- $where[] = ['in', 'refund_status', [ RefundStatusEnum::HANDEL, RefundStatusEnum::RETURN_GOODS, RefundStatusEnum::EXCHANGE_GOODS]];
- }else{
- $where[] = ['=', 'refund_status', $param['refund_status']];
- }
- } else {
- $where[] = ['in', 'refund_status', [RefundStatusEnum::APPLY, RefundStatusEnum::HANDEL, RefundStatusEnum::FINISH, RefundStatusEnum::RETURN_GOODS, RefundStatusEnum::EXCHANGE_GOODS, RefundStatusEnum::REFUSE]];
- }
- $with = ['base_user', 'orderDetail', 'order'];
- $select = 'id,order_id,order_detail_id,reason,remark,refund_price,refund_status,user_id';
- $order = "id desc";
- $params = compact('where', 'with', 'order', 'select');
- $page_data = OrderRefund::listPage($params, false, true);
- if ($page_data === false) return $this->error(OrderRefund::getStaticError());
- $compact_params = array_keys($page_data);
- extract($page_data);
- foreach ($list as &$order) {
- foreach ($order['orderDetail'] as &$detail) {
- if (!empty($detail['attr_groups_format'])) {
- //规格
- $attr_groups_format = Json::decode($detail['attr_groups_format'], true);
- $attr_list = $attr_groups_format[$detail['sign_id']];
- $attr_group_name_list = array_column($attr_list, 'attr_group_name');
- $attr_name_list = array_column($attr_list, 'attr_name');
- $detail['attr_list'] = [];
- foreach ($attr_group_name_list as $index => $attr_group_name) {
- $detail['attr_list'][] = $attr_group_name . ':' . $attr_name_list[$index];
- }
- }
- }
- }
- //导航栏售后状态-数量
- $stat = OrderRefund::find()->select('count(id) as num ,refund_status')
- ->where(['mall_id' => $this->mall_id, 'store_id' => $this->store_id
- ])->groupBy('refund_status')->asArray()->all();
- $stat = array_column($stat, 'num', 'refund_status');
- //$stat_tab = [];
- $stat_tab[] = [
- 'refund_status' => 999,
- 'num' => 0 ,
- 'refund_status_text' => '全部'
- ];
- foreach ($refund_status_list as $key => $value) {
- if (!in_array($key, [RefundStatusEnum::APPLY, RefundStatusEnum::HANDEL, RefundStatusEnum::FINISH])) continue;
- $stat_tab[] = [
- 'refund_status' => $key,
- 'num' => $stat[$key] ?? 0,
- 'refund_status_text' => $value
- ];
- }
- return $this->success('操作成功', compact($compact_params, 'refund_status_list', 'refund_type_list', 'stat_tab'));
- }
- /**
- * 订单详情
- * @return void
- */
- public function actionOrderDetail()
- {
- $get = Yii::$app->request->get();
- $rules = [[['id'], 'required']];
- $res = Yii::$app->services->validate->validate($get, $rules);
- if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $order_status_list = OrderStatusEnum::getMap();
- $payment_type_list = PayTypeEnum::getMap();
- $shipping_type_list = ShippingTypeEnum::getMap();
- $where = [['mall_id' => $this->mall_id]];
- $where[] = ['=', 'id', $get['id']];
- $where[] = ['=', 'store_id', $this->store_id];
- $where[] = ['>=', 'status', StatusEnum::DISABLED];
- $with = [
- 'base_user',
- 'detail'
- ];
- $params = compact('where', 'with');
- $order = StoreOrder::getOne($where, true, $with);
- if ($order === false) return $this->error(StoreOrder::getStaticError());
- $main_order = Order::getOne([['order_no'=>$order['order_no']]],true,['express','express_log']);
- $express_log = [];
- $order['order_type_text'] = '普通订单';
- //佣金分红
- $order['commission_total'] = 0;
- //服务费
- $order['service_fee'] = 0;
- //商家实收:
- $order['amount_received'] = 0;
- $store_commission = StoreCommission::findOne(['store_id'=>$this->store_id,'order_no' =>$order['order_no']]);
- if($store_commission){
- $order['service_fee'] = $store_commission->service_charge;
- $order['commission_total'] = $store_commission->addons_bonus;
- $order['amount_received'] = $store_commission->amount_received;
- }
- $order_setting = Yii::$app->services->setting->mall->get($this->mall_id, 'order');
- $order['payment_expire_time'] = $order_setting['payment_expire_time'] ?? 30;
- $order['auto_receiving_time'] = $order_setting['auto_receiving_time'] ?? 14;
- if (!empty($order['detail'])) {
- foreach ($order['detail'] as &$detail) {
- if (!empty($detail['attr_groups_format'])) {
- $attr_groups_format = json_decode($detail['attr_groups_format'], true);
- $attr_list = $attr_groups_format[$detail['sign_id']];
- $attr_group_name_list = array_column($attr_list, 'attr_group_name');
- $attr_name_list = array_column($attr_list, 'attr_name');
- $detail['attr_list'] = [];
- foreach ($attr_group_name_list as $index => $attr_group_name) {
- $detail['attr_list'][] = $attr_group_name . ':' . $attr_name_list[$index];
- }
- }
- }
- }
- $shipping_type_text = ShippingTypeEnum::getShippingType($order['shipping_type']);
- $step_arr = StoreEnum::setpArrMap($order['order_status'], $shipping_type_text);// 订单状态跟踪
- $order_action = OrderAction::getOrderAction([['order_id' => $main_order['id']]]);
- $stepArr[] = ['title' => '买家下单', 'created_at' => '0', 'is_step' => 0];
- $stepArr[] = ['title' => '买家付款', 'created_at' => '0', 'is_step' => 0,];
- $stepArr[] = ['title' => $shipping_type_text, 'created_at' => '0', 'is_step' => 0,];
- $stepArr[] = ['title' => '交易完成', 'created_at' => '0', 'is_step' => 0,];
- $store = Store::getOne([['id' => $order['store_id']]], true);
-
- return $this->success('操作成功', compact('order', 'stepArr', 'order_status_list', 'payment_type_list', 'shipping_type_list', 'step_arr', 'order_action', 'store'));
- }
- /**
- * 售后订单详情
- * @return mixed|void
- */
- public function actionRefundDetail()
- {
- $get = Yii::$app->request->get();
- $rules = [[['id'], 'required']];
- $res = Yii::$app->services->validate->validate($get, $rules);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $order_status_list = OrderStatusEnum::getMap();
- $address_list = StoreRefundAddress::lists([
- 'where' => [
- ['store_id' => $this->store_id],
- ['status' => StatusEnum::ENABLED]
- ],
- 'select' => 'address,mobile,name, refund_name as consignee',
- ]);
- $where = [['mall_id' => $this->mall_id], ['store_id' => $this->store_id]];
- $where[] = ['=', 'id', $get['id']];
- $where[] = ['>=', 'status', StatusEnum::DISABLED];
- $with = ['base_user', 'order', 'orderDetail', 'marketing', 'step'];
- $params = compact('where', 'with');
- $refund = OrderRefund::getOne($where, true, $with);
- if ($refund === false) return $this->error(OrderRefund::getStaticError());
- $main_order = Order::findOne(['id' => $refund['order_id']]);
- $store_order = StoreOrder::findOne(['order_no' => $main_order['order_no'] ?? 0]);
- $store_order_credit = StoreOrderCredit::find()->where(['type' => 1, 'order_id' => $store_order['id'] ?? 0])
- ->andWhere(['>', 'pay_time', 0])->one();
- $refund['orderDetail']['credit_money'] = 0;
- if (!empty($store_order_credit['extra'])) {
- $goods_id = $refund['orderDetail']['goods_id'];
- $extra = json_decode($store_order_credit['extra'], true);
- if (!empty($extra[$goods_id]['credit_money'])) {
- $refund['orderDetail']['goods_price'] = bcadd($refund['orderDetail']['goods_price'], $extra[$goods_id]['credit_money'], 2);
- $refund['orderDetail']['credit_money'] = $extra[$goods_id]['credit_money'];
- }
- }
- foreach ($refund['orderDetail'] as $key => $detail) {
- if (!empty($detail['attr_groups_format'])) {
- $attr_groups_format = Json::decode($detail['attr_groups_format'], true);
- $attr_list = $attr_groups_format[$detail['sign_id']];
- $attr_group_name_list = array_column($attr_list, 'attr_group_name');
- $attr_name_list = array_column($attr_list, 'attr_name');
- $detail['attr_list'] = [];
- }
- }
- // 返还优惠内容
- if (!empty($refund['marketing'])) {
- $discount = [];
- $marketing = $refund['marketing'];
- if (!empty($marketing['deduct_score'])) {
- $score_name = Yii::$app->services->setting->mall->get($this->mall_id, 'score.score_name');
- $discount[] = floatval($marketing['deduct_score']) . $score_name;
- }
- $refund['discount'] = implode('+', $discount);
- }
- $step_status = $refund['step'][0]['step_status'] ?? 0;
- $step_arr = RefundStatusEnum::stepNumArr(in_array($step_status, [RefundStatusEnum::STEP_NEGATIVE_1, RefundStatusEnum::STEP_NEGATIVE_2]) ? 1 : $refund['type']);// 进度条
- $step_text = RefundStatusEnum::getStepStatusText($step_status);
- $refund_type_text = RefundTypeEnum::getMap();
- $refund_status_text = RefundStatusEnum::getMap();
- $refund['type_text'] = $refund_type_text[$refund['type']] ?? '';
- $refund['refund_status_text'] = $refund_status_text[$refund['refund_status']] ?? '';
- //关闭时间
- $refund['finish_at'] = 0;
- if($refund['status'] == RefundStatusEnum::FINISH){
- //售后完成
- $refund['finish_at'] = $refund['updated_at'];
- }
- return $this->success('操作成功', compact('refund', 'order_status_list', 'step_arr', 'address_list', 'step_text'));
- }
- /**
- * 资产
- * @return mixed|void
- */
- public function actionFinance()
- {
- $store = Store::findOne(['id' => $this->store_id]);
- // $balance_cash_service_fee = \Yii::$app->services->setting->mall->get($this->mall_id, 'withdraw_balance.balance_cash_service_fee');
- $user = User::getOne([['id' => $store->user_id]], true, [], false, 'id,nickname,avatar_url,mobile');
- $finance = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'finance');
- $storeSetting = StoreSettings::findOne(['store_id' => $this->store_id]);
- $freeze_is_enable = 0;
- $finance_name = '资产';
- if(!empty($finance)){
- if(!empty($finance['freeze_is_enable'])){
- $freeze_is_enable = $finance['freeze_is_enable'];
- }
- if(!empty($finance['finance_name'])){
- $finance_name = $finance['finance_name'];
- }
- }
- //提现条件
- if(isset($finance['balance_cash_type'])){
- $cashType = json_decode($finance['balance_cash_type'],true);
- }else{
- //默认银行卡/余额提现
- $cashType = ['balance','bank'];
- }
- $balance_cash_service_fee = 0;
- $balance_cash_service_fee_limit = 0;
- $balance_cash_service_fee_month = 0;
- if (!empty($storeSetting->is_enable_withdraw_setting)) {
- $finance['balance_cash_service_fee_limit'] = $storeSetting->balance_cash_service_fee_limit;
- $finance['balance_cash_service_fee_month'] = $storeSetting->balance_cash_service_fee_month;
- $finance['balance_cash_service_fee_diff'] = $storeSetting->balance_cash_service_fee_diff;
- $finance['balance_cash_service_fee'] = $storeSetting->balance_cash_service_fee;
- }
- if(!empty($finance['balance_cash_service_fee_limit'])){
- $balance_cash_service_fee_limit = $finance['balance_cash_service_fee_limit'];
- $balance_cash_service_fee_month = $finance['balance_cash_service_fee_month'];
- $balance_cash_service_fee = $finance['balance_cash_service_fee_diff'] ?? 0;
- }else{
- if(isset($finance['balance_cash_service_fee'])){
- $balance_cash_service_fee = $finance['balance_cash_service_fee'] ?? 0;
- }else{
- $balance_cash_service_fee = \Yii::$app->services->setting->mall->get($this->mall_id, 'withdraw_balance.balance_cash_service_fee');
- }
- }
- if (!$cashType) {
- return $this->error('系统未设置提现方式');
- }
- $cash__type_name = [];
- $get_system_setting = PlatformSetting::getConfByGroup('system', true);
- if (!empty($cashType)) {
- $cash_type = $cashType;
- $cash__type_name = [];
- $default_withdraw_way = WithdrawWayEnum::getDefaultWithDrawWayMap(WithdrawWayEnum::WITHDRAW_TYPE_2);
- $extension_withdraw_way = GlobalInvoke::exec(GlobalInvoke::INVOKE_GET_WITHDRAW_EXTENSION_WAY,$this->mall_id,['mall_id'=>$this->mall_id]);
- $all_withdraw = array_merge($default_withdraw_way,$extension_withdraw_way);
- $cash_type_keys = array_keys($all_withdraw);
- if (in_array('bank', $cash_type_keys) || in_array('joinpay', $cash_type_keys)) {
- $bank_card_list = StoreBank::lists(['where' => [['store_id' => $this->store_id], ['status' => StatusEnum::ENABLED]], 'select' => 'id,mall_id,store_id,username,bank as bank_name,card_no as bank_card_no']);
- }
- foreach ($cash_type as $i => $item) {
- if (isset($all_withdraw[$item])) {
- $taxFee = 0;
- $name = '';
- if (isset($all_withdraw[$item])) {
- if (is_array($all_withdraw[$item])) {
- $name = $all_withdraw[$item]['name'] ?? '';
- $taxFee = $all_withdraw[$item]['taxFee'] ?? 0;
- } else {
- $name = $all_withdraw[$item];
- }
- }
- $cash__type_name[$i]['type'] = $item;
- $cash__type_name[$i]['taxFee'] = $taxFee;
- $cash__type_name[$i]['name'] = $name;
- $cash__type_name[$i]['img'] = $get_system_setting['api_url']['value'] . '/resources/img/payment/' . $item . '.png';
- if ('bank' == $item || 'joinpay' == $item) {
- $cash__type_name[$i]['bank_card_list'] = $bank_card_list;
- }
- }
- }
- }
- $return = [
- 'balance' => $store->balance, //可提现金额
- 'unsettled_amount' => $store->unsettled_amount,//待结算金额
- // 'store_banks' => $store_banks,
- 'balance_cash_service_fee' => $balance_cash_service_fee,
- 'balance_cash_service_fee_limit' => $balance_cash_service_fee_limit,
- 'balance_cash_service_fee_month' => $balance_cash_service_fee_month,
- 'freeze_is_enable' => $freeze_is_enable,
- 'finance_name' => $finance_name,
- 'user' => $user,
- 'cash_type_name' => $cash__type_name,
- ];
- return $this->success('操作成功', $return,ApiStatusEnum::CODE_SUCCESS,JSON_UNESCAPED_UNICODE);
- }
- /**
- * 添加银行卡
- * @return void
- */
- public function actionAddBankCard()
- {
- try {
- $params = \Yii::$app->request->post();
- $res = \Yii::$app->services->validate->validate($params, [
- [['username', 'bank', 'card_no'], 'required'],
- ['card_no', 'string', 'max' => 64],
- [['username'], 'string', 'max' => 50],
- [['bank'], 'string', 'max' => 255],
- ]);
- if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- $bank_card_info = StoreBank::findONe(['mall_id' => $this->mall_id, 'card_no' => $params['card_no'], 'store_id' => $this->store_id, 'status' => StatusEnum::ENABLED]);
- if (!empty($bank_card_info)) {
- throw new \Exception('银行卡已经被绑定');
- }
- $params['mall_id'] = $this->mall_id;
- $params['store_id'] = $this->store_id;
- $res = StoreBank::setData($params);
- if (!$res) throw new \Exception(StoreBank::getStaticError());
- return $this->success('添加成功');
- } catch (\Exception $exception) {
- return $this->error('操作失败:' . $exception->getMessage());
- }
- }
- /**
- * 提现
- * @throws \Exception
- */
- public function actionWithdraw()
- {
- $params = \Yii::$app->request->post();
- $need_auth = GlobalInvoke::exec(GlobalInvoke::REAL_AUTH, $this->mall_id, ['user_id' => $this->user_id,'mall_id' => $this->mall_id,'type' => 'cash']);
- if($need_auth === true){
- //需要先进行实名认证
- return $this->error('请先进行实名认证',[],ApiStatusEnum::CODE_ERROR_NEED_REAL_AUTH);
- }
- $form = new StoreWithdrawLog();
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $params['store_id'] = $this->store_id;
- $form->attributes = $params;
- $data = $form->saveRecord($params);
- if ($data['state']) {
- return $this->success('操作成功', $data['data']);
- } else {
- return $this->error($data['msg']);
- }
- }
- }
|