init commit

This commit is contained in:
2026-03-17 09:56:00 +08:00
commit e2c8ae752d
6827 changed files with 1211784 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
// +----------------------------------------------------------------------
namespace app\api\model\wdsxh\points;
use app\api\model\wdsxh\Base;
use traits\model\SoftDelete;
class Goods extends Base
{
use SoftDelete;
// 表名
protected $name = 'wdsxh_points_goods';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = false;
protected $updateTime = false;
protected $deleteTime = 'deletetime';
protected function getSliderImagesAttr($value)
{
$array = explode(',',$value);
foreach ($array as $k=>$v) {
$array[$k] = wdsxh_full_url($v);
}
return implode(',',$array);
}
}

View File

@@ -0,0 +1,105 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
// +----------------------------------------------------------------------
namespace app\api\model\wdsxh\points;
use app\admin\model\wdsxh\points\Express;
use app\admin\model\wdsxh\points\Logistics;
use app\common\model\wdsxh\points\UserWechatPointsLog;
use think\Db;
use think\Exception;
use think\exception\PDOException;
use think\exception\ValidateException;
use think\Model;
class Order extends Model
{
// 表名
protected $name = 'wdsxh_points_order';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
protected $append = [
'goods_info',
];
protected $type = [
'redemption_time' => 'timestamp:Y-m-d H:i:s',
];
protected static function init()
{
self::beforeInsert(function ($data) {
$data['order_no'] = wdsxh_create_order();
$address = (new \app\api\model\wdsxh\goods\Address())->where('id',$data['address_id'])->find();
$data['real_name'] = $address['name'];//用户名称
$data['user_phone'] = $address['tel'];//手机号
$data['user_address'] = $address['address'];//详细地址
$data['redemption_time'] = time();//兑换时间
});
self::afterInsert(function ($data) {
$goodsObj = (new Goods())->where('id',$data['goods_id'])->find();
UserWechatPointsLog::pointsMall(2,$data,$goodsObj,'积分兑换');
});
}
public function submitSettlement($data)
{
$orderModel = new self();
Db::startTrans();
try {
$orderModel->allowField(true)->save($data);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
throw new \think\Exception($e->getMessage());
}
return ['order_id'=>$orderModel->id];
}
public function getGoodsInfoAttr($value, $data)
{
$goods = (new Goods())
->withTrashed()
->where('id',$data['goods_id'])
->field('name,image')
->find();
$goods->points = $data['points'];
return $goods;
}
/**
* Desc 获取发货信息
* Create on 2025/11/13 下午3:46
* Create by wangyafang
*/
public function logistics($order_id){
$logistics = (new Logistics())
->where('order_id',$order_id)
->field('delivery_id,delivery_no,send_time')
->find();
$logistics['delivery_name'] = (new Express())->where('id',$logistics['delivery_id'])->value('name');
$logistics->hidden(['delivery_id']);
return $logistics;
}
}