OrderTuanzhang.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class OrderTuanzhang extends Model
  5. {
  6. protected $connection = 'mysql';
  7. protected $pk = 'id';
  8. protected $name = 'order_tuanzhang';
  9. public static function getuuid($order_id)
  10. {
  11. $tuanzhang = self::where('order_id', $order_id)->order('id desc')->find();
  12. return $tuanzhang->uuid;
  13. }
  14. public static function is_tuanzhang($order_id)
  15. {
  16. $tuanzhang = self::where('order_id', $order_id)->order('id desc')->find();
  17. return $tuanzhang->id;
  18. }
  19. public static function timesremain($order_id)
  20. {
  21. return self::where(['order_id' => $order_id, 'is_complete' => 0])->count();
  22. }
  23. public static function timesused($order_id)
  24. {
  25. return self::where(['order_id' => $order_id, 'is_complete' => 1])->count();
  26. }
  27. public static function ordercount($uuid)
  28. {
  29. return self::where('uuid', $uuid)->count();
  30. }
  31. public static function tuanzhang($order_id)
  32. {
  33. $tuanzhang = self::where('order_id', $order_id)->order('id desc')->find();
  34. return Tuanzhang::getTitlebyuuid($tuanzhang->uuid);
  35. }
  36. public static function getTuanzhang($order_id)
  37. {
  38. $tuanzhang = self::where('order_id', $order_id)->order('id desc')->find();
  39. return Tuanzhang::getInfo($tuanzhang->uuid);
  40. }
  41. public static function addtuanzhang($order_tuanzhang)
  42. {
  43. $order = self::where(['order_id' => $order_tuanzhang['order_id'], 'is_complete' => 0])->select()->toArray();
  44. if (!empty($order)) {
  45. self::where(['order_id' => $order_tuanzhang['order_id'], 'is_complete' => 0])->update(['uuid' => $order_tuanzhang['uuid']]);
  46. } else {
  47. $res = self::create($order_tuanzhang);
  48. }
  49. }
  50. }