MoneyLog.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\model\StockConfig;
  4. use app\common\model\ShopList;
  5. use app\common\model\StockLog;
  6. use think\exception\ValidateException;
  7. use app\api\validate\Stock as StockValidate;
  8. use app\common\model\StockDetail;
  9. use think\facade\Db;
  10. //记账记录表
  11. class MoneyLog extends Base
  12. {
  13. //首页数据分组统计品种
  14. public function index(StockLog $stockLog)
  15. {
  16. $data= $stockLog->where('user_id', $this->userinfo['id'])
  17. ->field('type,count(id) as count')
  18. ->group('type')
  19. ->select();
  20. $this->success('ok', $data);
  21. }
  22. //记账
  23. public function money(StockConfig $stockConfig, StockDetail $stockDetail)
  24. {
  25. $result = [];
  26. $list = $stockConfig->where('status', $stockConfig::StatusNormal)->field('id,type_id,title')
  27. ->orderRaw("field('variety_name','packing_box','material')")->select();
  28. $this->success('ok', $result);
  29. }
  30. /**
  31. * @return void 全部类型图标
  32. */
  33. public function getConfig()
  34. {
  35. $type = $this->request->post('type/s', 'bank_account');
  36. if(!in_array($type, ['bank_account', 'money_in_type', 'money_out_type'])) $this->error('参数有误');
  37. $this->success('提交成功', site_config('addonsd.'.$type));
  38. }
  39. }