WithdrawSetController.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /****************************************************************
  3. * Author: libaojia
  4. * Date: 2017/11/14 上午9:58
  5. * Email: livsyitian@163.com
  6. * QQ: 995265288
  7. * User: 芸众商城 www.yunzshop.com
  8. ****************************************************************/
  9. namespace app\backend\modules\finance\controllers;
  10. use app\backend\modules\finance\models\Withdraw;
  11. use app\backend\modules\withdraw\models\WithdrawRichText;
  12. use app\common\components\BaseController;
  13. use app\common\facades\Setting;
  14. use app\common\helpers\Url;
  15. class WithdrawSetController extends BaseController
  16. {
  17. public function see()
  18. {
  19. $set = Setting::get('withdraw.balance');
  20. $resultModel = \YunShop::request()->withdraw;
  21. if ($resultModel) {
  22. $validator = null;
  23. foreach ($resultModel as $key => $item) {
  24. $validator = (new Withdraw())->validator($item);
  25. if ($validator->fails()) {
  26. $this->error($validator->messages());
  27. break;
  28. }
  29. }
  30. if ($validator && !$validator->fails()) {
  31. foreach ($resultModel as $key => $item) {
  32. if ($key == 'balance') {
  33. (new \app\common\services\operation\BalanceSetLog(['type'=> 'withdraw.balance','old'=>Setting::get('withdraw.'.$key),'new'=>$item], 'update'));
  34. } elseif ($key == 'income') {
  35. (new \app\common\services\operation\IncomeSetLog(['old'=>Setting::get('withdraw.'.$key),'new'=>$item], 'update'));
  36. // 去空值
  37. foreach($item['servicetax'] as $k=>$v){
  38. $item['servicetax'][$k] = array_filter($v);
  39. }
  40. $item['servicetax'] = array_filter($item['servicetax']);
  41. WithdrawRichText::createOrUpdate($item['withdraw_rich_text']);
  42. }
  43. Setting::set('withdraw.' . $key, $item);
  44. }
  45. return $this->message('设置保存成功', Url::absoluteWeb('finance.withdraw-set.see'));
  46. }
  47. }
  48. return view('finance.withdraw.withdraw-set', [
  49. 'set' => $set,
  50. ])->render();
  51. }
  52. }