Commit 468221ff authored by luhongguang's avatar luhongguang

Merge branch 'test'

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