OrderGoods.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\console\model;
  13. use app\common\enum\order\DeliveryStatus;
  14. use app\common\enum\order\PayStatus as PayStatusEnum;
  15. use app\common\enum\order\ReceiptStatus;
  16. use app\common\model\OrderGoods as OrderGoodsModel;
  17. use app\common\enum\order\orderGoods\FrozenStatus as FrozenStatusEnum;
  18. /**
  19. * 订单商品模型
  20. * Class OrderGoods
  21. * @package app\console\model
  22. */
  23. class OrderGoods extends OrderGoodsModel
  24. {
  25. /**
  26. * 批量解冻订单商品
  27. * @param array $orderGoodsIds
  28. * @return false|int
  29. */
  30. public function onUpdateFrozen(array $orderGoodsIds)
  31. {
  32. return $this->onBatchUpdate($orderGoodsIds, [
  33. 'frozen_status'=>FrozenStatusEnum::NOT_FROZEN,
  34. ]);
  35. }
  36. /**
  37. * 查询截止时间未确认收货的订单列表
  38. * @param int $storeId 商城ID
  39. * @param int $deadlineTime 截止时间
  40. * @return array
  41. */
  42. public function getOrderGoodsListByReceive(int $storeId, int $deadlineTime)
  43. {
  44. // 查询条件
  45. $filter = [
  46. ['g.delivery_status', '=', DeliveryStatus::DELIVERED],
  47. ['g.receipt_status', '=', ReceiptStatus::NOT_RECEIVED],
  48. ['g.auto_receipt_time', '<=', $deadlineTime],
  49. ['g.auto_receipt_time', '>', 0]
  50. ];
  51. // 查询列表记录
  52. return $this->getList($storeId, $filter);
  53. }
  54. /**
  55. * 获取订单ID集
  56. * @param int $storeId 商城ID
  57. * @param array $filter
  58. * @return array
  59. */
  60. public function getList(int $storeId, $filter = [])
  61. {
  62. return $this->alias('g')->field('g.order_id,g.order_goods_id')
  63. ->leftJoin('order','order.order_id=g.order_id')
  64. ->where($filter)
  65. ->where('order.pay_status',PayStatusEnum::SUCCESS)
  66. ->where('g.store_id', '=', $storeId)
  67. ->where('order.is_delete', '=', 0)
  68. ->select();
  69. }
  70. /**
  71. * 批量更新订单商品状态为已收货
  72. * @param array $orderGoodsIds
  73. * @return false|int
  74. */
  75. public function onUpdateReceived(array $orderGoodsIds)
  76. {
  77. return $this->onBatchUpdate($orderGoodsIds, [
  78. 'receipt_status' => ReceiptStatus::RECEIVED,
  79. 'receipt_time' => time(),
  80. // 'order_status' => OrderStatusEnum::COMPLETED
  81. ]);
  82. }
  83. }