refill_exception.model.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. defined('InShopNC') or exit('Access Invalid!');
  3. class refill_exception_type
  4. {
  5. const EUnKnown = 0; //不确定的
  6. const EOfficialSN = 1; //错误的流水号,过短,过长,以及风险流水号
  7. const ERefundOrder = 2; //检测出来的,统付返销
  8. const EqualOfficialSN = 3; // 相同流水号
  9. }
  10. class refill_exceptionModel extends Model
  11. {
  12. public function __construct()
  13. {
  14. parent::__construct('refill_exception');
  15. }
  16. public function getExceptionList($condition, $pagesize = '',$total = 0, $field = '*', $order = 'order_time desc', $limit = '', $master = false)
  17. {
  18. $list = $this->table('refill_exception,refill_order')
  19. ->field($field)->where($condition)
  20. ->join('inner')->on('refill_exception.order_id=refill_order.order_id')
  21. ->page($pagesize,$total)->order($order)->limit($limit)->master($master)->select();
  22. if (empty($list)) return [];
  23. return $list;
  24. }
  25. public function setHandled($exc_id, $update)
  26. {
  27. $update['except_state'] = 1;
  28. return $this->table('refill_exception')->where(['except_id' => $exc_id])->update($update);
  29. }
  30. public function add_except($datas)
  31. {
  32. return $this->insert($datas);
  33. }
  34. public function exist_order($order_sn)
  35. {
  36. $item = $this->field('*')->where(['order_sn' => $order_sn])->find();
  37. return !empty($item);
  38. }
  39. public function getAllExceptionOrders($condition)
  40. {
  41. $len = 1000;
  42. $i = 0;
  43. $orders = [];
  44. while (true)
  45. {
  46. $start = $i * $len;
  47. $items = $this->table('refill_exception')
  48. ->where($condition)
  49. ->order('oper_time desc')
  50. ->limit("{$start},{$len}")
  51. ->select();
  52. $orders = array_merge($orders,$items);
  53. if (empty($items) || count($items) < $len) {
  54. break;
  55. }
  56. $i++;
  57. }
  58. return $orders;
  59. }
  60. }