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
self::PRINTER_ALREADY_EXIST => '打印机已被%s绑定',
self::EMPTY_OTA_ID => '供应商id为空',
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
18 => '当前填写的拼单活动名称已经存在',
19 => '当前活动不存在',
self::TAKE_PLACE_NOT_EXIST => '自提点不存在',
21 => "活动开始时间不能大于或者等雨结束时间",
21 => "活动开始时间不能大于或者等于结束时间",
22 => "自提点不能为空",
];
}
\ No newline at end of file
......@@ -20,5 +20,6 @@ class UserException extends BaseException
6 => '解密失败 不存在',
7 => '手机号获取失败',
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
{
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
'take_place_id' => 'require',
'name' => 'require',
'address' => 'require',
'location' => 'require',
'longitude' => 'require',
'latitude' => 'require',
'province' => 'require',
......@@ -29,7 +30,8 @@ class TakePlaceValidate extends \Validate\BaseValidate
"take_place_id" => "take_place_id不能为空",
"marketing_id" => "marketing_id不能为空",
"name" => "自提点名称不能为空",
"address" => "详细地址不能为空",
"address" => "详细地址(原商圈)不能为空",
"location" => "高德地图详细地址不能为空",
"longitude" => "经度不能为空",
"latitude" => "纬度不能为空",
"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
const BELONG_TYPE_DISANFANG = 1;//第三方商品
const BELONG_TYPE_ZIYING = 2;//自营商品
const CAN_SHOW_ES_YES = 1;
const CAN_SHOW_ES_NO = 2;
public static function getRecord($where, $colums = [])
{
if (empty($colums)) {
......
......@@ -17,4 +17,12 @@ class Ota extends MysqlBase
const STATUS_NORMAL = 0; // 正常
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
self::ONLINE_STATUS_DAOQI => "到期",
];
const COMMISSION_MODE_RATE = 1;
const COMMISSION_MODE_FIXED = 2;
public static function getRecord($where, $colums = [])
{
if (empty($colums)) {
......
......@@ -81,7 +81,7 @@ class GoodstoesController extends Cli
"goods_name" => $goodsSkuInfo["goods_name"],
"inventory_rest" => $goodsSkuInfo["inventory_rest"],
"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_sort" => (int)$goodsSkuInfo["price"],
"audit_status" => $goodsSkuInfo["audit_status"],
......
......@@ -280,10 +280,8 @@ class GoodstoinitController extends Cli
GoodsSku::save($skuParams);
} else {
$skuParams = [
"inventory_total" => $inventoryTotal,
"inventory_rest" => $inventoryRest,
"total_amount_order" => $totalAmountOrder,
"total_amount_sold" => $totalAmountOrder,
"original_price" => $originalPrice,
"price" => $price,
];
GoodsSku::save($skuParams, ["goods_sku_id"=>$goodsSku["goods_sku_id"]]);
}
......
......@@ -11,12 +11,15 @@ use \Validate\GoodsInfoOpValidate;
use \Validate\GoodsInfoFeValidate;
use \Validate\GoodsListCValidate;
use \Validate\OrderGoodsValidate;
use \Validate\RefundGoodsValidate;
use \Validate\GoodsOnlineOfflineValidate;
use \Validate\PaySuccessGoodsCallbackValidate;
use \Validate\GoodsInitShopValidate;
use \Validate\PindanGoodsAddValidate;
use \App\Services\goods\ElasticGoodService;
use \App\Services\goods\MarketingPindanGoodsService;
use \App\Models\marketing\mysql\Marketing;
use \App\Services\goods\GoodsSnapshotsService;
class GoodsController extends Base
......@@ -48,7 +51,7 @@ class GoodsController extends Base
{
$params = $this->params;
if (!empty($params["marketing_type"]) && $params["marketing_type"] == Marketing::MARKETING_TYPE_PINDAN) {
(new PindanGoodsAddValidate())->validate();
} else {
(new GoodsAddValidate())->validate();
}
......@@ -289,4 +292,26 @@ class GoodsController extends Base
$list = MarketingPindanGoodsService::getPindanGoodsList($params);
$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
$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
......
......@@ -5,6 +5,8 @@ use App\Services\marketing\MarketingService;
use App\Exception\custom\MarketingException;
use App\Services\marketing\MarketingGoodsService;
use \Validate\MarketingGoodsRateValidate;
use \Validate\MarketingOnlineStatusValidate;
use \Validate\MarketingInfoValidate;
class MarketingController extends Base
{
......@@ -120,6 +122,8 @@ class MarketingController extends Base
*/
public function marketing_infoAction()
{
(new MarketingInfoValidate())->validate();
$params = $this->params;
$marketingInfo = MarketingService::marketingInfo($params);
$this->success(['result' => $marketingInfo]);
......@@ -139,4 +143,16 @@ class MarketingController extends Base
$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
$res = Tcc2Service::cancelConfirm($this->params["keys"]);
if ($res) {
$this->success();
} else {
throw new GoodsException(["cus" => 27]);
}
}
}
\ No newline at end of file
......@@ -159,7 +159,7 @@ class ElasticGoodService
$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_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"];
}
}
......
......@@ -694,9 +694,15 @@ class GoodsService
"inventory_rest" => $inventoryCount,
"original_price" => empty($params["original_price"]) ? 0 : $params["original_price"] * 100,
"price" => $params["price"] * 100,
"clear_price" => empty($params["clear_price"]) ? 0 : $params["clear_price"] * 100,
"goods_version" => (int)$skuData["goods_version"] + 1,
];
//验证结算价格
if (!empty($params["clear_price"])) {
self::checkClearPrice($goodsSkuId, $skuParams);
}
if (self::isInitGoodsStatus($params, $skuData)) {
$skuParams["audit_status"] = GoodsSku::STATUS_AUDIT;
$skuParams["online_status"] = GoodsSku::ONLINE_STATUS_NO_ONLINE;
......@@ -724,6 +730,48 @@ class GoodsService
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
......@@ -744,7 +792,8 @@ class GoodsService
|| $params["rule_desc"] != $sku["rule_desc"]
|| $params["rule_refund"] != $sku["rule_refund"]
|| $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
}
$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"]["inventory"] = $sku["inventory_rest"];
......@@ -832,7 +882,7 @@ class GoodsService
$data["goods_info"]["is_tuanzhang"] = true;
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
*/
public static function getGoodsSkuInfo($params = [])
{
$marketingType = !empty($params['marketing_type']) ? $params['marketing_type'] : 0;
if ($marketingType == Marketing::MARKETING_TYPE_PINDAN) {
$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::pindanGoodsInfo($params);
} else {
return self::generalGoodsInfo($params);
}
} else {
throw new GoodsException(["cus" => 41]);
}
}
/**
......@@ -892,6 +948,7 @@ class GoodsService
$data["goods_info"] = $sku;
$data["goods_info"]["original_price"] = empty($sku["original_price"]) ? '' : (string)($sku["original_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"] = [];
if (!empty($sku["desc_pic_url"])) {
$ksyun = self::getUrlList($sku["desc_pic_url"]);
......@@ -1514,7 +1571,14 @@ class GoodsService
"marketing_id" => $marketingId]
);
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]);
}
if (empty($goodsSku)) {
throw new GoodsException(["cus" => 15]);
}
......@@ -1627,4 +1691,24 @@ class GoodsService
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;
use App\Exception\custom\GoodsException;
use App\Models\goods\mysql\Category;
use App\Models\goods\mysql\GoodsOperationRecord;
use App\Models\goods\mysql\GoodsRefundRecord;
use App\Models\goods\mysql\GoodsSku;
use App\Models\goods\mysql\GoodsSkuPicRecord;
use App\Models\goods\mysql\GoodsSkuSubShop;
......@@ -54,7 +55,22 @@ class MarketingPindanGoodsService
//生活号信息
$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);
$skuId = self::addGoodsSku($spuData, $shopId, $params);
//商品操作记录
......@@ -88,6 +104,13 @@ class MarketingPindanGoodsService
$ksyun = GoodsService::getUrlList($sku["desc_pic_url"]);
$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;
}
......@@ -124,6 +147,7 @@ class MarketingPindanGoodsService
"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"],
"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);
return $spuParams;
......@@ -150,7 +174,7 @@ class MarketingPindanGoodsService
if (empty($res)) {
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) {
throw new GoodsException(['cus' => 33]);
......@@ -172,7 +196,7 @@ class MarketingPindanGoodsService
"goods_spu_id" => $spuData["goods_spu_id"],
"life_account_id" => $skuData["life_account_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_2_id" => 0,
"goods_name" => $skuData["goods_name"],
......@@ -285,7 +309,7 @@ class MarketingPindanGoodsService
"desc_pic_url" => $params["desc_pic_url"],
"desc" => $params["desc"],
"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,
"original_price" => empty($params["original_price"]) ? "" : $params["original_price"] * 100,
"price" => $params["price"] * 100,
......@@ -392,7 +416,7 @@ class MarketingPindanGoodsService
$count = PindanGoodsSku::count("*", $where);
if (!empty($list)) {
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;
if (!empty($otaData) && !empty($otaData[$item["ota_id"]])) {
$list[$key]["ota_name"] = $otaData[$item["ota_id"]]["ota_name"];
......@@ -426,7 +450,68 @@ class MarketingPindanGoodsService
if (!empty($sku["desc_pic_url"])) {
$ksyun = GoodsService::getUrlList($sku["desc_pic_url"]);
$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;
}
/**
* 退款拼单商品,库存调整
* @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
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
......
<?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
"online_status" => 1,
];
$marketingList = Marketing::getMarketingList($marketingWhere);
$list = [];
$lastId = "";
if (!empty($marketingList)) {
$marketingId = array_column($marketingList, 'marketing_id');
$where['marketing_id'] = !empty($marketingId) ? $marketingId : [];
$data = MarketingGoods::marketingGoodsList($where);
......@@ -97,7 +100,6 @@ class MarketingGoodsService
$lifeAccountList = CommonService::getlifeAccountList(['life_account_id' => $lifeAccountId]);
$list = [];
$i = 0;
foreach ($data as $key => $value) {
......@@ -160,8 +162,7 @@ class MarketingGoodsService
$list[$i]['goods_share_code'] = $goodsShareId;
$i++;
}
}
}
$result = ['result' => $list ,'last_id' => $lastId];
......
......@@ -3,6 +3,7 @@
namespace App\Services\marketing;
use Api\PhpServices\Ksy\Ks3Api;
use App\Models\goods\mysql\Ota;
use App\Models\goods\mysql\PindanGoodsSku;
use App\Models\marketing\mysql\Marketing;
......@@ -17,7 +18,7 @@ use App\Models\marketing\mysql\TakePlace;
use App\Services\common\CommonService;
use App\Services\goods\GoodsService;
use Daemon\Goods;
use App\Exception\custom\GoodsException;
class MarketingService
{
......@@ -33,7 +34,7 @@ class MarketingService
} elseif (in_array($env, ['test'])) {
$lifeAccountId = "15559498695737346";
}else {
$lifeAccountId = "";
$lifeAccountId = "19019625839230981";
}
return $lifeAccountId;
}
......@@ -223,6 +224,8 @@ class MarketingService
private static function pindanMarketingList($params)
{
$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;
$limit = !empty($params['page_size']) ? $params['page_size'] : 20;
$page = ($params['page'] - 1) * $limit;
......@@ -245,6 +248,11 @@ class MarketingService
$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['LIMIT'] = [$page, $limit];
$list = Marketing::select(["marketing_id", "marketing_name", "start_time", "end_time",
......@@ -258,7 +266,8 @@ class MarketingService
$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]);
$priceData = [];
if (!empty($marketingPindanData)) {
......@@ -269,6 +278,7 @@ class MarketingService
$publishLifeAccountIds = array_unique(array_column($marketingPindanData, "publish_life_account_id"));
$lifeAccountList = CommonService::getlifeAccountList(['life_account_id' => $publishLifeAccountIds]);
$defaultPic = "SHQ_goods_0_012Xh1AQcMqu";
foreach ($list as $key => $value) {
$lists[$key] = $value;
$lists[$key]["online_status_desc"] = Marketing::$onlineStatusDesc[$value["online_status"]];
......@@ -279,10 +289,20 @@ class MarketingService
$lists[$key]["life_account_icon"] = $lifeAccountList[$currentLifeAccountId]["life_account_icon"];
$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]["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
*/
private static function addFenxiaoMarketing($params)
{
$commissionMode = !empty($params['commission_mode']) ? $params['commission_mode'] : 1;
$marketingName = !empty($params['marketing_name']) ? $params['marketing_name'] : '';
$firstCommissionRate = !empty($params['first_commission_value']) ? $params['first_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'] : '';
......@@ -332,10 +354,12 @@ class MarketingService
$type = !empty($params['marketing_type']) ? $params['marketing_type'] : 1;
$goodsSkuId = !empty($params['goods_sku_id']) ? explode(",", $params['goods_sku_id']) : [];
if ($commissionMode == 1) {
$rate = $firstCommissionRate + $secondCommissionRate;
if ($rate > 5000) {
throw new MarketingException(['cus'=>15]);
}
}
if (empty($goodsSkuId)) {
throw new MarketingException(['cus'=>12]);
......@@ -439,6 +463,7 @@ class MarketingService
'update_user_email' => $createUserEmail,
'update_time' => date("Y-m-d H:i:s"),
'create_time' => date("Y-m-d H:i:s"),
'commission_mode' => $commissionMode,
];
$marketingId = Marketing::insertRecord($colums);
if (empty($marketingId)) {
......@@ -449,6 +474,22 @@ class MarketingService
$goodCount = !empty($goodsSkuId) ? count($goodsSkuId) : 0;
$goodsSkuList = GoodsSku::select('*', ['goods_sku_id' => $goodsSkuId]);
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]['goods_spu_id'] = $value['goods_spu_id'];
$colums[$key]['goods_sku_id'] = $value['goods_sku_id'];
......@@ -503,6 +544,9 @@ class MarketingService
if ($startTime >= $endTime) {
throw new MarketingException(['cus' => 21]);
}
if (empty($takePlaceIds)) {
throw new MarketingException(['cus' => 22]);
}
//重复判断
$marketing = Marketing::getRecord(["marketing_name" => $marketingName], ["marketing_id"]);
......@@ -526,8 +570,8 @@ class MarketingService
}
$uniquePriceList = array_unique($priceList);
sort($uniquePriceList);
$minPrice = $priceList[0];
$maxPrice = end($priceList);
$minPrice = $uniquePriceList[0];
$maxPrice = end($uniquePriceList);
Marketing::beginTransaction();
$marketingParams = [
......@@ -536,6 +580,8 @@ class MarketingService
'end_time' => $endTime,
'online_status' => 1,
'marketing_type' => $type,
'good_count' => count($goodsSkuId),
'create_user_email' => $createUserEmail,
'update_user_email' => $createUserEmail,
'update_time' => date("Y-m-d H:i:s"),
'create_time' => date("Y-m-d H:i:s"),
......@@ -655,6 +701,9 @@ class MarketingService
if ($startTime >= $endTime) {
throw new MarketingException(['cus' => 21]);
}
if (empty($takePlaceIds)) {
throw new MarketingException(['cus' => 22]);
}
//获取商品的最大最小值
$skuInfoList = PindanGoodsSku::getRecordMaster(["goods_sku_id" => $goodsSkuId]
......@@ -665,19 +714,19 @@ class MarketingService
}
$uniquePriceList = array_unique($priceList);
sort($uniquePriceList);
$minPrice = $priceList[0];
$maxPrice = end($priceList);
$minPrice = $uniquePriceList[0];
$maxPrice = end($uniquePriceList);
Marketing::beginTransaction();
$marketingParams = [
'marketing_name' => $marketingName,
'start_time' => $startTime,
'end_time' => $endTime,
'online_status' => 1,
'online_status' => Marketing::ONLINE_STATUS_QIDONG,
'marketing_type' => $type,
'good_count' => count($goodsSkuId),
'update_user_email' => $createUserEmail,
'update_time' => date("Y-m-d H:i:s"),
'create_time' => date("Y-m-d H:i:s"),
];
Marketing::updateRecord($marketingParams, ["marketing_id" => $marketingId]);
......@@ -740,6 +789,32 @@ class MarketingService
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
......@@ -834,11 +909,19 @@ class MarketingService
$marketingData["pindan_pic"] = $pindanMarketing["pindan_pic"];
$marketingData["pindan_pic_url"] = GoodsService::getUrlList($marketingData["pindan_pic"]);
$marketingData["pindan_desc"] = $pindanMarketing["pindan_desc"];
$marketingData["max_price"] = $pindanMarketing["max_price"];
$marketingData["min_price"] = $pindanMarketing["min_price"];
$marketingData["max_price"] = sprintf("%.2f", $pindanMarketing["max_price"] / 100);
$marketingData["min_price"] = sprintf("%.2f", $pindanMarketing["min_price"] / 100);
$marketingData["participate_number"] = $pindanMarketing["participate_number"];
$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;
if (!empty($goodsSkuList)) {
......@@ -850,7 +933,9 @@ class MarketingService
foreach ($goodsSkuList as $key => $item) {
$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;
use App\Models\marketing\mysql\MarketingTakePlace;
use App\Models\marketing\mysql\TakePlace;
use App\Exception\custom\MarketingException;
use Api\PhpUtils\Common\Geo;
class TakePlaceService
{
......@@ -56,6 +57,7 @@ class TakePlaceService
$data['take_place_name'] = $params['name'];
$data['longitude'] = $params['longitude'];
$data['latitude'] = $params['latitude'];
$data['location'] = $params['location'];
$data['address'] = $params['address'];
$data['contact_name'] = $params['contact_name'] ?? '';
$data['phone'] = $params['phone'] ?? '';
......@@ -112,6 +114,8 @@ class TakePlaceService
{
$marketingId = $params['marketing_id'];
$keywords = $params['keywords'] ?? '';
$longitude = $params['longitude'] ?? '';
$latitude = $params['latitude'] ?? '';
$page = $params['page'] ?? 1;
$limit = $params['limit'] ?? 20;
......@@ -138,7 +142,8 @@ class TakePlaceService
//获取自提点信息
$makePlaceIds = array_column($relations,'take_place_id');
$takePlaceWhere = ['take_place_id'=>$makePlaceIds];
$res['list'] = TakePlace::select('*', $takePlaceWhere);
//本页按距离返回列表
$res['list'] = self::sortByDistance($latitude,$longitude,TakePlace::select('*', $takePlaceWhere));
unset($where['ORDER'],$where['LIMIT']);
$res['total'] = MarketingTakePlace::count('*', $where);
$res['total_page'] = ceil($res['total']/$limit);
......@@ -146,4 +151,36 @@ class TakePlaceService
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 @@
namespace App\Services\tcc;
use Api\PhpUtils\Common\GoodsSkuId;
use App\Exception\custom\GoodsException;
use App\Models\goods\mysql\GoodsSku;
use App\Models\goods\mysql\PindanGoodsSku;
use App\Models\goods\mysql\Tcc;
use App\Models\marketing\mysql\Marketing;
use App\Models\marketing\mysql\MarketingPindan;
use App\Services\goods\MarketingPindanGoodsService;
class Tcc2Service
{
......@@ -24,13 +27,13 @@ class Tcc2Service
{
$goodsInfoList = json_decode($keys, true);
if (empty($goodsInfoList)) {
return self::TCC_RESULT_FAIL;
throw new GoodsException(["cus" => 42]);
}
$isPindan = false;
foreach ($goodsInfoList as $item) {
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) {
$isPindan = true;
......@@ -84,7 +87,7 @@ class Tcc2Service
}
} else {
GoodsSku::rollback();
return self::TCC_RESULT_FAIL;
throw new GoodsException(["cus" => 43]);
}
}
Tcc::save([
......@@ -95,7 +98,7 @@ class Tcc2Service
if (!GoodsSku::commit()) {
GoodsSku::rollback();
return self::TCC_RESULT_FAIL;
throw new GoodsException(["cus" => 44]);
}
}
......@@ -131,7 +134,7 @@ class Tcc2Service
}
} else {
PindanGoodsSku::rollback();
return self::TCC_RESULT_FAIL;
throw new GoodsException(["cus" => 43]);
}
}
Tcc::save([
......@@ -142,7 +145,7 @@ class Tcc2Service
if (!PindanGoodsSku::commit()) {
PindanGoodsSku::rollback();
return self::TCC_RESULT_FAIL;
throw new GoodsException(["cus" => 44]);
}
}
......@@ -161,13 +164,13 @@ class Tcc2Service
{
$goodsInfoList = json_decode($keys, true);
if (empty($goodsInfoList)) {
return self::TCC_RESULT_FAIL;
throw new GoodsException(["cus" => 42]);
}
$isPindan = false;
foreach ($goodsInfoList as $item) {
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) {
$isPindan = true;
......@@ -181,12 +184,12 @@ class Tcc2Service
}
//在confirm时候必须已经有try,如果没有就直接返回fail
if (!empty($tccInfo["status"]) && !in_array($tccInfo["status"], [Tcc::STATUS_T_SUCCESS])) {
return self::TCC_RESULT_FAIL;
throw new GoodsException(["cus" => 45]);
}
//如果已经 cancel 成功, 则失败
if (!empty($tccInfo["status"]) && in_array($tccInfo["status"], [Tcc::STATUS_C2_SUCCESS])) {
return self::TCC_RESULT_FAIL;
throw new GoodsException(["cus" => 46]);
}
if ($isPindan) {
......@@ -226,14 +229,14 @@ class Tcc2Service
}
} else {
GoodsSku::rollback();
return self::TCC_RESULT_FAIL;
throw new GoodsException(["cus" => 43]);
}
}
Tcc::save(["status" => Tcc::STATUS_C1_SUCCESS,], ["tid" => $tid]);
if (!GoodsSku::commit()) {
GoodsSku::rollback();
return self::TCC_RESULT_FAIL;
throw new GoodsException(["cus" => 44]);
}
}
......@@ -255,10 +258,9 @@ class Tcc2Service
$goodsSkuId = $item["goods_sku_id"];
$num = $item["num"];
$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) {
//条件加上乐观锁
$rowCount = PindanGoodsSku::save([
"inventory_lock" => $sku["inventory_lock"] - $num,
......@@ -270,20 +272,45 @@ class Tcc2Service
}
} else {
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]);
if (!PindanGoodsSku::commit()) {
PindanGoodsSku::rollback();
return self::TCC_RESULT_FAIL;
throw new GoodsException(["cus" => 44]);
}
}
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
* @param $keys
......@@ -295,13 +322,13 @@ class Tcc2Service
{
$goodsInfoList = json_decode($keys, true);
if (empty($goodsInfoList)) {
return self::TCC_RESULT_FAIL;
throw new GoodsException(["cus" => 42]);
}
$isPindan = false;
foreach ($goodsInfoList as $item) {
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) {
$isPindan = true;
......@@ -379,7 +406,7 @@ class Tcc2Service
if (!GoodsSku::commit()) {
GoodsSku::rollback();
return self::TCC_RESULT_FAIL;
throw new GoodsException(["cus" => 44]);
}
}
......@@ -433,7 +460,7 @@ class Tcc2Service
if (!PindanGoodsSku::commit()) {
PindanGoodsSku::rollback();
return self::TCC_RESULT_FAIL;
throw new GoodsException(["cus" => 44]);
}
}
......@@ -453,25 +480,42 @@ class Tcc2Service
return self::TCC_RESULT_FAIL;
}
$goodsSkuIds = $numList = [];
$isPindan = false;
foreach ($goodsInfoList as $item) {
if (empty($item["goods_sku_id"]) || empty($item["num"])) {
return self::TCC_RESULT_FAIL;
}
$goodsSkuIds[] = $item["goods_sku_id"];
$numList[$item["goods_sku_id"]] = $item["num"];
$goodsSukParams = GoodsSkuId::getGoodsSkuIdParams($item["goods_sku_id"]);
if (!empty($goodsSukParams)) {
if (isset($goodsSukParams["table_tag"]) && ($goodsSukParams["table_tag"] == GoodsSkuId::TABLE_TAG_PINDAN)) {
$isPindan = true;
}
}
}
$skus = GoodsSku::getRecords(["goods_sku_id" => $goodsSkuIds]
, ["goods_sku_id", "total_amount_order", "inventory_rest", "inventory_lock", "online_status"]);
if (!empty($skus)) {
GoodsSku::beginTransaction();
foreach ($skus as $sku) {
$goodsSkuId = $sku["goods_sku_id"];
if (empty($numList[$goodsSkuId])) {
return self::TCC_RESULT_FAIL;
if ($isPindan) {
return self::pindanCancelConfirm($goodsInfoList);
} else {
return self::generalCancelConfirm($goodsInfoList);
}
$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 = [
"inventory_rest" => $sku["inventory_rest"] + $num,
"total_amount_order" => $sku["total_amount_order"] - $num,
......@@ -490,6 +534,41 @@ class Tcc2Service
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 数据记录
* @param $tid
......
......@@ -56,6 +56,7 @@ class UserService
$openid = !empty($response['openid']) ? $response['openid'] : '';
//}
$user = UserWechatBind::getRecord(['openid' => $openid]);
//如果系统不存在,用户信息,则注册新用户
if (empty($user) && !empty($response)) {
......@@ -95,8 +96,8 @@ class UserService
{
$openid = !empty($params['openid']) ? $params['openid'] : '';
$encryptedData = !empty($params['encryptedData']) ? urldecode($params['encryptedData']) : '';
$iv = !empty($params['iv']) ? urldecode($params['iv']) : '';
$encryptedData = !empty($params['encryptedData']) ? $params['encryptedData'] : '';
$iv = !empty($params['iv']) ? $params['iv'] : '';
$appid = \Yaf\Registry::get('config')->wechat->appid;
if (!$encryptedData) {
......@@ -114,11 +115,19 @@ class UserService
throw new UserException(['cus' => 5]);
}
//解密
$decryptData = [];
$wXBizDataCrypt = new WxBizDataCrypt($appid, $sessionKey);
$errCode = $wXBizDataCrypt->decryptData($encryptedData, $iv, $decryptData);
if ($errCode) {
throw new UserException(['cus' => 6]);
}
......@@ -130,6 +139,12 @@ class UserService
$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]);
$userId = '';
if (!empty($jwUser['data'])) {
......@@ -142,16 +157,15 @@ class UserService
"update_time" => date("Y-m-d H:i:s"),
'user_id' => $userId,
];
$bindStatus = UserWechatBind::save($update,['wechat_id' => $userInfo['wechat_id']]);
if (!$bindStatus) {
if (!$phoneNumber) {
throw new UserException(['cus' => 8]);
}
$userInfo['user_id'] = $userId;
$userInfo['phone'] = $phoneNumber;
$userInfo['is_pop_up'] = 1;
$userInfo['pop_up_text'] = "你不是老用户";
$userInfo['is_pop_up'] = !empty($user) ? 2 : 1;
$userInfo['pop_up_text'] = "";
return $userInfo;
}
......@@ -192,7 +206,7 @@ class UserService
if (!$bindStatus) {
throw new UserException(['cus' => 8]);
}
return $bindStatus;
return $update;
}
private static function generate3rdSession($openid) {
......
......@@ -6,7 +6,7 @@
"require": {
"php": "7.2.*",
"ext-json": "*",
"api/php_utils":"1.0.6",
"api/php_utils":"1.0.10",
"api/php_services":"1.0.1",
"ext-openssl": "*"
},
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "1a4f3ce8dedec1cb91d3fe8719dc4436",
"content-hash": "d50c89a59fac1ed443c2ff43906a2d3a",
"packages": [
{
"name": "api/php_services",
......@@ -30,11 +30,11 @@
},
{
"name": "api/php_utils",
"version": "v1.0.6",
"version": "v1.0.10",
"source": {
"type": "git",
"url": "https://git.yidian-inc.com:8021/bp/php_utils.git",
"reference": "8e8e414961ea10f32b79dbaeeb60d9e441a97ad6"
"reference": "4fb2b99ebe6cc3ad1a99bece88f217874de5db85"
},
"require": {
"elasticsearch/elasticsearch": "~7.0",
......@@ -53,7 +53,7 @@
}
},
"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",
......@@ -610,16 +610,16 @@
},
{
"name": "khanamiryan/qrcode-detector-decoder",
"version": "1.0.5.1",
"version": "1.0.5.2",
"source": {
"type": "git",
"url": "https://github.com/khanamiryan/php-qrcode-detector-decoder.git",
"reference": "b96163d4f074970dfe67d4185e75e1f4541b30ca"
"reference": "04fdd58d86a387065f707dc6d3cc304c719910c1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/khanamiryan/php-qrcode-detector-decoder/zipball/b96163d4f074970dfe67d4185e75e1f4541b30ca",
"reference": "b96163d4f074970dfe67d4185e75e1f4541b30ca",
"url": "https://api.github.com/repos/khanamiryan/php-qrcode-detector-decoder/zipball/04fdd58d86a387065f707dc6d3cc304c719910c1",
"reference": "04fdd58d86a387065f707dc6d3cc304c719910c1",
"shasum": ""
},
"require": {
......@@ -659,9 +659,9 @@
],
"support": {
"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",
......@@ -1692,12 +1692,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/property-access.git",
"reference": "d6ef552ac9b41f96e94e1e81d3a8746dfee3b34b"
"reference": "aaa09eb714623e935494b5852c1eff260b704ae1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/property-access/zipball/d6ef552ac9b41f96e94e1e81d3a8746dfee3b34b",
"reference": "d6ef552ac9b41f96e94e1e81d3a8746dfee3b34b",
"url": "https://api.github.com/repos/symfony/property-access/zipball/aaa09eb714623e935494b5852c1eff260b704ae1",
"reference": "aaa09eb714623e935494b5852c1eff260b704ae1",
"shasum": ""
},
"require": {
......@@ -1765,7 +1765,7 @@
"type": "tidelift"
}
],
"time": "2021-08-04T21:21:08+00:00"
"time": "2021-08-09T12:23:16+00:00"
},
{
"name": "symfony/property-info",
......
......@@ -11,6 +11,7 @@ use Api\PhpServices\Wechat\Msg;
class Pindan implements DaemonServiceInterface
{
const DEFAULT_DESC = '9.9元吃午餐开始预定啦,戳这里点餐吧';
public function run()
{
......@@ -41,21 +42,35 @@ class Pindan implements DaemonServiceInterface
$type = 2; // 1 公众号 2 小程序
//活动信息
$params = [
$list['result'][0]['marketing_name'],
self::emojiFilter($list['result'][0]['marketing_name']),
$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);
DaemonLog::info(
'DaemonServiceInterface_pindan',
'send at '.date('Y-m-d H:i:s').' params:'.json_encode($params)
);
sleep(60);//保证16:40只执行一次
}catch (Exception $e) {
DaemonLog::info(
DaemonLog::error(
'DaemonServiceInterface_pindan',
'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;
class GoodsSkuId
{
const TABLE_TAG_GENERAL = "000";//普通表 goods_sku 商品
const TABLE_TAG_PINDAN = "001";//接龙表 pindan_goods_sku 商品
/**
* 生成加密后的 sku_id
* id 非雪花算法生成的sku_id
* category_1_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 $category1Id
* @param $category2Id
* @param $spuType
* @param $goodsType
* @param $belongType
* @param $tableTag
* @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) {
$category1Id = "0" . $category1Id;
......@@ -28,7 +34,7 @@ class GoodsSkuId
if (strlen($category2Id) == 2) {
$category2Id = "0" . $category2Id;
}
$idStr = $id . $category1Id . $category2Id . $spuType . $goodsType;
$idStr = $id . $category1Id . $category2Id . $goodsType . $belongType . $tableTag;
//转62进制
$tmp = BaseConvert::decToOther($idStr);
......@@ -97,4 +103,79 @@ class GoodsSkuId
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;
use Api\PhpUtils\Log\FileLog;
use Api\PhpUtils\Log\Tracer;
use Api\PhpUtils\Mon\MonUtil;
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
{
// 增加traceId
if(is_array($headers)) {
$headers['X-TRACE-ID'] = Tracer::getTraceId();
}
$url = $url ."?". http_build_query($params);
return self::curl($url, $timeout, $retries, $headers, [], $proxy, 'GET', $curl_opts);
}
......@@ -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
{
// 增加traceId
if(is_array($headers)) {
$headers['X-TRACE-ID'] = Tracer::getTraceId();
}
return self::curl($url, $timeout, $retries, $headers, $post, $proxy, 'POST', $curl_opts);
}
......
......@@ -2,6 +2,7 @@
namespace Api\PhpUtils\Http;
use Api\PhpUtils\Log\FileLog;
use Api\PhpUtils\Log\Tracer;
use Api\PhpUtils\Mon\MonUtil;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Exception\TransferException;
......@@ -64,6 +65,12 @@ class Request
if (!empty($timeout)) {
$options['timeout'] = $timeout / 1000;
}
// 增加traceId
if(is_array($headers)) {
$headers['X-TRACE-ID'] = Tracer::getTraceId();
}
if (!empty($headers)) {
$options['headers'] = $headers;
}
......@@ -140,6 +147,12 @@ class Request
if (!empty($timeout)) {
$options['timeout'] = $timeout / 1000;
}
// 增加traceId
if(is_array($headers)) {
$headers['X-TRACE-ID'] = Tracer::getTraceId();
}
if (!empty($headers)) {
$options['headers'] = $headers;
}
......
......@@ -83,7 +83,7 @@ class FileLog
}
}
private static function accessLog()
public static function accessLog()
{
$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'];
$query = http_build_query($_GET, '', '&');
......@@ -109,7 +109,7 @@ class FileLog
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地址, 运维会传一个占位符“-”
$ips = $_SERVER['IPV6_REMOTE_ADDR'];
......@@ -126,7 +126,7 @@ class FileLog
return $ip[0];
}
private static function shouldSendEmail($key)
public static function shouldSendEmail($key)
{
$result = true;
// 每分钟发一条
......
......@@ -24,6 +24,7 @@ use Api\PhpUtils\Log\FileLog;
* $options参数可选项:
* - $options['max_execution_time'] = 10; // 单位毫秒
* - $options['rowCount'] = true; // 返回insert后的影响行数
* - $options['alertMail'] = true; // SQL执行出错是否发送报警邮件标识,默认发送
* @see https://medoo.in (英文网站)
* @see https://medoo.lvtao.net (中文网站)
......@@ -37,7 +38,7 @@ use Api\PhpUtils\Log\FileLog;
* @method static MysqlBase select($columns, $where, $options)
* @method static MysqlBase selectMaster($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 get($columns, $where, $options)
* @method static MysqlBase count($columns, $where)
......@@ -329,7 +330,15 @@ abstract class MysqlBase
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));
}
//throw Exception
// $msg = "mysql error catch:" . $method . "-" . json_encode($arguments) . '-' . json_encode([$sqlState, $errorCode, $errorMessage]);
......
......@@ -32,7 +32,7 @@ private static $installed = array (
'aliases' =>
array (
),
'reference' => 'ec360a59edfff2b202d7dd90a61cbfff5075f554',
'reference' => 'aa0ce40f0ea3b01d62acfef75790d113f0caee3d',
'name' => 'yidian/yaf_demo',
),
'versions' =>
......@@ -48,12 +48,12 @@ private static $installed = array (
),
'api/php_utils' =>
array (
'pretty_version' => 'v1.0.6',
'version' => '1.0.6.0',
'pretty_version' => 'v1.0.10',
'version' => '1.0.10.0',
'aliases' =>
array (
),
'reference' => '8e8e414961ea10f32b79dbaeeb60d9e441a97ad6',
'reference' => '4fb2b99ebe6cc3ad1a99bece88f217874de5db85',
),
'bacon/bacon-qr-code' =>
array (
......@@ -141,12 +141,12 @@ private static $installed = array (
),
'khanamiryan/qrcode-detector-decoder' =>
array (
'pretty_version' => '1.0.5.1',
'version' => '1.0.5.1',
'pretty_version' => '1.0.5.2',
'version' => '1.0.5.2',
'aliases' =>
array (
),
'reference' => 'b96163d4f074970dfe67d4185e75e1f4541b30ca',
'reference' => '04fdd58d86a387065f707dc6d3cc304c719910c1',
),
'mongodb/mongodb' =>
array (
......@@ -305,7 +305,7 @@ private static $installed = array (
'aliases' =>
array (
),
'reference' => 'd6ef552ac9b41f96e94e1e81d3a8746dfee3b34b',
'reference' => 'aaa09eb714623e935494b5852c1eff260b704ae1',
),
'symfony/property-info' =>
array (
......@@ -332,7 +332,7 @@ private static $installed = array (
'aliases' =>
array (
),
'reference' => 'ec360a59edfff2b202d7dd90a61cbfff5075f554',
'reference' => 'aa0ce40f0ea3b01d62acfef75790d113f0caee3d',
),
),
);
......
......@@ -104,6 +104,7 @@ return array(
'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\\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\\GoodsSkuPicRecord' => $baseDir . '/application/models/goods/mysql/GoodsSkuPicRecord.php',
'App\\Models\\goods\\mysql\\GoodsSkuSubShop' => $baseDir . '/application/models/goods/mysql/GoodsSkuSubShop.php',
......@@ -137,10 +138,12 @@ return array(
'App\\Services\\goods\\CategoryService' => $baseDir . '/application/services/goods/CategoryService.php',
'App\\Services\\goods\\ElasticGoodService' => $baseDir . '/application/services/goods/ElasticGoodService.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\\OtaService' => $baseDir . '/application/services/goods/OtaService.php',
'App\\Services\\marketing\\DistributionService' => $baseDir . '/application/services/marketing/DistributionService.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\\MarketingService' => $baseDir . '/application/services/marketing/MarketingService.php',
'App\\Services\\marketing\\TakePlaceService' => $baseDir . '/application/services/marketing/TakePlaceService.php',
......
......@@ -333,6 +333,7 @@ class ComposerStaticInit5871a7b0b10b793d91ef1c8029b23ea5
'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\\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\\GoodsSkuPicRecord' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSkuPicRecord.php',
'App\\Models\\goods\\mysql\\GoodsSkuSubShop' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSkuSubShop.php',
......@@ -366,10 +367,12 @@ class ComposerStaticInit5871a7b0b10b793d91ef1c8029b23ea5
'App\\Services\\goods\\CategoryService' => __DIR__ . '/../..' . '/application/services/goods/CategoryService.php',
'App\\Services\\goods\\ElasticGoodService' => __DIR__ . '/../..' . '/application/services/goods/ElasticGoodService.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\\OtaService' => __DIR__ . '/../..' . '/application/services/goods/OtaService.php',
'App\\Services\\marketing\\DistributionService' => __DIR__ . '/../..' . '/application/services/marketing/DistributionService.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\\MarketingService' => __DIR__ . '/../..' . '/application/services/marketing/MarketingService.php',
'App\\Services\\marketing\\TakePlaceService' => __DIR__ . '/../..' . '/application/services/marketing/TakePlaceService.php',
......
......@@ -27,12 +27,12 @@
},
{
"name": "api/php_utils",
"version": "v1.0.6",
"version_normalized": "1.0.6.0",
"version": "v1.0.10",
"version_normalized": "1.0.10.0",
"source": {
"type": "git",
"url": "https://git.yidian-inc.com:8021/bp/php_utils.git",
"reference": "8e8e414961ea10f32b79dbaeeb60d9e441a97ad6"
"reference": "4fb2b99ebe6cc3ad1a99bece88f217874de5db85"
},
"require": {
"elasticsearch/elasticsearch": "~7.0",
......@@ -44,7 +44,7 @@
"mongodb/mongodb": "1.4.3",
"php": "7.2.*"
},
"time": "2021-08-06T16:38:16+00:00",
"time": "2021-08-12T11:16:58+00:00",
"type": "library",
"installation-source": "source",
"autoload": {
......@@ -637,17 +637,17 @@
},
{
"name": "khanamiryan/qrcode-detector-decoder",
"version": "1.0.5.1",
"version_normalized": "1.0.5.1",
"version": "1.0.5.2",
"version_normalized": "1.0.5.2",
"source": {
"type": "git",
"url": "https://github.com/khanamiryan/php-qrcode-detector-decoder.git",
"reference": "b96163d4f074970dfe67d4185e75e1f4541b30ca"
"reference": "04fdd58d86a387065f707dc6d3cc304c719910c1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/khanamiryan/php-qrcode-detector-decoder/zipball/b96163d4f074970dfe67d4185e75e1f4541b30ca",
"reference": "b96163d4f074970dfe67d4185e75e1f4541b30ca",
"url": "https://api.github.com/repos/khanamiryan/php-qrcode-detector-decoder/zipball/04fdd58d86a387065f707dc6d3cc304c719910c1",
"reference": "04fdd58d86a387065f707dc6d3cc304c719910c1",
"shasum": ""
},
"require": {
......@@ -656,7 +656,7 @@
"require-dev": {
"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",
"installation-source": "dist",
"autoload": {
......@@ -689,7 +689,7 @@
],
"support": {
"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"
},
......@@ -1768,12 +1768,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/property-access.git",
"reference": "d6ef552ac9b41f96e94e1e81d3a8746dfee3b34b"
"reference": "aaa09eb714623e935494b5852c1eff260b704ae1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/property-access/zipball/d6ef552ac9b41f96e94e1e81d3a8746dfee3b34b",
"reference": "d6ef552ac9b41f96e94e1e81d3a8746dfee3b34b",
"url": "https://api.github.com/repos/symfony/property-access/zipball/aaa09eb714623e935494b5852c1eff260b704ae1",
"reference": "aaa09eb714623e935494b5852c1eff260b704ae1",
"shasum": ""
},
"require": {
......@@ -1788,7 +1788,7 @@
"suggest": {
"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",
"installation-source": "dist",
"autoload": {
......
......@@ -6,7 +6,7 @@
'aliases' =>
array (
),
'reference' => 'ec360a59edfff2b202d7dd90a61cbfff5075f554',
'reference' => 'aa0ce40f0ea3b01d62acfef75790d113f0caee3d',
'name' => 'yidian/yaf_demo',
),
'versions' =>
......@@ -22,12 +22,12 @@
),
'api/php_utils' =>
array (
'pretty_version' => 'v1.0.6',
'version' => '1.0.6.0',
'pretty_version' => 'v1.0.10',
'version' => '1.0.10.0',
'aliases' =>
array (
),
'reference' => '8e8e414961ea10f32b79dbaeeb60d9e441a97ad6',
'reference' => '4fb2b99ebe6cc3ad1a99bece88f217874de5db85',
),
'bacon/bacon-qr-code' =>
array (
......@@ -115,12 +115,12 @@
),
'khanamiryan/qrcode-detector-decoder' =>
array (
'pretty_version' => '1.0.5.1',
'version' => '1.0.5.1',
'pretty_version' => '1.0.5.2',
'version' => '1.0.5.2',
'aliases' =>
array (
),
'reference' => 'b96163d4f074970dfe67d4185e75e1f4541b30ca',
'reference' => '04fdd58d86a387065f707dc6d3cc304c719910c1',
),
'mongodb/mongodb' =>
array (
......@@ -279,7 +279,7 @@
'aliases' =>
array (
),
'reference' => 'd6ef552ac9b41f96e94e1e81d3a8746dfee3b34b',
'reference' => 'aaa09eb714623e935494b5852c1eff260b704ae1',
),
'symfony/property-info' =>
array (
......@@ -306,7 +306,7 @@
'aliases' =>
array (
),
'reference' => 'ec360a59edfff2b202d7dd90a61cbfff5075f554',
'reference' => 'aa0ce40f0ea3b01d62acfef75790d113f0caee3d',
),
),
);
......@@ -91,7 +91,7 @@ final class QrReader
{
$this->decode();
if (method_exists($this->result, 'toString')) {
if ($this->result !== false && method_exists($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