Commit 89a205dc authored by cuiweifeng's avatar cuiweifeng

Merge branch 'jielong' of https://gitlab.yidian-inc.com/bp/goods into jielong

parents cbba1498 f8bb93f1
...@@ -55,5 +55,13 @@ class GoodsException extends BaseException ...@@ -55,5 +55,13 @@ class GoodsException extends BaseException
self::PRINTER_ALREADY_EXIST => '打印机已被%s绑定', self::PRINTER_ALREADY_EXIST => '打印机已被%s绑定',
self::EMPTY_OTA_ID => '供应商id为空', self::EMPTY_OTA_ID => '供应商id为空',
self::OTA_NOT_EXIST => '供应商不存在', self::OTA_NOT_EXIST => '供应商不存在',
39 => '结算价不能大于售价',
40 => '结算价不符合标准',
41 => '商品id非法',
42 => 'TCC 参数错误',
43 => 'TCC 商品非上架状态',
44 => 'TCC 事务commit失败',
45 => 'TCC 还没有try,就去执行confirm',
46 => 'TCC 已经执行过cancel',
]; ];
} }
\ No newline at end of file
...@@ -36,6 +36,7 @@ class MarketingException extends BaseException ...@@ -36,6 +36,7 @@ class MarketingException extends BaseException
18 => '当前填写的拼单活动名称已经存在', 18 => '当前填写的拼单活动名称已经存在',
19 => '当前活动不存在', 19 => '当前活动不存在',
self::TAKE_PLACE_NOT_EXIST => '自提点不存在', self::TAKE_PLACE_NOT_EXIST => '自提点不存在',
21 => "活动开始时间不能大于或者等雨结束时间", 21 => "活动开始时间不能大于或者等于结束时间",
22 => "自提点不能为空",
]; ];
} }
\ No newline at end of file
...@@ -20,5 +20,6 @@ class UserException extends BaseException ...@@ -20,5 +20,6 @@ class UserException extends BaseException
6 => '解密失败 不存在', 6 => '解密失败 不存在',
7 => '手机号获取失败', 7 => '手机号获取失败',
8 => '绑定手机号失败', 8 => '绑定手机号失败',
9 => '该手机号已绑定其他用户不能重复绑定',
]; ];
} }
\ No newline at end of file
<?php
namespace Validate;
/**
* Class MarketingInfoValidate
*
* @package Validate
*/
class MarketingInfoValidate extends BaseValidate
{
protected $rule = [
'marketing_id' => 'require',
];
protected $message = [
"marketing_id" => "marketing_id 不能为空",
];
}
\ No newline at end of file
<?php
namespace Validate;
/**
* Class MarketingOnlineStatusValidate
*
* @package Validate
*/
class MarketingOnlineStatusValidate extends BaseValidate
{
protected $rule = [
'marketing_id' => 'require',
'marketing_type' => 'require',
'online_status' => 'require',
];
protected $message = [
"marketing_id" => "marketing_id 不能为空",
"marketing_type" => "marketing_type 不能为空",
"online_status" => "online_status 不能为空",
];
}
\ No newline at end of file
...@@ -45,4 +45,8 @@ class OtaValidate extends \Validate\BaseValidate ...@@ -45,4 +45,8 @@ class OtaValidate extends \Validate\BaseValidate
{ {
return $this->only(['ota_id']); return $this->only(['ota_id']);
} }
public function sceneListByIds()
{
return $this->only(['ota_id']);
}
} }
\ No newline at end of file
<?php
namespace Validate;
/**
* Class PindanGoodsAddValidate
*
* @package Validate
*/
class PindanGoodsAddValidate extends BaseValidate
{
protected $rule = [
'marketing_name' => 'require',
'goods_name' => 'require|length:1,50',
'price' => 'require',
'inventory' => 'require',
];
protected $message = [
'marketing_name' => 'marketing_name 不能为空',
'goods_name' => '请检查商品名称,内容不能太长或者不填写',
'price' => '请填写售价',
'inventory' => '请填写库存',
];
}
\ No newline at end of file
<?php
namespace Validate;
/**
* Class RefundGoodsValidate
*
* @package Validate
*/
class RefundGoodsValidate extends BaseValidate
{
protected $rule = [
'goods_sku_id' => 'require',
'order_id' => 'require',
'order_item_id' => 'require',
'num' => 'require',
];
protected $message = [
"goods_sku_id" => "goods_sku_id 不能为空",
"order_id" => "order_id 不能为空",
"order_item_id" => "order_item_id 不能为空",
"num" => "num 不能为空",
];
}
\ No newline at end of file
...@@ -15,6 +15,7 @@ class TakePlaceValidate extends \Validate\BaseValidate ...@@ -15,6 +15,7 @@ class TakePlaceValidate extends \Validate\BaseValidate
'take_place_id' => 'require', 'take_place_id' => 'require',
'name' => 'require', 'name' => 'require',
'address' => 'require', 'address' => 'require',
'location' => 'require',
'longitude' => 'require', 'longitude' => 'require',
'latitude' => 'require', 'latitude' => 'require',
'province' => 'require', 'province' => 'require',
...@@ -29,7 +30,8 @@ class TakePlaceValidate extends \Validate\BaseValidate ...@@ -29,7 +30,8 @@ class TakePlaceValidate extends \Validate\BaseValidate
"take_place_id" => "take_place_id不能为空", "take_place_id" => "take_place_id不能为空",
"marketing_id" => "marketing_id不能为空", "marketing_id" => "marketing_id不能为空",
"name" => "自提点名称不能为空", "name" => "自提点名称不能为空",
"address" => "详细地址不能为空", "address" => "详细地址(原商圈)不能为空",
"location" => "高德地图详细地址不能为空",
"longitude" => "经度不能为空", "longitude" => "经度不能为空",
"latitude" => "纬度不能为空", "latitude" => "纬度不能为空",
"province" => "省不能为空", "province" => "省不能为空",
......
<?php
namespace App\Models\goods\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
/**
* Class GoodsRefundRecord
* 商品退款记录
* @package App\Models\goods\mysql
*/
class GoodsRefundRecord extends MysqlBase
{
const TABLE_NAME = 'goods_refund_record';
const CONFIG_INDEX = 'goods';
const OPERATOR_RESULT_FAILURE = 0;
const OPERATOR_RESULT_SUCCESS = 1;
public static function getRecord($where, $columns = [])
{
if (empty($columns)) {
$columns = '*';
}
return self::get($columns, $where);
}
public static function getRecordMaster($where, $columns = [])
{
if (empty($columns)) {
$columns = '*';
}
return self::selectMaster($columns, $where);
}
public static function save($data, $where = [])
{
if (empty($where)) {
return self::insert($data);
}
return self::update($data, $where);
}
public static function deleteRecord($where)
{
return self::delete($where);
}
}
\ No newline at end of file
...@@ -27,6 +27,9 @@ class GoodsSpu extends MysqlBase ...@@ -27,6 +27,9 @@ class GoodsSpu extends MysqlBase
const BELONG_TYPE_DISANFANG = 1;//第三方商品 const BELONG_TYPE_DISANFANG = 1;//第三方商品
const BELONG_TYPE_ZIYING = 2;//自营商品 const BELONG_TYPE_ZIYING = 2;//自营商品
const CAN_SHOW_ES_YES = 1;
const CAN_SHOW_ES_NO = 2;
public static function getRecord($where, $colums = []) public static function getRecord($where, $colums = [])
{ {
if (empty($colums)) { if (empty($colums)) {
......
...@@ -17,4 +17,12 @@ class Ota extends MysqlBase ...@@ -17,4 +17,12 @@ class Ota extends MysqlBase
const STATUS_NORMAL = 0; // 正常 const STATUS_NORMAL = 0; // 正常
const STATUS_DELETE = 1; // 删除 const STATUS_DELETE = 1; // 删除
public static function getRecord($where, $columns = [])
{
if (empty($columns)) {
$columns = '*';
}
return self::get($columns, $where);
}
} }
...@@ -25,6 +25,9 @@ class Marketing extends MysqlBase ...@@ -25,6 +25,9 @@ class Marketing extends MysqlBase
self::ONLINE_STATUS_DAOQI => "到期", self::ONLINE_STATUS_DAOQI => "到期",
]; ];
const COMMISSION_MODE_RATE = 1;
const COMMISSION_MODE_FIXED = 2;
public static function getRecord($where, $colums = []) public static function getRecord($where, $colums = [])
{ {
if (empty($colums)) { if (empty($colums)) {
......
...@@ -81,7 +81,7 @@ class GoodstoesController extends Cli ...@@ -81,7 +81,7 @@ class GoodstoesController extends Cli
"goods_name" => $goodsSkuInfo["goods_name"], "goods_name" => $goodsSkuInfo["goods_name"],
"inventory_rest" => $goodsSkuInfo["inventory_rest"], "inventory_rest" => $goodsSkuInfo["inventory_rest"],
"total_amount_sold" => $goodsSkuInfo["total_amount_sold"], "total_amount_sold" => $goodsSkuInfo["total_amount_sold"],
"original_price" => $goodsSkuInfo["original_price"] / 100, "original_price" => empty($goodsSkuInfo["original_price"]) ? "" : (string)($goodsSkuInfo["original_price"] / 100),
"price" => $goodsSkuInfo["price"] / 100, "price" => $goodsSkuInfo["price"] / 100,
"price_sort" => (int)$goodsSkuInfo["price"], "price_sort" => (int)$goodsSkuInfo["price"],
"audit_status" => $goodsSkuInfo["audit_status"], "audit_status" => $goodsSkuInfo["audit_status"],
......
...@@ -280,10 +280,8 @@ class GoodstoinitController extends Cli ...@@ -280,10 +280,8 @@ class GoodstoinitController extends Cli
GoodsSku::save($skuParams); GoodsSku::save($skuParams);
} else { } else {
$skuParams = [ $skuParams = [
"inventory_total" => $inventoryTotal, "original_price" => $originalPrice,
"inventory_rest" => $inventoryRest, "price" => $price,
"total_amount_order" => $totalAmountOrder,
"total_amount_sold" => $totalAmountOrder,
]; ];
GoodsSku::save($skuParams, ["goods_sku_id"=>$goodsSku["goods_sku_id"]]); GoodsSku::save($skuParams, ["goods_sku_id"=>$goodsSku["goods_sku_id"]]);
} }
......
...@@ -11,12 +11,15 @@ use \Validate\GoodsInfoOpValidate; ...@@ -11,12 +11,15 @@ use \Validate\GoodsInfoOpValidate;
use \Validate\GoodsInfoFeValidate; use \Validate\GoodsInfoFeValidate;
use \Validate\GoodsListCValidate; use \Validate\GoodsListCValidate;
use \Validate\OrderGoodsValidate; use \Validate\OrderGoodsValidate;
use \Validate\RefundGoodsValidate;
use \Validate\GoodsOnlineOfflineValidate; use \Validate\GoodsOnlineOfflineValidate;
use \Validate\PaySuccessGoodsCallbackValidate; use \Validate\PaySuccessGoodsCallbackValidate;
use \Validate\GoodsInitShopValidate; use \Validate\GoodsInitShopValidate;
use \Validate\PindanGoodsAddValidate;
use \App\Services\goods\ElasticGoodService; use \App\Services\goods\ElasticGoodService;
use \App\Services\goods\MarketingPindanGoodsService; use \App\Services\goods\MarketingPindanGoodsService;
use \App\Models\marketing\mysql\Marketing; use \App\Models\marketing\mysql\Marketing;
use \App\Services\goods\GoodsSnapshotsService;
class GoodsController extends Base class GoodsController extends Base
...@@ -48,7 +51,7 @@ class GoodsController extends Base ...@@ -48,7 +51,7 @@ class GoodsController extends Base
{ {
$params = $this->params; $params = $this->params;
if (!empty($params["marketing_type"]) && $params["marketing_type"] == Marketing::MARKETING_TYPE_PINDAN) { if (!empty($params["marketing_type"]) && $params["marketing_type"] == Marketing::MARKETING_TYPE_PINDAN) {
(new PindanGoodsAddValidate())->validate();
} else { } else {
(new GoodsAddValidate())->validate(); (new GoodsAddValidate())->validate();
} }
...@@ -289,4 +292,26 @@ class GoodsController extends Base ...@@ -289,4 +292,26 @@ class GoodsController extends Base
$list = MarketingPindanGoodsService::getPindanGoodsList($params); $list = MarketingPindanGoodsService::getPindanGoodsList($params);
$this->success(["result" => $list]); $this->success(["result" => $list]);
} }
/**
* 拼单商品退款商品逻辑
* @throws Exception
*/
public function refundAction()
{
(new RefundGoodsValidate())->validate();
$params = $this->params;
$res = GoodsService::refundGoods($params);
$this->success(["result" => $res]);
}
/**
* 拼单商品快照批量获取
* @throws Exception
*/
public function pindan_goods_snapshotsAction()
{
$res = GoodsSnapshotsService::pindanGoodsSnapshots($this->params);
$this->success(["result" => $res]);
}
} }
\ No newline at end of file
...@@ -29,6 +29,20 @@ class OtaController extends Base ...@@ -29,6 +29,20 @@ class OtaController extends Base
$this->success(['result' => $res]); $this->success(['result' => $res]);
} }
/**
* 根据id批量获取供应商信息
* @throws \App\Exception\custom\ParamException
*/
public function ota_list_by_idsAction()
{
(new OtaValidate())->scene('listByIds')->validate();
$otaIds = $this->params['ota_id'] ?? '';
$otaIds = explode(',',$otaIds);
$res = OtaService::getOtaListByIds($otaIds);
$this->success(['result' => $res]);
}
/** /**
* 添加供应商 * 添加供应商
* @throws \App\Exception\custom\ParamException * @throws \App\Exception\custom\ParamException
......
...@@ -5,6 +5,8 @@ use App\Services\marketing\MarketingService; ...@@ -5,6 +5,8 @@ use App\Services\marketing\MarketingService;
use App\Exception\custom\MarketingException; use App\Exception\custom\MarketingException;
use App\Services\marketing\MarketingGoodsService; use App\Services\marketing\MarketingGoodsService;
use \Validate\MarketingGoodsRateValidate; use \Validate\MarketingGoodsRateValidate;
use \Validate\MarketingOnlineStatusValidate;
use \Validate\MarketingInfoValidate;
class MarketingController extends Base class MarketingController extends Base
{ {
...@@ -120,6 +122,8 @@ class MarketingController extends Base ...@@ -120,6 +122,8 @@ class MarketingController extends Base
*/ */
public function marketing_infoAction() public function marketing_infoAction()
{ {
(new MarketingInfoValidate())->validate();
$params = $this->params; $params = $this->params;
$marketingInfo = MarketingService::marketingInfo($params); $marketingInfo = MarketingService::marketingInfo($params);
$this->success(['result' => $marketingInfo]); $this->success(['result' => $marketingInfo]);
...@@ -139,4 +143,16 @@ class MarketingController extends Base ...@@ -139,4 +143,16 @@ class MarketingController extends Base
$this->success(['result' => $marketingInfo]); $this->success(['result' => $marketingInfo]);
} }
/**
* 拼单活动修改活动状态
* @throws Exception
*/
public function update_marketing_online_statusAction()
{
(new MarketingOnlineStatusValidate())->validate();
MarketingService::updateMarketingOnlineStatus($this->params);
$this->success();
}
} }
\ No newline at end of file
<?php
use App\Base\Base;
use \App\Services\marketing\MarketingForOrderService;
class MarketingfororderController extends Base
{
/**
* 分销活动列表
* @throws Exception
*/
public function marketing_listAction()
{
$params = $this->params;
$data = MarketingForOrderService::getMarketingList($params);
$this->success(["result" => $data]);
}
/**
* 分销活动的商品
* @throws \App\Exception\custom\MarketingException
*/
public function goods_listAction()
{
$params = $this->params;
$data = MarketingForOrderService::getMarketingGoodsList($params);
$this->success(["result" => $data]);
}
/**
* 活动的自提点
* @throws \App\Exception\custom\MarketingException
*/
public function take_place_listAction()
{
$params = $this->params;
$data = MarketingForOrderService::getMarketingTakePlaceList($params);
$this->success(["result" => $data]);
}
}
\ No newline at end of file
...@@ -67,6 +67,8 @@ class TccController extends Base ...@@ -67,6 +67,8 @@ class TccController extends Base
$res = Tcc2Service::cancelConfirm($this->params["keys"]); $res = Tcc2Service::cancelConfirm($this->params["keys"]);
if ($res) { if ($res) {
$this->success(); $this->success();
} else {
throw new GoodsException(["cus" => 27]);
} }
} }
} }
\ No newline at end of file
...@@ -159,7 +159,7 @@ class ElasticGoodService ...@@ -159,7 +159,7 @@ class ElasticGoodService
$result["list"][$key]["life_account_id"] = $source["_source"]["life_account_id"]; $result["list"][$key]["life_account_id"] = $source["_source"]["life_account_id"];
$result["list"][$key]["life_account_name"] = $source["_source"]["life_account_name"]; $result["list"][$key]["life_account_name"] = $source["_source"]["life_account_name"];
$result["list"][$key]["life_account_icon"] = $source["_source"]["life_account_icon"]; $result["list"][$key]["life_account_icon"] = $source["_source"]["life_account_icon"];
$result["list"][$key]["distance"] = empty(end($source["sort"])) ? "" : round(end($source["sort"]), 2) . "km"; $result["list"][$key]["distance"] = empty($source["sort"]) ? "" : round(end($source["sort"]), 2) . "km";
$result["list"][$key]["update_time"] = $source["_source"]["update_time"]; $result["list"][$key]["update_time"] = $source["_source"]["update_time"];
} }
} }
......
...@@ -694,9 +694,15 @@ class GoodsService ...@@ -694,9 +694,15 @@ class GoodsService
"inventory_rest" => $inventoryCount, "inventory_rest" => $inventoryCount,
"original_price" => empty($params["original_price"]) ? 0 : $params["original_price"] * 100, "original_price" => empty($params["original_price"]) ? 0 : $params["original_price"] * 100,
"price" => $params["price"] * 100, "price" => $params["price"] * 100,
"clear_price" => empty($params["clear_price"]) ? 0 : $params["clear_price"] * 100,
"goods_version" => (int)$skuData["goods_version"] + 1, "goods_version" => (int)$skuData["goods_version"] + 1,
]; ];
//验证结算价格
if (!empty($params["clear_price"])) {
self::checkClearPrice($goodsSkuId, $skuParams);
}
if (self::isInitGoodsStatus($params, $skuData)) { if (self::isInitGoodsStatus($params, $skuData)) {
$skuParams["audit_status"] = GoodsSku::STATUS_AUDIT; $skuParams["audit_status"] = GoodsSku::STATUS_AUDIT;
$skuParams["online_status"] = GoodsSku::ONLINE_STATUS_NO_ONLINE; $skuParams["online_status"] = GoodsSku::ONLINE_STATUS_NO_ONLINE;
...@@ -724,6 +730,48 @@ class GoodsService ...@@ -724,6 +730,48 @@ class GoodsService
return GoodsSku::save($skuParams, ["goods_sku_id" => $goodsSkuId]); return GoodsSku::save($skuParams, ["goods_sku_id" => $goodsSkuId]);
} }
/**
* 检查结算价格
* @param $goodsSkuId
* @param $skuParams
* @throws GoodsException
*/
private static function checkClearPrice($goodsSkuId, $skuParams)
{
$clearPrice = $skuParams["clear_price"];
$price = $skuParams["price"];
if ($clearPrice > 0 && $clearPrice > $price) {
throw new GoodsException(['cus' => 39]);
}
$marketingIds = MarketingGoods::select(["marketing_id"], ["goods_sku_id" => $goodsSkuId]);
if (!empty($marketingIds)) {
$marketingIds = array_column($marketingIds, "marketing_id");
$marketings = Marketing::select("*", [
"marketing_id" => $marketingIds,
"marketing_type"=> Marketing::MARKETING_TYPE_FENXIAO,
"online_status" => Marketing::ONLINE_STATUS_QIDONG]
);
if (!empty($marketings)) {
foreach ($marketings as $marketing) {
if ($marketing["commission_mode"] == Marketing::COMMISSION_MODE_RATE) {
$commissionTotal = ($marketing["first_commission_value"] + $marketing["second_commission_value"]) / 1000 * $price;
if ($price - $commissionTotal < $clearPrice) {
throw new GoodsException(['cus' => 40]);
}
}
if ($marketing["commission_mode"] == Marketing::COMMISSION_MODE_FIXED) {
$commissionTotal = ($marketing["first_commission_value"] + $marketing["second_commission_value"]);
if ($price - $commissionTotal < $clearPrice) {
throw new GoodsException(['cus' => 40]);
}
}
}
}
}
}
/** /**
* 是否要初始化状态 * 是否要初始化状态
* @param $params * @param $params
...@@ -744,7 +792,8 @@ class GoodsService ...@@ -744,7 +792,8 @@ class GoodsService
|| $params["rule_desc"] != $sku["rule_desc"] || $params["rule_desc"] != $sku["rule_desc"]
|| $params["rule_refund"] != $sku["rule_refund"] || $params["rule_refund"] != $sku["rule_refund"]
|| $params["original_price"] != $sku["original_price"] || $params["original_price"] != $sku["original_price"]
|| $params["price"] != $sku["price"]; || $params["price"] != $sku["price"]
|| $params["clear_price"] != $sku["clear_price"];
} }
/** /**
...@@ -798,6 +847,7 @@ class GoodsService ...@@ -798,6 +847,7 @@ class GoodsService
} }
$data["goods_info"]["original_price"] = empty($sku["original_price"]) ? '' : (string)($sku["original_price"] / 100); $data["goods_info"]["original_price"] = empty($sku["original_price"]) ? '' : (string)($sku["original_price"] / 100);
$data["goods_info"]["clear_price"] = empty($sku["clear_price"]) ? 0 : $sku["clear_price"] / 100;
$data["goods_info"]["price"] = $sku["price"] / 100; $data["goods_info"]["price"] = $sku["price"] / 100;
$data["goods_info"]["inventory"] = $sku["inventory_rest"]; $data["goods_info"]["inventory"] = $sku["inventory_rest"];
...@@ -832,7 +882,7 @@ class GoodsService ...@@ -832,7 +882,7 @@ class GoodsService
$data["goods_info"]["is_tuanzhang"] = true; $data["goods_info"]["is_tuanzhang"] = true;
if (!empty($runningMarketing)) { if (!empty($runningMarketing)) {
//分销返现多少钱 //分销返现多少钱
$data["goods_info"]["cash_back"] = sprintf("%.2f",$runningMarketing[$sku["goods_sku_id"]] * $data["goods_info"]["price"]); $data["goods_info"]["cash_back"] = substr(sprintf("%.4f",$runningMarketing[$sku["goods_sku_id"]] * $data["goods_info"]["price"]),0,-2);
} }
} }
} }
...@@ -863,12 +913,18 @@ class GoodsService ...@@ -863,12 +913,18 @@ class GoodsService
*/ */
public static function getGoodsSkuInfo($params = []) public static function getGoodsSkuInfo($params = [])
{ {
$marketingType = !empty($params['marketing_type']) ? $params['marketing_type'] : 0; $goodsSukParams = GoodsSkuId::getGoodsSkuIdParams($params["goods_sku_id"]);
if ($marketingType == Marketing::MARKETING_TYPE_PINDAN) { if (!empty($goodsSukParams)) {
if (isset($goodsSukParams["table_tag"]) && ($goodsSukParams["table_tag"] == GoodsSkuId::TABLE_TAG_PINDAN
|| $goodsSukParams["category_1_id"] == "00")) {
return MarketingPindanGoodsService::pindanGoodsInfo($params); return MarketingPindanGoodsService::pindanGoodsInfo($params);
} else { } else {
return self::generalGoodsInfo($params); return self::generalGoodsInfo($params);
} }
} else {
throw new GoodsException(["cus" => 41]);
}
} }
/** /**
...@@ -892,6 +948,7 @@ class GoodsService ...@@ -892,6 +948,7 @@ class GoodsService
$data["goods_info"] = $sku; $data["goods_info"] = $sku;
$data["goods_info"]["original_price"] = empty($sku["original_price"]) ? '' : (string)($sku["original_price"] / 100); $data["goods_info"]["original_price"] = empty($sku["original_price"]) ? '' : (string)($sku["original_price"] / 100);
$data["goods_info"]["price"] = $sku["price"] / 100; $data["goods_info"]["price"] = $sku["price"] / 100;
$data["goods_info"]["clear_price"] = empty($sku["clear_price"]) ? 0 : $sku["clear_price"] / 100;
$data["goods_info"]["desc_pic_url_list"] = []; $data["goods_info"]["desc_pic_url_list"] = [];
if (!empty($sku["desc_pic_url"])) { if (!empty($sku["desc_pic_url"])) {
$ksyun = self::getUrlList($sku["desc_pic_url"]); $ksyun = self::getUrlList($sku["desc_pic_url"]);
...@@ -1514,7 +1571,14 @@ class GoodsService ...@@ -1514,7 +1571,14 @@ class GoodsService
"marketing_id" => $marketingId] "marketing_id" => $marketingId]
); );
if (empty($record)) { if (empty($record)) {
if (!empty($marketingId)) {
$marketing = Marketing::getRecord(["marketing_id" => $marketingId]);
if (!empty($marketing) && $marketing["marketing_type"] == Marketing::MARKETING_TYPE_PINDAN) {
$goodsSku = PindanGoodsSku::getRecord(["goods_sku_id" => $goodsSkuId]);
}
} else {
$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]);
} }
...@@ -1627,4 +1691,24 @@ class GoodsService ...@@ -1627,4 +1691,24 @@ class GoodsService
return self::addShop($lifeAccount); return self::addShop($lifeAccount);
} }
/**
* 退款拼单商品,库存调整
* @param $params
* @return bool
* @throws GoodsException
*/
public static function refundGoods($params)
{
$goodsSukParams = GoodsSkuId::getGoodsSkuIdParams($params["goods_sku_id"]);
if (!empty($goodsSukParams)) {
if (isset($goodsSukParams["table_tag"]) && ($goodsSukParams["table_tag"] == GoodsSkuId::TABLE_TAG_PINDAN
|| $goodsSukParams["category_1_id"] == "00")) {
return MarketingPindanGoodsService::refundGoods($params);
}
} else {
throw new GoodsException(["cus" => 41]);
}
return true;
}
} }
\ No newline at end of file
<?php
namespace App\Services\goods;
use App\Models\goods\mysql\PindanGoodsSnapshot;
class GoodsSnapshotsService
{
/**
* 拼单商品快照批量获取
* @param $params
* @return array
*/
public static function pindanGoodsSnapshots($params)
{
$str = empty($params["snapshots_str"]) ? "" : $params["snapshots_str"];
$pindanGoodsSnapshot = [];
if (!empty($str)) {
$paramsArr = json_decode($str, true);
if (!empty($paramsArr)) {
foreach ($paramsArr as $param) {
if (isset($param["goods_sku_id"]) || isset($param["goods_version"])) {
$key = $param["goods_sku_id"]."_".$param["goods_version"];
$pindanGoodsSnapshot[$key] = PindanGoodsSnapshot::select("*", [
"goods_sku_id" => $param["goods_sku_id"],
"goods_version" => $param["goods_version"]
]);
}
}
}
}
return $pindanGoodsSnapshot;
}
}
\ No newline at end of file
...@@ -14,6 +14,7 @@ use Api\PhpUtils\Http\HttpUtil; ...@@ -14,6 +14,7 @@ use Api\PhpUtils\Http\HttpUtil;
use App\Exception\custom\GoodsException; use App\Exception\custom\GoodsException;
use App\Models\goods\mysql\Category; use App\Models\goods\mysql\Category;
use App\Models\goods\mysql\GoodsOperationRecord; use App\Models\goods\mysql\GoodsOperationRecord;
use App\Models\goods\mysql\GoodsRefundRecord;
use App\Models\goods\mysql\GoodsSku; use App\Models\goods\mysql\GoodsSku;
use App\Models\goods\mysql\GoodsSkuPicRecord; use App\Models\goods\mysql\GoodsSkuPicRecord;
use App\Models\goods\mysql\GoodsSkuSubShop; use App\Models\goods\mysql\GoodsSkuSubShop;
...@@ -54,7 +55,22 @@ class MarketingPindanGoodsService ...@@ -54,7 +55,22 @@ class MarketingPindanGoodsService
//生活号信息 //生活号信息
$params["life_account_id"] = MarketingService::getPublicLifeAccountId(); $params["life_account_id"] = MarketingService::getPublicLifeAccountId();
$shopId = "00"; //生活号信息
$url = config('interface', 'merchant.lifeaccount.get_life_account_by_id');
if (empty($url)) {
throw new InterfaceException(['cus' => 0]);
}
$lifeAccountRes = HttpUtil::get($url, ["life_account_id" => $params["life_account_id"]]);
if (empty($lifeAccountRes["response"]["result"])) {
throw new GoodsException(['cus' => 29]);
}
$lifeAccount = [
"life_account_id" => $params["life_account_id"],
"merchant_id" => $lifeAccountRes["response"]["result"]["merchant_id"],
];
$shopId = GoodsService::addShop($lifeAccount);
$spuData = self::addGoodsSpu($shopId, $params); $spuData = self::addGoodsSpu($shopId, $params);
$skuId = self::addGoodsSku($spuData, $shopId, $params); $skuId = self::addGoodsSku($spuData, $shopId, $params);
//商品操作记录 //商品操作记录
...@@ -88,6 +104,13 @@ class MarketingPindanGoodsService ...@@ -88,6 +104,13 @@ class MarketingPindanGoodsService
$ksyun = GoodsService::getUrlList($sku["desc_pic_url"]); $ksyun = GoodsService::getUrlList($sku["desc_pic_url"]);
$data["goods_info"]["desc_pic_url_list"] = $ksyun; $data["goods_info"]["desc_pic_url_list"] = $ksyun;
} }
$data["goods_info"]["ota_name"] = "";
if (!empty($sku["ota_id"])) {
$ota = Ota::getRecord(["ota_id" => $sku["ota_id"]], ["ota_name"]);
if (!empty($ota)) {
$data["goods_info"]["ota_name"] = $ota["ota_name"];
}
}
} }
return $data; return $data;
} }
...@@ -124,6 +147,7 @@ class MarketingPindanGoodsService ...@@ -124,6 +147,7 @@ class MarketingPindanGoodsService
"goods_sub_type" => empty($spuData["goods_sub_type"]) ? GoodsSpu::SUB_TYPE_INSTANT : $spuData["goods_sub_type"], "goods_sub_type" => empty($spuData["goods_sub_type"]) ? GoodsSpu::SUB_TYPE_INSTANT : $spuData["goods_sub_type"],
"belong_type" => empty($spuData["belong_type"]) ? GoodsSpu::BELONG_TYPE_DISANFANG : $spuData["belong_type"], "belong_type" => empty($spuData["belong_type"]) ? GoodsSpu::BELONG_TYPE_DISANFANG : $spuData["belong_type"],
"goods_sale_type" => empty($spuData["setmeal"]) ? GoodsSpu::SALE_TYPE_NO_COMBINATION : GoodsSpu::SALE_TYPE_COMBINATION, "goods_sale_type" => empty($spuData["setmeal"]) ? GoodsSpu::SALE_TYPE_NO_COMBINATION : GoodsSpu::SALE_TYPE_COMBINATION,
"can_show_es" => GoodsSpu::CAN_SHOW_ES_NO,
]; ];
GoodsSpu::save($spuParams); GoodsSpu::save($spuParams);
return $spuParams; return $spuParams;
...@@ -150,7 +174,7 @@ class MarketingPindanGoodsService ...@@ -150,7 +174,7 @@ class MarketingPindanGoodsService
if (empty($res)) { if (empty($res)) {
throw new GoodsException(['cus' => 2]); throw new GoodsException(['cus' => 2]);
} }
$skuId = GoodsSkuId::generateGoodSkuId($res[0], 0, 0, $spuData["goods_type"], $spuData["belong_type"]); $skuId = GoodsSkuId::generateGoodSkuId($res[0], "00", "000", $spuData["goods_type"], $spuData["belong_type"], "001");
if ($skuData["price"] <= 0) { if ($skuData["price"] <= 0) {
throw new GoodsException(['cus' => 33]); throw new GoodsException(['cus' => 33]);
...@@ -172,7 +196,7 @@ class MarketingPindanGoodsService ...@@ -172,7 +196,7 @@ class MarketingPindanGoodsService
"goods_spu_id" => $spuData["goods_spu_id"], "goods_spu_id" => $spuData["goods_spu_id"],
"life_account_id" => $skuData["life_account_id"], "life_account_id" => $skuData["life_account_id"],
"publish_user_id" => empty($skuData["publish_user_id"]) ? "" : $skuData["publish_user_id"], "publish_user_id" => empty($skuData["publish_user_id"]) ? "" : $skuData["publish_user_id"],
"ota_id" => $skuData["ota_id"], "ota_id" => empty($skuData["ota_id"]) ? 0 : $skuData["ota_id"],
"category_1_id" => 0, "category_1_id" => 0,
"category_2_id" => 0, "category_2_id" => 0,
"goods_name" => $skuData["goods_name"], "goods_name" => $skuData["goods_name"],
...@@ -285,7 +309,7 @@ class MarketingPindanGoodsService ...@@ -285,7 +309,7 @@ class MarketingPindanGoodsService
"desc_pic_url" => $params["desc_pic_url"], "desc_pic_url" => $params["desc_pic_url"],
"desc" => $params["desc"], "desc" => $params["desc"],
"inventory_total" => $skuData["inventory_total"] + $params["inventory_add"], "inventory_total" => $skuData["inventory_total"] + $params["inventory_add"],
//"inventory_total" => $params["inventory"], "ota_id" => empty($params["ota_id"]) ? 0 : $params["ota_id"],
"inventory_rest" => $inventoryCount, "inventory_rest" => $inventoryCount,
"original_price" => empty($params["original_price"]) ? "" : $params["original_price"] * 100, "original_price" => empty($params["original_price"]) ? "" : $params["original_price"] * 100,
"price" => $params["price"] * 100, "price" => $params["price"] * 100,
...@@ -392,7 +416,7 @@ class MarketingPindanGoodsService ...@@ -392,7 +416,7 @@ class MarketingPindanGoodsService
$count = PindanGoodsSku::count("*", $where); $count = PindanGoodsSku::count("*", $where);
if (!empty($list)) { if (!empty($list)) {
foreach ($list as $key => $item) { foreach ($list as $key => $item) {
$list[$key]["original_price"] = $item["original_price"] / 100; $list[$key]["original_price"] = (int)$item["original_price"] / 100;
$list[$key]["price"] = $item["price"] / 100; $list[$key]["price"] = $item["price"] / 100;
if (!empty($otaData) && !empty($otaData[$item["ota_id"]])) { if (!empty($otaData) && !empty($otaData[$item["ota_id"]])) {
$list[$key]["ota_name"] = $otaData[$item["ota_id"]]["ota_name"]; $list[$key]["ota_name"] = $otaData[$item["ota_id"]]["ota_name"];
...@@ -426,7 +450,68 @@ class MarketingPindanGoodsService ...@@ -426,7 +450,68 @@ class MarketingPindanGoodsService
if (!empty($sku["desc_pic_url"])) { if (!empty($sku["desc_pic_url"])) {
$ksyun = GoodsService::getUrlList($sku["desc_pic_url"]); $ksyun = GoodsService::getUrlList($sku["desc_pic_url"]);
$data["goods_info"]["desc_pic_url_list"] = $ksyun; $data["goods_info"]["desc_pic_url_list"] = $ksyun;
$strList = explode(",", $sku["desc_pic_url"]);
$shareStr = $strList[0];
$shareRes = Ks3Api::picEncryptUrl($shareStr, 500, 400);
$shareUrl = empty($shareRes["response"]["data"]["url"]) ? "" : $shareRes["response"]["data"]["url"];
$data["goods_info"]["share_url"] = $shareUrl;
} }
return $data; return $data;
} }
/**
* 退款拼单商品,库存调整
* @param $params
* @return bool
* @throws GoodsException
*/
public static function refundGoods($params)
{
$sku = PindanGoodsSku::get("*", ["goods_sku_id" => $params["goods_sku_id"]]);
if (empty($sku)) {
throw new GoodsException(["cus" => 15]);
}
PindanGoodsSku::beginTransaction();
$records = GoodsRefundRecord::getRecordMaster([
"goods_sku_id" => $params["goods_sku_id"],
"order_item_id" => $params["order_item_id"],
"operator_result" => GoodsRefundRecord::OPERATOR_RESULT_SUCCESS
]);
if (empty($records)) {
GoodsRefundRecord::save([
"goods_sku_id" => $params["goods_sku_id"],
"order_id" => $params["order_id"],
"order_item_id" => $params["order_item_id"],
"num" => $params["num"],
"operator_result" => GoodsRefundRecord::OPERATOR_RESULT_SUCCESS
]);
$row = PindanGoodsSku::save([
"total_amount_sold" => $sku["total_amount_sold"] - $params["num"],
"total_amount_order" => $sku["total_amount_order"] - $params["num"],
"inventory_rest" => $sku["inventory_rest"] + $params["num"],
], ["goods_sku_id" => $sku["goods_sku_id"], "total_amount_sold[>=]" => $params["num"], "total_amount_order[>=]" => $params["num"]]);
if ($row < 1){
PindanGoodsSku::rollback();
GoodsRefundRecord::save([
"goods_sku_id" => $params["goods_sku_id"],
"order_id" => $params["order_id"],
"order_item_id" => $params["order_item_id"],
"num" => $params["num"],
"operator_result" => GoodsRefundRecord::OPERATOR_RESULT_FAILURE
]);
throw new GoodsException(["cus" => 0]);
}
}
if (!PindanGoodsSku::commit()) {
PindanGoodsSku::rollback();
throw new GoodsException(["cus" => 0]);
}
return true;
}
} }
\ No newline at end of file
...@@ -44,6 +44,21 @@ class OtaService ...@@ -44,6 +44,21 @@ class OtaService
return Ota::get(self::COLUMNS,['ota_id'=>$OtaId]); return Ota::get(self::COLUMNS,['ota_id'=>$OtaId]);
} }
/**
* 根据id批量获取供应商信息
* @param $otaIds
* @return \Api\PhpUtils\Mysql\MysqlBase|array
*/
public static function getOtaListByIds($otaIds)
{
if(empty($otaIds)) {
return [];
}
return Ota::select(self::COLUMNS,['ota_id'=>$otaIds]);
}
/** /**
* 添加供应商 * 添加供应商
* @param $params * @param $params
......
<?php
namespace App\Services\marketing;
use App\Exception\custom\MarketingException;
use App\Models\goods\mysql\GoodsSku;
use App\Models\goods\mysql\PindanGoodsSku;
use App\Models\marketing\mysql\Marketing;
use App\Models\marketing\mysql\MarketingGoods;
use App\Models\marketing\mysql\MarketingTakePlace;
use App\Models\marketing\mysql\TakePlace;
class MarketingForOrderService
{
/**
* 活动列表
* @param $params
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public static function getMarketingList($params)
{
$where['marketing_type'] = !empty($params['marketing_type']) ? $params['marketing_type'] : Marketing::MARKETING_TYPE_PINDAN;
return Marketing::select(["marketing_id", "marketing_name", "create_time"], ["marketing_type" => $where['marketing_type']]);
}
/**
* 活动的商品
* @param $params
* @return \Api\PhpUtils\Mysql\MysqlBase|array
* @throws MarketingException
*/
public static function getMarketingGoodsList($params)
{
if (empty($params["marketing_id"])) {
throw new MarketingException(['cus' => 6]);
}
$goodsSkuIdList = MarketingGoods::select(["goods_sku_id"], ["marketing_id" => $params["marketing_id"]]);
$goodsSkuList = [];
if (!empty($goodsSkuIdList)) {
$goodsSkuIdArr = array_column($goodsSkuIdList, "goods_sku_id");
$goodsSkuList = PindanGoodsSku::select(["goods_sku_id", "goods_name", "create_time"], ["goods_sku_id" => $goodsSkuIdArr]);
}
return $goodsSkuList;
}
/**
* 活动的自提点
* @param $params
* @return \Api\PhpUtils\Mysql\MysqlBase|array
* @throws MarketingException
*/
public static function getMarketingTakePlaceList($params)
{
if (!empty($params["marketing_id"])) {
$takePlaceIdList = MarketingTakePlace::select(["take_place_id"], ["marketing_id" => $params["marketing_id"]]);
$takePlaceList = [];
if (!empty($takePlaceIdList)) {
$takePlaceIdArr = array_column($takePlaceIdList, "take_place_id");
$takePlaceList = TakePlace::select(["take_place_id", "take_place_name", "create_time"], ["take_place_id" => $takePlaceIdArr]);
}
} else {
$takePlaceList = TakePlace::select(["take_place_id", "take_place_name", "create_time"]);
}
return $takePlaceList;
}
}
\ No newline at end of file
...@@ -70,6 +70,9 @@ class MarketingGoodsService ...@@ -70,6 +70,9 @@ class MarketingGoodsService
"online_status" => 1, "online_status" => 1,
]; ];
$marketingList = Marketing::getMarketingList($marketingWhere); $marketingList = Marketing::getMarketingList($marketingWhere);
$list = [];
$lastId = "";
if (!empty($marketingList)) {
$marketingId = array_column($marketingList, 'marketing_id'); $marketingId = array_column($marketingList, 'marketing_id');
$where['marketing_id'] = !empty($marketingId) ? $marketingId : []; $where['marketing_id'] = !empty($marketingId) ? $marketingId : [];
$data = MarketingGoods::marketingGoodsList($where); $data = MarketingGoods::marketingGoodsList($where);
...@@ -97,7 +100,6 @@ class MarketingGoodsService ...@@ -97,7 +100,6 @@ class MarketingGoodsService
$lifeAccountList = CommonService::getlifeAccountList(['life_account_id' => $lifeAccountId]); $lifeAccountList = CommonService::getlifeAccountList(['life_account_id' => $lifeAccountId]);
$list = [];
$i = 0; $i = 0;
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
...@@ -160,8 +162,7 @@ class MarketingGoodsService ...@@ -160,8 +162,7 @@ class MarketingGoodsService
$list[$i]['goods_share_code'] = $goodsShareId; $list[$i]['goods_share_code'] = $goodsShareId;
$i++; $i++;
} }
}
} }
$result = ['result' => $list ,'last_id' => $lastId]; $result = ['result' => $list ,'last_id' => $lastId];
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Services\marketing; namespace App\Services\marketing;
use Api\PhpServices\Ksy\Ks3Api;
use App\Models\goods\mysql\Ota; use App\Models\goods\mysql\Ota;
use App\Models\goods\mysql\PindanGoodsSku; use App\Models\goods\mysql\PindanGoodsSku;
use App\Models\marketing\mysql\Marketing; use App\Models\marketing\mysql\Marketing;
...@@ -17,7 +18,7 @@ use App\Models\marketing\mysql\TakePlace; ...@@ -17,7 +18,7 @@ use App\Models\marketing\mysql\TakePlace;
use App\Services\common\CommonService; use App\Services\common\CommonService;
use App\Services\goods\GoodsService; use App\Services\goods\GoodsService;
use Daemon\Goods; use Daemon\Goods;
use App\Exception\custom\GoodsException;
class MarketingService class MarketingService
{ {
...@@ -33,7 +34,7 @@ class MarketingService ...@@ -33,7 +34,7 @@ class MarketingService
} elseif (in_array($env, ['test'])) { } elseif (in_array($env, ['test'])) {
$lifeAccountId = "15559498695737346"; $lifeAccountId = "15559498695737346";
}else { }else {
$lifeAccountId = ""; $lifeAccountId = "19019625839230981";
} }
return $lifeAccountId; return $lifeAccountId;
} }
...@@ -223,6 +224,8 @@ class MarketingService ...@@ -223,6 +224,8 @@ class MarketingService
private static function pindanMarketingList($params) private static function pindanMarketingList($params)
{ {
$params['activity_status'] = !empty($params['activity_status']) ? $params['activity_status'] : 0; $params['activity_status'] = !empty($params['activity_status']) ? $params['activity_status'] : 0;
//默认from=0,主要是判断小程序(from=1)时候特殊逻辑
$params['from'] = !empty($params['from']) ? $params['from'] : 0;
$params['page'] = !empty($params['page']) ? $params['page'] : 1; $params['page'] = !empty($params['page']) ? $params['page'] : 1;
$limit = !empty($params['page_size']) ? $params['page_size'] : 20; $limit = !empty($params['page_size']) ? $params['page_size'] : 20;
$page = ($params['page'] - 1) * $limit; $page = ($params['page'] - 1) * $limit;
...@@ -245,6 +248,11 @@ class MarketingService ...@@ -245,6 +248,11 @@ class MarketingService
$where["end_time[<]"] = $now; $where["end_time[<]"] = $now;
} }
if (!empty($params['from'])) {
$beforeSevenDay = date("Y-m-d H:i:s", strtotime("-7 day"));
$where["start_time[>]"] = $beforeSevenDay;
}
$where['ORDER'] = ["update_time" => "DESC"]; $where['ORDER'] = ["update_time" => "DESC"];
$where['LIMIT'] = [$page, $limit]; $where['LIMIT'] = [$page, $limit];
$list = Marketing::select(["marketing_id", "marketing_name", "start_time", "end_time", $list = Marketing::select(["marketing_id", "marketing_name", "start_time", "end_time",
...@@ -258,7 +266,8 @@ class MarketingService ...@@ -258,7 +266,8 @@ class MarketingService
$marketingIds[] = $value["marketing_id"]; $marketingIds[] = $value["marketing_id"];
} }
$marketingPindanData = MarketingPindan::select(["marketing_id", "publish_life_account_id", "min_price", "max_price", "pindan_desc","participate_number"] $marketingPindanData = MarketingPindan::select(["marketing_id", "publish_life_account_id",
"min_price", "max_price", "pindan_desc","participate_number", "pindan_pic"]
, ["marketing_id" => $marketingIds]); , ["marketing_id" => $marketingIds]);
$priceData = []; $priceData = [];
if (!empty($marketingPindanData)) { if (!empty($marketingPindanData)) {
...@@ -269,6 +278,7 @@ class MarketingService ...@@ -269,6 +278,7 @@ class MarketingService
$publishLifeAccountIds = array_unique(array_column($marketingPindanData, "publish_life_account_id")); $publishLifeAccountIds = array_unique(array_column($marketingPindanData, "publish_life_account_id"));
$lifeAccountList = CommonService::getlifeAccountList(['life_account_id' => $publishLifeAccountIds]); $lifeAccountList = CommonService::getlifeAccountList(['life_account_id' => $publishLifeAccountIds]);
$defaultPic = "SHQ_goods_0_012Xh1AQcMqu";
foreach ($list as $key => $value) { foreach ($list as $key => $value) {
$lists[$key] = $value; $lists[$key] = $value;
$lists[$key]["online_status_desc"] = Marketing::$onlineStatusDesc[$value["online_status"]]; $lists[$key]["online_status_desc"] = Marketing::$onlineStatusDesc[$value["online_status"]];
...@@ -279,10 +289,20 @@ class MarketingService ...@@ -279,10 +289,20 @@ class MarketingService
$lists[$key]["life_account_icon"] = $lifeAccountList[$currentLifeAccountId]["life_account_icon"]; $lists[$key]["life_account_icon"] = $lifeAccountList[$currentLifeAccountId]["life_account_icon"];
$lists[$key]["life_account_name"] = $lifeAccountList[$currentLifeAccountId]["life_account_name"]; $lists[$key]["life_account_name"] = $lifeAccountList[$currentLifeAccountId]["life_account_name"];
} }
$lists[$key]["min_price"] = $priceData[$value["marketing_id"]]["min_price"];
$lists[$key]["max_price"] = $priceData[$value["marketing_id"]]["max_price"]; $picUrl = GoodsService::getUrlList($priceData[$value["marketing_id"]]["pindan_pic"]);
$lists[$key]["min_price"] = sprintf("%.2f", $priceData[$value["marketing_id"]]["min_price"] / 100);
$lists[$key]["max_price"] = sprintf("%.2f", $priceData[$value["marketing_id"]]["max_price"] / 100);
$lists[$key]["pindan_pic_url"] = $picUrl;
$lists[$key]["pindan_desc"] = $priceData[$value["marketing_id"]]["pindan_desc"]; $lists[$key]["pindan_desc"] = $priceData[$value["marketing_id"]]["pindan_desc"];
$lists[$key]["participate_number"] = $priceData[$value["marketing_id"]]["participate_number"]; $lists[$key]["participate_number"] = $priceData[$value["marketing_id"]]["participate_number"];
$shareDefaultStr = empty($priceData[$value["marketing_id"]]["pindan_pic"]) ? $defaultPic : $priceData[$value["marketing_id"]]["pindan_pic"];
$strList = explode(",", $shareDefaultStr);
$shareStr = $strList[0];
$shareRes = Ks3Api::picEncryptUrl($shareStr, 500, 400);
$shareUrl = empty($shareRes["response"]["data"]["url"]) ? "" : $shareRes["response"]["data"]["url"];
$lists[$key]["share_url"] = $shareUrl;
} }
} }
} }
...@@ -323,7 +343,9 @@ class MarketingService ...@@ -323,7 +343,9 @@ class MarketingService
*/ */
private static function addFenxiaoMarketing($params) private static function addFenxiaoMarketing($params)
{ {
$commissionMode = !empty($params['commission_mode']) ? $params['commission_mode'] : 1;
$marketingName = !empty($params['marketing_name']) ? $params['marketing_name'] : ''; $marketingName = !empty($params['marketing_name']) ? $params['marketing_name'] : '';
$firstCommissionRate = !empty($params['first_commission_value']) ? $params['first_commission_value']*100 : 0; $firstCommissionRate = !empty($params['first_commission_value']) ? $params['first_commission_value']*100 : 0;
$secondCommissionRate = !empty($params['second_commission_value']) ? $params['second_commission_value']*100 : 0; $secondCommissionRate = !empty($params['second_commission_value']) ? $params['second_commission_value']*100 : 0;
$createUserEmail = !empty($params['op_cur_user']) ? $params['op_cur_user'] : ''; $createUserEmail = !empty($params['op_cur_user']) ? $params['op_cur_user'] : '';
...@@ -332,10 +354,12 @@ class MarketingService ...@@ -332,10 +354,12 @@ class MarketingService
$type = !empty($params['marketing_type']) ? $params['marketing_type'] : 1; $type = !empty($params['marketing_type']) ? $params['marketing_type'] : 1;
$goodsSkuId = !empty($params['goods_sku_id']) ? explode(",", $params['goods_sku_id']) : []; $goodsSkuId = !empty($params['goods_sku_id']) ? explode(",", $params['goods_sku_id']) : [];
if ($commissionMode == 1) {
$rate = $firstCommissionRate + $secondCommissionRate; $rate = $firstCommissionRate + $secondCommissionRate;
if ($rate > 5000) { if ($rate > 5000) {
throw new MarketingException(['cus'=>15]); throw new MarketingException(['cus'=>15]);
} }
}
if (empty($goodsSkuId)) { if (empty($goodsSkuId)) {
throw new MarketingException(['cus'=>12]); throw new MarketingException(['cus'=>12]);
...@@ -439,6 +463,7 @@ class MarketingService ...@@ -439,6 +463,7 @@ class MarketingService
'update_user_email' => $createUserEmail, 'update_user_email' => $createUserEmail,
'update_time' => date("Y-m-d H:i:s"), 'update_time' => date("Y-m-d H:i:s"),
'create_time' => date("Y-m-d H:i:s"), 'create_time' => date("Y-m-d H:i:s"),
'commission_mode' => $commissionMode,
]; ];
$marketingId = Marketing::insertRecord($colums); $marketingId = Marketing::insertRecord($colums);
if (empty($marketingId)) { if (empty($marketingId)) {
...@@ -449,6 +474,22 @@ class MarketingService ...@@ -449,6 +474,22 @@ class MarketingService
$goodCount = !empty($goodsSkuId) ? count($goodsSkuId) : 0; $goodCount = !empty($goodsSkuId) ? count($goodsSkuId) : 0;
$goodsSkuList = GoodsSku::select('*', ['goods_sku_id' => $goodsSkuId]); $goodsSkuList = GoodsSku::select('*', ['goods_sku_id' => $goodsSkuId]);
foreach ($goodsSkuList as $key => $value) { foreach ($goodsSkuList as $key => $value) {
$clearPrice = !empty($value["clear_price"]) ? $value["clear_price"]*100 : 0;
$price = !empty($value["price"]) ? $value["price"]*100 : 0;
// if ($commissionMode == Marketing::COMMISSION_MODE_RATE) {
// $commissionTotal = ($firstCommissionRate + $secondCommissionRate) / 1000 * $price;
// if ($price - $commissionTotal < $clearPrice) {
// throw new GoodsException(['cus' => 36]);
// }
// }
//
// if ($commissionMode == Marketing::COMMISSION_MODE_FIXED) {
// $commissionTotal = ($firstCommissionRate + $secondCommissionRate);
// if ($price - $commissionTotal < $clearPrice) {
// throw new GoodsException(['cus' => 36]);
// }
// }
$colums[$key]['marketing_id'] = $marketingId; $colums[$key]['marketing_id'] = $marketingId;
$colums[$key]['goods_spu_id'] = $value['goods_spu_id']; $colums[$key]['goods_spu_id'] = $value['goods_spu_id'];
$colums[$key]['goods_sku_id'] = $value['goods_sku_id']; $colums[$key]['goods_sku_id'] = $value['goods_sku_id'];
...@@ -503,6 +544,9 @@ class MarketingService ...@@ -503,6 +544,9 @@ class MarketingService
if ($startTime >= $endTime) { if ($startTime >= $endTime) {
throw new MarketingException(['cus' => 21]); throw new MarketingException(['cus' => 21]);
} }
if (empty($takePlaceIds)) {
throw new MarketingException(['cus' => 22]);
}
//重复判断 //重复判断
$marketing = Marketing::getRecord(["marketing_name" => $marketingName], ["marketing_id"]); $marketing = Marketing::getRecord(["marketing_name" => $marketingName], ["marketing_id"]);
...@@ -526,8 +570,8 @@ class MarketingService ...@@ -526,8 +570,8 @@ class MarketingService
} }
$uniquePriceList = array_unique($priceList); $uniquePriceList = array_unique($priceList);
sort($uniquePriceList); sort($uniquePriceList);
$minPrice = $priceList[0]; $minPrice = $uniquePriceList[0];
$maxPrice = end($priceList); $maxPrice = end($uniquePriceList);
Marketing::beginTransaction(); Marketing::beginTransaction();
$marketingParams = [ $marketingParams = [
...@@ -536,6 +580,8 @@ class MarketingService ...@@ -536,6 +580,8 @@ class MarketingService
'end_time' => $endTime, 'end_time' => $endTime,
'online_status' => 1, 'online_status' => 1,
'marketing_type' => $type, 'marketing_type' => $type,
'good_count' => count($goodsSkuId),
'create_user_email' => $createUserEmail,
'update_user_email' => $createUserEmail, 'update_user_email' => $createUserEmail,
'update_time' => date("Y-m-d H:i:s"), 'update_time' => date("Y-m-d H:i:s"),
'create_time' => date("Y-m-d H:i:s"), 'create_time' => date("Y-m-d H:i:s"),
...@@ -655,6 +701,9 @@ class MarketingService ...@@ -655,6 +701,9 @@ class MarketingService
if ($startTime >= $endTime) { if ($startTime >= $endTime) {
throw new MarketingException(['cus' => 21]); throw new MarketingException(['cus' => 21]);
} }
if (empty($takePlaceIds)) {
throw new MarketingException(['cus' => 22]);
}
//获取商品的最大最小值 //获取商品的最大最小值
$skuInfoList = PindanGoodsSku::getRecordMaster(["goods_sku_id" => $goodsSkuId] $skuInfoList = PindanGoodsSku::getRecordMaster(["goods_sku_id" => $goodsSkuId]
...@@ -665,19 +714,19 @@ class MarketingService ...@@ -665,19 +714,19 @@ class MarketingService
} }
$uniquePriceList = array_unique($priceList); $uniquePriceList = array_unique($priceList);
sort($uniquePriceList); sort($uniquePriceList);
$minPrice = $priceList[0]; $minPrice = $uniquePriceList[0];
$maxPrice = end($priceList); $maxPrice = end($uniquePriceList);
Marketing::beginTransaction(); Marketing::beginTransaction();
$marketingParams = [ $marketingParams = [
'marketing_name' => $marketingName, 'marketing_name' => $marketingName,
'start_time' => $startTime, 'start_time' => $startTime,
'end_time' => $endTime, 'end_time' => $endTime,
'online_status' => 1, 'online_status' => Marketing::ONLINE_STATUS_QIDONG,
'marketing_type' => $type, 'marketing_type' => $type,
'good_count' => count($goodsSkuId),
'update_user_email' => $createUserEmail, 'update_user_email' => $createUserEmail,
'update_time' => date("Y-m-d H:i:s"), 'update_time' => date("Y-m-d H:i:s"),
'create_time' => date("Y-m-d H:i:s"),
]; ];
Marketing::updateRecord($marketingParams, ["marketing_id" => $marketingId]); Marketing::updateRecord($marketingParams, ["marketing_id" => $marketingId]);
...@@ -740,6 +789,32 @@ class MarketingService ...@@ -740,6 +789,32 @@ class MarketingService
return true; return true;
} }
/**
* 修改活动的状态
* @param $params
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public static function updateMarketingOnlineStatus($params)
{
$marketingId = $params["marketing_id"];
$marketingType = $params["marketing_type"];
$onlineStatus = Marketing::ONLINE_STATUS_DAOQI;
$endTime = date("Y-m-d H:i:s");
if ($params["online_status"] == Marketing::ONLINE_STATUS_QIDONG) {
$onlineStatus = Marketing::ONLINE_STATUS_QIDONG;
$endTime = date("Y-m-d H:i:s", strtotime("+7 day"));
}
if ($params["online_status"] == Marketing::ONLINE_STATUS_GUANBI) {
$onlineStatus = Marketing::ONLINE_STATUS_GUANBI;
$endTime = date("Y-m-d H:i:s");
}
$marketingParams = [
'online_status' => $onlineStatus,
'end_time' => $endTime,
];
Marketing::updateRecord($marketingParams, ["marketing_id" => $marketingId, "marketing_type" => $marketingType]);
}
/** /**
* 分销活动详情 * 分销活动详情
* @param $params * @param $params
...@@ -834,11 +909,19 @@ class MarketingService ...@@ -834,11 +909,19 @@ class MarketingService
$marketingData["pindan_pic"] = $pindanMarketing["pindan_pic"]; $marketingData["pindan_pic"] = $pindanMarketing["pindan_pic"];
$marketingData["pindan_pic_url"] = GoodsService::getUrlList($marketingData["pindan_pic"]); $marketingData["pindan_pic_url"] = GoodsService::getUrlList($marketingData["pindan_pic"]);
$marketingData["pindan_desc"] = $pindanMarketing["pindan_desc"]; $marketingData["pindan_desc"] = $pindanMarketing["pindan_desc"];
$marketingData["max_price"] = $pindanMarketing["max_price"]; $marketingData["max_price"] = sprintf("%.2f", $pindanMarketing["max_price"] / 100);
$marketingData["min_price"] = $pindanMarketing["min_price"]; $marketingData["min_price"] = sprintf("%.2f", $pindanMarketing["min_price"] / 100);
$marketingData["participate_number"] = $pindanMarketing["participate_number"]; $marketingData["participate_number"] = $pindanMarketing["participate_number"];
$marketingData["create_time"] = $marketingInfo["create_time"]; $marketingData["create_time"] = $marketingInfo["create_time"];
$defaultPic = "SHQ_goods_0_012Xh1AQcMqu";
$shareDefaultStr = empty($marketingData["pindan_pic"]) ? $defaultPic : $marketingData["pindan_pic"];
$strList = explode(",", $shareDefaultStr);
$shareStr = $strList[0];
$shareRes = Ks3Api::picEncryptUrl($shareStr, 500, 400);
$shareUrl = empty($shareRes["response"]["data"]["url"]) ? "" : $shareRes["response"]["data"]["url"];
$marketingData["share_url"] = $shareUrl;
$info['marketing_info'] = $marketingData; $info['marketing_info'] = $marketingData;
if (!empty($goodsSkuList)) { if (!empty($goodsSkuList)) {
...@@ -850,7 +933,9 @@ class MarketingService ...@@ -850,7 +933,9 @@ class MarketingService
foreach ($goodsSkuList as $key => $item) { foreach ($goodsSkuList as $key => $item) {
$goodsSkuList[$key]["desc_pic_url_list"] = GoodsService::getUrlList($item["desc_pic_url"]); $goodsSkuList[$key]["desc_pic_url_list"] = GoodsService::getUrlList($item["desc_pic_url"]);
$goodsSkuList[$key]["ota_name"] = $otasData[$item["ota_id"]]["ota_name"]; $goodsSkuList[$key]["ota_name"] = empty($otasData[$item["ota_id"]]["ota_name"]) ? "" : $otasData[$item["ota_id"]]["ota_name"];
$goodsSkuList[$key]["original_price"] = sprintf("%.2f", (int)$item["original_price"] / 100);
$goodsSkuList[$key]["price"] = sprintf("%.2f", $item["price"] / 100);
} }
} }
......
...@@ -7,6 +7,7 @@ use Api\PhpUtils\Http\Request; ...@@ -7,6 +7,7 @@ use Api\PhpUtils\Http\Request;
use App\Models\marketing\mysql\MarketingTakePlace; use App\Models\marketing\mysql\MarketingTakePlace;
use App\Models\marketing\mysql\TakePlace; use App\Models\marketing\mysql\TakePlace;
use App\Exception\custom\MarketingException; use App\Exception\custom\MarketingException;
use Api\PhpUtils\Common\Geo;
class TakePlaceService class TakePlaceService
{ {
...@@ -56,6 +57,7 @@ class TakePlaceService ...@@ -56,6 +57,7 @@ class TakePlaceService
$data['take_place_name'] = $params['name']; $data['take_place_name'] = $params['name'];
$data['longitude'] = $params['longitude']; $data['longitude'] = $params['longitude'];
$data['latitude'] = $params['latitude']; $data['latitude'] = $params['latitude'];
$data['location'] = $params['location'];
$data['address'] = $params['address']; $data['address'] = $params['address'];
$data['contact_name'] = $params['contact_name'] ?? ''; $data['contact_name'] = $params['contact_name'] ?? '';
$data['phone'] = $params['phone'] ?? ''; $data['phone'] = $params['phone'] ?? '';
...@@ -112,6 +114,8 @@ class TakePlaceService ...@@ -112,6 +114,8 @@ class TakePlaceService
{ {
$marketingId = $params['marketing_id']; $marketingId = $params['marketing_id'];
$keywords = $params['keywords'] ?? ''; $keywords = $params['keywords'] ?? '';
$longitude = $params['longitude'] ?? '';
$latitude = $params['latitude'] ?? '';
$page = $params['page'] ?? 1; $page = $params['page'] ?? 1;
$limit = $params['limit'] ?? 20; $limit = $params['limit'] ?? 20;
...@@ -138,7 +142,8 @@ class TakePlaceService ...@@ -138,7 +142,8 @@ class TakePlaceService
//获取自提点信息 //获取自提点信息
$makePlaceIds = array_column($relations,'take_place_id'); $makePlaceIds = array_column($relations,'take_place_id');
$takePlaceWhere = ['take_place_id'=>$makePlaceIds]; $takePlaceWhere = ['take_place_id'=>$makePlaceIds];
$res['list'] = TakePlace::select('*', $takePlaceWhere); //本页按距离返回列表
$res['list'] = self::sortByDistance($latitude,$longitude,TakePlace::select('*', $takePlaceWhere));
unset($where['ORDER'],$where['LIMIT']); unset($where['ORDER'],$where['LIMIT']);
$res['total'] = MarketingTakePlace::count('*', $where); $res['total'] = MarketingTakePlace::count('*', $where);
$res['total_page'] = ceil($res['total']/$limit); $res['total_page'] = ceil($res['total']/$limit);
...@@ -146,4 +151,36 @@ class TakePlaceService ...@@ -146,4 +151,36 @@ class TakePlaceService
return $res; return $res;
} }
/**
* 根据经纬度按距离排序
* @param $lat
* @param $lng
* @param $list
* @return array
*/
private static function sortByDistance($lat, $lng, $list)
{
//未传经纬度
if(empty($lat) || empty($lng)) {
return $list;
}
//按距离返回自提点列表
$sort = [];
if(!empty($list) && is_array($list)) {
foreach ($list as &$item) {
if($item['longitude'] && $item['latitude']) {
$item['distance'] = Geo::geoDistance($lat,$lng,$item['longitude'],$item['latitude'],true);
$sort[] = $item['distance'];
}else {
$item['distance'] = '';
}
}
unset($item);
//按距离排序
array_multisort($sort, SORT_ASC, $list);
return $list;
}
}
} }
\ No newline at end of file
...@@ -2,11 +2,14 @@ ...@@ -2,11 +2,14 @@
namespace App\Services\tcc; namespace App\Services\tcc;
use Api\PhpUtils\Common\GoodsSkuId;
use App\Exception\custom\GoodsException; use App\Exception\custom\GoodsException;
use App\Models\goods\mysql\GoodsSku; use App\Models\goods\mysql\GoodsSku;
use App\Models\goods\mysql\PindanGoodsSku; use App\Models\goods\mysql\PindanGoodsSku;
use App\Models\goods\mysql\Tcc; use App\Models\goods\mysql\Tcc;
use App\Models\marketing\mysql\Marketing; use App\Models\marketing\mysql\Marketing;
use App\Models\marketing\mysql\MarketingPindan;
use App\Services\goods\MarketingPindanGoodsService;
class Tcc2Service class Tcc2Service
{ {
...@@ -24,13 +27,13 @@ class Tcc2Service ...@@ -24,13 +27,13 @@ class Tcc2Service
{ {
$goodsInfoList = json_decode($keys, true); $goodsInfoList = json_decode($keys, true);
if (empty($goodsInfoList)) { if (empty($goodsInfoList)) {
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 42]);
} }
$isPindan = false; $isPindan = false;
foreach ($goodsInfoList as $item) { foreach ($goodsInfoList as $item) {
if (empty($item["goods_sku_id"]) || empty($item["num"])) { if (empty($item["goods_sku_id"]) || empty($item["num"])) {
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 42]);
} }
if (!empty($item["marketing_id"]) && !empty($item["marketing_type"]) && $item["marketing_type"] == Marketing::MARKETING_TYPE_PINDAN) { if (!empty($item["marketing_id"]) && !empty($item["marketing_type"]) && $item["marketing_type"] == Marketing::MARKETING_TYPE_PINDAN) {
$isPindan = true; $isPindan = true;
...@@ -84,7 +87,7 @@ class Tcc2Service ...@@ -84,7 +87,7 @@ class Tcc2Service
} }
} else { } else {
GoodsSku::rollback(); GoodsSku::rollback();
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 43]);
} }
} }
Tcc::save([ Tcc::save([
...@@ -95,7 +98,7 @@ class Tcc2Service ...@@ -95,7 +98,7 @@ class Tcc2Service
if (!GoodsSku::commit()) { if (!GoodsSku::commit()) {
GoodsSku::rollback(); GoodsSku::rollback();
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 44]);
} }
} }
...@@ -131,7 +134,7 @@ class Tcc2Service ...@@ -131,7 +134,7 @@ class Tcc2Service
} }
} else { } else {
PindanGoodsSku::rollback(); PindanGoodsSku::rollback();
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 43]);
} }
} }
Tcc::save([ Tcc::save([
...@@ -142,7 +145,7 @@ class Tcc2Service ...@@ -142,7 +145,7 @@ class Tcc2Service
if (!PindanGoodsSku::commit()) { if (!PindanGoodsSku::commit()) {
PindanGoodsSku::rollback(); PindanGoodsSku::rollback();
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 44]);
} }
} }
...@@ -161,13 +164,13 @@ class Tcc2Service ...@@ -161,13 +164,13 @@ class Tcc2Service
{ {
$goodsInfoList = json_decode($keys, true); $goodsInfoList = json_decode($keys, true);
if (empty($goodsInfoList)) { if (empty($goodsInfoList)) {
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 42]);
} }
$isPindan = false; $isPindan = false;
foreach ($goodsInfoList as $item) { foreach ($goodsInfoList as $item) {
if (empty($item["goods_sku_id"]) || empty($item["num"])) { if (empty($item["goods_sku_id"]) || empty($item["num"])) {
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 42]);
} }
if (!empty($item["marketing_id"]) && !empty($item["marketing_type"]) && $item["marketing_type"] == Marketing::MARKETING_TYPE_PINDAN) { if (!empty($item["marketing_id"]) && !empty($item["marketing_type"]) && $item["marketing_type"] == Marketing::MARKETING_TYPE_PINDAN) {
$isPindan = true; $isPindan = true;
...@@ -181,12 +184,12 @@ class Tcc2Service ...@@ -181,12 +184,12 @@ class Tcc2Service
} }
//在confirm时候必须已经有try,如果没有就直接返回fail //在confirm时候必须已经有try,如果没有就直接返回fail
if (!empty($tccInfo["status"]) && !in_array($tccInfo["status"], [Tcc::STATUS_T_SUCCESS])) { if (!empty($tccInfo["status"]) && !in_array($tccInfo["status"], [Tcc::STATUS_T_SUCCESS])) {
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 45]);
} }
//如果已经 cancel 成功, 则失败 //如果已经 cancel 成功, 则失败
if (!empty($tccInfo["status"]) && in_array($tccInfo["status"], [Tcc::STATUS_C2_SUCCESS])) { if (!empty($tccInfo["status"]) && in_array($tccInfo["status"], [Tcc::STATUS_C2_SUCCESS])) {
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 46]);
} }
if ($isPindan) { if ($isPindan) {
...@@ -226,14 +229,14 @@ class Tcc2Service ...@@ -226,14 +229,14 @@ class Tcc2Service
} }
} else { } else {
GoodsSku::rollback(); GoodsSku::rollback();
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 43]);
} }
} }
Tcc::save(["status" => Tcc::STATUS_C1_SUCCESS,], ["tid" => $tid]); Tcc::save(["status" => Tcc::STATUS_C1_SUCCESS,], ["tid" => $tid]);
if (!GoodsSku::commit()) { if (!GoodsSku::commit()) {
GoodsSku::rollback(); GoodsSku::rollback();
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 44]);
} }
} }
...@@ -255,10 +258,9 @@ class Tcc2Service ...@@ -255,10 +258,9 @@ class Tcc2Service
$goodsSkuId = $item["goods_sku_id"]; $goodsSkuId = $item["goods_sku_id"];
$num = $item["num"]; $num = $item["num"];
$sku = PindanGoodsSku::getRecord(["goods_sku_id" => $goodsSkuId] $sku = PindanGoodsSku::getRecord(["goods_sku_id" => $goodsSkuId]
, ["goods_sku_id", "inventory_rest", "total_amount_order", "inventory_lock", "online_status"]); , ["goods_sku_id", "inventory_rest", "total_amount_order", "total_amount_sold", "inventory_lock", "online_status", "price"]);
if (!empty($sku["inventory_lock"]) && $sku["online_status"] == PindanGoodsSku::ONLINE_STATUS_ONLINE) { if (!empty($sku["inventory_lock"]) && $sku["online_status"] == PindanGoodsSku::ONLINE_STATUS_ONLINE) {
//条件加上乐观锁 //条件加上乐观锁
$rowCount = PindanGoodsSku::save([ $rowCount = PindanGoodsSku::save([
"inventory_lock" => $sku["inventory_lock"] - $num, "inventory_lock" => $sku["inventory_lock"] - $num,
...@@ -270,20 +272,45 @@ class Tcc2Service ...@@ -270,20 +272,45 @@ class Tcc2Service
} }
} else { } else {
PindanGoodsSku::rollback(); PindanGoodsSku::rollback();
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 43]);
}
//0元单
if (isset($item["payment"]) && $item["payment"] == 0) {
self::zeroOrder($item["marketing_id"], $item["num"], $sku, $goodsSkuId);
} }
} }
Tcc::save(["status" => Tcc::STATUS_C1_SUCCESS,], ["tid" => $tid]); Tcc::save(["status" => Tcc::STATUS_C1_SUCCESS,], ["tid" => $tid]);
if (!PindanGoodsSku::commit()) { if (!PindanGoodsSku::commit()) {
PindanGoodsSku::rollback(); PindanGoodsSku::rollback();
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 44]);
} }
} }
return self::TCC_RESULT_SUCCESS; return self::TCC_RESULT_SUCCESS;
} }
/**
* 0元单处理
* @param $marketingId
* @param $num
* @param $goodsSku
* @param $goodsSkuId
*/
private static function zeroOrder($marketingId, $num, $goodsSku, $goodsSkuId)
{
$marketing = Marketing::getRecord(["marketing_id" => $marketingId]);
if (!empty($marketing) && $marketing["marketing_type"] == Marketing::MARKETING_TYPE_PINDAN) {
$marketingPindan = MarketingPindan::getRecord(["marketing_id" => $marketingId]);
if (!empty($marketingPindan)) {
MarketingPindan::save(["participate_number" => $marketingPindan["participate_number"] + $num]
, ["marketing_pindan_id" => $marketingPindan["marketing_pindan_id"]]);
}
PindanGoodsSku::save(["total_amount_sold" => $goodsSku["total_amount_sold"] + $num], ["goods_sku_id" => $goodsSkuId]);
}
}
/** /**
* 下单 商品tcc cancel * 下单 商品tcc cancel
* @param $keys * @param $keys
...@@ -295,13 +322,13 @@ class Tcc2Service ...@@ -295,13 +322,13 @@ class Tcc2Service
{ {
$goodsInfoList = json_decode($keys, true); $goodsInfoList = json_decode($keys, true);
if (empty($goodsInfoList)) { if (empty($goodsInfoList)) {
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 42]);
} }
$isPindan = false; $isPindan = false;
foreach ($goodsInfoList as $item) { foreach ($goodsInfoList as $item) {
if (empty($item["goods_sku_id"]) || empty($item["num"])) { if (empty($item["goods_sku_id"]) || empty($item["num"])) {
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 42]);
} }
if (!empty($item["marketing_id"]) && !empty($item["marketing_type"]) && $item["marketing_type"] == Marketing::MARKETING_TYPE_PINDAN) { if (!empty($item["marketing_id"]) && !empty($item["marketing_type"]) && $item["marketing_type"] == Marketing::MARKETING_TYPE_PINDAN) {
$isPindan = true; $isPindan = true;
...@@ -379,7 +406,7 @@ class Tcc2Service ...@@ -379,7 +406,7 @@ class Tcc2Service
if (!GoodsSku::commit()) { if (!GoodsSku::commit()) {
GoodsSku::rollback(); GoodsSku::rollback();
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 44]);
} }
} }
...@@ -433,7 +460,7 @@ class Tcc2Service ...@@ -433,7 +460,7 @@ class Tcc2Service
if (!PindanGoodsSku::commit()) { if (!PindanGoodsSku::commit()) {
PindanGoodsSku::rollback(); PindanGoodsSku::rollback();
return self::TCC_RESULT_FAIL; throw new GoodsException(["cus" => 44]);
} }
} }
...@@ -453,25 +480,42 @@ class Tcc2Service ...@@ -453,25 +480,42 @@ class Tcc2Service
return self::TCC_RESULT_FAIL; return self::TCC_RESULT_FAIL;
} }
$goodsSkuIds = $numList = []; $isPindan = false;
foreach ($goodsInfoList as $item) { foreach ($goodsInfoList as $item) {
if (empty($item["goods_sku_id"]) || empty($item["num"])) { if (empty($item["goods_sku_id"]) || empty($item["num"])) {
return self::TCC_RESULT_FAIL; return self::TCC_RESULT_FAIL;
} }
$goodsSkuIds[] = $item["goods_sku_id"]; $goodsSukParams = GoodsSkuId::getGoodsSkuIdParams($item["goods_sku_id"]);
$numList[$item["goods_sku_id"]] = $item["num"]; if (!empty($goodsSukParams)) {
if (isset($goodsSukParams["table_tag"]) && ($goodsSukParams["table_tag"] == GoodsSkuId::TABLE_TAG_PINDAN)) {
$isPindan = true;
}
}
} }
$skus = GoodsSku::getRecords(["goods_sku_id" => $goodsSkuIds] if ($isPindan) {
, ["goods_sku_id", "total_amount_order", "inventory_rest", "inventory_lock", "online_status"]); return self::pindanCancelConfirm($goodsInfoList);
if (!empty($skus)) { } else {
GoodsSku::beginTransaction(); return self::generalCancelConfirm($goodsInfoList);
foreach ($skus as $sku) {
$goodsSkuId = $sku["goods_sku_id"];
if (empty($numList[$goodsSkuId])) {
return self::TCC_RESULT_FAIL;
} }
$num = $numList[$goodsSkuId]; }
/**
* 普通订单退库存
* @param $goodsInfoList
* @return bool
* @throws GoodsException
*/
private static function generalCancelConfirm($goodsInfoList)
{
if (!empty($goodsInfoList)) {
GoodsSku::beginTransaction();
foreach ($goodsInfoList as $item) {
$goodsSkuId = $item["goods_sku_id"];
$num = $item["num"];
$sku = GoodsSku::getRecord(["goods_sku_id" => $goodsSkuId]
, ["goods_sku_id", "total_amount_order", "inventory_rest", "inventory_lock", "online_status"]);
$params = [ $params = [
"inventory_rest" => $sku["inventory_rest"] + $num, "inventory_rest" => $sku["inventory_rest"] + $num,
"total_amount_order" => $sku["total_amount_order"] - $num, "total_amount_order" => $sku["total_amount_order"] - $num,
...@@ -490,6 +534,41 @@ class Tcc2Service ...@@ -490,6 +534,41 @@ class Tcc2Service
return self::TCC_RESULT_SUCCESS; return self::TCC_RESULT_SUCCESS;
} }
/**
* 拼单活动取消订单退库存
* @param $goodsInfoList
* @return bool
* @throws GoodsException
*/
private static function pindanCancelConfirm($goodsInfoList)
{
if (!empty($goodsInfoList)) {
PindanGoodsSku::beginTransaction();
foreach ($goodsInfoList as $item) {
$goodsSkuId = $item["goods_sku_id"];
$num = $item["num"];
$sku = PindanGoodsSku::getRecord(["goods_sku_id" => $goodsSkuId]
, ["goods_sku_id", "total_amount_order", "inventory_rest", "inventory_lock", "online_status"]);
$params = [
"inventory_rest" => $sku["inventory_rest"] + $num,
"total_amount_order" => $sku["total_amount_order"] - $num,
];
$rowCount = PindanGoodsSku::save($params, ["goods_sku_id" => $goodsSkuId, "total_amount_order[>=]" => $num]);
if ($rowCount <= 0) {
PindanGoodsSku::rollback();
throw new GoodsException(["cus" => 32]);
}
}
if (!PindanGoodsSku::commit()) {
PindanGoodsSku::rollback();
}
}
return self::TCC_RESULT_SUCCESS;
}
/** /**
* 获取 tcc 数据记录 * 获取 tcc 数据记录
* @param $tid * @param $tid
......
...@@ -56,6 +56,7 @@ class UserService ...@@ -56,6 +56,7 @@ class UserService
$openid = !empty($response['openid']) ? $response['openid'] : ''; $openid = !empty($response['openid']) ? $response['openid'] : '';
//} //}
$user = UserWechatBind::getRecord(['openid' => $openid]); $user = UserWechatBind::getRecord(['openid' => $openid]);
//如果系统不存在,用户信息,则注册新用户 //如果系统不存在,用户信息,则注册新用户
if (empty($user) && !empty($response)) { if (empty($user) && !empty($response)) {
...@@ -95,8 +96,8 @@ class UserService ...@@ -95,8 +96,8 @@ class UserService
{ {
$openid = !empty($params['openid']) ? $params['openid'] : ''; $openid = !empty($params['openid']) ? $params['openid'] : '';
$encryptedData = !empty($params['encryptedData']) ? urldecode($params['encryptedData']) : ''; $encryptedData = !empty($params['encryptedData']) ? $params['encryptedData'] : '';
$iv = !empty($params['iv']) ? urldecode($params['iv']) : ''; $iv = !empty($params['iv']) ? $params['iv'] : '';
$appid = \Yaf\Registry::get('config')->wechat->appid; $appid = \Yaf\Registry::get('config')->wechat->appid;
if (!$encryptedData) { if (!$encryptedData) {
...@@ -114,11 +115,19 @@ class UserService ...@@ -114,11 +115,19 @@ class UserService
throw new UserException(['cus' => 5]); throw new UserException(['cus' => 5]);
} }
//解密 //解密
$decryptData = []; $decryptData = [];
$wXBizDataCrypt = new WxBizDataCrypt($appid, $sessionKey); $wXBizDataCrypt = new WxBizDataCrypt($appid, $sessionKey);
$errCode = $wXBizDataCrypt->decryptData($encryptedData, $iv, $decryptData); $errCode = $wXBizDataCrypt->decryptData($encryptedData, $iv, $decryptData);
if ($errCode) { if ($errCode) {
throw new UserException(['cus' => 6]); throw new UserException(['cus' => 6]);
} }
...@@ -130,6 +139,12 @@ class UserService ...@@ -130,6 +139,12 @@ class UserService
$phoneNumber = strval($decryptData['phoneNumber']); $phoneNumber = strval($decryptData['phoneNumber']);
//判断是否已
$user = UserWechatBind::getRecord(['phone' => $phoneNumber]);
if (!empty($user) && $openid != $user['openid']) {
throw new UserException(['cus' => 9]);
}
$jwUser = (new JwUser ())->getUserInfo(['mobile' => $phoneNumber]); $jwUser = (new JwUser ())->getUserInfo(['mobile' => $phoneNumber]);
$userId = ''; $userId = '';
if (!empty($jwUser['data'])) { if (!empty($jwUser['data'])) {
...@@ -142,16 +157,15 @@ class UserService ...@@ -142,16 +157,15 @@ class UserService
"update_time" => date("Y-m-d H:i:s"), "update_time" => date("Y-m-d H:i:s"),
'user_id' => $userId, 'user_id' => $userId,
]; ];
$bindStatus = UserWechatBind::save($update,['wechat_id' => $userInfo['wechat_id']]); $bindStatus = UserWechatBind::save($update,['wechat_id' => $userInfo['wechat_id']]);
if (!$bindStatus) { if (!$phoneNumber) {
throw new UserException(['cus' => 8]); throw new UserException(['cus' => 8]);
} }
$userInfo['user_id'] = $userId; $userInfo['user_id'] = $userId;
$userInfo['phone'] = $phoneNumber; $userInfo['phone'] = $phoneNumber;
$userInfo['is_pop_up'] = 1; $userInfo['is_pop_up'] = !empty($user) ? 2 : 1;
$userInfo['pop_up_text'] = "你不是老用户"; $userInfo['pop_up_text'] = "";
return $userInfo; return $userInfo;
} }
...@@ -192,7 +206,7 @@ class UserService ...@@ -192,7 +206,7 @@ class UserService
if (!$bindStatus) { if (!$bindStatus) {
throw new UserException(['cus' => 8]); throw new UserException(['cus' => 8]);
} }
return $bindStatus; return $update;
} }
private static function generate3rdSession($openid) { private static function generate3rdSession($openid) {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"require": { "require": {
"php": "7.2.*", "php": "7.2.*",
"ext-json": "*", "ext-json": "*",
"api/php_utils":"1.0.6", "api/php_utils":"1.0.10",
"api/php_services":"1.0.1", "api/php_services":"1.0.1",
"ext-openssl": "*" "ext-openssl": "*"
}, },
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "1a4f3ce8dedec1cb91d3fe8719dc4436", "content-hash": "d50c89a59fac1ed443c2ff43906a2d3a",
"packages": [ "packages": [
{ {
"name": "api/php_services", "name": "api/php_services",
...@@ -30,11 +30,11 @@ ...@@ -30,11 +30,11 @@
}, },
{ {
"name": "api/php_utils", "name": "api/php_utils",
"version": "v1.0.6", "version": "v1.0.10",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://git.yidian-inc.com:8021/bp/php_utils.git", "url": "https://git.yidian-inc.com:8021/bp/php_utils.git",
"reference": "8e8e414961ea10f32b79dbaeeb60d9e441a97ad6" "reference": "4fb2b99ebe6cc3ad1a99bece88f217874de5db85"
}, },
"require": { "require": {
"elasticsearch/elasticsearch": "~7.0", "elasticsearch/elasticsearch": "~7.0",
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
} }
}, },
"description": "bp api php_utils", "description": "bp api php_utils",
"time": "2021-08-06T16:38:16+00:00" "time": "2021-08-12T11:16:58+00:00"
}, },
{ {
"name": "bacon/bacon-qr-code", "name": "bacon/bacon-qr-code",
...@@ -610,16 +610,16 @@ ...@@ -610,16 +610,16 @@
}, },
{ {
"name": "khanamiryan/qrcode-detector-decoder", "name": "khanamiryan/qrcode-detector-decoder",
"version": "1.0.5.1", "version": "1.0.5.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/khanamiryan/php-qrcode-detector-decoder.git", "url": "https://github.com/khanamiryan/php-qrcode-detector-decoder.git",
"reference": "b96163d4f074970dfe67d4185e75e1f4541b30ca" "reference": "04fdd58d86a387065f707dc6d3cc304c719910c1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/khanamiryan/php-qrcode-detector-decoder/zipball/b96163d4f074970dfe67d4185e75e1f4541b30ca", "url": "https://api.github.com/repos/khanamiryan/php-qrcode-detector-decoder/zipball/04fdd58d86a387065f707dc6d3cc304c719910c1",
"reference": "b96163d4f074970dfe67d4185e75e1f4541b30ca", "reference": "04fdd58d86a387065f707dc6d3cc304c719910c1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -659,9 +659,9 @@ ...@@ -659,9 +659,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/khanamiryan/php-qrcode-detector-decoder/issues", "issues": "https://github.com/khanamiryan/php-qrcode-detector-decoder/issues",
"source": "https://github.com/khanamiryan/php-qrcode-detector-decoder/tree/1.0.5.1" "source": "https://github.com/khanamiryan/php-qrcode-detector-decoder/tree/1.0.5.2"
}, },
"time": "2021-04-21T08:02:08+00:00" "time": "2021-07-13T18:46:38+00:00"
}, },
{ {
"name": "mongodb/mongodb", "name": "mongodb/mongodb",
...@@ -1692,12 +1692,12 @@ ...@@ -1692,12 +1692,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/property-access.git", "url": "https://github.com/symfony/property-access.git",
"reference": "d6ef552ac9b41f96e94e1e81d3a8746dfee3b34b" "reference": "aaa09eb714623e935494b5852c1eff260b704ae1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/property-access/zipball/d6ef552ac9b41f96e94e1e81d3a8746dfee3b34b", "url": "https://api.github.com/repos/symfony/property-access/zipball/aaa09eb714623e935494b5852c1eff260b704ae1",
"reference": "d6ef552ac9b41f96e94e1e81d3a8746dfee3b34b", "reference": "aaa09eb714623e935494b5852c1eff260b704ae1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -1765,7 +1765,7 @@ ...@@ -1765,7 +1765,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2021-08-04T21:21:08+00:00" "time": "2021-08-09T12:23:16+00:00"
}, },
{ {
"name": "symfony/property-info", "name": "symfony/property-info",
......
...@@ -11,6 +11,7 @@ use Api\PhpServices\Wechat\Msg; ...@@ -11,6 +11,7 @@ use Api\PhpServices\Wechat\Msg;
class Pindan implements DaemonServiceInterface class Pindan implements DaemonServiceInterface
{ {
const DEFAULT_DESC = '9.9元吃午餐开始预定啦,戳这里点餐吧';
public function run() public function run()
{ {
...@@ -41,21 +42,35 @@ class Pindan implements DaemonServiceInterface ...@@ -41,21 +42,35 @@ class Pindan implements DaemonServiceInterface
$type = 2; // 1 公众号 2 小程序 $type = 2; // 1 公众号 2 小程序
//活动信息 //活动信息
$params = [ $params = [
$list['result'][0]['marketing_name'], self::emojiFilter($list['result'][0]['marketing_name']),
$list['result'][0]['create_time'], $list['result'][0]['create_time'],
$list['result'][0]['pindan_desc'] $list['result'][0]['pindan_desc'] ?: self::DEFAULT_DESC
]; ];
//发送消息 //发送消息
Msg::send(999, $app_id, $template_id, $page_url, $type, $params); Msg::send(999, $app_id, $template_id, $page_url, $type, $params);
DaemonLog::info(
'DaemonServiceInterface_pindan',
'send at '.date('Y-m-d H:i:s').' params:'.json_encode($params)
);
sleep(60);//保证16:40只执行一次 sleep(60);//保证16:40只执行一次
}catch (Exception $e) { }catch (Exception $e) {
DaemonLog::info( DaemonLog::error(
'DaemonServiceInterface_pindan', 'DaemonServiceInterface_pindan',
'params:'.json_encode($params).' exception:'.$e->getMessage() 'params:'.json_encode($params).' exception:'.$e->getMessage()
); );
} }
} }
/**
* 过滤emoji表情
* @param string $str
* @return string
*/
private function emojiFilter($str) {
$str = preg_replace_callback('/./u',function(array $match){
return strlen($match[0]) >= 4 ? '' : $match[0];
},$str);
return $str;
}
} }
\ No newline at end of file
...@@ -5,22 +5,28 @@ namespace Api\PhpUtils\Common; ...@@ -5,22 +5,28 @@ namespace Api\PhpUtils\Common;
class GoodsSkuId class GoodsSkuId
{ {
const TABLE_TAG_GENERAL = "000";//普通表 goods_sku 商品
const TABLE_TAG_PINDAN = "001";//接龙表 pindan_goods_sku 商品
/** /**
* 生成加密后的 sku_id * 生成加密后的 sku_id
* id 非雪花算法生成的sku_id * id 非雪花算法生成的sku_id
* category_1_id 一级分类的id,两位,不足两位在十位补零 * category_1_id 一级分类的id,两位,不足两位在十位补零
* category_2_id 二级分类的id,两位,不足三位在百位补零 * category_2_id 二级分类的id,两位,不足三位在百位补零
* spu 商品类型,1虚拟商品,2实体商品 * goodsType 商品类型,1虚拟商品,2实体商品 占一位
* goodsType 1、(默认)第三方商品 2、自营商品 * belongType 1、(默认)第三方商品 2、自营商品 占一位
* tableTag 数据所在表: 000: goods_sku, 001: pindan_goods_sku
* *
* @param $id * @param $id
* @param $category1Id * @param $category1Id
* @param $category2Id * @param $category2Id
* @param $spuType * @param $spuType
* @param $goodsType * @param $goodsType
* @param $belongType
* @param $tableTag
* @return string * @return string
*/ */
public static function generateGoodSkuId($id, $category1Id, $category2Id, $spuType, $goodsType = 1) public static function generateGoodSkuId($id, $category1Id, $category2Id, $goodsType, $belongType = 1, $tableTag = "000")
{ {
if (strlen($category1Id) == 1) { if (strlen($category1Id) == 1) {
$category1Id = "0" . $category1Id; $category1Id = "0" . $category1Id;
...@@ -28,7 +34,7 @@ class GoodsSkuId ...@@ -28,7 +34,7 @@ class GoodsSkuId
if (strlen($category2Id) == 2) { if (strlen($category2Id) == 2) {
$category2Id = "0" . $category2Id; $category2Id = "0" . $category2Id;
} }
$idStr = $id . $category1Id . $category2Id . $spuType . $goodsType; $idStr = $id . $category1Id . $category2Id . $goodsType . $belongType . $tableTag;
//转62进制 //转62进制
$tmp = BaseConvert::decToOther($idStr); $tmp = BaseConvert::decToOther($idStr);
...@@ -97,4 +103,79 @@ class GoodsSkuId ...@@ -97,4 +103,79 @@ class GoodsSkuId
return $ret === $code; return $ret === $code;
} }
/**
* 恢复加密前的订单号
* @param $str
* @return bool|int|string
*/
public static function recoverGoodSkuId($str)
{
$strlen = strlen($str);
$chklen = 2;
$code = substr($str, -$chklen);
$str = substr($str, 0, $strlen-$chklen);
$strlen -= $chklen;
$base = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if ($strlen % 2 == 1)
{
$str = '0' . $str;
$strlen += 1;
}
$sum = 0;
$len = $strlen/2;
for ($i=0; $i<$len; $i++)
{
$sum *= 137;
$sum += ord($str[$i]) ^ ord($str[$strlen-$i-1]);
}
$ret = '';
for ($i=$chklen; $i>0; $i--)
{
$idx = $sum % 62;
$sum = ($sum-$idx) / 62;
$ret = $base[$idx] . $ret;
}
if ($ret === $code) {
$codeLen = strlen($code);
return BaseConvert::otherToDec($str);
}
return "";
}
/**
* 根据skuId获取对应的参数
* @param $goodsSkuId
* @return array
*/
public static function getGoodsSkuIdParams($goodsSkuId)
{
$goodsSkuIdNum = self::recoverGoodSkuId($goodsSkuId);
$data = [];
if (!empty($goodsSkuIdNum)) {
$idgenId = substr($goodsSkuIdNum, 0, 20);
$category1Id = substr($goodsSkuIdNum, 20, 2);
$category2Id = substr($goodsSkuIdNum, 22, 3);
$goodsType = substr($goodsSkuIdNum, 25, 1);
$belongType = substr($goodsSkuIdNum, 26, 1);
$tableTag = substr($goodsSkuIdNum, 27, 3);
$data = [
"idgent_id" => $idgenId,
"category_1_id" => $category1Id,
"category_2_id" => $category2Id,
"goods_type" => $goodsType,
"belong_type" => $belongType,
"table_tag" => $tableTag,
];
}
return $data;
}
} }
\ No newline at end of file
...@@ -21,6 +21,7 @@ namespace Api\PhpUtils\Http; ...@@ -21,6 +21,7 @@ namespace Api\PhpUtils\Http;
use Api\PhpUtils\Log\FileLog; use Api\PhpUtils\Log\FileLog;
use Api\PhpUtils\Log\Tracer;
use Api\PhpUtils\Mon\MonUtil; use Api\PhpUtils\Mon\MonUtil;
class HttpUtil class HttpUtil
...@@ -58,6 +59,10 @@ class HttpUtil ...@@ -58,6 +59,10 @@ class HttpUtil
*/ */
public static function get(string $url,array $params = [], int $timeout = 10000,int $retries = 1, array $headers = [], string $proxy = '',array $curl_opts = []): array public static function get(string $url,array $params = [], int $timeout = 10000,int $retries = 1, array $headers = [], string $proxy = '',array $curl_opts = []): array
{ {
// 增加traceId
if(is_array($headers)) {
$headers['X-TRACE-ID'] = Tracer::getTraceId();
}
$url = $url ."?". http_build_query($params); $url = $url ."?". http_build_query($params);
return self::curl($url, $timeout, $retries, $headers, [], $proxy, 'GET', $curl_opts); return self::curl($url, $timeout, $retries, $headers, [], $proxy, 'GET', $curl_opts);
} }
...@@ -90,6 +95,10 @@ class HttpUtil ...@@ -90,6 +95,10 @@ class HttpUtil
*/ */
public static function post(string $url, $post,int $timeout = 10000,int $retries = 1,array $headers = [], string $proxy = '',array $curl_opts = []): array public static function post(string $url, $post,int $timeout = 10000,int $retries = 1,array $headers = [], string $proxy = '',array $curl_opts = []): array
{ {
// 增加traceId
if(is_array($headers)) {
$headers['X-TRACE-ID'] = Tracer::getTraceId();
}
return self::curl($url, $timeout, $retries, $headers, $post, $proxy, 'POST', $curl_opts); return self::curl($url, $timeout, $retries, $headers, $post, $proxy, 'POST', $curl_opts);
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Api\PhpUtils\Http; namespace Api\PhpUtils\Http;
use Api\PhpUtils\Log\FileLog; use Api\PhpUtils\Log\FileLog;
use Api\PhpUtils\Log\Tracer;
use Api\PhpUtils\Mon\MonUtil; use Api\PhpUtils\Mon\MonUtil;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Exception\TransferException;
...@@ -64,6 +65,12 @@ class Request ...@@ -64,6 +65,12 @@ class Request
if (!empty($timeout)) { if (!empty($timeout)) {
$options['timeout'] = $timeout / 1000; $options['timeout'] = $timeout / 1000;
} }
// 增加traceId
if(is_array($headers)) {
$headers['X-TRACE-ID'] = Tracer::getTraceId();
}
if (!empty($headers)) { if (!empty($headers)) {
$options['headers'] = $headers; $options['headers'] = $headers;
} }
...@@ -140,6 +147,12 @@ class Request ...@@ -140,6 +147,12 @@ class Request
if (!empty($timeout)) { if (!empty($timeout)) {
$options['timeout'] = $timeout / 1000; $options['timeout'] = $timeout / 1000;
} }
// 增加traceId
if(is_array($headers)) {
$headers['X-TRACE-ID'] = Tracer::getTraceId();
}
if (!empty($headers)) { if (!empty($headers)) {
$options['headers'] = $headers; $options['headers'] = $headers;
} }
......
...@@ -83,7 +83,7 @@ class FileLog ...@@ -83,7 +83,7 @@ class FileLog
} }
} }
private static function accessLog() public static function accessLog()
{ {
$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']; $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'];
$query = http_build_query($_GET, '', '&'); $query = http_build_query($_GET, '', '&');
...@@ -109,7 +109,7 @@ class FileLog ...@@ -109,7 +109,7 @@ class FileLog
fclose($log_file); fclose($log_file);
} }
private static function ip() public static function ip()
{ {
if (isset($_SERVER['IPV6_REMOTE_ADDR']) && !empty($_SERVER['IPV6_REMOTE_ADDR']) && trim($_SERVER['IPV6_REMOTE_ADDR']) !== '-') { // 如果没有ipv6地址, 运维会传一个占位符“-” if (isset($_SERVER['IPV6_REMOTE_ADDR']) && !empty($_SERVER['IPV6_REMOTE_ADDR']) && trim($_SERVER['IPV6_REMOTE_ADDR']) !== '-') { // 如果没有ipv6地址, 运维会传一个占位符“-”
$ips = $_SERVER['IPV6_REMOTE_ADDR']; $ips = $_SERVER['IPV6_REMOTE_ADDR'];
...@@ -126,7 +126,7 @@ class FileLog ...@@ -126,7 +126,7 @@ class FileLog
return $ip[0]; return $ip[0];
} }
private static function shouldSendEmail($key) public static function shouldSendEmail($key)
{ {
$result = true; $result = true;
// 每分钟发一条 // 每分钟发一条
......
...@@ -24,6 +24,7 @@ use Api\PhpUtils\Log\FileLog; ...@@ -24,6 +24,7 @@ use Api\PhpUtils\Log\FileLog;
* $options参数可选项: * $options参数可选项:
* - $options['max_execution_time'] = 10; // 单位毫秒 * - $options['max_execution_time'] = 10; // 单位毫秒
* - $options['rowCount'] = true; // 返回insert后的影响行数 * - $options['rowCount'] = true; // 返回insert后的影响行数
* - $options['alertMail'] = true; // SQL执行出错是否发送报警邮件标识,默认发送
* @see https://medoo.in (英文网站) * @see https://medoo.in (英文网站)
* @see https://medoo.lvtao.net (中文网站) * @see https://medoo.lvtao.net (中文网站)
...@@ -37,7 +38,7 @@ use Api\PhpUtils\Log\FileLog; ...@@ -37,7 +38,7 @@ use Api\PhpUtils\Log\FileLog;
* @method static MysqlBase select($columns, $where, $options) * @method static MysqlBase select($columns, $where, $options)
* @method static MysqlBase selectMaster($columns, $where, $options) * @method static MysqlBase selectMaster($columns, $where, $options)
* @method static MysqlBase selectForUpdate($columns, $where, $options) * @method static MysqlBase selectForUpdate($columns, $where, $options)
* * @method static MysqlBase selectForUpdateSkipLocked($columns, $where, $options) * @method static MysqlBase selectForUpdateSkipLocked($columns, $where, $options)
* @method static MysqlBase getMaster($columns, $where, $options) * @method static MysqlBase getMaster($columns, $where, $options)
* @method static MysqlBase get($columns, $where, $options) * @method static MysqlBase get($columns, $where, $options)
* @method static MysqlBase count($columns, $where) * @method static MysqlBase count($columns, $where)
...@@ -329,7 +330,15 @@ abstract class MysqlBase ...@@ -329,7 +330,15 @@ abstract class MysqlBase
return true; return true;
} }
if (in_array(strtolower($method), ['insert']) && isset($arguments[2]['alertMail']) && $arguments[2]['alertMail'] === false) {
FileLog::info("mysql info catch:" . $method . "-" . json_encode($arguments) . '-' . print_r([$sqlState, $errorCode, $errorMessage], 1));
}
elseif (in_array(strtolower($method), ['select', 'selectmaster', 'selectforupdate', 'get', 'getmaster']) && isset($arguments[3]['alertMail']) && $arguments[3]['alertMail'] === false) {
FileLog::info("mysql info catch:" . $method . "-" . json_encode($arguments) . '-' . print_r([$sqlState, $errorCode, $errorMessage], 1));
}
else {
FileLog::error("mysql error catch:" . $method . "-" . json_encode($arguments) . '-' . print_r([$sqlState, $errorCode, $errorMessage], 1)); FileLog::error("mysql error catch:" . $method . "-" . json_encode($arguments) . '-' . print_r([$sqlState, $errorCode, $errorMessage], 1));
}
//throw Exception //throw Exception
// $msg = "mysql error catch:" . $method . "-" . json_encode($arguments) . '-' . json_encode([$sqlState, $errorCode, $errorMessage]); // $msg = "mysql error catch:" . $method . "-" . json_encode($arguments) . '-' . json_encode([$sqlState, $errorCode, $errorMessage]);
......
...@@ -32,7 +32,7 @@ private static $installed = array ( ...@@ -32,7 +32,7 @@ private static $installed = array (
'aliases' => 'aliases' =>
array ( array (
), ),
'reference' => 'ec360a59edfff2b202d7dd90a61cbfff5075f554', 'reference' => 'aa0ce40f0ea3b01d62acfef75790d113f0caee3d',
'name' => 'yidian/yaf_demo', 'name' => 'yidian/yaf_demo',
), ),
'versions' => 'versions' =>
...@@ -48,12 +48,12 @@ private static $installed = array ( ...@@ -48,12 +48,12 @@ private static $installed = array (
), ),
'api/php_utils' => 'api/php_utils' =>
array ( array (
'pretty_version' => 'v1.0.6', 'pretty_version' => 'v1.0.10',
'version' => '1.0.6.0', 'version' => '1.0.10.0',
'aliases' => 'aliases' =>
array ( array (
), ),
'reference' => '8e8e414961ea10f32b79dbaeeb60d9e441a97ad6', 'reference' => '4fb2b99ebe6cc3ad1a99bece88f217874de5db85',
), ),
'bacon/bacon-qr-code' => 'bacon/bacon-qr-code' =>
array ( array (
...@@ -141,12 +141,12 @@ private static $installed = array ( ...@@ -141,12 +141,12 @@ private static $installed = array (
), ),
'khanamiryan/qrcode-detector-decoder' => 'khanamiryan/qrcode-detector-decoder' =>
array ( array (
'pretty_version' => '1.0.5.1', 'pretty_version' => '1.0.5.2',
'version' => '1.0.5.1', 'version' => '1.0.5.2',
'aliases' => 'aliases' =>
array ( array (
), ),
'reference' => 'b96163d4f074970dfe67d4185e75e1f4541b30ca', 'reference' => '04fdd58d86a387065f707dc6d3cc304c719910c1',
), ),
'mongodb/mongodb' => 'mongodb/mongodb' =>
array ( array (
...@@ -305,7 +305,7 @@ private static $installed = array ( ...@@ -305,7 +305,7 @@ private static $installed = array (
'aliases' => 'aliases' =>
array ( array (
), ),
'reference' => 'd6ef552ac9b41f96e94e1e81d3a8746dfee3b34b', 'reference' => 'aaa09eb714623e935494b5852c1eff260b704ae1',
), ),
'symfony/property-info' => 'symfony/property-info' =>
array ( array (
...@@ -332,7 +332,7 @@ private static $installed = array ( ...@@ -332,7 +332,7 @@ private static $installed = array (
'aliases' => 'aliases' =>
array ( array (
), ),
'reference' => 'ec360a59edfff2b202d7dd90a61cbfff5075f554', 'reference' => 'aa0ce40f0ea3b01d62acfef75790d113f0caee3d',
), ),
), ),
); );
......
...@@ -104,6 +104,7 @@ return array( ...@@ -104,6 +104,7 @@ return array(
'App\\Models\\demo\\mysql\\User' => $baseDir . '/application/models/demo/mysql/User.php', 'App\\Models\\demo\\mysql\\User' => $baseDir . '/application/models/demo/mysql/User.php',
'App\\Models\\goods\\mysql\\Category' => $baseDir . '/application/models/goods/mysql/Category.php', 'App\\Models\\goods\\mysql\\Category' => $baseDir . '/application/models/goods/mysql/Category.php',
'App\\Models\\goods\\mysql\\GoodsOperationRecord' => $baseDir . '/application/models/goods/mysql/GoodsOperationRecord.php', 'App\\Models\\goods\\mysql\\GoodsOperationRecord' => $baseDir . '/application/models/goods/mysql/GoodsOperationRecord.php',
'App\\Models\\goods\\mysql\\GoodsRefundRecord' => $baseDir . '/application/models/goods/mysql/GoodsRefundRecord.php',
'App\\Models\\goods\\mysql\\GoodsSku' => $baseDir . '/application/models/goods/mysql/GoodsSku.php', 'App\\Models\\goods\\mysql\\GoodsSku' => $baseDir . '/application/models/goods/mysql/GoodsSku.php',
'App\\Models\\goods\\mysql\\GoodsSkuPicRecord' => $baseDir . '/application/models/goods/mysql/GoodsSkuPicRecord.php', 'App\\Models\\goods\\mysql\\GoodsSkuPicRecord' => $baseDir . '/application/models/goods/mysql/GoodsSkuPicRecord.php',
'App\\Models\\goods\\mysql\\GoodsSkuSubShop' => $baseDir . '/application/models/goods/mysql/GoodsSkuSubShop.php', 'App\\Models\\goods\\mysql\\GoodsSkuSubShop' => $baseDir . '/application/models/goods/mysql/GoodsSkuSubShop.php',
...@@ -137,10 +138,12 @@ return array( ...@@ -137,10 +138,12 @@ return array(
'App\\Services\\goods\\CategoryService' => $baseDir . '/application/services/goods/CategoryService.php', 'App\\Services\\goods\\CategoryService' => $baseDir . '/application/services/goods/CategoryService.php',
'App\\Services\\goods\\ElasticGoodService' => $baseDir . '/application/services/goods/ElasticGoodService.php', 'App\\Services\\goods\\ElasticGoodService' => $baseDir . '/application/services/goods/ElasticGoodService.php',
'App\\Services\\goods\\GoodsService' => $baseDir . '/application/services/goods/GoodsService.php', 'App\\Services\\goods\\GoodsService' => $baseDir . '/application/services/goods/GoodsService.php',
'App\\Services\\goods\\GoodsSnapshotsService' => $baseDir . '/application/services/goods/GoodsSnapshotsService.php',
'App\\Services\\goods\\MarketingPindanGoodsService' => $baseDir . '/application/services/goods/MarketingPindanGoodsService.php', 'App\\Services\\goods\\MarketingPindanGoodsService' => $baseDir . '/application/services/goods/MarketingPindanGoodsService.php',
'App\\Services\\goods\\OtaService' => $baseDir . '/application/services/goods/OtaService.php', 'App\\Services\\goods\\OtaService' => $baseDir . '/application/services/goods/OtaService.php',
'App\\Services\\marketing\\DistributionService' => $baseDir . '/application/services/marketing/DistributionService.php', 'App\\Services\\marketing\\DistributionService' => $baseDir . '/application/services/marketing/DistributionService.php',
'App\\Services\\marketing\\DistributorService' => $baseDir . '/application/services/marketing/DistributorService.php', 'App\\Services\\marketing\\DistributorService' => $baseDir . '/application/services/marketing/DistributorService.php',
'App\\Services\\marketing\\MarketingForOrderService' => $baseDir . '/application/services/marketing/MarketingForOrderService.php',
'App\\Services\\marketing\\MarketingGoodsService' => $baseDir . '/application/services/marketing/MarketingGoodsService.php', 'App\\Services\\marketing\\MarketingGoodsService' => $baseDir . '/application/services/marketing/MarketingGoodsService.php',
'App\\Services\\marketing\\MarketingService' => $baseDir . '/application/services/marketing/MarketingService.php', 'App\\Services\\marketing\\MarketingService' => $baseDir . '/application/services/marketing/MarketingService.php',
'App\\Services\\marketing\\TakePlaceService' => $baseDir . '/application/services/marketing/TakePlaceService.php', 'App\\Services\\marketing\\TakePlaceService' => $baseDir . '/application/services/marketing/TakePlaceService.php',
......
...@@ -333,6 +333,7 @@ class ComposerStaticInit5871a7b0b10b793d91ef1c8029b23ea5 ...@@ -333,6 +333,7 @@ class ComposerStaticInit5871a7b0b10b793d91ef1c8029b23ea5
'App\\Models\\demo\\mysql\\User' => __DIR__ . '/../..' . '/application/models/demo/mysql/User.php', 'App\\Models\\demo\\mysql\\User' => __DIR__ . '/../..' . '/application/models/demo/mysql/User.php',
'App\\Models\\goods\\mysql\\Category' => __DIR__ . '/../..' . '/application/models/goods/mysql/Category.php', 'App\\Models\\goods\\mysql\\Category' => __DIR__ . '/../..' . '/application/models/goods/mysql/Category.php',
'App\\Models\\goods\\mysql\\GoodsOperationRecord' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsOperationRecord.php', 'App\\Models\\goods\\mysql\\GoodsOperationRecord' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsOperationRecord.php',
'App\\Models\\goods\\mysql\\GoodsRefundRecord' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsRefundRecord.php',
'App\\Models\\goods\\mysql\\GoodsSku' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSku.php', 'App\\Models\\goods\\mysql\\GoodsSku' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSku.php',
'App\\Models\\goods\\mysql\\GoodsSkuPicRecord' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSkuPicRecord.php', 'App\\Models\\goods\\mysql\\GoodsSkuPicRecord' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSkuPicRecord.php',
'App\\Models\\goods\\mysql\\GoodsSkuSubShop' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSkuSubShop.php', 'App\\Models\\goods\\mysql\\GoodsSkuSubShop' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSkuSubShop.php',
...@@ -366,10 +367,12 @@ class ComposerStaticInit5871a7b0b10b793d91ef1c8029b23ea5 ...@@ -366,10 +367,12 @@ class ComposerStaticInit5871a7b0b10b793d91ef1c8029b23ea5
'App\\Services\\goods\\CategoryService' => __DIR__ . '/../..' . '/application/services/goods/CategoryService.php', 'App\\Services\\goods\\CategoryService' => __DIR__ . '/../..' . '/application/services/goods/CategoryService.php',
'App\\Services\\goods\\ElasticGoodService' => __DIR__ . '/../..' . '/application/services/goods/ElasticGoodService.php', 'App\\Services\\goods\\ElasticGoodService' => __DIR__ . '/../..' . '/application/services/goods/ElasticGoodService.php',
'App\\Services\\goods\\GoodsService' => __DIR__ . '/../..' . '/application/services/goods/GoodsService.php', 'App\\Services\\goods\\GoodsService' => __DIR__ . '/../..' . '/application/services/goods/GoodsService.php',
'App\\Services\\goods\\GoodsSnapshotsService' => __DIR__ . '/../..' . '/application/services/goods/GoodsSnapshotsService.php',
'App\\Services\\goods\\MarketingPindanGoodsService' => __DIR__ . '/../..' . '/application/services/goods/MarketingPindanGoodsService.php', 'App\\Services\\goods\\MarketingPindanGoodsService' => __DIR__ . '/../..' . '/application/services/goods/MarketingPindanGoodsService.php',
'App\\Services\\goods\\OtaService' => __DIR__ . '/../..' . '/application/services/goods/OtaService.php', 'App\\Services\\goods\\OtaService' => __DIR__ . '/../..' . '/application/services/goods/OtaService.php',
'App\\Services\\marketing\\DistributionService' => __DIR__ . '/../..' . '/application/services/marketing/DistributionService.php', 'App\\Services\\marketing\\DistributionService' => __DIR__ . '/../..' . '/application/services/marketing/DistributionService.php',
'App\\Services\\marketing\\DistributorService' => __DIR__ . '/../..' . '/application/services/marketing/DistributorService.php', 'App\\Services\\marketing\\DistributorService' => __DIR__ . '/../..' . '/application/services/marketing/DistributorService.php',
'App\\Services\\marketing\\MarketingForOrderService' => __DIR__ . '/../..' . '/application/services/marketing/MarketingForOrderService.php',
'App\\Services\\marketing\\MarketingGoodsService' => __DIR__ . '/../..' . '/application/services/marketing/MarketingGoodsService.php', 'App\\Services\\marketing\\MarketingGoodsService' => __DIR__ . '/../..' . '/application/services/marketing/MarketingGoodsService.php',
'App\\Services\\marketing\\MarketingService' => __DIR__ . '/../..' . '/application/services/marketing/MarketingService.php', 'App\\Services\\marketing\\MarketingService' => __DIR__ . '/../..' . '/application/services/marketing/MarketingService.php',
'App\\Services\\marketing\\TakePlaceService' => __DIR__ . '/../..' . '/application/services/marketing/TakePlaceService.php', 'App\\Services\\marketing\\TakePlaceService' => __DIR__ . '/../..' . '/application/services/marketing/TakePlaceService.php',
......
...@@ -27,12 +27,12 @@ ...@@ -27,12 +27,12 @@
}, },
{ {
"name": "api/php_utils", "name": "api/php_utils",
"version": "v1.0.6", "version": "v1.0.10",
"version_normalized": "1.0.6.0", "version_normalized": "1.0.10.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://git.yidian-inc.com:8021/bp/php_utils.git", "url": "https://git.yidian-inc.com:8021/bp/php_utils.git",
"reference": "8e8e414961ea10f32b79dbaeeb60d9e441a97ad6" "reference": "4fb2b99ebe6cc3ad1a99bece88f217874de5db85"
}, },
"require": { "require": {
"elasticsearch/elasticsearch": "~7.0", "elasticsearch/elasticsearch": "~7.0",
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
"mongodb/mongodb": "1.4.3", "mongodb/mongodb": "1.4.3",
"php": "7.2.*" "php": "7.2.*"
}, },
"time": "2021-08-06T16:38:16+00:00", "time": "2021-08-12T11:16:58+00:00",
"type": "library", "type": "library",
"installation-source": "source", "installation-source": "source",
"autoload": { "autoload": {
...@@ -637,17 +637,17 @@ ...@@ -637,17 +637,17 @@
}, },
{ {
"name": "khanamiryan/qrcode-detector-decoder", "name": "khanamiryan/qrcode-detector-decoder",
"version": "1.0.5.1", "version": "1.0.5.2",
"version_normalized": "1.0.5.1", "version_normalized": "1.0.5.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/khanamiryan/php-qrcode-detector-decoder.git", "url": "https://github.com/khanamiryan/php-qrcode-detector-decoder.git",
"reference": "b96163d4f074970dfe67d4185e75e1f4541b30ca" "reference": "04fdd58d86a387065f707dc6d3cc304c719910c1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/khanamiryan/php-qrcode-detector-decoder/zipball/b96163d4f074970dfe67d4185e75e1f4541b30ca", "url": "https://api.github.com/repos/khanamiryan/php-qrcode-detector-decoder/zipball/04fdd58d86a387065f707dc6d3cc304c719910c1",
"reference": "b96163d4f074970dfe67d4185e75e1f4541b30ca", "reference": "04fdd58d86a387065f707dc6d3cc304c719910c1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -656,7 +656,7 @@ ...@@ -656,7 +656,7 @@
"require-dev": { "require-dev": {
"phpunit/phpunit": "^5.7 | ^7.5 | ^8.0 | ^9.0" "phpunit/phpunit": "^5.7 | ^7.5 | ^8.0 | ^9.0"
}, },
"time": "2021-04-21T08:02:08+00:00", "time": "2021-07-13T18:46:38+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {
...@@ -689,7 +689,7 @@ ...@@ -689,7 +689,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/khanamiryan/php-qrcode-detector-decoder/issues", "issues": "https://github.com/khanamiryan/php-qrcode-detector-decoder/issues",
"source": "https://github.com/khanamiryan/php-qrcode-detector-decoder/tree/1.0.5.1" "source": "https://github.com/khanamiryan/php-qrcode-detector-decoder/tree/1.0.5.2"
}, },
"install-path": "../khanamiryan/qrcode-detector-decoder" "install-path": "../khanamiryan/qrcode-detector-decoder"
}, },
...@@ -1768,12 +1768,12 @@ ...@@ -1768,12 +1768,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/property-access.git", "url": "https://github.com/symfony/property-access.git",
"reference": "d6ef552ac9b41f96e94e1e81d3a8746dfee3b34b" "reference": "aaa09eb714623e935494b5852c1eff260b704ae1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/property-access/zipball/d6ef552ac9b41f96e94e1e81d3a8746dfee3b34b", "url": "https://api.github.com/repos/symfony/property-access/zipball/aaa09eb714623e935494b5852c1eff260b704ae1",
"reference": "d6ef552ac9b41f96e94e1e81d3a8746dfee3b34b", "reference": "aaa09eb714623e935494b5852c1eff260b704ae1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -1788,7 +1788,7 @@ ...@@ -1788,7 +1788,7 @@
"suggest": { "suggest": {
"psr/cache-implementation": "To cache access methods." "psr/cache-implementation": "To cache access methods."
}, },
"time": "2021-08-04T21:21:08+00:00", "time": "2021-08-09T12:23:16+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
'aliases' => 'aliases' =>
array ( array (
), ),
'reference' => 'ec360a59edfff2b202d7dd90a61cbfff5075f554', 'reference' => 'aa0ce40f0ea3b01d62acfef75790d113f0caee3d',
'name' => 'yidian/yaf_demo', 'name' => 'yidian/yaf_demo',
), ),
'versions' => 'versions' =>
...@@ -22,12 +22,12 @@ ...@@ -22,12 +22,12 @@
), ),
'api/php_utils' => 'api/php_utils' =>
array ( array (
'pretty_version' => 'v1.0.6', 'pretty_version' => 'v1.0.10',
'version' => '1.0.6.0', 'version' => '1.0.10.0',
'aliases' => 'aliases' =>
array ( array (
), ),
'reference' => '8e8e414961ea10f32b79dbaeeb60d9e441a97ad6', 'reference' => '4fb2b99ebe6cc3ad1a99bece88f217874de5db85',
), ),
'bacon/bacon-qr-code' => 'bacon/bacon-qr-code' =>
array ( array (
...@@ -115,12 +115,12 @@ ...@@ -115,12 +115,12 @@
), ),
'khanamiryan/qrcode-detector-decoder' => 'khanamiryan/qrcode-detector-decoder' =>
array ( array (
'pretty_version' => '1.0.5.1', 'pretty_version' => '1.0.5.2',
'version' => '1.0.5.1', 'version' => '1.0.5.2',
'aliases' => 'aliases' =>
array ( array (
), ),
'reference' => 'b96163d4f074970dfe67d4185e75e1f4541b30ca', 'reference' => '04fdd58d86a387065f707dc6d3cc304c719910c1',
), ),
'mongodb/mongodb' => 'mongodb/mongodb' =>
array ( array (
...@@ -279,7 +279,7 @@ ...@@ -279,7 +279,7 @@
'aliases' => 'aliases' =>
array ( array (
), ),
'reference' => 'd6ef552ac9b41f96e94e1e81d3a8746dfee3b34b', 'reference' => 'aaa09eb714623e935494b5852c1eff260b704ae1',
), ),
'symfony/property-info' => 'symfony/property-info' =>
array ( array (
...@@ -306,7 +306,7 @@ ...@@ -306,7 +306,7 @@
'aliases' => 'aliases' =>
array ( array (
), ),
'reference' => 'ec360a59edfff2b202d7dd90a61cbfff5075f554', 'reference' => 'aa0ce40f0ea3b01d62acfef75790d113f0caee3d',
), ),
), ),
); );
...@@ -91,7 +91,7 @@ final class QrReader ...@@ -91,7 +91,7 @@ final class QrReader
{ {
$this->decode(); $this->decode();
if (method_exists($this->result, 'toString')) { if ($this->result !== false && method_exists($this->result, 'toString')) {
return $this->result->toString(); return $this->result->toString();
} }
......
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