1
0

OrderEffectiveLogLogic.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\api\logic;
  15. use app\common\model\orders\OrderEffectiveLog;
  16. use app\common\logic\BaseLogic;
  17. use think\facade\Db;
  18. /**
  19. * OrderEffectiveLog逻辑
  20. * Class OrderEffectiveLogLogic
  21. * @package app\api\logic
  22. */
  23. class OrderEffectiveLogLogic extends BaseLogic
  24. {
  25. /**
  26. * @notes 提交保修工单申请
  27. */
  28. public static function submitEffective(array $params): bool
  29. {
  30. //Db::startTrans();
  31. try {
  32. $info = OrderEffectiveLog::find($params['id']);
  33. if($info['end_effective_time'] < time()){
  34. throw new \Exception('该保修卡已过期');
  35. }
  36. if($info['effective_status'] > 0){
  37. throw new \Exception('该保修卡已提交过');
  38. }
  39. OrderEffectiveLog::where('id', $params['id'])->update([
  40. 'effective_images' => json_encode($params['effective_images']),
  41. 'remark' => $params['remark'] ?? '',
  42. 'effective_status' => 1,
  43. 'effective_time' => time()
  44. ]);
  45. //Db::commit();
  46. return true;
  47. } catch (\Exception $e) {
  48. //Db::rollback();
  49. self::setError($e->getMessage());
  50. return false;
  51. }
  52. }
  53. }