Reconciliation.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\merchant\store\order;
  12. use think\App;
  13. use crmeb\basic\BaseController;
  14. use app\common\repositories\system\merchant\MerchantRepository;
  15. use app\common\repositories\store\order\MerchantReconciliationRepository as repository;
  16. class Reconciliation extends BaseController
  17. {
  18. protected $repository;
  19. public function __construct(App $app,repository $repository)
  20. {
  21. parent::__construct($app);
  22. $this->repository = $repository;
  23. }
  24. /**
  25. * 获取列表数据
  26. *
  27. * @return \think\response\Json
  28. */
  29. public function lst()
  30. {
  31. [$page, $limit] = $this->getPage();
  32. $where = $this->request->params(['date', 'status', 'is_accounts', 'reconciliation_id', 'keyword']);
  33. // 添加商家ID条件
  34. $where['mer_id'] = $this->request->merId();
  35. return app('json')->success($this->repository->getList($where, $page, $limit));
  36. }
  37. /**
  38. * 确认订单
  39. * @param $id
  40. * @return mixed
  41. * @author Qinii
  42. * @day 2020-06-15
  43. */
  44. public function switchStatus($id)
  45. {
  46. if(!$this->repository->merWhereCountById($id,$this->request->merId()))
  47. return app('json')->fail('数据不存在或状态错误');
  48. $status = ($this->request->param('status') == 1) ? 1 : 2;
  49. $data['status'] = $status;
  50. $data['mer_admin_id'] = $this->request->merId();
  51. $this->repository->switchStatus($id,$data);
  52. return app('json')->success('修改成功');
  53. }
  54. /**
  55. * 标记表单
  56. *
  57. * @param int $id 表单ID
  58. * @return \think\response\Json
  59. */
  60. public function markForm($id)
  61. {
  62. if (!$this->repository->getWhereCount([$this->repository->getPk() => $id, 'mer_id' => $this->request->merId()]))
  63. return app('json')->fail('数据不存在');
  64. // 返回标记后的表单数据
  65. return app('json')->success(formToData($this->repository->markForm($id)));
  66. }
  67. /**
  68. * 标记
  69. *
  70. * @param int $id 表单ID
  71. * @return \think\response\Json
  72. */
  73. public function mark($id)
  74. {
  75. if (!$this->repository->getWhereCount([$this->repository->getPk() => $id, 'mer_id' => $this->request->merId()]))
  76. return app('json')->fail('数据不存在');
  77. // 获取备注信息
  78. $data = $this->request->params(['mark']);
  79. $this->repository->update($id, $data);
  80. // 返回成功信息
  81. return app('json')->success('备注成功');
  82. }
  83. }