Commit 468221ff authored by luhongguang's avatar luhongguang

Merge branch 'test'

parents f3156032 1d874d89
......@@ -12,14 +12,12 @@ namespace Validate;
class PaySuccessGoodsCallbackValidate extends BaseValidate
{
protected $rule = [
'pay_order_id' => 'require',
'goods_sku_id' => 'require',
'num' => 'require',
'order_id' => 'require',
'goods' => 'require',
];
protected $message = [
"pay_order_id" => "pay_order_id 不能为空",
"goods_sku_id" => "goods_sku_id 不能为空",
"num" => "商品数量不能为空",
"order_id" => "order_id 不能为空",
"goods" => "goods 信息不能为空",
];
}
\ No newline at end of file
......@@ -355,7 +355,7 @@ class GoodsService
}
$goodsSkuId = $sku["goods_sku_id"];
$rejectedReason = empty($params["rejected_reason"]) ? "" : $params["rejected_reason"];
$rejectedReason = strlen(trim($params["rejected_reason"])) == 0 ? "" : $params["rejected_reason"];
if ($status == GoodsSku::STATUS_PASS) {
$statusData = [
"online_status" => GoodsSku::ONLINE_STATUS_ONLINE,
......@@ -769,7 +769,7 @@ class GoodsService
}
}
}
$recordList = GoodsOperationRecord::select("*", ["goods_spu_id" => $goodsSpuId, "ORDER"=>["create_time"=>"DESC"]]);
$recordList = GoodsOperationRecord::select("*", ["goods_spu_id" => $goodsSpuId, "ORDER" => ["create_time" => "DESC"]]);
if (!empty($recordList)) {
foreach ($recordList as $key => $record) {
$data["record_list"][$key]["status"] = $record["goods_status"];
......@@ -824,7 +824,7 @@ class GoodsService
$data["goods_info"]["rule"]["rule_limit"] = $sku["rule_limit"];
$data["goods_info"]["rule"]["rule_refund"] = $ruleRefundDesc;
$data["goods_info"]["rule"]["rule_date_type"] = $ruleDateTypeDesc;
$data["goods_info"]["rule"]["rule_time"] = date('H:i', strtotime($sku["rule_start_time"]))." ~ ".date('H:i', strtotime($sku["rule_end_time"]));
$data["goods_info"]["rule"]["rule_time"] = date('H:i', strtotime($sku["rule_start_time"])) . " ~ " . date('H:i', strtotime($sku["rule_end_time"]));
$data["goods_info"]["rule"]["rule_desc"] = $sku["rule_desc"];
$data["goods_info"]["rule"]["expiration_time"] = $sku["expiration_time"];
......@@ -905,7 +905,7 @@ class GoodsService
$status = explode(",", $params["audit_status"]);
$where["audit_status"] = $status;
}
if (!empty($params["online_status"]) || (isset($params["online_status"]) && $params["online_status"] === '0')) {
if (!empty($params["online_status"]) || (isset($params["online_status"]) && $params["online_status"] === '0')) {
$onlineStatus = explode(",", $params["online_status"]);
$where["online_status"] = $onlineStatus;
}
......@@ -975,6 +975,7 @@ class GoodsService
$data = [];
if (!empty($list)) {
$count = count($list);
foreach ($list as $key => $sku) {
$sku["original_price"] = $sku["original_price"] / 100;
$sku["price"] = $sku["price"] / 100;
......@@ -986,6 +987,9 @@ class GoodsService
}
$lastId = $sku["goods_spu_id"];
}
if ($count < $limit) {
$lastId = "-1";
}
} else {
$lastId = "-1";
}
......@@ -1017,7 +1021,7 @@ class GoodsService
if (!empty($subShopList)) {
foreach ($subShopList as $subShop) {
if (!empty($subShop["latitude"]) && !empty($subShop["longitude"])) {
$esId = $goodsSkuInfo["goods_sku_id"]."_".$subShop["sub_shop_id"];
$esId = $goodsSkuInfo["goods_sku_id"] . "_" . $subShop["sub_shop_id"];
$data = [
"doc" => [
"goods_sku_id" => $goodsSkuInfo["goods_sku_id"],
......@@ -1040,7 +1044,7 @@ class GoodsService
"life_account_icon" => empty($lifeAccountRes["response"]["result"]["life_account_icon"]) ? "" : $lifeAccountRes["response"]["result"]["life_account_icon"],
"shop_name" => $subShop["shop_name"],
"shop_address" => $subShop["address"],
"shop_location" => $subShop["latitude"].",".$subShop["longitude"],
"shop_location" => $subShop["latitude"] . "," . $subShop["longitude"],
"update_time" => strtotime($goodsSkuInfo["update_time"]),
],
];
......@@ -1225,8 +1229,8 @@ class GoodsService
}
$info = GoodsSku::getRecord($where);
$info['original_price'] = empty($info['original_price']) ? 0 : $info['original_price']/100;
$info['price'] = !empty($info['price']) ? $info['price']/100 : 0;
$info['original_price'] = empty($info['original_price']) ? 0 : $info['original_price'] / 100;
$info['price'] = !empty($info['price']) ? $info['price'] / 100 : 0;
$info['desc_pic_url'] = !empty($info['desc_pic_url']) ? self::getUrlList($info['desc_pic_url']) : '';
$info['introduce_pic_url'] = !empty($info['introduce_pic_url']) ? self::getUrlList($info['introduce_pic_url']) : "";
return $info;
......@@ -1283,7 +1287,7 @@ class GoodsService
if (empty($params)) {
return [];
}
if (!empty($params['goods_spu_id'])) {
$where['goods_spu_id'] = $params['goods_spu_id'];
}
......@@ -1353,46 +1357,52 @@ class GoodsService
*/
public static function paySuccessGoodsCallback($params = [])
{
$payOrderId = $params["pay_order_id"];
$goodsSkuId = $params["goods_sku_id"];
$num = $params["num"];
$record = PaySuccessGoodsCallbackRecord::getRecord([
"pay_order_id" => $payOrderId,
"goods_sku_id" => $goodsSkuId,
"operator_result" => PaySuccessGoodsCallbackRecord::OPERATOR_RESULT_SUCCESS]
);
if (empty($record)) {
GoodsSku::beginTransaction();
$goodsSku = GoodsSku::getRecord(["goods_sku_id"=>$goodsSkuId]);
if (empty($goodsSku)) {
throw new GoodsException(["cus" => 15]);
}
GoodsSku::save(["total_amount_sold" => $goodsSku["total_amount_sold"] + $num]
, ["goods_sku_id" => $goodsSkuId]);
$orderId = $params["order_id"];
$goodsPayInfos = json_decode($params["goods"], true);
PaySuccessGoodsCallbackRecord::insertRecord([
"pay_order_id" => $payOrderId,
"goods_sku_id" => $goodsSkuId,
"operator_result" => PaySuccessGoodsCallbackRecord::OPERATOR_RESULT_SUCCESS]
GoodsSku::beginTransaction();
foreach ($goodsPayInfos as $goodsSkuId => $num) {
$record = PaySuccessGoodsCallbackRecord::getRecord([
"order_id" => $orderId,
"goods_sku_id" => $goodsSkuId,
"operator_result" => PaySuccessGoodsCallbackRecord::OPERATOR_RESULT_SUCCESS]
);
if (empty($record)) {
$goodsSku = GoodsSku::getRecord(["goods_sku_id" => $goodsSkuId]);
if (empty($goodsSku)) {
throw new GoodsException(["cus" => 15]);
}
if (!GoodsSku::commit()) {
GoodsSku::rollback();
GoodsSku::save(["total_amount_sold" => $goodsSku["total_amount_sold"] + $num]
, ["goods_sku_id" => $goodsSkuId]);
PaySuccessGoodsCallbackRecord::insertRecord([
"pay_order_id" => $payOrderId,
"order_id" => $orderId,
"goods_sku_id" => $goodsSkuId,
"num" => $num,
"operator_result" => PaySuccessGoodsCallbackRecord::OPERATOR_RESULT_SUCCESS]
);
}
}
if (!GoodsSku::commit()) {
GoodsSku::rollback();
foreach ($goodsPayInfos as $goodsSkuId => $num) {
PaySuccessGoodsCallbackRecord::insertRecord([
"order_id" => $orderId,
"goods_sku_id" => $goodsSkuId,
"num" => $num,
"operator_result" => PaySuccessGoodsCallbackRecord::OPERATOR_RESULT_FAIL]
);
return false;
}
return false;
} else {
//同步到es
self::updateGoodsInfoToEs($goodsSkuId);
foreach ($goodsPayInfos as $goodsSkuId => $num) {
self::updateGoodsInfoToEs($goodsSkuId);
}
}
return true;
}
......@@ -1411,14 +1421,14 @@ class GoodsService
$introducePicUrl = explode(",", $skuData["introduce_pic_url"]);
}
$ids = GoodsSkuPicRecord::select("id", ["goods_sku_id"=>$goodsSkuId]);
GoodsSkuPicRecord::delete(["id"=>$ids]);
$ids = GoodsSkuPicRecord::select("id", ["goods_sku_id" => $goodsSkuId]);
GoodsSkuPicRecord::delete(["id" => $ids]);
$urlList = array_unique(array_merge($descPicUrl, $introducePicUrl));
$data = [];
if (!empty($urlList)) {
foreach ($urlList as $url) {
$data[] = ["goods_sku_id"=>$goodsSkuId, "url"=>$url];
$data[] = ["goods_sku_id" => $goodsSkuId, "url" => $url];
}
GoodsSkuPicRecord::save($data);
}
......
......@@ -142,11 +142,17 @@ class MarketingService
if (!empty($params['goods_sku_id'])) {
$goodsSkuId = $params['goods_sku_id'];
$marketingGoodsList = MarketingGoods::marketingGoodsList(['goods_sku_id' => $goodsSkuId]);
$marketingId = array_column($marketingGoodsList, 'marketing_id');
if (!empty($where['marketing_id'])) {
array_push($marketingId,$where['marketing_id']);
if (empty($marketingGoodsList)) {
$where['marketing_id'] = "-1";
}else{
$marketingId = array_column($marketingGoodsList, 'marketing_id');
if (!empty($where['marketing_id'])) {
array_push($marketingId,$where['marketing_id']);
}
$where['marketing_id'] = $marketingId;
}
$where['marketing_id'] = $marketingId;
}
$where['ORDER'] = ["create_time" => "DESC"];
......@@ -227,7 +233,6 @@ class MarketingService
throw new MarketingException(['cus'=>14]);
}
$tmpMarketingId = [];
$tmpGoodsSkuId = [];
$goodsData = [
......@@ -235,8 +240,12 @@ class MarketingService
"start_time[>=]" => $startTime,
"end_time[>=]" => $startTime,
],
"online_status" => 1,
];
//存在的活动
$tmpMarketingList = Marketing::getMarketingList($goodsData);
if (!empty($tmpMarketingList)) {
$tmpMarketingId = array_column($tmpMarketingList, 'marketing_id');
}
......
......@@ -6,14 +6,9 @@ namespace Daemon;
use Api\PhpServices\Daemon\DaemonServiceInterface;
use App\Models\goods\mysql\GoodsSku;
use Api\PhpUtils\Log\FileLog;
use Api\PhpUtils\Log\DaemonLog;
class Goods implements DaemonServiceInterface
{
public function __construct(int $mid)
{
$this->mid = $mid;
}
public function run()
{
sleep(2);
......@@ -22,7 +17,7 @@ class Goods implements DaemonServiceInterface
'expiration_time[<]' => date("Y-m-d H:i:s",time())
];
$goodsList = GoodsSku::getRecords($orderData);
FileLog::info('DaemonServiceInterface_goods', json_encode($goodsList));
DaemonLog::info('DaemonServiceInterface_goods', json_encode($goodsList));
foreach ($goodsList as $key => $value) {
$where = [];
$where['goods_sku_id'] = !empty($value['goods_sku_id']) ? $value['goods_sku_id'] : '';
......
......@@ -5,15 +5,11 @@ namespace Daemon;
use Api\PhpServices\Daemon\DaemonServiceInterface;
use App\Models\marketing\mysql\Marketing;
use App\Models\marketing\mysql\Marketing as MarketingDao;
use Api\PhpUtils\Log\DaemonLog;
class Marketing implements DaemonServiceInterface
{
const EXPIRE_DATA = 86400;
public function __construct(int $mid)
{
$this->mid = $mid;
}
public function run()
{
sleep(2);
......@@ -21,15 +17,15 @@ class Marketing implements DaemonServiceInterface
'online_status' => 1,
'end_time[<]' => date("Y-m-d H:i:s",time())
];
$orderInfoList = Marketing::getMarketingList($orderData);
$orderInfoList = MarketingDao::getMarketingList($orderData);
DaemonLog::info('DaemonServiceInterface_marketing', json_encode($orderInfoList));
foreach ($orderInfoList as $key => $value) {
$where = [];
$where['marketing_id'] = !empty($value['marketing_id']) ? $value['marketing_id'] : '';
$colums = [
'online_status' => 3,
];
Marketing::updateRecord($colums, $where);
MarketingDao::updateRecord($colums, $where);
}
}
......
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