| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace app\api\controller;
- use app\common\model\StockConfig;
- use app\common\model\MoneyLog as MonuyModel;
- use app\common\model\StockLog;
- use think\exception\ValidateException;
- use app\api\validate\Money as MoneyValidate;
- use app\common\model\StockDetail;
- use think\facade\Db;
- //记账记录表
- class MoneyLog extends Base
- {
- //记账记录
- public function moneylog(MonuyModel $monuyModel)
- {
- $time = $this->request->post('time/d', date('Y-m'));
- $result['count'] = $monuyModel::getCountBalance($this->userinfo['id'], $time);
- $result['list'] = $monuyModel->where('user_id', $this->userinfo['id'])
- ->whereMonth('create_date', $time)
- ->order('id desc')
- //->group('create_date')
- ->paginate(10);
- $this->success('ok', $result);
- }
- //添加记账
- public function money(MonuyModel $monuyModel)
- {
- $data = $this->request->post();
- $result = false;
- Db::startTrans();
- try {
- validate(MoneyValidate::class)->scene('add')->check($data);
-
- //发货数据
- $data['user_id'] = $this->userinfo['id'];
- $result = $monuyModel::create($data);
- Db::commit();
- }catch (ValidateException $e) {
- Db::rollback();
- return $this->error($e->getError());
- } catch (\Exception $e) {
- Db::rollback();
- $this->error($e->getMessage());
- }
- if ($result === false) {
- $this->error(__('没有新增任何数据'));
- }
- $this->success();
- }
- /**
- * @return void 全部类型图标
- */
- public function getConfig()
- {
- $type = $this->request->post('type/s', 'bank_account');
- if(!in_array($type, ['bank_account', 'money_in_type', 'money_out_type'])) $this->error('参数有误');
- $this->success('提交成功', site_config('addonsd.'.$type));
- }
-
-
- }
|