Purchease.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace app\admin\controller;
  3. use think\App;
  4. class Purchease extends Base
  5. {
  6. public function __construct(App $app)
  7. {
  8. parent::__construct($app);
  9. $this->model = new \app\admin\model\PurcheaseOrder();
  10. }
  11. public function list(){
  12. }
  13. //批量同步到结算
  14. public function SyscnToSettle(){
  15. $params = $this->request->param(['idArr'=>[]],"post","trim");
  16. $valid = $this->validate($params,[
  17. 'idArr|订单编号'=>'require|array'
  18. ]);
  19. if($valid!==true) return error($valid);
  20. $orderArr = $this->model->whereIn("id",$params['idArr'])->select();
  21. if($orderArr->isEmpty()) return error("订单不存在");
  22. $this->model->startTrans();
  23. try{
  24. $up=$this->model->whereIn("id",$params['idArr'])->save(["update_time"=>date("Y-m-d H:i:s")]);
  25. if($up===false) throw new \Exception("更新失败");
  26. $this->model->commit();
  27. }catch (\Exception $e){
  28. $this->model->rollback();
  29. return error($e->getMessage());
  30. }
  31. return success("批量同步提交成功");
  32. }
  33. }