Commit faa0cb5c authored by 强海明's avatar 强海明

Merge branch 'online_time' into 'master'

Online time

See merge request bp/goods!26
parents 5d3bf93c 29521b6b
......@@ -70,5 +70,6 @@ class GoodsException extends BaseException
49 => '库存不得小于已售库存',
self::RULE_LIMIT_ERROR => '单人可买上限填写错误',
self::NOT_FIND_MARKETING => '找不到活动',
52 => '过期时间不得小于等于上架开始时间',
];
}
\ No newline at end of file
<?php
namespace Validate;
/**
* Class GoodsAuditValidate
*
* @package Validate
*/
class GoodsOnlineSiteValidate extends BaseValidate
{
protected $rule = [
'goods_spu_id' => 'require',
'online_type' => 'require',
];
protected $message = [
"goods_spu_id" => "商品id不能为空",
"online_type" => "设置类型不能为空",
];
}
\ No newline at end of file
......@@ -16,6 +16,7 @@ use \Validate\GoodsOnlineOfflineValidate;
use \Validate\PaySuccessGoodsCallbackValidate;
use \Validate\GoodsInitShopValidate;
use \Validate\PindanGoodsAddValidate;
use \Validate\GoodsOnlineSiteValidate;
use \App\Services\goods\ElasticGoodService;
use \App\Services\goods\MarketingPindanGoodsService;
use \App\Models\marketing\mysql\Marketing;
......@@ -118,6 +119,20 @@ class GoodsController extends Base
$this->success();
}
/**
* 修改商品定点上架设置
* @date 2021-08-25
* @license [license]
* @version [version]
*/
public function online_siteAction()
{
$params = $this->params;
(new GoodsOnlineSiteValidate())->validate();
GoodsService::onlineSite($params);
$this->success();
}
/**
* 审核通过/驳回
*/
......
This diff is collapsed.
......@@ -150,12 +150,12 @@ class MarketingGoodsService
//比例
if (!empty($secondCommission) && $commissionMode == 1) {
$price = !empty($list[$i]['price']) ? $list[$i]['price'] : 0;
$list[$i]['share_price'] = substr(sprintf("%.4f",$secondCommission*$price/100),0,-2);
$list[$i]['share_price'] = (float) substr(sprintf("%.4f",$secondCommission*$price/100),0,-2);
}
//固定
if (!empty($commissionMode) && $commissionMode == 2) {
$list[$i]['share_price'] = substr(sprintf("%.4f",$secondCommission/100),0,-2);
$list[$i]['share_price'] = (float) substr(sprintf("%.4f",$secondCommission),0,-2);
}
$content = $userId .'_' .$value['marketing_id'];
......@@ -195,9 +195,13 @@ class MarketingGoodsService
$data = [];
foreach ($marketingInfoIds as $goodsSkuId => $marketingId) {
if (!empty($marketingList[$marketingId]["second_commission_value"])) {
if (!empty($marketingList[$marketingId]["second_commission_value"]) && $marketingList[$marketingId]["commission_mode"] == 1) {
$data[$goodsSkuId] = substr(sprintf("%.4f", $marketingList[$marketingId]["second_commission_value"]/10000), 0, -2);
}
if (!empty($marketingList[$marketingId]["second_commission_value"]) && $marketingList[$marketingId]["commission_mode"] == 2) {
$data[$goodsSkuId] = substr(sprintf("%.4f", $marketingList[$marketingId]["second_commission_value"]/100), 0, -2);
}
}
return $data;
}
......
......@@ -493,6 +493,9 @@ class MarketingService
$clearPrice = !empty($value["clear_price"]) ? $value["clear_price"] : 0;
$price = !empty($value["price"]) ? $value["price"] : 0;
$chargeFee = !empty($price) ? (float)bcmul($price , self::CHARGEFEE,2) : 0; //手续费 (分)
if ($chargeFee < 1) {
$chargeFee = 0;
}
if (!empty($clearPrice) && $clearPrice > 0) {
if ($commissionMode == Marketing::COMMISSION_MODE_RATE) {
$commissionTotal = ($firstCommissionRate + $secondCommissionRate) / 10000 * $price;
......
......@@ -29,8 +29,10 @@ class Goods implements DaemonServiceInterface
GoodsSku::save($colums, $where);
//更新es
GoodsService::updateGoodsInfoToEs($where['goods_sku_id']);
}
$this->onlineGoods();
$this->onlineOffGoods();
}
......@@ -53,4 +55,65 @@ class Goods implements DaemonServiceInterface
GoodsService::updateGoodsInfoToEs($where['goods_sku_id']);
}
}
/**
*
* 自动上线
*/
public function onlineGoods()
{
sleep(2);
$orderData = [
'online_type' => 2,
'online_status' => [0,2],
'audit_status' => 1,
'online_start_time[<]' => date("Y-m-d H:i:s",time()),
'online_end_time[>]' => date("Y-m-d H:i:s",time()),
'LIMIT' => 100,
];
$goodsList = GoodsSku::getRecords($orderData);
DaemonLog::info('DaemonServiceOnline_goods', json_encode($goodsList));
foreach ($goodsList as $key => $value) {
$where = [];
$where['goods_sku_id'] = !empty($value['goods_sku_id']) ? $value['goods_sku_id'] : '';
$colums = [
'online_status' => 1,
];
GoodsSku::save($colums, $where);
//更新es
GoodsService::updateGoodsInfoToEs($where['goods_sku_id']);
}
}
/**
*
* 自动下架
*/
public function onlineOffGoods()
{
sleep(2);
$orderData = [
'online_type' => 2,
'online_status' => 1,
'audit_status' => 1,
'online_end_time[<]' => date("Y-m-d H:i:s",time()),
'LIMIT' => 100,
];
$goodsList = GoodsSku::getRecords($orderData);
DaemonLog::info('DaemonServiceOnlineOff_goods', json_encode($goodsList));
foreach ($goodsList as $key => $value) {
$where = [];
$where['goods_sku_id'] = !empty($value['goods_sku_id']) ? $value['goods_sku_id'] : '';
$colums = [
'online_status' => 2,
];
GoodsSku::save($colums, $where);
//更新es
GoodsService::updateGoodsInfoToEs($where['goods_sku_id']);
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment