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

190 行
4.8 KiB

  1. <?php
  2. namespace backend\modules\zzcs\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "order_title_cancel_request".
  6. *
  7. * @property integer $id
  8. * @property integer $order_title_id
  9. * @property integer $from_org_id
  10. * @property string $create_time
  11. * @property string $update_time
  12. * @property integer $request_status
  13. * @property string $limit_time
  14. * @property string $operate_user_id
  15. */
  16. class OrderTitleCancelRequest extends \yii\db\ActiveRecord
  17. {
  18. /**
  19. * @inheritdoc
  20. */
  21. public static function tableName()
  22. {
  23. return 'order_title_cancel_request';
  24. }
  25. /**
  26. * @inheritdoc
  27. */
  28. public function rules()
  29. {
  30. return [
  31. [['order_title_id', 'from_org_id', 'request_status'], 'integer'],
  32. [['create_time', 'update_time', 'limit_time', 'operate_user_id'], 'string', 'max' => 20],
  33. [['sequence_id', 'last_time'], 'string', 'max' => 30],
  34. ];
  35. }
  36. /**
  37. * @inheritdoc
  38. */
  39. public function attributeLabels()
  40. {
  41. return [
  42. 'id' => 'ID',
  43. 'order_title_id' => 'Order Title ID',
  44. 'from_org_id' => 'From Org ID',
  45. 'create_time' => 'Create Time',
  46. 'update_time' => 'Update Time',
  47. 'request_status' => 'Request Status',
  48. 'limit_time' => 'Limit Time',
  49. 'operate_user_id' => 'Operate User ID',
  50. 'sequence_id' => 'sequence_id',
  51. 'last_time' => 'last_time'
  52. ];
  53. }
  54. /**
  55. * Function Description:筛选即将过期的待审核订单
  56. * Function Name: check_cancel_request
  57. * @return array
  58. *
  59. * @author 冒炎
  60. */
  61. public function check_cancel_request()
  62. {
  63. $today = date('Y-m-d');
  64. $yesterday = date('Y-m-d', strtotime('-1 day'));
  65. $select = [
  66. 'order_title_id',
  67. 'create_time',
  68. 'limit_time',
  69. 'last_time'
  70. ];
  71. $where = ['and', ['=', 'request_status', 1]];
  72. $where[] = ['or', ['like', 'create_time', $today], ['like', 'create_time', $yesterday]];
  73. $recent_arr = self::find()
  74. ->select($select)
  75. ->from(self::tableName())
  76. ->where($where)
  77. ->orderBy('create_time asc')
  78. ->asArray()
  79. ->all();
  80. $arr = [];
  81. foreach ($recent_arr as $val) {
  82. if((strtotime($val['last_time'])-time())<300){
  83. $arr[] = $val['order_title_id'];
  84. }
  85. }
  86. return $arr;
  87. }
  88. /**
  89. * Des:获取最后的申请记录
  90. * Name: getLastInfo
  91. * @param $order_id
  92. * @return array
  93. * @author 倪宗锋
  94. */
  95. public function getLastInfo($order_id)
  96. {
  97. $select = [
  98. 'id',
  99. 'order_title_id',
  100. 'from_org_id',
  101. 'create_time',
  102. 'update_time',
  103. 'request_status',
  104. 'limit_time',
  105. 'operate_user_id',
  106. 'sequence_id'
  107. ];
  108. $where = ['=', 'order_title_id', $order_id];
  109. $getInfo = self::find()->select($select)
  110. ->where($where)
  111. ->orderBy('id desc')
  112. ->limit(1)
  113. ->asArray()
  114. ->one();
  115. return $getInfo;
  116. }
  117. /**
  118. * Des:添加记录
  119. * Name: addRow
  120. * @param $params
  121. * @return int
  122. * @author 倪宗锋
  123. */
  124. public function addRow($params)
  125. {
  126. $values = [
  127. 'order_title_id' => $params['order_title_id'],
  128. 'from_org_id' => $params['from_org_id'],
  129. 'create_time' => $params['create_time'],
  130. 'limit_time' => $params['limit_time'],
  131. 'last_time' => $params['last_time'],
  132. 'sequence_id' => $params['sequence_id']
  133. ];
  134. $tab = clone $this;
  135. $tab->attributes = $values;
  136. $res = $tab->insert();
  137. if ($res == false) {
  138. return 0;
  139. }
  140. return $tab->id;
  141. }
  142. /**
  143. * Des:修改
  144. * Name: updateStatusById
  145. * @param $params
  146. * @param $id
  147. * @return bool
  148. * @author 倪宗锋
  149. */
  150. public function updateStatusById($params, $id)
  151. {
  152. $flag = self::updateAll($params, 'id=:id', array(':id' => $id));
  153. if ($flag == false) {
  154. return false;
  155. }
  156. return true;
  157. }
  158. /***
  159. * Des: 获取超时的取消申请
  160. * Name: getCancelOutTimes
  161. * @return array
  162. * @author 倪宗锋
  163. */
  164. public function getCancelOutTimes()
  165. {
  166. $select = ['order_title_id'];
  167. $where = [
  168. 'and',
  169. ['=', 'request_status', 1],
  170. ['<', 'last_time', date('Y-m-d H:i:s')]
  171. ];
  172. $getList = self::find()->select($select)->distinct()
  173. ->where($where)
  174. ->asArray()
  175. ->all();
  176. return $getList;
  177. }
  178. }