StoreUserAdmin::class ] ]); } /** * 商品 **/ //管理中心 public function actionStoreInfo(){ $form = new StoreAdminForm(); $form->wechat = $this->wechat; $form->store_id = $this->store_id; $res = $form->storeInfo(); return $this->asJson($res); } //店铺数据 public function actionShopData() { $form = new StoreAdminForm(); $form->start_date = input_params('start_date'); $form->end_date = input_params('end_date'); $form->wechat = $this->wechat; $form->store_id = $this->store_id; $form->tab = input_params('tab'); $form->type = input_params('type'); $res = $form->shopData(); return $this->asJson($res); } //修改获取商城数据 public function actionGetStoreInfo() { $form = new StoreAdminForm(); $form->logo = post_params('logo'); $form->name = post_params('name'); $form->coordinate = post_params('coordinate'); $form->address = post_params('address'); $form->store_id = $this->store_id; $res = $form->getStoreInfo(); return $this->asJson($res); } //店铺数据 public function actionGetYesData() { $form = new StoreAdminForm(); $form->start_date = input_params('start_date'); $form->end_date = input_params('end_date'); $form->wechat = $this->wechat; $form->store_id = $this->store_id; $res = $form->getYesData(); return $this->asJson($res); } //用户列表 public function actionUserList(){ $form = new StoreAdminUserForm(); $attributes = all_params(); $res = $form->userList($this->store_id, $attributes); return $this->asJson($res); } //充值积分或者余额 public function actionUserRecharge() { $form = new StoreAdminUserForm(); $data = post_params(); $admin = get_admin(); // $admin = json_decode(json_encode(['username' => 'uuu', 'id' => 1])); return $this->asJson($form->userRecharge($admin, $this->store_id, $data)); } //商品列表 public function actionGoodsList(){ $form = new StoreAdminGoodsForm(); $form->status = get_params('status',1); $form->sort = get_params('sort'); $form->store_id = $this->store_id; $res = $form->goodsList(); return $this->asJson($res); } //修改标题 public function actionSetGoodsName(){ $form = new StoreAdminGoodsForm(); $form->id = post_params('id'); $form->goods_name = post_params('name'); $form->store_id = $this->store_id; $res = $form->setGoodsName(); return $this->asJson($res); } //删除商品 public function actionGoodsDel(){ $form = new StoreAdminGoodsForm(); $form->id = post_params('id'); $form->store_id = $this->store_id; $res = $form->goodsDel(); return $this->asJson($res); } //分享商品 public function actionShareGoods(){ $form = new ShareQrcodeForm(); $form->goods_id = post_params('id'); $form->type = 0; $form->user = get_user(); $form->user_id = get_user_id(); $form->store_id = $this->store_id; return $this->asJson($form->search()); } //修改上下架状态 public function actionSetGoodsStatus(){ $form = new StoreAdminGoodsForm(); $form->id = post_params('id'); $form->status = post_params('status'); $form->store_id = $this->store_id; $res = $form->setGoodsStatus(); return $this->asJson($res); } //修改价格库存 public function actionSetGoodsPrice(){ $form = new StoreAdminGoodsForm(); $form->id = post_params('id'); $form->goods_price = post_params('goods_price', 0); $form->goods_num = post_params('goods_num', 0); $form->attr = post_params('attr', 0); $form->store_id = $this->store_id; $res = $form->setPrice(); return $this->asJson($res); } //获取修改商品数据 public function actionGetGoodsEdit(){ $form = new StoreAdminGoodsForm(); $form->id = get_params('id'); $form->store_id = $this->store_id; $res = $form->getGoodsEdit(); return $this->asJson($res); } //获取运费规则 public function actionGetPostageData(){ $form = new StoreAdminGoodsForm(); $res = $form->getPostageData(); return $this->asJson($res); } //保存商品 public function actionSaveGoods(){ $form = new StoreAdminGoodsForm(); $form->goods_info = post_params('goods_info'); $form->store_id = $this->store_id; $res = $form->saveGoods(); return $this->asJson($res); } //商品详情 public function actionGoodsDetail(){ $form = new StoreAdminGoodsForm(); $form->id = post_params('id'); $form->store_id = $this->store_id; $res = $form->goodsDetail(); return $this->asJson($res); } //获取商品规格信息 public function actionGetGoodsAttr(){ $form = new StoreAdminGoodsForm(); $form->id = post_params('id'); $form->store_id = $this->store_id; $res = $form->getGoodsAttr(); return $this->asJson($res); } //分类列表 public function actionCatList() { $form = new StoreAdminGoodsForm(); $form->store_id = $this->store_id; $res = $form->catList(); return $this->asJson($res); } //分类添加保存 public function actionCatSave() { $form = new StoreAdminGoodsForm(); $form->cat_name = post_params("name"); $form->id = post_params("id"); $form->parent_id = post_params("parent_id", 0); $form->pic_url = post_params("pic_url"); $form->status = post_params("is_show", 1); $form->store_id = $this->store_id; $res = $form->catAdd(); return $this->asJson($res); } //分类添加保存 public function actionCatBatchSave() { $form = new StoreAdminGoodsForm(); $form->store_id = $this->store_id; $res = $form->catAddBatch(input_params("name_1"), input_params("name_2"), input_params("name_3")); return $this->asJson($res); } //分类修改状态 public function actionSetCatStatus() { $form = new StoreAdminGoodsForm(); $form->id = post_params("id"); $form->status = post_params("status", 0); $form->store_id = $this->store_id; $res = $form->setCatStatus(); return $this->asJson($res); } /** * 订单 */ //订单列表 public function actionOrderList() { $form = new StoreAdminOrderForm(); $form->status = get_params("status"); $form->date_range = (empty(get_params("begin_time")) || empty(get_params("end_time")))?false:[ 'begin_time' => get_params("begin_time"), 'end_time' => get_params("end_time") ]; $form->store_id = $this->store_id; $res = $form->orderList(); return $this->asJson($res); } //订单商品评价 public function actionOrderCommentGoodsList() { $form = new StoreAdminCommentForm(); $form->goods_name = get_params("goods_name"); $form->date_range = (empty(get_params("begin_time")) || empty(get_params("end_time")))?false:[ 'begin_time' => get_params("begin_time"), 'end_time' => get_params("end_time") ]; $form->store_id = $this->store_id; $res = $form->commentGoodsList(); return $this->asJson($res); } //订单评价 public function actionOrderCommentList() { $form = new StoreAdminCommentForm(); $form->goods_name = get_params("goods_name"); $form->goods_id = get_params("goods_id"); $form->status = get_params("status"); $form->type = get_params("type"); $form->store_id = $this->store_id; $res = $form->commentList(); return $this->asJson($res); } //删除评论 public function actionCommentDel() { $form = new StoreAdminCommentForm(); $form->id = post_params("id"); $form->store_id = $this->store_id; $res = $form->commentDel(); return $this->asJson($res); } //回复评论 public function actionCommentReply() { $form = new StoreAdminCommentForm(); $form->id = post_params("id"); $form->reply_content = post_params("reply_content"); $form->store_id = $this->store_id; $res = $form->commentReply(); return $this->asJson($res); } //取消订单 public function actionOrderCancel() { $form = new StoreAdminOrderForm(); $form->remark = post_params("remark"); $form->id = post_params("id"); $form->store_id = $this->store_id; $res = $form->orderCancel(); return $this->asJson($res); } //拒绝取消订单 public function actionOrderRejectCancel() { $form = new StoreAdminOrderForm(); // $form->remark = post_params("remark"); $form->id = post_params("id"); $form->store_id = $this->store_id; $res = $form->orderRejectCancel(); return $this->asJson($res); } //订单发货 public function actionOrderSend() { $form = new OrderSendForm(); $post = post_params(); if (($post['is_express'] == OrderSendForm::EXPRESS_TYPE_EXPRESS)) { $form->scenario = 'EXPRESS'; }elseif ($post['is_express'] == OrderSendForm::EXPRESS_TYPE_DADA){ $form->scenario = 'DADA'; }elseif ($post['is_express'] == OrderSendForm::EXPRESS_TYPE_UU){ $form->scenario = 'UU'; }elseif ($post['is_express'] == OrderSendForm::EXPRESS_TYPE_PEISONG){ $form->scenario = 'PEISONG'; } $form->attributes = $post; $form->store_id = $this->store_id; return $this->asJson($form->save()); } //售后订单 public function actionOrderRefund() { $form = new StoreAdminOrderForm(); $form->status = get_params("status", 0); $form->date_range = (empty(get_params("begin_time")) || empty(get_params("end_time")))?false:[ 'begin_time' => get_params("begin_time"), 'end_time' => get_params("end_time") ]; $form->store_id = $this->store_id; $res = $form->orderRefund(); return $this->asJson($res); } //订单详情 public function actionOrderDetail() { $form = new StoreAdminOrderForm(); $form->id = post_params("id"); $form->type = post_params("type", 0); $form->store_id = $this->store_id; $res = $form->orderDetail(); return $this->asJson($res); } //获取快递公司数据 public function actionGetExpress(){ $form = new StoreAdminOrderForm(); $form->store_id = $this->store_id; $res = $form->express(); return $this->asJson($res); } //售后订单处理 public function actionOrderRefundApply() { $form = new OrderRefundForm(); $form->order_refund_id = post_params("id"); $form->store_id = $this->store_id; $form->action = post_params("action", 0); $form->type = post_params("type", 1); $form->refund = post_params("refund", 0); $form->address_id = post_params("address_id", 0); $res = $form->save(); return $this->asJson($res); } //售后地址添加 public function actionRefundAddressSave() { $form = new StoreAdminOrderForm(); $form->id = post_params("id"); $form->mch_name = post_params("name"); $form->mch_mobile = post_params("mobile"); $form->mch_address = post_params("address"); $form->is_default = post_params("is_default", 0); $form->store_id = $this->store_id; $res = $form->refundAddressSave(); return $this->asJson($res); } //商家收货地址列表 public function actionRefundAddress() { $form = new StoreAdminOrderForm(); $form->store_id = $this->store_id; $res = $form->refundAddress(); return $this->asJson($res); } //商家收货地址删除 public function actionRefundAddressDel() { $form = new StoreAdminOrderForm(); $form->id = post_params("id"); $form->store_id = $this->store_id; $res = $form->refundAddressDel(); return $this->asJson($res); } //商家收货地址设置默认 public function actionRefundAddressDefault(){ $form = new StoreAdminOrderForm(); $form->id = post_params("id"); $form->store_id = $this->store_id; $res = $form->refundAddressDefault(); return $this->asJson($res); } //设置订单中的收货地址 public function actionSetRefundAddress(){ $form = new StoreAdminOrderForm(); $form->id = post_params("id"); $form->store_id = $this->store_id; $form->mch_address = post_params("address_id"); $res = $form->setRefundAddress(); return $this->asJson($res); } //获取单个收货地址 public function actionGetAddressInfo(){ $form = new StoreAdminOrderForm(); $form->id = post_params("id"); $form->store_id = $this->store_id; $res = $form->getAddressInfo(); return $this->asJson($res); } /** * 批量修改价格 */ public function actionUpPriceBatch() { $goods_id = input_params('goods_id'); $num = input_params('num'); $form = new \app\modules\admin\models\GoodsForm(); $res = $form->upPriceBatch($goods_id, $num, 'add'); return $this->asJson($res); } public function actionTemplateList() { $name = input_params('name', ''); $category_id = input_params('category_id', 0); $cond = ['is_delete' => 0, 'status' => 1]; $name && $cond['name'] = $name; $category_id && $cond['category_id'] = $category_id; $query = StoreTemplate::find()->where($cond); $pagination = pagination_make($query); $list = $pagination['list']; foreach($list as &$item){ $item['cat_name'] = '-'; if ($item['category_id'] > 0) { $cat = SaasCategory::findOne($item['category_id']); if ($cat) { $item['cat_name'] = $cat->name; } } $item['home_pic'] = json_decode($item['home_pic'], true); $item['center_pic'] = json_decode($item['center_pic'], true); } $store_template_used = \app\models\Option::get('store_template_used', $this->store_id, 'saas', 0)['value']; return $this->asJson([ 'code' => 0, 'msg' => 'success', 'data' => [ 'store_template_used' => $store_template_used, 'data' => $list, 'pageNo' => $pagination['pageNo'], 'totalCount' => $pagination['totalCount'], 'sql' => '111'.$query->createCommand()->getRawSql(), ], ]); } public function actionTemplateInfo() { $store_id = $this->store_id; $id = input_params('id', 0); $model = StoreTemplate::findOne($id); $store_template_used = \app\models\Option::get('store_template_used', $store_id, 'saas', 0)['value']; $used = $store_template_used == $model->id ? 1 : 0; return $this->asJson([ 'code' => 0, 'msg' => 'success', 'data' => $model, 'used' => $used, ]); } public function actionTemplateUsed() { $store_id = $this->store_id; $id = input_params('id', 0); $type = input_params('type', ['home']);//home/category/product/center/all $model = StoreTemplate::findOne($id); $useTemp = $model->useTemp($store_id, $type); if($useTemp['code'] != 0){ return $this->asJson($useTemp); } if(in_array('all', $type)){ \app\models\Option::set('store_template_used', $id, $store_id, 'saas'); $model->use_count++; $model->save(); } return $this->asJson([ 'code' => 0, 'msg' => 'success', 'data' => $model, 'copy' => $useTemp, ]); } public function actionStoreCopyStatus() { $id = input_params('id', 0); $res = \app\models\StoreCopy::doCopyStatus($id); return $this->asJson($res); } //店铺初始化 public function actionStoreInit() { $id = input_params("id", 0); $default = \app\models\Option::get('store_template_default', 0, 'saas', null)['value']; if($default){ $default = json_decode($default, true); }else{ return $this->asJson([ 'code' => 0, 'msg' => '暂无默认模板', ]); } // $res = \app\models\StoreCopy::doCopy($default['store_id'], $id, $default['type']); // return $this->asJson($res); $id = \queue_push(new StoreSyncJob(['type' => 1, 'to_id' => $id]), 0, 1); return $this->asJson([ 'code' => 0, 'msg' => '操作成功', ]); } /** * 获取提现方式 */ public function actionGetCashMethod() { $saas_user = get_saas_user(); $cash_method = []; if (!empty($saas_user->withdraw_method)) { $decode = json_decode($saas_user->withdraw_method, true); if (is_array($decode)) { $cash_method = $decode; } } return $this->asJson([ 'code' => 0, 'msg' => 'success', 'data' => [ 'list' => $cash_method, ], ]); } /** * 获取提现方式 */ public function actionDelCashMethod() { $saas_user = get_saas_user(); $type = post_params('type'); if (empty($type)) { return $this->asJson([ 'code' => 1, 'msg' => '参数错误', ]); } if (empty($saas_user->withdraw_method)) { return $this->asJson([ 'code' => 0, 'msg' => '操作成功', ]); } $cash_method = json_decode($saas_user->withdraw_method, true); if (is_array($cash_method)) { foreach ($cash_method as $key => $value) { if ($value['type'] == $type) { unset($cash_method[$key]); } } $saas_user->withdraw_method = json_encode(array_values($cash_method)); } else { $saas_user->withdraw_method = ''; } if ($saas_user->save()) { return $this->asJson([ 'code' => 0, 'msg' => '操作成功', ]); } return $this->asJson([ 'code' => 0, 'msg' => '操作失败', ]); } /** * 添加提现方式 */ public function actionAddCashMethod() { $type = post_params('type'); if (empty($type)) { return $this->asJson([ 'code' => 1, 'msg' => '参数错误', ]); } $name = post_params('name'); $account = post_params('account'); $bank = post_params('bank'); if (empty($name) || empty($account)) { return $this->asJson([ 'code' => 1, 'msg' => '账号和姓名不能为空', ]); } if ($type == 'bank_card' && empty($bank)) { return $this->asJson([ 'code' => 1, 'msg' => '银行不能为空', ]); } $data = [ 'type' => $type, 'name' => $name, 'account' => $account, ]; if ($type == 'bank_card') { $data['bank'] = $bank; } $saas_user = get_saas_user(); if (empty($saas_user->withdraw_method)) { $saas_user->withdraw_method = json_encode(array_values([$data])); } else { $decode = json_decode($saas_user->withdraw_method, true); if (!$decode) { $saas_user->withdraw_method = json_encode(array_values([$data])); } else { foreach ($decode as $key => $value) { if ($value['type'] == $type) { unset($decode[$key]); break; } } $decode[] = $data; $saas_user->withdraw_method = json_encode(array_values($decode)); } } if ($saas_user->save()) { return $this->asJson([ 'code' => 0, 'msg' => '操作成功', ]); } return $this->asJson([ 'code' => 1, 'msg' => '操作失败', ]); } // 联盟券提现 private function allianceCouponWithdraw($store, $price, $type) { if ($price > $store->league_price) { return $this->asJson([ 'code' => 1, 'msg' => '提现金额不能大于联盟券余额', ]); } $user_id = get_user_id(); $t = \Yii::$app->db->beginTransaction(); try { $cash = new StoreCash(); $cash->order_no = OrderNo::getOrderNo(OrderNo::ORDER_CASH); $cash->is_delete = 0; $cash->status = 0; $cash->price = $price; $cash->created_at = time(); $cash->user_id = $user_id; $cash->store_id = $store->id; $saas_user = get_saas_user(); $cash->saas_id = $saas_user->id; $withdraw_method = json_decode($saas_user->withdraw_method, true); if ($withdraw_method) { $withdraw_method = array_column($withdraw_method, null, 'type'); if ($type == 'wechat') { $cash->type = 0; $cash->name = $withdraw_method['wechat']['name']; $cash->mobile = $withdraw_method['wechat']['account']; } if ($type == 'alipay') { $cash->type = 1; $cash->name = $withdraw_method['alipay']['name']; $cash->mobile = $withdraw_method['alipay']['account']; } if ($type == 'bank_card') { $cash->type = 2; $cash->name = $withdraw_method['bank_card']['name']; $cash->mobile = $withdraw_method['bank_card']['account']; $cash->bank_name = $withdraw_method['bank_card']['bank']; } } if ($type == 'wechat_auto') { $cash->type = 4; // 微信自动打款 } $cash->pay_time = 0; $cash->cash_type = StoreCash::CASH_TYPE_ALLIANCE_COUPON; if (!$cash->save()) { throw new \Exception('申请失败'); } $before = $store->league_price; $store->updateCounters(['league_price' => -floatval($price)]); \app\models\SaaSLeaguePriceLog::setLeaguePriceLog( $store->id, $cash->saas_id, $cash->price, $before, \app\models\SaaSLeaguePriceLog::TYPE_WITHDRAW, \app\models\SaaSLeaguePriceLog::TAKE_TYPE, \app\models\SaaSLeaguePriceLog::ROLE_STORE, $cash->id ); $t->commit(); return $this->asJson([ 'code' => 0, 'msg' => '申请成功', ]); } catch (\Exception $e) { $t->rollBack(); return $this->asJson([ 'code' => 1, 'msg' => '申请失败', ]); } } //商城账户提现申请 public function actionCashApply() { $price = post_params('cash'); $type = post_params('type'); $scene = post_params('scene'); if (!$price || !in_array($type, ['alipay', 'bank_card', 'wechat', 'wechat_auto'])) { return $this->asJson([ 'code' => 1, 'msg' => '参数非法', ]); } $user_id = get_user_id(); $user = get_user(); $store_id = $this->store_id; $store = Store::findOne($store_id); if (!$store) { return $this->asJson([ 'code' => 1, 'msg' => '参数非法', ]); } if ($scene == 'allianceCoupon') { // 联盟券提现 return $this->allianceCouponWithdraw($store, $price, $type); } if ($store->cusid){ $orderYunst = new OrderYunst(); $res = $orderYunst->queryAcctInfo($store->store_number); $amount = 0; if ($res['subCode'] == 'SUCCESS'){ $amount = $res['data']['amount'];//真的 // $amount = 10;//写的假的 } if ($price > $amount) { \Yii::error([__METHOD__, $price, $amount]); return $this->asJson([ 'code' => 1, 'msg' => '当前大于可提现金额' ]); } }else{ //商城余额是否充足 $storeMoney = \app\models\StoreCash::getMaxCash($store); if ($price > $storeMoney) { \Yii::error([__METHOD__, $price, $storeMoney]); return $this->asJson([ 'code' => 1, 'msg' => '当前大于可提现金额' ]); } } $exit = StoreCash::find()->andWhere(['=', 'status', 0])->andWhere(['store_id' => $store_id, 'cash_type' => StoreCash::CASH_TYPE_NORMAL])->exists(); if ($exit) { \Yii::error([__METHOD__, $store_id, $exit]); // return $this->asJson([ // 'code' => 1, // 'msg' => '尚有未完成的提现申请' // ]); } $t = \Yii::$app->db->beginTransaction(); $cash = new StoreCash(); $cash->order_no = OrderNo::getOrderNo(OrderNo::ORDER_CASH); $cash->is_delete = 0; $cash->status = 0; $cash->price = $price; $cash->created_at = time(); $cash->user_id = $user_id; $cash->store_id = $store_id; $saas_user = get_saas_user(); $cash->saas_id = $saas_user->id; $withdraw_method = json_decode($saas_user->withdraw_method, true); if ($withdraw_method) { $withdraw_method = array_column($withdraw_method, null, 'type'); if ($type == 'wechat') { $cash->type = 0; $cash->name = $withdraw_method['wechat']['name']; $cash->mobile = $withdraw_method['wechat']['account']; } if ($type == 'alipay') { $cash->type = 1; $cash->name = $withdraw_method['alipay']['name']; $cash->mobile = $withdraw_method['alipay']['account']; } if ($type == 'bank_card') { $cash->type = 2; $cash->name = $withdraw_method['bank_card']['name']; $cash->mobile = $withdraw_method['bank_card']['account']; $cash->bank_name = $withdraw_method['bank_card']['bank']; } } if ($type == 'wechat_auto') { $cash->type = 4; // 微信自动打款 } $cash->pay_time = 0; if ($cash->save()) { $subMoney = \app\models\Store::subMoney($store, $price, '商城提现'); if (!$subMoney) { $t->rollBack(); \Yii::error([__METHOD__, $subMoney, $cash]); return $this->asJson([ 'code' => 1, 'msg' => '扣款失败', ]); } $t->commit(); return $this->asJson([ 'code' => 0, 'msg' => '申请成功' ]); } else { $t->rollBack(); return $this->asJson([ 'code' => 1, 'msg' => $cash->errors ]); } } /** * 提现明细 * @return \yii\web\Response */ public function actionCashDetail() { $status = get_params('status', -1); $saasUser = get_saas_user(); $store_id = $this->store_id; $cash_type = get_params('cash_type', 0); if ($cash_type) { $admin = Admin::findOne(['saas_user_id' => $saasUser->id, 'is_delete' => 0, 'type' => Admin::ADMIN_TYPE_STORE]); $store = Store::findOne(['id' => $admin->type_id, 'is_delete' => 0]); $store_id = $store->id; } $query = StoreCash::find()->where(['store_id' => $store_id, 'is_delete' => 0]); if ($status > -1) { // 待审核 if ($status == 0) { $query->andWhere(['status' => $status]); } // 已审核 if ($status == 1) { $query->andWhere(['status' => $status]); } // 已打款 if ($status == 2) { $query->andWhere(['in', 'status', [2, 4]]); } // 已拒绝 if ($status == 3) { $query->andWhere(['status' => $status]); } } if (intval($cash_type)) { $query->andWhere(['cash_type' => $cash_type]); } $query->orderBy('id DESC'); $pagination = pagination_make($query); $list = $pagination['list']; foreach ($list as &$value) { $value['created_at'] = date('Y-m-d H:i:s', $value['created_at']); $value['audit_time'] = date('Y-m-d H:i:s', $value['updated_at']); if ($value['status'] == 2 || $value['status'] == 4) { $value['audit_time'] = date('Y-m-d H:i:s', $value['pay_time']); } } return $this->asJson([ 'code' => 0, 'msg' => 'success', 'data' => [ 'list' => $list, 'pageNo' => $pagination['pageNo'], 'totalCount' => $pagination['totalCount'] ] ]); } /** * 获取提现详情 */ public function actionCashDetailInfo() { $id = get_params('id'); $store_cash = StoreCash::findOne($id); if (!$store_cash) { return $this->asJson([ 'code' => 1, 'msg' => '提现记录不存在' ]); } // $wechat = getServiceClientWxConfig(); // if (!$wechat) { // return $this->asJson([ // 'code' => 1, // 'msg' => '未开启微信提现功能' // ]); // } $platform_mch_appid = Option::get('platform_mch_appid', 0, 'saas')['value']; $platform_mch_id = Option::get('platform_mch_id', 0, 'saas')['value']; // $serial_no = Option::get('platform_mch_api_serial_no', 0, 'saas')['value']; // if (empty($serial_no)) { // return $this->asJson([ // 'code' => 1, // 'msg' => '未开启微信提现功能' // ]); // } $saasUser = null; $name = $store_cash->name ?: ''; if (intval($store_cash->type) === StoreCash::TYPE_WECHAT_AUTO) { $storeAdmin = Admin::findOne([ 'type' => 'store', 'type_id' => $store_cash->store_id, 'is_delete' => 0, ]); if ($storeAdmin) { $saasUser = SaasUser::findOne($storeAdmin->saas_user_id); if ($saasUser) { $name = $saasUser->name; } } } $package = ''; if (!empty($store_cash->wx_cash_result_info)) { $wx_cash_result_info = json_decode($store_cash->wx_cash_result_info, true); $package = $wx_cash_result_info['package_info']; } $is_user_confirm = 1; $status = $store_cash->status; //如果是微信提现且为自动打款 if ($store_cash->type == StoreCash::TYPE_WECHAT_AUTO && $store_cash->status == Cash::STATUS_GIVEN) { //如果使用的是微信新版打款方式 if (1 || intval($store_cash->wx_cash_type)) { //如果微信新版状态是等待用户确认 if ($store_cash->wx_cash_state == 'WAIT_USER_CONFIRM') { $is_user_confirm = 0; if ($saasUser->id != get_saas_user_id()) { $is_user_confirm = 1; } // $status = Cash::STATUS_CONFIRM; } } } $price = StoreCash::getServiceMoney($store_cash); $data = [ 'type' => StoreCash::$type[$store_cash->type],//提现方式 'status' => $status,//提现状态 'order_no' => $store_cash->order_no, 'created_at' => date('Y-m-d H:i:s', $store_cash->created_at), 'updated_at' => $store_cash->updated_at > 0 ? date('Y-m-d H:i:s', $store_cash->updated_at) : '', 'name' => $name, 'appid' => $platform_mch_appid, 'mch_id' => $platform_mch_id, 'package' => $package, 'is_user_confirm' => $is_user_confirm, 'price' => $price, ]; return $this->asJson([ 'code' => 0, 'msg' => 'success', 'data' => $data ]); } //商城账户余额信息 public function actionStoreMoney() { $store_id = $this->store_id; $store = \app\models\Store::findOne($store_id); $data = []; $maxMoney = StoreCash::getMaxCash($store, $data); // 已提现 $moneyCash = StoreCash::find()->where(['store_id' => $store->id, 'is_delete' => 0, 'status' => 2, 'cash_type' => StoreCash::CASH_TYPE_NORMAL]) ->andWhere(['>', 'price', 0]) ->sum('price'); $yunstFreeZenAmount = 0; $yunstMaxMoney = 0; $yunstMoneyTotal = 0; if ($store->cusid){ //查询余额账户信息 $orderYunst = new OrderYunst(); // print_r(111);die; $res = $orderYunst->queryAcctInfo($store->store_number); // $res = $orderYunst->queryAcctInfo('XDQXCJSZPJYB'); // print_r($res);die; if ($res['subCode']=='SUCCESS' ){ // print_r($res);die; $yunstFreeZenAmount = $res['data']['freezenAmount'];//冻结 $amount = $res['data']['amount'];//可用余额 if (($yunstFreeZenAmount + $amount) >0){ $yunstMoneyTotal = ($yunstFreeZenAmount + $amount) / 100; }else{ $yunstMoneyTotal = 0; } $yunstFreeZenAmount = $yunstFreeZenAmount? $yunstFreeZenAmount/100 : 0;;//冻结 $yunstMaxMoney = $amount?$amount/100:0;//账户总金额 可提现的 } } return $this->asJson([ 'code' => 0, 'msg' => 'ok', 'data' => [ 'max_cash' => $maxMoney,//总计提现 'moneyFrozen' => $data['moneyFrozen'],//冻结金额 'moneyCash' => $moneyCash,//可提现 'moneyTotal' => bcadd($data['storeMoneyTotal'], $yunstMoneyTotal, 2),//累计金额 'yunstFreeZenAmount' => $yunstFreeZenAmount,//通联冻结 'yunstMaxMoney' => $yunstMaxMoney,//通联账户总金额 'yunstMoneyTotal' => $yunstMoneyTotal, //通联冻结+账户可提现 'league_price' => $store->league_price, ] ]); } /** * 商城账户明细列表 * @return \yii\web\Response */ public function actionStoreAccountLogList() { $store_id = $this->store_id; $start_time = get_params('start_time'); $end_time = get_params('end_time'); $type = get_params('type'); $query = StoreAccountLog::find()->alias('c'); $store_id > 0 && $query->andWhere(['c.store_id' => $store_id]); if ($start_time) { $query->andWhere(['>=', 'c.time', strtotime($start_time)]); } if ($end_time) { $query->andWhere(['<=', 'c.time', strtotime($end_time)]); } if ($type > 0) { $query->andWhere(['c.type' => $type]); } $query->orderBy('c.id DESC'); $pagination = pagination_make($query); $list = $pagination['list']; return $this->asJson([ 'code' => 0, 'msg' => 'success', 'data' => [ 'data' => $list, 'pageNo' => $pagination['pageNo'], 'totalCount' => $pagination['totalCount'] ], ]); } /** * 获取商城溢价 */ public function actionStoreSetting() { $form = new StoreAdminForm(); $form->store_id = $this->store_id; $form->rate = post_params('rate'); // $form->is_auth_trans = post_params('is_auth_trans'); $form->cloud_is_update = post_params('cloud_is_update'); $res = $form->storeSetting(); return $this->asJson($res); } //核销支付宝商家券 public function actionClerkAlipayVoucher() { $form = new \app\modules\admin\models\alipay\Ordervoucher(); $form->mini_id = get_mini_id(); $form->store_id = get_store_id(); $form->user_id = get_user_id(); $total_price = post_params('total_price', 100); $ov = post_params('ov', ''); $submit = post_params('submit', 1); $res = $form->use($submit, $ov, $total_price); return $this->asJson($res); } //扫码入库 public function actionErpScanGetGoodsList() { $form = new StoreAdminGoodsForm(); $form->attributes = get_params(); $form->store_id = $this->store_id; $res = $form->erpScanGetGoodsList(); return $this->asJson($res); } //erp入库 public function actionPurchaseInSave() { $form = new StoreAdminGoodsForm(); $form->attributes = all_params(); $form->store_id = $this->store_id; $res = $form->purchaseInSave(); return $this->asJson($res); } }