|
|
|
@ -45,6 +45,7 @@ class UserAssetsLogRepository extends BaseRepository |
|
|
|
|
const CHANGE_TYPE_DIAMOND_LOTTERY = 10; // 抽奖 |
|
|
|
|
const CHANGE_TYPE_DIAMOND = 11; // 兑换钻石 |
|
|
|
|
const CHANGE_TYPE_STOCK = 12; // 兑换本票 |
|
|
|
|
const CHANGE_TYPE_USE = 13; // 消费 |
|
|
|
|
|
|
|
|
|
const STATUS_GET = 1; // 获取 |
|
|
|
|
const STATUS_USE = 2; // 使用 |
|
|
|
@ -88,6 +89,7 @@ class UserAssetsLogRepository extends BaseRepository |
|
|
|
|
self::CHANGE_TYPE_DIAMOND_LOTTERY => '抽奖', |
|
|
|
|
self::CHANGE_TYPE_DIAMOND => '兑换钻石', |
|
|
|
|
self::CHANGE_TYPE_STOCK => '兑换本票', |
|
|
|
|
self::CHANGE_TYPE_USE => '消费', |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -112,7 +114,6 @@ class UserAssetsLogRepository extends BaseRepository |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* notes 订单收货事件处理 |
|
|
|
|
* @param $orderItem |
|
|
|
@ -157,12 +158,92 @@ class UserAssetsLogRepository extends BaseRepository |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function _getValue($value) |
|
|
|
|
/** |
|
|
|
|
* notes 分享奖励 |
|
|
|
|
* @create 2024/4/9 15:11 |
|
|
|
|
* @update 2024/4/9 15:11 |
|
|
|
|
* @author zhangkxiang |
|
|
|
|
* @editor |
|
|
|
|
*/ |
|
|
|
|
public function shareAward($orderId) |
|
|
|
|
{ |
|
|
|
|
if ($value < 0.01) { |
|
|
|
|
return 0.01; |
|
|
|
|
/** |
|
|
|
|
* @var StoreOrderRepository $orderRepository |
|
|
|
|
*/ |
|
|
|
|
$orderRepository = app(StoreOrderRepository::class); |
|
|
|
|
$order = $orderRepository->getDetail($orderId); |
|
|
|
|
|
|
|
|
|
// Log::info('order is '.json_encode($order)); |
|
|
|
|
|
|
|
|
|
$LogList = array(); |
|
|
|
|
foreach ($order['orderProduct'] as $productItem) { |
|
|
|
|
$product = $this->productRepository->get($productItem['product_id']); |
|
|
|
|
Log::info("product is " . json_encode($product)); |
|
|
|
|
$profit = $productItem['total_price'] - $productItem['cost']; |
|
|
|
|
|
|
|
|
|
if ($product['is_hot']) { |
|
|
|
|
$integralOne = $product['hot_integral_one']; |
|
|
|
|
$integralTwo = $product['hot_integral_two']; |
|
|
|
|
$diamondOne = $product['hot_diamond_one']; |
|
|
|
|
$diamondTwo = $product['hot_diamond_two']; |
|
|
|
|
} else { |
|
|
|
|
$integralOne = $product['normal_integral_one']; |
|
|
|
|
$integralTwo = $product['normal_integral_two']; |
|
|
|
|
$diamondOne = $product['normal_diamond_one']; |
|
|
|
|
$diamondTwo = $product['normal_diamond_two']; |
|
|
|
|
} |
|
|
|
|
if ($order['spread_uid']) { |
|
|
|
|
$tmp = array('diamond' => $diamondOne, 'integral' => $this->_getValue($profit * $integralOne / 100)); |
|
|
|
|
$LogList[] = array( |
|
|
|
|
'uid' => $order['spread_uid'], |
|
|
|
|
'asset_type' => self::ASSET_TYPE_INTEGRAL, |
|
|
|
|
'type' => self::CHANGE_TYPE_SHARE, |
|
|
|
|
'status' => self::STATUS_GET, |
|
|
|
|
'product_id' => $productItem['product_id'], |
|
|
|
|
'order_id' => $orderId, |
|
|
|
|
'count' => $tmp['integral'], |
|
|
|
|
); |
|
|
|
|
$LogList[] = array( |
|
|
|
|
'uid' => $order['spread_uid'], |
|
|
|
|
'asset_type' => self::ASSET_TYPE_DIAMOND, |
|
|
|
|
'type' => self::CHANGE_TYPE_SHARE, |
|
|
|
|
'status' => self::STATUS_GET, |
|
|
|
|
'product_id' => $productItem['product_id'], |
|
|
|
|
'order_id' => $orderId, |
|
|
|
|
'count' => $diamondOne, |
|
|
|
|
); |
|
|
|
|
$this->userAssetsRepository->updateAssets($order['spread_uid'], $tmp); |
|
|
|
|
} |
|
|
|
|
if ($order['top_uid']) { |
|
|
|
|
$tmp = array('diamond' => $diamondTwo, 'integral' => $this->_getValue($profit * $integralTwo / 100)); |
|
|
|
|
$LogList[] = array( |
|
|
|
|
'uid' => $order['top_uid'], |
|
|
|
|
'asset_type' => self::ASSET_TYPE_INTEGRAL, |
|
|
|
|
'type' => self::CHANGE_TYPE_SHARE, |
|
|
|
|
'status' => self::STATUS_GET, |
|
|
|
|
'product_id' => $productItem['product_id'], |
|
|
|
|
'order_id' => $orderId, |
|
|
|
|
'count' => $tmp['integral'], |
|
|
|
|
); |
|
|
|
|
$LogList[] = array( |
|
|
|
|
'uid' => $order['top_uid'], |
|
|
|
|
'asset_type' => self::ASSET_TYPE_DIAMOND, |
|
|
|
|
'type' => self::CHANGE_TYPE_SHARE, |
|
|
|
|
'status' => self::STATUS_GET, |
|
|
|
|
'product_id' => $productItem['product_id'], |
|
|
|
|
'order_id' => $orderId, |
|
|
|
|
'count' => $diamondTwo, |
|
|
|
|
); |
|
|
|
|
$this->userAssetsRepository->updateAssets($order['top_uid'], $tmp); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return $value; |
|
|
|
|
$this->addLog($LogList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function _getValue($value) |
|
|
|
|
{ |
|
|
|
|
return round($value, 2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|