截流自动化的商城平台
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

DistributionOrderGoods.php 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace app\common\model\distribution;
  3. use app\common\basics\Models;
  4. use app\common\server\UrlServer;
  5. class DistributionOrderGoods extends Models
  6. {
  7. //分销订单状态
  8. const STATUS_WAIT_HANDLE = 1;//待返佣
  9. const STATUS_SUCCESS = 2;//已结算
  10. const STATUS_ERROR = 3;//已失效
  11. public function getStatusDescAttr($value)
  12. {
  13. $statusDesc = [
  14. 1 => '待返佣',
  15. 2 => '已结算',
  16. 3 => '已失效',
  17. ];
  18. return $statusDesc[$value];
  19. }
  20. public function getDistributionCreateTimeAttr($value)
  21. {
  22. return date('Y-m-d H:i:s', $value);
  23. }
  24. /**
  25. * Notes: 更新指定分佣订单状态
  26. * @param $distribution_id
  27. * @param $status
  28. * @author 段誉(2021/4/23 10:10)
  29. * @return DistributionOrder
  30. */
  31. public static function updateOrderStatus($distribution_id, $status)
  32. {
  33. return self::where('id', $distribution_id)
  34. ->update([
  35. 'status' => $status,
  36. 'update_time' => time()
  37. ]);
  38. }
  39. /**
  40. * @notes 获取指定用户佣金情况
  41. * @param $userId
  42. * @return array
  43. * @author Tab
  44. * @date 2021/9/2 19:14
  45. */
  46. public static function getEarnings($userId)
  47. {
  48. // 待返佣
  49. $wait = self::where([
  50. 'user_id' => $userId,
  51. 'status' => 1,
  52. ])->sum('money');
  53. // 已入账
  54. $success = self::where([
  55. 'user_id' => $userId,
  56. 'status' => 2,
  57. ])->sum('money');
  58. // 已失效
  59. $fail = self::where([
  60. 'user_id' => $userId,
  61. 'status' => 3,
  62. ])->sum('money');
  63. return [
  64. 'wait' => $wait,
  65. 'success' => $success,
  66. 'fail' => $fail,
  67. ];
  68. }
  69. public function getSettlementTimeAttr($value)
  70. {
  71. return empty($value) ? '' : date('Y-m-d H:i:s', $value);
  72. }
  73. /**
  74. * @notes 商品图片
  75. * @param $fieldValue
  76. * @param $data
  77. * @return string
  78. * @author lbzy
  79. * @datetime 2023-07-26 10:35:04
  80. */
  81. function getGoodsImageAttr($fieldValue, $data)
  82. {
  83. return UrlServer::getFileUrl($fieldValue);
  84. }
  85. }