新增获取商品库存对接、修正实际付款金额返回值
This commit is contained in:
parent
55991b6987
commit
cff132c5d4
@ -4,8 +4,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Model\Product;
|
||||
use App\Model\ProductPlatform;
|
||||
use App\Utils\Log;
|
||||
use Extend\Prescription\Prescription;
|
||||
use Hyperf\Command\Command as HyperfCommand;
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
@ -29,8 +34,37 @@ class getProductCommand extends HyperfCommand
|
||||
// 主逻辑处理
|
||||
public function handle()
|
||||
{
|
||||
$sign = $this->input->getArgument('sign');
|
||||
$this->line($sign);
|
||||
$this->line("商品更新开始");
|
||||
|
||||
try {
|
||||
$prescription = new Prescription();
|
||||
|
||||
$page = 1;
|
||||
$page_size = 10;
|
||||
$result = $prescription->getProd(1, 10);
|
||||
if (!empty($result['rows'])){
|
||||
foreach ($result['rows'] as $item) {
|
||||
// 执行入库
|
||||
$this->handleData($item);
|
||||
}
|
||||
|
||||
$count = ceil($result['count'] / $page * $page_size);
|
||||
|
||||
if ($result['count'] > $page * $page_size) {
|
||||
for ($i = 2; $i < $count; $i++) {
|
||||
$result = $prescription->getProd($i, $page_size);
|
||||
foreach ($result['rows'] as $item) {
|
||||
// 执行入库
|
||||
$this->handleData($item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->line("商品更新失败:" . $e->getMessage());
|
||||
}
|
||||
|
||||
$this->line("商品更新成功");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,7 +74,230 @@ class getProductCommand extends HyperfCommand
|
||||
protected function getArguments(): array
|
||||
{
|
||||
return [
|
||||
['sign', InputArgument::REQUIRED, '签名数据']
|
||||
// ['sign', InputArgument::REQUIRED, '签名数据']
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 入库
|
||||
* @param array $item
|
||||
* @return bool
|
||||
*/
|
||||
protected function handleData(array $item): bool
|
||||
{
|
||||
try {
|
||||
Db::beginTransaction();
|
||||
|
||||
if (empty($item['drugCode'])) {
|
||||
Db::rollBack();
|
||||
$this->line("商品更新失败,缺少平台药品编码" . json_encode($item, JSON_UNESCAPED_UNICODE));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($item['drugPrice'])) {
|
||||
Db::rollBack();
|
||||
$this->line("商品更新失败,缺少药品价格" . json_encode($item, JSON_UNESCAPED_UNICODE));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 查询是否存在
|
||||
$params = array();
|
||||
$params['product_platform_code'] = $item['drugCode'];
|
||||
$product_platform = ProductPlatform::getOne($params);
|
||||
if (!empty($product_platform)) {
|
||||
// 已存在,更新
|
||||
$product_platform_data = array();
|
||||
$product_data = array();
|
||||
|
||||
// 商品名称
|
||||
if (isset($item['tradeName'])) {
|
||||
if ($product_platform['product_name'] != $item['tradeName']) {
|
||||
$product_platform_data['product_name'] = $item['tradeName'];
|
||||
$product_data['product_name'] = $item['tradeName'];
|
||||
}
|
||||
}
|
||||
|
||||
// 商品价格
|
||||
if ($product_platform['product_price'] != $item['drugPrice']) {
|
||||
$product_platform_data['product_price'] = $item['drugPrice'];
|
||||
$product_data['product_price'] = $item['drugPrice'];
|
||||
}
|
||||
|
||||
// 药品类型
|
||||
if (isset($item['drugClassCode'])) {
|
||||
if ($item['drugClassCode'] == 1) {
|
||||
$product_type = 1;
|
||||
} elseif ($item['drugClassCode'] == 2) {
|
||||
$product_type = 2;
|
||||
} else {
|
||||
$product_type = 0;
|
||||
}
|
||||
|
||||
if ($product_platform['product_type'] != $product_type) {
|
||||
$product_platform_data['product_type'] = $product_type;
|
||||
$product_data['product_type'] = $product_type;
|
||||
}
|
||||
}
|
||||
|
||||
// 商品规格
|
||||
if (isset($item['specifications'])) {
|
||||
if ($product_platform['product_spec'] != $item['specifications']) {
|
||||
$product_platform_data['product_spec'] = $item['specifications'];
|
||||
$product_data['product_spec'] = $item['specifications'];
|
||||
}
|
||||
}
|
||||
|
||||
// 批准文号
|
||||
if (isset($item['approvalNumber'])) {
|
||||
if ($product_platform['license_number'] != $item['approvalNumber']) {
|
||||
$product_platform_data['license_number'] = $item['approvalNumber'];
|
||||
$product_data['license_number'] = $item['approvalNumber'];
|
||||
}
|
||||
}
|
||||
|
||||
// 生产厂家
|
||||
if (isset($item['manufacturer'])) {
|
||||
if ($product_platform['manufacturer'] != $item['manufacturer']) {
|
||||
$product_platform_data['manufacturer'] = $item['manufacturer'];
|
||||
$product_data['manufacturer'] = $item['manufacturer'];
|
||||
}
|
||||
}
|
||||
|
||||
// 零售包装单位
|
||||
if (isset($item['packingUnit'])) {
|
||||
if ($product_platform['retail_unit'] != $item['packingUnit']) {
|
||||
$product_platform_data['retail_unit'] = $item['packingUnit'];
|
||||
$product_data['packaging_unit'] = $item['packingUnit']; // 平台返回零售包装单位为:盒,此结果适用于商品表的基本包装单位
|
||||
}
|
||||
}
|
||||
|
||||
// 第三方药店商品编码
|
||||
if (isset($item['thirdDrugCode'])) {
|
||||
if ($product_platform['product_pharmacy_code'] != $item['thirdDrugCode']) {
|
||||
$product_platform_data['product_pharmacy_code'] = $item['thirdDrugCode'];
|
||||
$product_data['product_pharmacy_code'] = $item['thirdDrugCode'];
|
||||
}
|
||||
}
|
||||
|
||||
// 基本包装数量
|
||||
if (isset($item['basicPackingCount'])) {
|
||||
if ($product_platform['packaging_count'] != $item['basicPackingCount']) {
|
||||
$product_platform_data['packaging_count'] = $item['basicPackingCount'];
|
||||
}
|
||||
}
|
||||
|
||||
// 基本包装单位
|
||||
if (isset($item['basicPackingUnit'])) {
|
||||
if ($product_platform['packaging_unit'] != $item['basicPackingUnit']) {
|
||||
$product_platform_data['packaging_unit'] = $item['basicPackingUnit'];
|
||||
}
|
||||
}
|
||||
|
||||
// 单次剂量单位
|
||||
if (isset($item['defaultSingleDosageUnit'])) {
|
||||
if ($product_platform['single_unit'] != $item['defaultSingleDosageUnit']) {
|
||||
$product_platform_data['single_unit'] = $item['defaultSingleDosageUnit'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($product_platform_data)) {
|
||||
// 更新商品表-处方平台
|
||||
$params = array();
|
||||
$params['product_platform_id'] = $product_platform['product_platform_id'];
|
||||
ProductPlatform::edit($params, $product_platform_data);
|
||||
|
||||
if (!empty($product_data)) {
|
||||
// 获取商品表数据
|
||||
$params = array();
|
||||
$params['product_platform_id'] = $product_platform['product_platform_id'];
|
||||
$product = Product::getOne($params);
|
||||
if (!empty($product)) {
|
||||
// 更新商品表
|
||||
$params = array();
|
||||
$params['product_platform_id'] = $product_platform['product_platform_id'];
|
||||
Product::edit($params, $product_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 不存在,创建
|
||||
$data = array();
|
||||
// 商品名称
|
||||
if (isset($item['tradeName'])) {
|
||||
$data['product_name'] = $item['tradeName'];
|
||||
}
|
||||
|
||||
// 商品价格
|
||||
$data['product_price'] = $item['drugPrice'];
|
||||
|
||||
// 药品类型
|
||||
if (isset($item['drugClassCode'])) {
|
||||
if ($item['drugClassCode'] == 1) {
|
||||
$data['product_type'] = 1;
|
||||
} elseif ($item['drugClassCode'] == 2) {
|
||||
$data['product_type'] = 2;
|
||||
} else {
|
||||
$data['product_type'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 处方平台商品编码
|
||||
$data['product_platform_code'] = $item['drugCode'];
|
||||
|
||||
// 第三方药店商品编码
|
||||
if (isset($item['thirdDrugCode'])) {
|
||||
$data['product_pharmacy_code'] = $item['thirdDrugCode'];
|
||||
}
|
||||
|
||||
// 商品规格
|
||||
if (isset($item['specifications'])) {
|
||||
$data['product_spec'] = $item['specifications'];
|
||||
}
|
||||
|
||||
// 批准文号
|
||||
if (isset($item['approvalNumber'])) {
|
||||
$data['license_number'] = $item['approvalNumber'];
|
||||
}
|
||||
|
||||
// 生产厂家
|
||||
if (isset($item['manufacturer'])) {
|
||||
$data['manufacturer'] = $item['manufacturer'];
|
||||
}
|
||||
|
||||
// 单次剂量单位
|
||||
if (isset($item['defaultSingleDosageUnit'])) {
|
||||
$data['single_unit'] = $item['defaultSingleDosageUnit'];
|
||||
}
|
||||
|
||||
// 基本包装单位
|
||||
if (isset($item['basicPackingUnit'])) {
|
||||
$data['packaging_unit'] = $item['basicPackingUnit'];
|
||||
}
|
||||
|
||||
// 基本包装数量
|
||||
if (isset($item['basicPackingCount'])) {
|
||||
$data['packaging_count'] = $item['basicPackingCount'];
|
||||
}
|
||||
|
||||
// 零售包装单位
|
||||
if (isset($item['packingUnit'])) {
|
||||
$data['retail_unit'] = $item['packingUnit'];
|
||||
}
|
||||
|
||||
$product_platform = ProductPlatform::addProductPlatform($data);
|
||||
if (empty($product_platform)) {
|
||||
Db::rollBack();
|
||||
$this->line("商品更新失败:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
$this->line("商品更新失败:" . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
66
app/Command/getProductStockCommand.php
Normal file
66
app/Command/getProductStockCommand.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Model\Product;
|
||||
use Extend\Prescription\Prescription;
|
||||
use Hyperf\Command\Command as HyperfCommand;
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* 更新商品库存
|
||||
*/
|
||||
#[Command]
|
||||
class getProductStockCommand extends HyperfCommand
|
||||
{
|
||||
public function __construct(protected ContainerInterface $container)
|
||||
{
|
||||
parent::__construct('getProductStock:command');
|
||||
}
|
||||
|
||||
public function configure()
|
||||
{
|
||||
parent::configure();
|
||||
$this->setDescription('获取处方平台商品库存数据');
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$this->line("商品库存更新开始");
|
||||
|
||||
try {
|
||||
// 获取商品
|
||||
$params = array();
|
||||
$product = Product::getPage($params);
|
||||
if (empty($product['data'])){
|
||||
$this->line("商品库存更新成功,无可更新库存商品");
|
||||
return;
|
||||
}
|
||||
|
||||
$prescription = new Prescription();
|
||||
|
||||
foreach ($product['data'] as $item){
|
||||
if (!empty($item['product_pharmacy_code'])){
|
||||
|
||||
}
|
||||
|
||||
$result = $prescription->getProdStock($item['product_pharmacy_code']);
|
||||
dump($result);die;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->line("商品库存更新失败:" . $e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->line("商品库存更新成功");
|
||||
}
|
||||
}
|
||||
@ -113,4 +113,46 @@ class Product extends Model
|
||||
->where($params)
|
||||
->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param array $params
|
||||
* @param array $data
|
||||
* @return int
|
||||
*/
|
||||
public static function edit(array $params = [], array $data = []): int
|
||||
{
|
||||
return self::where($params)->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数量
|
||||
* @param array $params
|
||||
* @return int
|
||||
*/
|
||||
public static function getCount(array $params): int
|
||||
{
|
||||
return self::where($params)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表-分页
|
||||
* @param array $params 条件
|
||||
* @param array $fields 字段
|
||||
* @param int|null $page 页码
|
||||
* @param int|null $per_page 每页个数
|
||||
* @return array
|
||||
*/
|
||||
public static function getPage(array $params, array $fields = ["*"], int $page = null, ?int $per_page = 10): array
|
||||
{
|
||||
$raw = self::where($params)->paginate($per_page, $fields, "page", $page);
|
||||
$data = array();
|
||||
$data['current_page'] = $raw->currentPage();// 当前页码
|
||||
$data['total'] = $raw->total();//数据总数
|
||||
$data['data'] = $raw->items();//数据
|
||||
$data['per_page'] = $raw->perPage();//每页个数
|
||||
$data['last_page'] = $raw->lastPage();//最后一页
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
97
app/Model/ProductPlatform.php
Normal file
97
app/Model/ProductPlatform.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $product_platform_id 主键id
|
||||
* @property string $product_name 商品名称
|
||||
* @property string $product_price 商品价格
|
||||
* @property int $product_type 药品类型(0:未知 1:中成药 2:西药)
|
||||
* @property string $product_platform_code 处方平台商品编码
|
||||
* @property string $product_pharmacy_code 第三方药店商品编码
|
||||
* @property string $product_spec 商品规格
|
||||
* @property string $license_number 批准文号
|
||||
* @property string $manufacturer 生产厂家
|
||||
* @property string $single_unit 单次剂量单位
|
||||
* @property string $packaging_unit 基本包装单位
|
||||
* @property string $packaging_count 基本包装数量
|
||||
* @property string $retail_unit 零售单位
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class ProductPlatform extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'product_platform';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['product_platform_id', 'product_name', 'product_price', 'product_type', 'product_platform_code', 'product_pharmacy_code', 'product_spec', 'license_number', 'manufacturer', 'single_unit', 'packaging_unit', 'packaging_count', 'retail_unit', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "product_platform_id";
|
||||
|
||||
/**
|
||||
* 获取数据-单
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据-多
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params = [], array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param array $params
|
||||
* @param array $data
|
||||
* @return int
|
||||
*/
|
||||
public static function edit(array $params = [], array $data = []): int
|
||||
{
|
||||
return self::where($params)->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return \Hyperf\Database\Model\Model|ProductPlatform
|
||||
*/
|
||||
public static function addProductPlatform(array $data = []): \Hyperf\Database\Model\Model|ProductPlatform
|
||||
{
|
||||
return self::create($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否存在
|
||||
* @param array $params
|
||||
* @return bool
|
||||
*/
|
||||
public static function getExists(array $params): bool
|
||||
{
|
||||
return self::where($params)->exists();
|
||||
}
|
||||
}
|
||||
@ -89,38 +89,38 @@ class InquiryRequest extends FormRequest
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'inquiry_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_mode.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_mode.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_mode.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_mode.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
|
||||
'patient_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'family_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'disease_class_id.required' => "请您选择疾病",
|
||||
'diagnosis_date.date' => HttpEnumCode::getMessage(HttpEnumCode::DATE_FORMAT_ERROR),
|
||||
'disease_desc.required' => "请您输入病情主诉",
|
||||
'is_allergy_history.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_allergy_history.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_allergy_history.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_family_history.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_family_history.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_family_history.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_pregnant.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_pregnant.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_pregnant.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'client_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'client_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'client_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'client_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
|
||||
'inquiry_status.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_status.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'inquiry_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'inquiry_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'inquiry_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'inquiry_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'inquiry_mode.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'inquiry_mode.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'inquiry_mode.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'inquiry_mode.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
//
|
||||
// 'patient_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'family_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'disease_class_id.required' => "请您选择疾病",
|
||||
// 'diagnosis_date.date' => HttpEnumCode::getMessage(HttpEnumCode::DATE_FORMAT_ERROR),
|
||||
// 'disease_desc.required' => "请您输入病情主诉",
|
||||
// 'is_allergy_history.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'is_allergy_history.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'is_allergy_history.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'is_family_history.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'is_family_history.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'is_family_history.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'is_pregnant.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'is_pregnant.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'is_pregnant.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'client_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'client_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'client_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'client_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
//
|
||||
// 'inquiry_status.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'inquiry_status.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'inquiry_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
// 'inquiry_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,7 +267,7 @@ class DoctorAccountService extends BaseService
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor_withdrawal = DoctorWithdrawal::getDatePage($params,$created_at_params,$page,$per_page);
|
||||
$doctor_withdrawal = DoctorWithdrawal::getDatePage($params,$created_at_params,['*'],$page,$per_page);
|
||||
if (empty($doctor_withdrawal['data'])){
|
||||
return success();
|
||||
}
|
||||
|
||||
@ -402,9 +402,8 @@ class DoctorInquiryService extends BaseService
|
||||
* @param string|int $inquiry_type 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
* @param string|int $inquiry_mode 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||
* @param string|int $doctor_id 医生id
|
||||
* @return int
|
||||
*/
|
||||
public function getDoctorInquiryPrice(string|int $inquiry_type, string|int $inquiry_mode, string|int $doctor_id): int
|
||||
public function getDoctorInquiryPrice(string|int $inquiry_type, string|int $inquiry_mode, string|int $doctor_id):float
|
||||
{
|
||||
// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊)
|
||||
if ($inquiry_type == 1 || $inquiry_type == 3) {
|
||||
|
||||
@ -82,30 +82,30 @@ class InquiryService extends BaseService
|
||||
|
||||
// 获取当前问诊医生信息
|
||||
// 专家问诊-公益问诊
|
||||
if ($request_params['inquiry_type'] == 3 || $request_params['inquiry_type'] == 1) {
|
||||
if (empty($request_params['doctor_id'])) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未选择医生");
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $request_params['doctor_id'];
|
||||
$doctor = UserDoctor::getOne($params);
|
||||
if (empty($doctor)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未知医生");
|
||||
}
|
||||
|
||||
if ($doctor['idcard_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "当前医生无法接诊,请重新选择");
|
||||
}
|
||||
|
||||
if ($doctor['iden_auth_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "当前医生无法接诊,请重新选择");
|
||||
}
|
||||
}
|
||||
// if ($request_params['inquiry_type'] == 3 || $request_params['inquiry_type'] == 1) {
|
||||
// if (empty($request_params['doctor_id'])) {
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, "未选择医生");
|
||||
// }
|
||||
//
|
||||
// $params = array();
|
||||
// $params['doctor_id'] = $request_params['doctor_id'];
|
||||
// $doctor = UserDoctor::getOne($params);
|
||||
// if (empty($doctor)) {
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, "未知医生");
|
||||
// }
|
||||
//
|
||||
// if ($doctor['idcard_status'] != 1) {
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, "当前医生无法接诊,请重新选择");
|
||||
// }
|
||||
//
|
||||
// if ($doctor['iden_auth_status'] != 1) {
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, "当前医生无法接诊,请重新选择");
|
||||
// }
|
||||
// }
|
||||
|
||||
// 获取问诊价格
|
||||
$DoctorInquiryService = new DoctorInquiryService();
|
||||
$inquiry_price = $DoctorInquiryService->getDoctorInquiryPrice($request_params['inquiry_type'], $request_params['inquiry_mode'], $request_params['doctor_id'] ?? "");
|
||||
$inquiry_price = $DoctorInquiryService->getDoctorInquiryPrice($request_params['inquiry_type'], $request_params['inquiry_mode'], $request_params['doctor_id'] ?: "");
|
||||
|
||||
// 获取可用优惠卷
|
||||
$CouponService = new CouponService();
|
||||
@ -127,6 +127,9 @@ class InquiryService extends BaseService
|
||||
// 实际付款金额
|
||||
$coupon_amount_total = $user_coupon['coupon']['coupon_price'] ?? 0;
|
||||
$payment_amount_total = $inquiry_price - $coupon_amount_total;
|
||||
if ($payment_amount_total < 0) {
|
||||
$payment_amount_total = 0;
|
||||
}
|
||||
|
||||
// 生成问诊订单
|
||||
$data = array();
|
||||
@ -235,14 +238,14 @@ class InquiryService extends BaseService
|
||||
}
|
||||
|
||||
// 修改优惠卷使用状态
|
||||
if (!empty($user_coupon)){
|
||||
if (!empty($user_coupon)) {
|
||||
$data = array();
|
||||
$data['user_coupon_status'] = 1;
|
||||
$data['coupon_use_date'] = date('Y-m-d H:i:s',time());
|
||||
$data['coupon_use_date'] = date('Y-m-d H:i:s', time());
|
||||
|
||||
$params = array();
|
||||
$params['user_coupon_id'] = $user_coupon['user_coupon_id'];
|
||||
UserCoupon::edit($params,$data);
|
||||
UserCoupon::edit($params, $data);
|
||||
}
|
||||
|
||||
// 增加至取消订单延迟队列
|
||||
@ -433,7 +436,7 @@ class InquiryService extends BaseService
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['order_inquiry_id'] = $order_inquiry_id;;
|
||||
$order_evaluation = OrderEvaluation::getOne($params);
|
||||
if (!empty($order_evaluation)){
|
||||
if (!empty($order_evaluation)) {
|
||||
// 已评价
|
||||
return success();
|
||||
}
|
||||
@ -463,7 +466,7 @@ class InquiryService extends BaseService
|
||||
$data['type'] = 1;
|
||||
$data['content'] = $content;
|
||||
$order_evaluation = OrderEvaluation::addOrderEvaluation($data);
|
||||
if (empty($order_evaluation)){
|
||||
if (empty($order_evaluation)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
@ -484,7 +487,7 @@ class InquiryService extends BaseService
|
||||
$params['inquiry_type'] = 2;
|
||||
$params['inquiry_mode'] = 1;
|
||||
$system_inquiry_config = SystemInquiryConfig::getOne($params);
|
||||
if (!empty($system_inquiry_config)){
|
||||
if (!empty($system_inquiry_config)) {
|
||||
$quick_inquiry_price = $system_inquiry_config['inquiry_price'];
|
||||
}
|
||||
|
||||
@ -494,7 +497,7 @@ class InquiryService extends BaseService
|
||||
$params['inquiry_type'] = 4;
|
||||
$params['inquiry_mode'] = 1;
|
||||
$system_inquiry_config = SystemInquiryConfig::getOne($params);
|
||||
if (!empty($system_inquiry_config)){
|
||||
if (!empty($system_inquiry_config)) {
|
||||
$medicine_inquiry_price = $system_inquiry_config['inquiry_price'];
|
||||
}
|
||||
|
||||
@ -504,12 +507,12 @@ class InquiryService extends BaseService
|
||||
$params['inquiry_type'] = 1;
|
||||
$params['inquiry_mode'] = 1;
|
||||
$expert_inquiry_price = DoctorInquiryConfig::getMinInquiryPriceMinOne($params);
|
||||
if (empty($expert_inquiry_price) || $expert_inquiry_price == 0){
|
||||
if (empty($expert_inquiry_price) || $expert_inquiry_price == 0) {
|
||||
$params = array();
|
||||
$params['inquiry_type'] = 1;
|
||||
$params['inquiry_mode'] = 1;
|
||||
$system_inquiry_config = SystemInquiryConfig::getOne($params);
|
||||
if (!empty($system_inquiry_config)){
|
||||
if (!empty($system_inquiry_config)) {
|
||||
$expert_inquiry_price = $system_inquiry_config['min_inquiry_price'];
|
||||
}
|
||||
}
|
||||
@ -520,13 +523,13 @@ class InquiryService extends BaseService
|
||||
$params['inquiry_mode'] = 1;
|
||||
$welfare_inquiry_price = DoctorInquiryConfig::getMinInquiryPriceMinOne($params);
|
||||
|
||||
if (empty($welfare_inquiry_price) || $welfare_inquiry_price == 0){
|
||||
if (empty($welfare_inquiry_price) || $welfare_inquiry_price == 0) {
|
||||
$params = array();
|
||||
$params['inquiry_type'] = 1;
|
||||
$params['inquiry_mode'] = 1;
|
||||
$system_inquiry_config = SystemInquiryConfig::getOne($params);
|
||||
if (!empty($system_inquiry_config)){
|
||||
$inquiry_price = explode(',',$system_inquiry_config['inquiry_price']);
|
||||
if (!empty($system_inquiry_config)) {
|
||||
$inquiry_price = explode(',', $system_inquiry_config['inquiry_price']);
|
||||
$welfare_inquiry_price = $inquiry_price[0] ?? 0;
|
||||
}
|
||||
}
|
||||
@ -670,7 +673,7 @@ class InquiryService extends BaseService
|
||||
}
|
||||
|
||||
// 发起退款
|
||||
$WechatPay = new WechatPay(1,1);
|
||||
$WechatPay = new WechatPay(1, 1);
|
||||
|
||||
$generator = $this->container->get(IdGeneratorInterface::class);
|
||||
|
||||
@ -743,7 +746,7 @@ class InquiryService extends BaseService
|
||||
* @param string|int $cancel_remarks 取消订单备注
|
||||
* @return array
|
||||
*/
|
||||
public function cancelUnpayInquiryOrder(string|int $order_no,string|int $cancel_reason,string|int $cancel_remarks): array
|
||||
public function cancelUnpayInquiryOrder(string|int $order_no, string|int $cancel_reason, string|int $cancel_remarks): array
|
||||
{
|
||||
$result = array();
|
||||
$result['status'] = 1;
|
||||
@ -774,7 +777,7 @@ class InquiryService extends BaseService
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (!in_array($order_inquiry['inquiry_refund_status'],[0,4,5])) {
|
||||
if (!in_array($order_inquiry['inquiry_refund_status'], [0, 4, 5])) {
|
||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "取消未支付的问诊订单:订单正在退款中";
|
||||
@ -800,30 +803,30 @@ class InquiryService extends BaseService
|
||||
$data = array();
|
||||
$data['inquiry_status'] = 7;
|
||||
$data['inquiry_pay_status'] = 5;
|
||||
$data['cancel_time'] = date("Y-m-d H:i:s",time());
|
||||
$data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$data['cancel_reason'] = $cancel_reason; // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||
$data['cancel_remarks'] = $cancel_remarks; // 取消订单备注
|
||||
$data['updated_at'] = date("Y-m-d H:i:s",time());
|
||||
$data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
OrderInquiry::edit($params,$data);
|
||||
OrderInquiry::edit($params, $data);
|
||||
|
||||
// 处理订单优惠卷
|
||||
if (!empty($order_inquiry['coupon_amount_total']) && $order_inquiry['coupon_amount_total'] > 0){
|
||||
if (!empty($order_inquiry['coupon_amount_total']) && $order_inquiry['coupon_amount_total'] > 0) {
|
||||
// 获取用户优惠卷信息
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$order_inquiry_coupon = OrderInquiryCoupon::getOne($params);
|
||||
if (!empty($order_inquiry_coupon)){
|
||||
if (!empty($order_inquiry_coupon)) {
|
||||
// 恢复优惠卷
|
||||
$data = array();
|
||||
$data['user_coupon_status'] = 0;
|
||||
$data['coupon_use_date'] = date('Y-m-d H:i:s',time());
|
||||
$data['coupon_use_date'] = date('Y-m-d H:i:s', time());
|
||||
|
||||
$params = array();
|
||||
$params['user_coupon_id'] = $order_inquiry_coupon['user_coupon_id'];
|
||||
UserCoupon::edit($params,$data);
|
||||
UserCoupon::edit($params, $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -613,6 +613,12 @@ class PatientOrderService extends BaseService
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单支付状态错误");
|
||||
}
|
||||
|
||||
// 验证订单过期支付时间
|
||||
$diff_time = (strtotime($order_inquiry['created_at']) - time()) / 60;
|
||||
if ($diff_time >= 30){
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单已过期");
|
||||
}
|
||||
|
||||
$order_id = $order_inquiry['order_inquiry_id'];
|
||||
$created_at = $order_inquiry['created_at'];
|
||||
$inquiry_type = $order_inquiry['inquiry_type'];
|
||||
@ -654,6 +660,12 @@ class PatientOrderService extends BaseService
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单支付状态错误");
|
||||
}
|
||||
|
||||
// 验证订单过期支付时间
|
||||
$diff_time = (strtotime($order_product['created_at']) - time()) / 60;
|
||||
if ($diff_time >= 30){
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单已过期");
|
||||
}
|
||||
|
||||
$order_id = $order_product['order_product_id'];
|
||||
$created_at = $order_product['created_at'];
|
||||
$inquiry_type = 0;
|
||||
|
||||
@ -78,11 +78,11 @@ class Prescription
|
||||
}
|
||||
|
||||
// 获取药品
|
||||
public function getProd(){
|
||||
public function getProd(int $page = 1,int $pageSize = 10){
|
||||
$option = [
|
||||
"json" => array(
|
||||
"page" => 1,
|
||||
"pageSize" => 1,
|
||||
"page" => $page,
|
||||
"pageSize" => $pageSize,
|
||||
),
|
||||
];
|
||||
|
||||
@ -93,20 +93,32 @@ class Prescription
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
}
|
||||
|
||||
if (empty($response['result']['rows'])){
|
||||
return true;
|
||||
}
|
||||
|
||||
dump($response);
|
||||
// 获取总数
|
||||
// $count
|
||||
return $response['result'];
|
||||
} catch (GuzzleException $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
|
||||
// return $response['token'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品库存
|
||||
* @param string $product_platform_code 处方平台商品编码(此处使用第三方药店商品编码!)
|
||||
* @return array
|
||||
*/
|
||||
public function getProdStock(string $product_platform_code): array
|
||||
{
|
||||
$option = [
|
||||
"json" => array(
|
||||
"pharmacyCode" => "JG-10009",
|
||||
"drugCode" => $product_platform_code,
|
||||
),
|
||||
];
|
||||
|
||||
try {
|
||||
return $this->httpRequest($this->api_url . $this->version . '/pharmacy/pharmacyInventory', $option);
|
||||
} catch (GuzzleException $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求封装
|
||||
@ -117,7 +129,7 @@ class Prescription
|
||||
*/
|
||||
protected function httpRequest(string $path,array $arg = []): array
|
||||
{
|
||||
if ($path != "http://49.233.3.200:6304/api/thridapi/v1/drug/syncDrugCatalogue"){
|
||||
if ($path != "http://49.233.3.200:6304/api/thridapi/v1/user_thrid/token"){
|
||||
$this->redis = $this->container->get(Redis::class);
|
||||
|
||||
$access_token = $this->redis->get("prescription_token");
|
||||
@ -139,7 +151,6 @@ class Prescription
|
||||
}
|
||||
|
||||
$response = $this->client->post($path, $arg);
|
||||
|
||||
if ($response->getStatusCode() != '200'){
|
||||
// 请求失败
|
||||
throw new BusinessException($response->getBody()->getContents());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user