user_id = get_user_id(); $form->store_id = get_store_id(); $form->attributes = post_params(); return $this->asJson($form->cashBalance()); } /** * 获取提现相关 */ public function actionGetPrice() { $store_id = get_store_id(); $store = Store::findOne($store_id); $balancToCash = (int)Option::get(OptionSetting::BALANCE_TO_CASH, $store_id, 'recharge', 0)['value']; if (!$balancToCash) { return $this->asJson([ 'code' => 1, 'msg' => '提现功能未开启' ]); } $balancToCashSet = json_decode(Option::get(OptionSetting::BALANCE_TO_CASH_SETTING, $this->store_id, 'recharge', '{}')['value'], true); if (!isset($balancToCashSet['cash_service_charge'])) { $balancToCashSet['cash_service_charge'] = 0; } $saas_user = get_saas_user(); $lg_info = Lg::find()->where(['user_id' => $saas_user->id, 'store_id' => get_store_id(),'status'=>1,'is_delete'=>0])->one(); $res = [ 'money' => get_user()->money, 'balancToCash' => $balancToCash, 'balancToCashSet' => $balancToCashSet, ]; // 新提现方式 $res['cash_method_list'] = []; $saas_user = get_saas_user(); if (!empty($saas_user->withdraw_method)) { $cash_method = json_decode($saas_user->withdraw_method, true); if($lg_info){ //灵工 $cash_method = array_merge($cash_method, [[ 'type' => 'lg' ]]); } if (is_array($cash_method)) { foreach($cash_method as $i => $item){ if ($item['type'] === 'wechat' && $balancToCashSet['balance_to_cash_pay_type']['wechat'] == 0) { unset($cash_method[$i]); } if ($item['type'] === 'alipay' && $balancToCashSet['balance_to_cash_pay_type']['alipay'] == 0) { unset($cash_method[$i]); } if ($item['type'] === 'bank_card' && $balancToCashSet['balance_to_cash_pay_type']['bank_card'] == 0) { unset($cash_method[$i]); } if ($item['type'] === 'lg' && $store->lg_cash == 0) { unset($cash_method[$i]); } } $res['cash_method_list'] = array_values($cash_method); } }else{ if($lg_info){ //灵工 $cash_method[]['type'] = 'lg'; $res['cash_method_list'] = array_values($cash_method); } } return $this->asJson(['code' => 0, 'msg' => 'success', 'data' => $res]); } public function actionIndex() { $user = get_user(); // 搜索指定月份的充值记录及余额消费记录 $form = new RecordForm(); $form->user = $user; $form->attributes = get_params(); $form->store_id = get_store_id(); $res = $form->search(); if ($res['code'] == 1) { return $this->asJson($res); } // 余额页设置 $form = new RechargeModule(); $form->store_id = get_store_id(); $setting = $form->search_recharge(); $data = [ 'money' => $user->money, 'list' => $res['data']['list'], 'setting' => $setting, 'date' => $res['data']['date'], ]; return $this->asJson(['code' => 0, 'msg' => 'success', 'data' => $data]); } /** * 搜索指定月份的充值记录及余额消费记录 * @return \yii\web\Response * @throws \yii\db\Exception */ public function actionRecord() { $user = get_user(); $form = new RecordForm(); $form->attributes = get_params(); $form->store_id = get_store_id(); $form->user = $user; $res = $form->search(); return $this->asJson($res); } //充值记录 public function actionRechargeOrder() { $user = get_user(); $form = new RecordForm(); $form->attributes = get_params(); $form->store_id = get_store_id(); $form->user = $user; return $this->asJson($form->rechargeOrder()); } //充值订单申请退款 public function actionRechargeOrderRefundMoneyApply() { $user = get_user(); $form = new ReOrderForm(); $form->store_id = get_store_id(); $order_id = input_params('order_id', 0); $desc_user = input_params('desc_user', ''); return $this->asJson($form->refundMoneyApply($user->id, $order_id, $desc_user)); } //充值订单退款列表 public function actionRechargeOrderRefundMoneyList() { $form = new ReOrderForm(); $form->store_id = get_store_id(); $form->user_id = get_user_id(); $form->order_id = input_params('order_id', 0); return $this->asJson($form->refundMoneyList()); } public function actionLeagueRecord() { $user = get_user(); $form = new RecordForm(); $form->attributes = get_params(); $form->store_id = get_store_id(); $form->user = $user; $res = $form->league_search(); return $this->asJson($res); } /** * 充值可选列表 * @return \yii\web\Response */ public function actionList() { $name = [ 'recharge_wallet_status', 'recharge_custom_status', 'recharge_pic_url', 'recharge_ad_pic_url', 'recharge_page_url', 'recharge_p_pic_url', 'recharge_help', ]; $data = Option::get($name, get_store_id(), 'recharge'); $data = array_column($data, null, 'name'); $balance = [ 'status' => $data['recharge_wallet_status']['value'], 'pic_url' => $data['recharge_pic_url']['value'], 'ad_pic_url' => $data['recharge_ad_pic_url']['value'], 'page_url' => $data['recharge_page_url']['value'], 'p_pic_url' => $data['recharge_p_pic_url']['value'], 'help' => $data['recharge_help']['value'], 'type' => $data['recharge_custom_status']['value'], ]; $list = Recharge::find()->where(['store_id' => get_store_id(), 'is_delete' => 0]) ->orderBy(['pay_price' => SORT_DESC])->asArray()->all(); $levelType = Level::find()->where(['store_id' => get_store_id(), 'is_delete' => Level::NOT_DELETE])->asArray()->all(); foreach ($list as &$val) { foreach ($levelType as $type) { if ($val['level_up'] == $type['level']) { $val['level_up_name'] = $type['name']; break; } } } // $list = array_filter($list, function($item) { // return $item['level_up'] != get_user()->level; // }); // TODO: msg_id $data = [ 'list' => array_values($list), 'tpl_msg_id' => '', 'balance' => $balance ]; return $this->asJson(['code' => 0, 'msg' => 'success', 'data' => $data]); } /** * 充值提交 * @return \yii\web\Response */ public function actionSubmit() { $form = new RechargeSubmitForm(); $form->store_id = get_store_id(); $form->user = get_user(); $form->attributes = post_params(); // if (get_params('_form') === 'h5') { // $form->pay_type = 1; // } return $this->asJson($form->save()); } /** * 余额收支详情 * @return \yii\web\Response */ public function actionDetail() { $form = new DetailForm(); $form->store_id = get_store_id(); $form->attributes = get_params(); return $this->asJson($form->search()); } //充值方式 public function actionGetPayTypeList() { $pay_type_list_json = Option::get(OptionSetting::STORE_PAYMENT, get_store_id(), 'pay', Option::get(OptionSetting::STORE_PAYMENT, get_store_id(), 'store', '{"wechat":{"value":1}}')['value']); $pay_type_list = Json::decode($pay_type_list_json['value']); $user_pay_list_json = Option::get('payment_' . get_user_id(), get_store_id(), 'user')['value']; if ($user_pay_list_json) { $user_pay_list_arr = Json::decode($user_pay_list_json); foreach ($pay_type_list as $key => &$value) { if (isset($user_pay_list_arr[$key]) && $user_pay_list_arr[$key]['value'] == 0 && $value['value'] == 1) { $value['value'] = 0; } } } $new_list = []; foreach ($pay_type_list as $index => $pay_type_value) { if ((is_wechat_platform() || is_h5() || is_app_platform()) && $index == 'wechat' && $pay_type_value['value'] == 1) { $new_list[] = [ 'name' => '微信支付', 'payment' => 1, 'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/recharge/icon-online.png' ]; } if ((is_wechat_platform()) && $index == Order::PAY_TYPE_KEY_WX_B2B && $pay_type_value['value'] == 1) { $new_list[] = [ 'name' => Order::PAY_TYPE_NAME_WX_B2B, 'payment' => Order::PAY_TYPE_WX_B2B, 'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/recharge/icon-online.png' ]; } if ((is_alipay_platform() || is_h5() || is_app_platform()) && $index == 'alipay' && $pay_type_value['value'] == 1) { $new_list[] = [ 'name' => '支付宝支付', 'payment' => 4, 'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/recharge/icon-alipay.png' ]; } } return $this->asJson([ 'code' => 0, 'msg' => '', 'data' => $new_list ]); } }