Commit 8bcf4677 authored by pengfei's avatar pengfei

Merge branch 'feature_optimize_order_create_refund' into pindan_activity_list_optimize

# Conflicts:
#	composer.json
#	composer.lock
#	vendor/composer/installed.json
#	vendor/composer/installed.php
parents fc87f3c9 3568ab33
......@@ -19,6 +19,7 @@ class GoodsException extends BaseException
const LABEL_PRINTER_ALREADY_EXIST = 53;
const PRINTER_BIND_ERROR = 54;
const PRINTER_SN_ERROR = 55;
const PARAMS_NULL_ERROR = 56;
protected $cus = [
0 => '商品创建失败,请稍后重试',
......@@ -77,5 +78,6 @@ class GoodsException extends BaseException
self::LABEL_PRINTER_ALREADY_EXIST => '标签打印机已被%s绑定',
self::PRINTER_BIND_ERROR => '打印机绑定失败:%s',
self::PRINTER_SN_ERROR => '打印机sn号码有误',
self:: PARAMS_NULL_ERROR => '参数不能为空',
];
}
\ No newline at end of file
......@@ -314,7 +314,7 @@ class GoodsController extends Base
*/
public function refundAction()
{
(new RefundGoodsValidate())->validate();
//(new RefundGoodsValidate())->validate();
$params = $this->params;
$res = GoodsService::refundGoods($params);
$this->success(["result" => $res]);
......@@ -349,4 +349,15 @@ class GoodsController extends Base
$res = GoodsSnapshotsService::goodsSnapshots($this->params);
$this->success(["result" => $res]);
}
/**
* 下单时获取商品数据 sku and spu
* @throws Exception
*/
public function place_order_goods_listAction()
{
$params = $this->params;
$data = GoodsService::getPlaceOrderGoodsList($params);
$this->success(["result" => $data]);
}
}
\ No newline at end of file
......@@ -1936,19 +1936,27 @@ class GoodsService
* @return bool
* @throws GoodsException
*/
public static function refundGoods($params)
public static function refundGoods($dataJson)
{
if (empty($dataJson)){
throw new GoodsException(["cus" => GoodsException::PARAMS_NULL_ERROR]);
}
foreach ($dataJson as $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);
$refundGoodsData[] = $params;
}
} else {
throw new GoodsException(["cus" => 41]);
}
}
if (empty($refundGoodsData)){
return true;
}
return MarketingPindanGoodsService::refundGoods($refundGoodsData);
}
/**
* 通过goods_sku_id 获取 拼单商品的ota信息
......@@ -1974,4 +1982,69 @@ class GoodsService
}
return $data;
}
/**
* 下单时获取商品数据
* @param array $params
* @return array
*/
public static function getPlaceOrderGoodsList($params)
{
if (!$goodsSkuList = self::getPlaceOrderGoodsSkuList($params)) {
return [];
}
$goodsSpuList = self::getGoodsSpuList(['goods_spu_id' => array_column($goodsSkuList, 'goods_spu_id')]);
$goodsSpuList = array_column($goodsSpuList, null, 'goods_spu_id');
$goodsSkuData = [];
foreach ($goodsSkuList as $goodsInfo) {
if (!empty($goodsSpuList[$goodsInfo['goods_spu_id']])) {
$goodsSpuInfo = $goodsSpuList[$goodsInfo['goods_spu_id']];
$goodsSkuData[] = [
'goods_sku_id' => $goodsInfo['goods_sku_id'],
'goods_spu_id' => $goodsInfo['goods_spu_id'],
'goods_version' => $goodsInfo['goods_version'],
'price' => $goodsInfo['price'],
'clear_price' => $goodsInfo['clear_price'],
'rule_limit' => $goodsInfo['rule_limit'],
'online_status' => $goodsInfo['online_status'],
'inventory_rest' => $goodsInfo['inventory_rest'],
'rule_refund' => $goodsSpuInfo['rule_refund'],
'goods_sale_type' => $goodsSpuInfo['goods_sale_type'],
'goods_type' => $goodsSpuInfo['goods_type'],
'shop_id' => $goodsSpuInfo['shop_id'],
'life_account_id' => $goodsSpuInfo['life_account_id']
];
}
}
return $goodsSkuData;
}
/**
* 下单时获取商品sku数据
* @param array $params
* @return array
*/
public static function getPlaceOrderGoodsSkuList($params)
{
if (empty($params['goods_sku_id'])) {
return [];
}
$goodsSkuIdList = [];
foreach ($params['goods_sku_id'] as $goodsSkuId) {
$goodsParams = GoodsSkuId::getGoodsSkuIdParams($goodsSkuId);
$goodsSkuIdList[$goodsParams['goods_type']][] = $goodsSkuId;
}
$goodsSkuList = [];
foreach ($goodsSkuIdList as $goodsType => $goodsSkuIds) {
// 现在只有两种类型 实体,虚拟 ($goodsType == '' 虚拟商品)
if (empty($goodsType) || $goodsType == GoodsSpu::TYPE_VIRTUAL) {
$goodsData = self::generalGetGoodsSkuList(['goods_sku_id' => $goodsSkuIds]);
} else {
$goodsData = self::generalGetPindanGoodsSkuList(['goods_sku_id' => $goodsSkuIds]);
}
$goodsSkuList = array_merge($goodsSkuList, $goodsData);
}
return $goodsSkuList;
}
}
\ No newline at end of file
......@@ -471,20 +471,22 @@ class MarketingPindanGoodsService
}
/**
* 退款拼单商品,库存调整
* 退款拼单商品,库存调整 (批量退库存)
* @param $params
* @return bool
* @throws GoodsException
*/
public static function refundGoods($params)
public static function refundGoods($dataJson)
{
if (empty($dataJson)){
throw new GoodsException(["cus" => GoodsException::PARAMS_NULL_ERROR]);
}
PindanGoodsSku::beginTransaction();
foreach ($dataJson as $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"],
......@@ -504,9 +506,7 @@ class MarketingPindanGoodsService
"total_amount_order[-]" => $params["num"],
"inventory_rest[+]" => $params["num"],
], ["goods_sku_id" => $sku["goods_sku_id"], "total_amount_sold[>=]" => $params["num"], "total_amount_order[>=]" => $params["num"]]);
FileLog::info('goods_refund_log', 'json decode error raw:' . json_encode($params));
if ($row < 1){
PindanGoodsSku::rollback();
GoodsRefundRecord::save([
......@@ -519,7 +519,7 @@ class MarketingPindanGoodsService
throw new GoodsException(["cus" => 0]);
}
}
}
if (!PindanGoodsSku::commit()) {
PindanGoodsSku::rollback();
throw new GoodsException(["cus" => 0]);
......
......@@ -5,6 +5,7 @@ namespace App\Services\tcc;
use Api\PhpUtils\Common\GoodsSkuId;
use Api\PhpUtils\Log\FileLog;
use App\Exception\custom\GoodsException;
use App\Exception\BaseException;
use App\Models\goods\mysql\GoodsSku;
use App\Models\goods\mysql\PindanGoodsSku;
use App\Models\goods\mysql\Tcc;
......@@ -75,7 +76,7 @@ class Tcc2Service
$goodsSkuId = $item["goods_sku_id"];
$num = $item["num"];
$sku = GoodsSku::getRecord(["goods_sku_id" => $goodsSkuId]
, ["goods_sku_id", "inventory_rest", "inventory_lock", "online_status"]);
, ["goods_sku_id", "inventory_rest", "inventory_lock", "online_status","goods_name"]);
if ($sku["online_status"] == GoodsSku::ONLINE_STATUS_ONLINE) {
//条件加上乐观锁
$rowCount = GoodsSku::save([
......@@ -84,11 +85,13 @@ class Tcc2Service
], ["goods_sku_id" => $goodsSkuId, "inventory_rest[>=]" => $num]);
if ($rowCount <= 0) {
GoodsSku::rollback();
throw new GoodsException(["cus" => 24]);
$msg = $sku['goods_name'] . '商品库存不足';
throw new BaseException(['code' => '400000024', 'msg' => $msg]);
}
} else {
GoodsSku::rollback();
throw new GoodsException(["cus" => 43]);
$msg = $sku['goods_name'] . '商品非上架状态';
throw new BaseException(['code' => '400000043', 'msg' => $msg]);
}
}
Tcc::save([
......@@ -122,7 +125,7 @@ class Tcc2Service
$goodsSkuId = $item["goods_sku_id"];
$num = $item["num"];
$sku = PindanGoodsSku::getRecord(["goods_sku_id" => $goodsSkuId]
, ["goods_sku_id", "inventory_rest", "inventory_lock", "online_status"]);
, ["goods_sku_id", "inventory_rest", "inventory_lock", "online_status","goods_name"]);
if ($sku["online_status"] == PindanGoodsSku::ONLINE_STATUS_ONLINE) {
//条件加上乐观锁
$rowCount = PindanGoodsSku::save([
......@@ -131,11 +134,13 @@ class Tcc2Service
], ["goods_sku_id" => $goodsSkuId, "inventory_rest[>=]" => $num]);
if ($rowCount <= 0) {
PindanGoodsSku::rollback();
throw new GoodsException(["cus" => 24]);
$msg = $sku['goods_name'] . '商品库存不足';
throw new BaseException(['code' => '400000024', 'msg' => $msg]);
}
} else {
PindanGoodsSku::rollback();
throw new GoodsException(["cus" => 43]);
$msg = $sku['goods_name'] . '商品非上架状态';
throw new BaseException(['code' => '400000043', 'msg' => $msg]);
}
}
Tcc::save([
......
<?php
namespace App\Services\user\Weixin\Weixin;
use App\Libraries\Http;
namespace App\Services\user\Weixin;
/**
* Created by PhpStorm.
* User: shixing
* Date: 2018/9/12
* Time: 10:48
*/
......
......@@ -38,7 +38,7 @@ class JwUser
$params = ["mobilePhone" => $params['mobile']];
$begin = microtime(true);
$user_info = (new Request())->get($url, $params);
$user_info = (new Request())->get($url, $params, 5000);
$end = microtime(true);
$total_time = round(($end - $begin), 4) * 1000;
if (!empty($user_info['response'])) {
......@@ -71,7 +71,7 @@ class JwUser
$params = ["userId" => $params['user_id']];
$begin = microtime(true);
$user_info = (new Request())->post($url, $params);
$user_info = (new Request())->post($url, $params, 5000);
$end = microtime(true);
$total_time = round(($end - $begin), 4) * 1000;
if (!empty($user_info['response'])) {
......@@ -102,7 +102,7 @@ class JwUser
$params = ["userIds" => $params['user_id']];
$begin = microtime(true);
$user_info = (new Request())->post($url, $params);
$user_info = (new Request())->post($url, $params, 5000);
$end = microtime(true);
$total_time = round(($end - $begin), 4) * 1000;
if (!empty($user_info['response'])) {
......@@ -133,7 +133,7 @@ class JwUser
}
$params = [];
//$city_list = (new TimeOut())->runGet($url, $params);
$city_list = (new Request())->get($url, $params);
$city_list = (new Request())->get($url, $params, 5000);
FileLog::info('jw_user_getAllCityTree', json_encode($city_list));
if (!$city_list) {
throw new CodeSpecialException("timeout");
......
......@@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit147d97defc074a277015f080b27e01c6::getLoader();
return ComposerAutoloaderInite9c1cf708c572b30ccbaa1adb865583e::getLoader();
......@@ -338,7 +338,7 @@ class ClassLoader
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return true|null True if loaded, null otherwise
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
......@@ -347,8 +347,6 @@ class ClassLoader
return true;
}
return null;
}
/**
......
This diff is collapsed.
......@@ -165,6 +165,7 @@ return array(
'App\\Services\\tcc\\TccService' => $baseDir . '/application/services/tcc/TccService.php',
'App\\Services\\user\\UserService' => $baseDir . '/application/services/user/UserService.php',
'App\\Services\\user\\Weixin\\ErrorCode' => $baseDir . '/application/services/user/Weixin/ErrorCode.php',
'App\\Services\\user\\Weixin\\Weixin' => $baseDir . '/application/services/user/Weixin/Weixin.php',
'App\\Services\\user\\Weixin\\WxBizDataCrypt' => $baseDir . '/application/services/user/Weixin/WxBizDataCrypt.php',
'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
'BaconQrCode\\Common\\BitArray' => $vendorDir . '/bacon/bacon-qr-code/src/Common/BitArray.php',
......
......@@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit147d97defc074a277015f080b27e01c6
class ComposerAutoloaderInite9c1cf708c572b30ccbaa1adb865583e
{
private static $loader;
......@@ -24,15 +24,15 @@ class ComposerAutoloaderInit147d97defc074a277015f080b27e01c6
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInit147d97defc074a277015f080b27e01c6', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInite9c1cf708c572b30ccbaa1adb865583e', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit147d97defc074a277015f080b27e01c6', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInite9c1cf708c572b30ccbaa1adb865583e', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit147d97defc074a277015f080b27e01c6::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInite9c1cf708c572b30ccbaa1adb865583e::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
......@@ -53,19 +53,19 @@ class ComposerAutoloaderInit147d97defc074a277015f080b27e01c6
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit147d97defc074a277015f080b27e01c6::$files;
$includeFiles = Composer\Autoload\ComposerStaticInite9c1cf708c572b30ccbaa1adb865583e::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire147d97defc074a277015f080b27e01c6($fileIdentifier, $file);
composerRequiree9c1cf708c572b30ccbaa1adb865583e($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire147d97defc074a277015f080b27e01c6($fileIdentifier, $file)
function composerRequiree9c1cf708c572b30ccbaa1adb865583e($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
......
......@@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit147d97defc074a277015f080b27e01c6
class ComposerStaticInite9c1cf708c572b30ccbaa1adb865583e
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
......@@ -394,6 +394,7 @@ class ComposerStaticInit147d97defc074a277015f080b27e01c6
'App\\Services\\tcc\\TccService' => __DIR__ . '/../..' . '/application/services/tcc/TccService.php',
'App\\Services\\user\\UserService' => __DIR__ . '/../..' . '/application/services/user/UserService.php',
'App\\Services\\user\\Weixin\\ErrorCode' => __DIR__ . '/../..' . '/application/services/user/Weixin/ErrorCode.php',
'App\\Services\\user\\Weixin\\Weixin' => __DIR__ . '/../..' . '/application/services/user/Weixin/Weixin.php',
'App\\Services\\user\\Weixin\\WxBizDataCrypt' => __DIR__ . '/../..' . '/application/services/user/Weixin/WxBizDataCrypt.php',
'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
'BaconQrCode\\Common\\BitArray' => __DIR__ . '/..' . '/bacon/bacon-qr-code/src/Common/BitArray.php',
......@@ -1315,9 +1316,9 @@ class ComposerStaticInit147d97defc074a277015f080b27e01c6
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit147d97defc074a277015f080b27e01c6::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit147d97defc074a277015f080b27e01c6::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit147d97defc074a277015f080b27e01c6::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInite9c1cf708c572b30ccbaa1adb865583e::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInite9c1cf708c572b30ccbaa1adb865583e::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInite9c1cf708c572b30ccbaa1adb865583e::$classMap;
}, null, ClassLoader::class);
}
......
......@@ -3,8 +3,8 @@
/*
* This file has been auto-generated by the Symfony String Component for internal use.
*
* Unicode version: 13.0.0
* Date: 2020-03-12T08:04:33+00:00
* Unicode version: 14.0.0
* Date: 2021-09-17T09:20:30+02:00
*/
return [
......@@ -450,10 +450,6 @@ return [
],
[
19968,
40956,
],
[
40957,
40959,
],
[
......@@ -840,13 +836,25 @@ return [
101632,
101640,
],
[
110576,
110579,
],
[
110581,
110587,
],
[
110589,
110590,
],
[
110592,
110847,
],
[
110848,
110878,
110882,
],
[
110928,
......@@ -996,6 +1004,10 @@ return [
128725,
128727,
],
[
128733,
128735,
],
[
128747,
128748,
......@@ -1008,6 +1020,10 @@ return [
128992,
129003,
],
[
129008,
129008,
],
[
129292,
129338,
......@@ -1018,14 +1034,6 @@ return [
],
[
129351,
129400,
],
[
129402,
129483,
],
[
129485,
129535,
],
[
......@@ -1034,7 +1042,7 @@ return [
],
[
129656,
129658,
129660,
],
[
129664,
......@@ -1042,34 +1050,42 @@ return [
],
[
129680,
129704,
129708,
],
[
129712,
129718,
129722,
],
[
129728,
129730,
129733,
],
[
129744,
129750,
129753,
],
[
129760,
129767,
],
[
129776,
129782,
],
[
131072,
173789,
173791,
],
[
173790,
173792,
173823,
],
[
173824,
177972,
177976,
],
[
177973,
177977,
177983,
],
[
......
......@@ -3,8 +3,8 @@
/*
* This file has been auto-generated by the Symfony String Component for internal use.
*
* Unicode version: 13.0.0
* Date: 2020-03-12T08:04:34+00:00
* Unicode version: 14.0.0
* Date: 2021-09-17T09:20:30+02:00
*/
return [
......@@ -109,7 +109,11 @@ return [
2139,
],
[
2259,
2200,
2207,
],
[
2250,
2273,
],
[
......@@ -272,6 +276,10 @@ return [
3076,
3076,
],
[
3132,
3132,
],
[
3134,
3136,
......@@ -470,7 +478,7 @@ return [
],
[
5938,
5940,
5939,
],
[
5970,
......@@ -504,6 +512,10 @@ return [
6155,
6157,
],
[
6159,
6159,
],
[
6277,
6278,
......@@ -574,7 +586,7 @@ return [
],
[
6847,
6848,
6862,
],
[
6912,
......@@ -666,10 +678,6 @@ return [
],
[
7616,
7673,
],
[
7675,
7679,
],
[
......@@ -916,6 +924,10 @@ return [
69446,
69456,
],
[
69506,
69509,
],
[
69633,
69633,
......@@ -924,6 +936,14 @@ return [
69688,
69702,
],
[
69744,
69744,
],
[
69747,
69748,
],
[
69759,
69761,
......@@ -936,6 +956,10 @@ return [
69817,
69818,
],
[
69826,
69826,
],
[
69888,
69890,
......@@ -1252,6 +1276,14 @@ return [
113821,
113822,
],
[
118528,
118573,
],
[
118576,
118598,
],
[
119143,
119145,
......@@ -1320,6 +1352,10 @@ return [
123184,
123190,
],
[
123566,
123566,
],
[
123628,
123631,
......
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