request->get(); $query = xhDrawCash::find(); $query->where(['merchantId' =>$this->merchantId]); $countQuery = clone $query; $count = $countQuery->count(); $page = isset($get['page']) ? $get['page'] : 1; $pageSize = 20; $offset = ($page - 1) * $pageSize; $models = $query->offset($offset)->orderBy('createTime desc')->limit($pageSize)->asArray()->all(); $page = new page($count,$page,$pageSize); $paging = $page->fpage(); $now = time(); return $this->render('list', ['models' => $models,'paging' => $paging]); } /** * 进行提现操作,全额提现 */ public function actionExec() { $connection = Yii::$app->db;//事务处理 $transaction = $connection->beginTransaction(); try { $merchantAsset = $this->merchantAsset; $amount = $merchantAsset['balance']; if($amount <= 0){ util::failInfo('余额不足'); } $mBalance = stringUtil::calcSub($merchantAsset['balance'], $amount); $newFreezeBalance = stringUtil::calcAdd($merchantAsset['freezeBalance'],$amount); $date = date("Y-m-d H:i:s"); $id = stringUtil::generateMerchantCashOrderNo($this->merchantId); $cashData = ['id'=>$id,'amount'=>$amount,'merchantId'=>$this->merchantId,'balance'=>$mBalance,'addTime'=>time(),'createTime'=>$date]; $order = xhDrawCashService::add($cashData); $orderId = $order['id']; xhMerchantAssetService::updateByMerchantId($this->merchantId, ['balance'=>$mBalance,'freezeBalance'=>$newFreezeBalance]); $now = time(); $capitalTypeArray = configDict::getConfig('capitalType','xhDrawCash'); $capitalType = $capitalTypeArray['id']; $mIncome = $merchantAsset['totalIncome']; $mExpend = $merchantAsset['totalExpend']; $payWay = configDict::getConfig('payWay','other'); $capitalData = [ 'relateId' => (string)$orderId, 'balance' => $mBalance, 'totalIncome' => $mIncome, 'totalExpend' => $mExpend, 'amount' => $amount, 'io' => 0, 'payWay' => $payWay, 'event' => '申请提现', 'merchantId' => $this->merchantId, 'userId' => 0, 'userName' => '', 'alipayId' => '', 'affectBalance' => 1,//会影响商家的余额 'createTime' => $date, 'addTime' => $now, 'capitalType' => $capitalType, 'operateId' => $this->adminId, ]; xhMerchantCapitalService::add($capitalData);//商家资金流水记录增加 /* $wxOpenId = configDict::getConfig('openId'); $open = xhWxOpenService::getById($wxOpenId); $merchantId = $open['merchantId']; $adminId = $open['adminId']; $merchant = xhMerchantService::getById($merchantId); $openAdmin = xhWxOpenAdminService::getById($adminId); $openId = $openAdmin['openId']; $shortTempId = 'OPENTM200605630';//任务处理通知 $allTM = xhTMessageService::getList($merchantId); $tempId = $allTM[$shortTempId]; $data = [ "touser" => $openId, "template_id" => $tempId, "url" => "", "data" => [ "first" => ["value" => $merchant['merchantName'].'申请提现'.$amount.'元',"color" => "#173177"], "keyword1" => ["value" => "商家提现","color" => "#173177"], "keyword2" => ["value" => "待办","color" => "#173177"], "remark" => ["value" => "请及时处理","color" => "#173177"]]]; weixinUtil::sendTaskInform($data,$merchant); */ xhCommonService::sendMobileMsg('15280215347','有客户申请提现,请及时处理'); $transaction->commit(); util::successInfo(); }catch (Exception $e) { $transaction->rollBack(); util::failInfo(); } } }