添加:商品独立设置抽成比例或固定金额
This commit is contained in:
parent
4edbcd9ead
commit
a94ac58e34
|
|
@ -151,7 +151,20 @@ class StoreProduct extends BaseController
|
||||||
*/
|
*/
|
||||||
public function checkParams(validate $validate)
|
public function checkParams(validate $validate)
|
||||||
{
|
{
|
||||||
$data = $this->request->params(['is_hot','is_best','is_benefit','is_new','store_name','content','rank','star']);
|
$data = $this->request->params([
|
||||||
|
'is_hot',
|
||||||
|
'is_best',
|
||||||
|
'is_benefit',
|
||||||
|
'is_new',
|
||||||
|
'store_name',
|
||||||
|
'content',
|
||||||
|
'rank',
|
||||||
|
'star',
|
||||||
|
'platform_commission_switch',
|
||||||
|
'platform_commission_type',
|
||||||
|
'platform_commission_rate',
|
||||||
|
'platform_commission_money',
|
||||||
|
]);
|
||||||
$validate->check($data);
|
$validate->check($data);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,17 +61,33 @@ class OrderPaySuccessEvent{
|
||||||
foreach($groupOrder->orderList as $orderInfo){
|
foreach($groupOrder->orderList as $orderInfo){
|
||||||
$orderIds[] = $orderInfo->order_id;
|
$orderIds[] = $orderInfo->order_id;
|
||||||
foreach($orderInfo->orderProduct as $orderProductInfo){
|
foreach($orderInfo->orderProduct as $orderProductInfo){
|
||||||
// 获取商户设置抽成比例 获取抽成总金额
|
// 获取商品订单金额 = 当前商品实际支付金额 + 豆豆积分抵扣金额
|
||||||
$platformCommissionRate = (float)Merchant::getDB()->where('mer_id', $orderInfo->mer_id)->value('platform_commission');
|
$orderTotalPrice = sprintf("%.2f",$orderProductInfo->product_price + $orderProductInfo->use_legumes_integral);
|
||||||
|
// 获取抽成金额
|
||||||
|
$platformCommissionRate = -1;// 抽成比例 -1=固定金额
|
||||||
|
$productInfo = $orderProductInfo->product;// 商品信息
|
||||||
|
if($productInfo->platform_commission_switch == 1){
|
||||||
|
// 独立设置
|
||||||
|
if($productInfo->platform_commission_type == 1) {
|
||||||
|
// 固定金额
|
||||||
|
$platformCommissionMoney = $productInfo->platform_commission_money;
|
||||||
|
}else{
|
||||||
|
// 独立比例
|
||||||
|
$platformCommissionRate = $productInfo->platform_commission_rate;
|
||||||
|
$platformCommissionMoney = (float)sprintf("%.2f",$orderTotalPrice * $platformCommissionRate / 100);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
// 统一设置 获取商户设置抽成比例 获取抽成总金额
|
||||||
|
$platformCommissionRate = (float)Merchant::getDB()->where('mer_id', $orderInfo->mer_id)->value('platform_commission');
|
||||||
|
$platformCommissionMoney = (float)sprintf("%.2f",$orderTotalPrice * $platformCommissionRate / 100);
|
||||||
|
}
|
||||||
// 使用商品售价进行处理
|
// 使用商品售价进行处理
|
||||||
if($orderProductInfo->total_price > 0 && $platformCommissionRate > 0){
|
if($platformCommissionMoney > 0){
|
||||||
// 获取平台抽成中总金额
|
|
||||||
$platformCommissionMoney = (float)sprintf("%.2f",$orderProductInfo->total_price * $platformCommissionRate / 100);
|
|
||||||
// 生成信息数组
|
// 生成信息数组
|
||||||
$insertData[] = [
|
$insertData[] = [
|
||||||
'uid' => $orderProductInfo->uid,
|
'uid' => $orderProductInfo->uid,
|
||||||
'order_id' => $orderProductInfo->order_id,
|
'order_id' => $orderProductInfo->order_id,
|
||||||
'order_total_price' => $orderInfo->total_price,
|
'order_total_price' => $orderTotalPrice,
|
||||||
'order_product_id' => $orderProductInfo->order_product_id,
|
'order_product_id' => $orderProductInfo->order_product_id,
|
||||||
'order_product_total_price' => $orderProductInfo->total_price,
|
'order_product_total_price' => $orderProductInfo->total_price,
|
||||||
'mer_id' => $orderInfo->mer_id,
|
'mer_id' => $orderInfo->mer_id,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue