feature/main20240421
郭嘉 6 months ago
parent 89d17018dc
commit f28d075702
  1. 9
      app/api/service/order/PaySuccess.php
  2. 13
      app/common/model/Merchant.php
  3. 71
      app/common/model/MerchantPay.php
  4. 65
      app/store/model/MerchantPay.php
  5. 32
      public/install/data/install_struct.sql

@ -15,6 +15,8 @@ namespace app\api\service\order;
use think\facade\Event;
use app\api\model\User as UserModel;
use app\api\model\Order as OrderModel;
use app\common\model\Merchant as merchantModel;
use app\common\model\MerchantPay as merchantPayModel;
use app\api\model\PaymentTrade as PaymentTradeModel;
use app\api\model\user\BalanceLog as BalanceLogModel;
use app\api\service\order\source\Factory as OrderSourceFactory;
@ -292,6 +294,7 @@ class PaySuccess extends BaseService
$this->updateOrderStatus();
// 累积用户总消费金额
UserModel::setIncPayMoney($orderInfo['user_id'], (float)$orderInfo['pay_price']);
// 记录订单支付信息
$this->updatePayInfo();
});
@ -349,6 +352,12 @@ class PaySuccess extends BaseService
'user_id' => (int)$orderInfo['user_id'],
'money' => -$orderInfo['pay_price'],
], ['order_no' => $orderInfo['order_no']]);
//增加商户支付详情
(new merchantPayModel())->addDetail($orderInfo);
//累计商户余额支付金额
merchantModel::setIncTotal($orderInfo['merchant_id'], (float)$orderInfo['pay_price']);
}
// 将第三方交易记录更新为已支付状态
if (in_array($this->method, [PaymentMethodEnum::WECHAT, PaymentMethodEnum::ALIPAY])) {

@ -123,4 +123,17 @@ class Merchant extends BaseModel
{
return $this->save(['is_delete' => 1]);
}
/**
* 累积用户可用余额
* @param int $userId
* @param float $money
* @return mixed
*/
public static function setIncTotal(int $merchantId, float $money)
{
(new static)->setInc($merchantId, 'total_amount', $money);
(new static)->setInc($merchantId, 'available_amount', $money);
return true;
}
}

@ -0,0 +1,71 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
use think\model\relation\HasOne;
/**
* Class Store
* @package app\common\model
*/
class MerchantPay extends BaseModel
{
// 定义表名
protected $name = 'merchant_pay';
// 定义主键
protected $pk = 'merchant_pay_id';
/**
* 累积用户可用余额
* @param int $userId
* @param float $money
* @return mixed
*/
public function addDetail($orderInfo)
{
if (!empty($orderInfo['merchant_id'])) {
$data = [
'order_id' => $orderInfo['order_id'],
//'store_id' => $orderInfo['store_id'],
'merchant_id' => $orderInfo['merchant_id'],
'total_amount' => (float)$orderInfo['pay_price'],
];
return $this->save($this->createData($data));
}
return true;
}
/**
* 创建数据
* @param array $data
* @return array
*/
private function createData(array $data): array
{
$data['store_id'] = self::$storeId;
return $data;
}
/**
* 软删除
* @return bool
*/
public function setDelete(): bool
{
return $this->save(['is_delete' => 1]);
}
}

@ -0,0 +1,65 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\store\model;
use app\common\model\MerchantPay as StoreModel;
/**
* 商家记录表模型
* Class Store
* @package app\store\model
*/
class MerchantPay extends StoreModel
{
/**
* 更新记录
* @param array $data
* @return bool
*/
public function edit(array $data): bool
{
// 是否删除图片
!isset($data['logo_image_id']) && $data['logo_image_id'] = 0;
return $this->save($data) !== false;
}
/**
* 新增记录
* @param array $data
* @return bool
*/
public function add(array $data): bool
{
return $this->save($this->createData($data));
}
/**
* 创建数据
* @param array $data
* @return array
*/
private function createData(array $data): array
{
$data['store_id'] = self::$storeId;
return $data;
}
/**
* 软删除
* @return bool
*/
public function setDelete(): bool
{
return $this->save(['is_delete' => 1]);
}
}

@ -756,7 +756,7 @@ CREATE TABLE `yoshop_order` (
`user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID',
`is_delete` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
`store_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID',
`merchant_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商户ID、商店ID 隔离商城里面的商户'
`merchant_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商户ID、商店ID 隔离商城里面的商户',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`order_id`),
@ -1731,22 +1731,40 @@ ADD COLUMN `is_page` tinyint(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT '是否为
DROP TABLE IF EXISTS `yoshop_merchant`;
CREATE TABLE `yoshop_merchant` (
`merchant_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`shop_name` varchar(100) NOT NULL DEFAULT '' COMMENT '名称',
`shop_label` varchar(100) NOT NULL DEFAULT '' COMMENT '标签',
`shop_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '名称',
`shop_label` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '标签',
`logo_image_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '门店logo图片ID',
`license_img_id` varchar(200) NOT NULL DEFAULT '' COMMENT '营业执照图片ID',
`user_name` varchar(100) NOT NULL DEFAULT '' COMMENT '买家用户名',
`license_img_id` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '营业执照图片ID',
`user_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '买家用户名',
`sort` int(11) NOT NULL DEFAULT '0' COMMENT '门店排序(数字越小越靠前)',
`score` varchar(100) NOT NULL DEFAULT '' COMMENT '得分',
`sale` varchar(100) NOT NULL DEFAULT '' COMMENT '销量',
`is_delete` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
`store_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
`score` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '得分',
`sale` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '销量',
`is_select_mechant` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '是否精选商户',
`total_amount` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '累计金额',
`available_amount` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '可用金额',
PRIMARY KEY (`merchant_id`),
KEY `store_id` (`store_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商户表';
DROP TABLE IF EXISTS `yoshop_merchant_pay`;
CREATE TABLE `yoshop_merchant_pay` (
`merchant_pay_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`store_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID',
`merchant_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商户id',
`order_id` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '订单id',
`is_delete` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
`total_amount` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '金额',
`is_add` tinyint(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT '是否为收入金额',
PRIMARY KEY (`merchant_pay_id`),
KEY `store_id` (`store_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商户收入表';
DROP TABLE IF EXISTS `yoshop_style`;
CREATE TABLE `yoshop_style` (
`style_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',

Loading…
Cancel
Save