12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace app\common\model\distribution;
-
- use app\common\basics\Models;
- use app\common\server\UrlServer;
-
- class DistributionOrderGoods extends Models
- {
-
- const STATUS_WAIT_HANDLE = 1;
- const STATUS_SUCCESS = 2;
- const STATUS_ERROR = 3;
-
- public function getStatusDescAttr($value)
- {
- $statusDesc = [
- 1 => '待返佣',
- 2 => '已结算',
- 3 => '已失效',
- ];
- return $statusDesc[$value];
- }
-
- public function getDistributionCreateTimeAttr($value)
- {
- return date('Y-m-d H:i:s', $value);
- }
-
-
-
- public static function updateOrderStatus($distribution_id, $status)
- {
- return self::where('id', $distribution_id)
- ->update([
- 'status' => $status,
- 'update_time' => time()
- ]);
- }
-
-
-
- public static function getEarnings($userId)
- {
-
- $wait = self::where([
- 'user_id' => $userId,
- 'status' => 1,
- ])->sum('money');
-
- $success = self::where([
- 'user_id' => $userId,
- 'status' => 2,
- ])->sum('money');
-
- $fail = self::where([
- 'user_id' => $userId,
- 'status' => 3,
- ])->sum('money');
-
- return [
- 'wait' => $wait,
- 'success' => $success,
- 'fail' => $fail,
- ];
- }
-
- public function getSettlementTimeAttr($value)
- {
- return empty($value) ? '' : date('Y-m-d H:i:s', $value);
- }
-
-
-
- function getGoodsImageAttr($fieldValue, $data)
- {
- return UrlServer::getFileUrl($fieldValue);
- }
- }
|