截流自动化的商城平台
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

IntegralOrderValidate.php 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop开源商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | gitee下载:https://gitee.com/likeshop_gitee
  7. // | github下载:https://github.com/likeshop-github
  8. // | 访问官网:https://www.likeshop.cn
  9. // | 访问社区:https://home.likeshop.cn
  10. // | 访问手册:http://doc.likeshop.cn
  11. // | 微信公众号:likeshop技术社区
  12. // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
  13. // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
  14. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  15. // | likeshop团队版权所有并拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshop.cn.team
  18. // +----------------------------------------------------------------------
  19. namespace app\admin\validate\integral;
  20. use app\common\basics\Validate;
  21. use app\common\enum\IntegralGoodsEnum;
  22. use app\common\enum\IntegralOrderEnum;
  23. use app\common\model\integral\IntegralOrder;
  24. class IntegralOrderValidate extends Validate
  25. {
  26. protected $rule = [
  27. 'id' => 'require',
  28. ];
  29. protected $message = [
  30. 'id.require' => '参数错误',
  31. ];
  32. public function sceneDeliveryHandle()
  33. {
  34. return $this->only(['id'])
  35. ->append('id','checkDeliveryHandle');
  36. }
  37. public function sceneConfirm()
  38. {
  39. return $this->only(['id'])
  40. ->append('id','checkConfirm');
  41. }
  42. public function sceneCancel()
  43. {
  44. return $this->only(['id'])
  45. ->append('id','checkCancel');
  46. }
  47. /**
  48. * @notes 检验订单能否发货
  49. * @param $value
  50. * @param $rule
  51. * @param $data
  52. * @return bool|string
  53. * @author ljj
  54. * @date 2022/3/3 12:06 下午
  55. */
  56. public function checkDeliveryHandle($value,$rule,$data)
  57. {
  58. $result = IntegralOrder::where(['id'=>$value,'del'=>0])->findOrEmpty()->toArray();
  59. if (!$result) {
  60. return '订单不存在';
  61. }
  62. if ($result['delivery_way'] == 0) {
  63. return '订单无需快递';
  64. }
  65. if (!isset($data['shipping_id']) || $data['shipping_id'] == '') {
  66. return '请选择快递';
  67. }
  68. if (!isset($data['invoice_no']) || $data['invoice_no'] == '') {
  69. return '请输入快递单号';
  70. }
  71. if ($result['shipping_status'] == 1) {
  72. return '订单已发货';
  73. }
  74. if ($result['order_status'] != IntegralOrderEnum::ORDER_STATUS_DELIVERY) {
  75. return '订单状态不正确,无法发货';
  76. }
  77. return true;
  78. }
  79. /**
  80. * @notes 检验订单能否确认收货
  81. * @param $value
  82. * @param $rule
  83. * @param $data
  84. * @return bool|string
  85. * @author ljj
  86. * @date 2022/3/3 3:37 下午
  87. */
  88. public function checkConfirm($value,$rule,$data)
  89. {
  90. $result = IntegralOrder::where(['id'=>$value,'del'=>0])->findOrEmpty()->toArray();
  91. if (!$result) {
  92. return '订单不存在';
  93. }
  94. if ($result['order_status'] != IntegralOrderEnum::ORDER_STATUS_GOODS) {
  95. return '订单状态不正确,无法确认收货';
  96. }
  97. return true;
  98. }
  99. /**
  100. * @notes 取消订单验证
  101. * @param $value
  102. * @param $rule
  103. * @param $data
  104. * @return bool|string
  105. * @author 段誉
  106. * @date 2022/3/3 17:58
  107. */
  108. public function checkCancel($value, $rule, $data)
  109. {
  110. $order = IntegralOrder::findOrEmpty($value);
  111. $goods_snap = $order['goods_snap'];
  112. if ($order->isEmpty()) {
  113. return '订单不存在';
  114. }
  115. // 商品类型为红包的不可取消
  116. if ($goods_snap['type'] == IntegralGoodsEnum::TYPE_BALANCE) {
  117. return '类型为红包的订单不可取消';
  118. }
  119. if ($order['order_status'] >= IntegralOrderEnum::ORDER_STATUS_GOODS) {
  120. return '已发货订单不可取消';
  121. }
  122. return true;
  123. }
  124. }