截流自动化的商城平台
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

IntegralOrderValidate.php 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. namespace app\api\validate;
  3. use app\common\basics\Validate;
  4. use app\common\enum\IntegralGoodsEnum;
  5. use app\common\enum\IntegralOrderEnum;
  6. use app\common\enum\PayEnum;
  7. use app\common\model\integral\IntegralOrder;
  8. /**
  9. * 积分订单验证
  10. * Class IntegralOrderValidate
  11. * @package app\api\validate
  12. */
  13. class IntegralOrderValidate extends Validate
  14. {
  15. protected $rule = [
  16. 'id' => 'require|number|checkOrder',
  17. ];
  18. protected $message = [
  19. 'id.require' => '参数缺失',
  20. 'id.number' => '参数类型错误',
  21. ];
  22. public function sceneDetail()
  23. {
  24. return $this->only(['id']);
  25. }
  26. public function sceneCancel()
  27. {
  28. return $this->only(['id'])->append('id', 'checkCancel');
  29. }
  30. public function sceneConfirm()
  31. {
  32. return $this->only(['id'])->append('id', 'checkConfirm');
  33. }
  34. public function sceneTraces()
  35. {
  36. return $this->only(['id']);
  37. }
  38. public function sceneDel()
  39. {
  40. return $this->only(['id'])->append('id','checkDel');
  41. }
  42. // 验证订单
  43. protected function checkOrder($value, $rule, $data)
  44. {
  45. $condition = ['id' => $value, 'user_id' => $data['user_id']];
  46. $order = IntegralOrder::where($condition)->findOrEmpty();
  47. if ($order->isEmpty()) {
  48. return '订单不存在';
  49. }
  50. if ($order['del'] == 1) {
  51. return '订单已删除';
  52. }
  53. return true;
  54. }
  55. protected function checkConfirm($value, $rule, $data)
  56. {
  57. $order = IntegralOrder::findOrEmpty($value);
  58. if ($order['order_status'] < IntegralOrderEnum::ORDER_STATUS_DELIVERY) {
  59. return '订单未发货';
  60. }
  61. if ($order['order_status'] == IntegralOrderEnum::ORDER_STATUS_COMPLETE) {
  62. return '订单已完成';
  63. }
  64. return true;
  65. }
  66. public function checkDel($value, $rule, $data)
  67. {
  68. $order = IntegralOrder::findOrEmpty($value);
  69. // 订单状态为 已关闭 且 [未支付 或者 已退款才可以删除]
  70. if ($order['order_status'] == IntegralOrderEnum::ORDER_STATUS_DOWN) {
  71. if ($order['pay_status'] == PayEnum::UNPAID || $order['refund_status'] == 1) {
  72. return true;
  73. }
  74. }
  75. return '订单不可删除';
  76. }
  77. // 取消
  78. public function checkCancel($value, $rule, $data)
  79. {
  80. $order = IntegralOrder::findOrEmpty($value);
  81. $goods_snap = $order['goods_snap'];
  82. // 商品类型为红包的不可取消
  83. if ($goods_snap['type'] == IntegralGoodsEnum::TYPE_BALANCE) {
  84. return '此订单不可取消';
  85. }
  86. if ($order['order_status'] >= IntegralOrderEnum::ORDER_STATUS_GOODS) {
  87. return '此订单不可取消';
  88. }
  89. return true;
  90. }
  91. }