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,249 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
namespace app\admin\controller\wdsxh\mall;
use app\common\controller\Backend;
use Exception;
use think\Db;
use think\exception\DbException;
use think\exception\PDOException;
use think\exception\ValidateException;
/**
* 轮播管理(商城)
*
* @icon fa fa-circle-o
*/
class Banner extends Backend
{
/**
* Banner模型对象
* @var \app\admin\model\wdsxh\mall\Banner
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\wdsxh\mall\Banner;
$this->view->assign("jumpTypeList", $this->model->getJumpTypeList());
$this->view->assign("statusList", $this->model->getStatusList());
}
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$type=$this->request->param('type');
$this->relationSearch = false;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
//如果发送的来源是Selectpage则转发到Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
$row->visible(['id','pages','title','image','jump_type','status','weigh','createtime']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
$this->assignconfig('type',$type);
return $this->view->fetch();
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 添加
*
* @return string
* @throws \think\Exception
*/
public function add()
{
if (false === $this->request->isPost()) {
return $this->view->fetch();
}
$params = $this->request->post('row/a');
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$params = $this->preExcludeFields($params);
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$result = false;
switch ($params['jump_type']){
case 2:
if(empty($params['jump_link'])){
$this->error('页面路径不能为空');
}
if(stripos($params['jump_link'],'?') !== false){
$params['content']=empty($params['param'])?$params['jump_link']:$params['jump_link'].'&'.$params['param'];
}else{
$params['content']=empty($params['param'])?$params['jump_link']:$params['jump_link'].'?'.$params['param'];
}
break;
case 1:
if(empty($params['content'])){
$this->error('图文内容不能为空');
}
break;
case 4:
if(empty($params['wxapp']['appid'])){
$this->error('小程序Appid不能为空');
}
$params['content']=json_encode(array('appid'=>$params['wxapp']['appid'],'path'=>$params['wxapp']['path']));
break;
case 3:
if(empty($params['jump_h5'])){
$this->error('外部链接不能为空');
}
$params['content']=trim($params['jump_h5']);
break;
}
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException()->validate($validate);
}
$result = $this->model->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result === false) {
$this->error(__('No rows were inserted'));
}
$this->success();
}
/**
* 编辑
*
* @param $ids
* @return string
* @throws DbException
* @throws \think\Exception
*/
public function edit($ids = null)
{
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
if (false === $this->request->isPost()) {
$row=$row->toArray();
switch ($row['jump_type']){
case 2:
$temp=explode('?',$row['content']);
$row['jump_link']=$temp['0'];
$row['param']=empty($temp['1'])?null:$temp['1'];
$row['content']=null;
break;
case 4:
$temp=json_decode($row['content'],true);
$row['wxapp']['appid']=$temp['appid'];
$row['wxapp']['path']=$temp['path'];
$row['content']=null;
break;
case 3:
$row['jump_h5']= $row['content'];
$row['content']=null;
break;
}
$this->view->assign('row', $row);
return $this->view->fetch();
}
$params = $this->request->post('row/a');
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$params = $this->preExcludeFields($params);
$result = false;
switch ($params['jump_type']){
case 2:
if(empty($params['jump_link'])){
$this->error('页面路径不能为空');
}
if(stripos($params['jump_link'],'?') !== false){
$params['content']=empty($params['param'])?$params['jump_link']:$params['jump_link'].'&'.$params['param'];
}else{
$params['content']=empty($params['param'])?$params['jump_link']:$params['jump_link'].'?'.$params['param'];
}
break;
case 1:
if(empty($params['content'])){
$this->error('图文内容不能为空');
}
break;
case 4:
if(empty($params['wxapp']['appid'])){
$this->error('小程序Appid不能为空');
}
$params['content']=json_encode(array('appid'=>$params['wxapp']['appid'],'path'=>$params['wxapp']['path']));
break;
case 3:
if(empty($params['jump_h5'])){
$this->error('外部链接不能为空');
}
$params['content']=trim($params['jump_h5']);
break;
}
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException()->validate($validate);
}
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
$this->success();
}
}

View File

@@ -0,0 +1,45 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
namespace app\admin\controller\wdsxh\mall;
use app\common\controller\Backend;
/**
* 快递公司
*
* @icon fa fa-circle-o
*/
class Express extends Backend
{
/**
* Express模型对象
* @var \app\admin\model\wdsxh\mall\Express
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\wdsxh\mall\Express;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
}

View File

@@ -0,0 +1,47 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
namespace app\admin\controller\wdsxh\mall;
use app\common\controller\Backend;
/**
* 商城运费规则
*
* @icon fa fa-circle-o
*/
class FreightRules extends Backend
{
/**
* FreightRules模型对象
* @var \app\admin\model\wdsxh\mall\FreightRules
*/
protected $model = null;
protected $modelValidate = true;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\wdsxh\mall\FreightRules;
$this->view->assign("statusList", $this->model->getStatusList());
$this->view->assign("openAreaList", $this->model->getOpenAreaList());
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
}

View File

@@ -0,0 +1,178 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
namespace app\admin\controller\wdsxh\mall;
use app\common\controller\Backend;
use think\Db;
use think\exception\DbException;
use think\exception\PDOException;
use think\exception\ValidateException;
use think\response\Json;
use think\Exception;
/**
* 商城商品管理
*
* @icon fa fa-circle-o
*/
class Goods extends Backend
{
/**
* Goods模型对象
* @var \app\admin\model\wdsxh\mall\Goods
*/
protected $model = null;
protected $relationSearch = true;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\wdsxh\mall\Goods;
$this->view->assign("isHotList", $this->model->getIsHotList());
$this->view->assign("statusList", $this->model->getStatusList());
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*
* @return string|Json
* @throws \think\Exception
* @throws DbException
*/
public function index()
{
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if (false === $this->request->isAjax()) {
return $this->view->fetch();
}
//如果发送的来源是 Selectpage则转发到 Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
$list = $this->model
->where($where)
->with(['category'])
->order($sort, $order)
->paginate($limit);
$result = ['total' => $list->total(), 'rows' => $list->items()];
return json($result);
}
/**
* 添加
*
* @return string
* @throws \think\Exception
*/
public function add()
{
if (false === $this->request->isPost()) {
return $this->view->fetch();
}
$params = $this->request->post('row/a');
if ($params['price'] == 0.00){
$this->error('商品价格必须大于0');
}
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$params = $this->preExcludeFields($params);
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException()->validate($validate);
}
$result = $this->model->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result === false) {
$this->error(__('No rows were inserted'));
}
$this->success();
}
/**
* 编辑
*
* @param $ids
* @return string
* @throws DbException
* @throws \think\Exception
*/
public function edit($ids = null)
{
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
if (false === $this->request->isPost()) {
$this->view->assign('row', $row);
return $this->view->fetch();
}
$params = $this->request->post('row/a');
if ($params['price'] == 0.00){
$this->error('商品价格必须大于0');
}
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$params = $this->preExcludeFields($params);
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException()->validate($validate);
}
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
$this->success();
}
}

View File

@@ -0,0 +1,144 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
namespace app\admin\controller\wdsxh\mall;
use app\common\controller\Backend;
use think\Db;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\exception\DbException;
use think\exception\PDOException;
use think\response\Json;
use Exception;
/**
* 单商城分类管理
*
* @icon fa fa-circle-o
*/
class GoodsCategory extends Backend
{
/**
* GoodsCategory模型对象
* @var \app\admin\model\wdsxh\mall\GoodsCategory
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\wdsxh\mall\GoodsCategory;
$this->view->assign("statusList", $this->model->getStatusList());
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*
* @return string|Json
* @throws \think\Exception
* @throws DbException
*/
public function index()
{
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if (false === $this->request->isAjax()) {
return $this->view->fetch();
}
//如果发送的来源是 Selectpage则转发到 Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
$list = $this->model
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as &$v) {
if (!empty($v['pid'])) {
$v['pid'] = $this->model->where('id',$v['pid'])->value('name');
} else {
$v['pid'] = '-';
}
}
$result = ['total' => $list->total(), 'rows' => $list->items()];
return json($result);
}
/**
* 删除
*
* @param $ids
* @return void
* @throws DbException
* @throws DataNotFoundException
* @throws ModelNotFoundException
*/
public function del($ids = null)
{
if (false === $this->request->isPost()) {
$this->error(__("Invalid parameters"));
}
$ids = $ids ?: $this->request->post("ids");
if (empty($ids)) {
$this->error(__('Parameter %s can not be empty', 'ids'));
}
$pk = $this->model->getPk();
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
$this->model->where($this->dataLimitField, 'in', $adminIds);
}
$list = $this->model->where($pk, 'in', $ids)->select();
$goodsModel = new \app\admin\model\wdsxh\mall\Goods();
foreach ($list as $item) {
$childCategoryCount = $this->model->where('pid',$item['id'])->count();
if ($childCategoryCount) {
$this->error('请先删除父级分类:'.$item['name'].',下的子分类');
}
unset($childCategoryCount);
$goodsCount = $goodsModel->where('category_id',$item['id'])->count();
if ($goodsCount) {
$this->error('分类:'.$item['name'].',有商品,无法删除');
}
unset($childCategoryCount);
}
$count = 0;
Db::startTrans();
try {
foreach ($list as $item) {
$count += $item->delete();
}
Db::commit();
} catch (PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($count) {
$this->success();
}
$this->error(__('No rows were deleted'));
}
}

View File

@@ -0,0 +1,309 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
namespace app\admin\controller\wdsxh\mall;
use addons\wdsxh\library\Wxapp;
use app\admin\model\wdsxh\mall\Express;
use app\admin\model\wdsxh\mall\Logistics;
use app\api\model\wdsxh\mall\OrderItem;
use Exception;
use app\common\controller\Backend;
use think\Db;
use think\exception\PDOException;
use think\exception\ValidateException;
/**
* 【订单表】
*
* @icon fa fa-circle-o
*/
class Order extends Backend
{
/**
* Order模型对象
* @var \app\admin\model\wdsxh\mall\Order
*/
protected $model = null;
protected $logisticsModel = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\wdsxh\mall\Order;
$this->logisticsModel = new Logistics;
$expressObj = (new Express())->select();
$this->view->assign('expressObj',$expressObj);
$this->view->assign("buyNowList", $this->model->getBuyNowList());
$this->view->assign("statusList", $this->model->getStateList());
$this->view->assign("refundStatusList", $this->model->getRefundStatusList());
$this->view->assign("paidList", $this->model->getPaidList());
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
public function delivery($ids = null){
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
if (false === $this->request->isPost()) {
$this->view->assign('row', $row);
return $this->view->fetch();
}
$params = $this->request->post('row/a');
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$params = $this->preExcludeFields($params);
$delivery_management = (new \app\admin\model\wdsxh\Config())->where('id',1)->value('delivery_management');
if ($delivery_management == 1){
$delivery_name = (new Express())->where('id',$params['delivery_id'])->value('brief_introduction');
$goods_name = (new \app\admin\model\wdsxh\mall\Goods())->where('id',$row['goods_id'])->value('name');
$delivery = Wxapp::upload_shipping_info(2,$row['trade_no'],1,1,$params['delivery_no'],$delivery_name,$goods_name,wdsxh_hide_phone_number($row['user_phone']),wdsxh_get_openid($row['wechat_id'],1));
if ($delivery['code'] != 0){
$this->error($delivery['errmsg']);
}
}
$result = false;
$send_time = time();
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException()->validate($validate);
}
$params = [
'order_id' => $row['id'],
'delivery_id' => $params['delivery_id'],
'delivery_no' => $params['delivery_no'],
'send_time' => $send_time
];
(new Logistics())->insert($params);
$order_data['state'] = 3;
$result = $row->allowField(true)->save($order_data);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
$openid = wdsxh_get_openid($row['wechat_id'],1);
$applet_order_shipping_notification = (new \app\admin\model\wdsxh\Config())->where('id',1)->value('applet_order_shipping_notification');
// 发送物流通知
if ($row['delivery_method'] == 1 && !empty($openid) && !empty($applet_order_shipping_notification)){
$goodsObj = (new \app\admin\model\wdsxh\mall\Goods())->where('id',$row['goods_id'])->find();
try{
$data=[
'thing1'=>[
'value'=>$goodsObj['name'],
],
'character_string2'=>[
'value'=>$row['order_no'],
],
'date3'=>[
'value'=>date('Y-m-d H:i:s',$send_time),
],
'character_string5'=>[
'value'=>$params['delivery_no'],
],
'amount7'=>[
'value'=>$row['total_price'].'元',
]
];
$result = Wxapp::subscribeMessage($applet_order_shipping_notification,trim($openid),'/pagesMall/order/details?order_id='.$ids,$data);
}catch (\think\Exception $e){
error_log('Applet_order_shipping_notification send fail: ' . $e->getMessage());
}
}
$this->success();
}
public function goods_details($ids = null){
$orderObj = $this->model->get($ids);
$usermodel = (new \app\admin\model\wdsxh\user\Wechat())->where('id',$orderObj['wechat_id'])->find();
$logisticsModel = (new Logistics())->where('order_id',$orderObj['id'])->find();
if ($orderObj['buy_now'] == '1') {
$goodsObj = (new \app\admin\model\wdsxh\mall\Goods())->withTrashed()->where('id',$orderObj['goods_id'])->select();
foreach ($goodsObj as &$v) {
$v->goods_num = $orderObj['number'];
}
} else {
$order_item_goods_id_array = (new OrderItem())->where('order_id',$ids)->column('goods_id');
$goodsObj = (new \app\admin\model\wdsxh\mall\Goods())->withTrashed()->where('id','in',$order_item_goods_id_array)->select();
foreach ($goodsObj as &$v) {
$v->goods_num = (new OrderItem())->where('order_id',$ids)->where('goods_id',$v['id'])->value('goods_num');
}
}
$refundMode = (new \app\admin\model\wdsxh\mall\Refund())->where('order_id',$orderObj['id'])->find();
$this->view->assign("refundMode", $refundMode);
$this->view->assign("goodsObj", $goodsObj);
$this->view->assign("usermodel", $usermodel);
$this->view->assign("orderObj", $orderObj);
$this->view->assign("logisticsModel", $logisticsModel);
return $this->view->fetch();
}
public function multi($ids = null)
{
return;
}
public function del($ids = null)
{
return;
}
public function edit($ids = null)
{
return;
}
public function add()
{
return;
}
public function recyclebin($ids = null)
{
return;
}
public function restore($ids = null)
{
return;
}
public function destroy($ids = null)
{
return;
}
/**
* Desc 确认自提
* Create on 2025/4/15 17:00
* Create by wangyafang
*/
public function confirm_self_pickup($ids=null){
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$row = $this->model->get($ids);
if (!$row) {
$this->error('订单不存在');
}
if ($row['state'] == 3) {
$this->error('订单已自提,无需操作');
}
if ($row['state'] != 2) {
$this->error('没有查到订单付款信息');
}
$delivery_management = (new \app\admin\model\wdsxh\Config())->where('id',1)->value('delivery_management');
if ($delivery_management == 1){
$delivery = Wxapp::upload_shipping_info(2,$row['trade_no'],1,4,'','','用户自提',wdsxh_hide_phone_number($row['user_phone']),wdsxh_get_openid($row['wechat_id'],1));
if ($delivery['code'] != 0){
$this->error($delivery['errmsg']);
}
}
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException()->validate($validate);
}
$order_data['state'] = 3;
$result = $row->allowField(true)->save($order_data);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
$this->success('操作成功');
}
/**
* Desc 确认收货
* Create on 2025/8/14 下午4:59
* Create by wangyafang
*/
public function confirm_receipt($ids=null){
if(!$this->request->isPost()) {
$this->error('请求类型错误');
}
$row = $this->model->get($ids);
if (!$row) {
$this->error('订单不存在');
}
if ($row['state'] == 4) {
$this->error('已确认收获');
}
if ($row['state'] != 3) {
$this->error('不是待收获状态,无法操作');
}
$delivery_management = (new \app\admin\model\wdsxh\Config())->where('id',1)->value('delivery_management');
if ($delivery_management == 1){
$get_order_result = Wxapp::get_order($row['trade_no']);
if ($get_order_result['code'] != 0){
$this->error($get_order_result['errmsg']);
}
if (!empty($get_order_result['order'])) {
if (!in_array($get_order_result['order']['order_state'],[3,4,6])) {
$this->error('订单状态不是:确认收货,交易完成,资金待结算;无法操作');
}
}
}
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException()->validate($validate);
}
$order_data['state'] = 4;
$result = $row->allowField(true)->save($order_data);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
$this->success('操作成功');
}
}

View File

@@ -0,0 +1,246 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
// +----------------------------------------------------------------------
namespace app\admin\controller\wdsxh\mall;
use app\admin\model\wdsxh\mall\OrderRefundLog;
use app\admin\model\wdsxh\user\Wechat;
use app\common\controller\Backend;
use think\Db;
use think\exception\DbException;
use think\exception\PDOException;
use think\exception\ValidateException;
use think\response\Json;
use Exception;
/**
* 订单退款管理
*
* @icon fa fa-circle-o
*/
class Refund extends Backend
{
/**
* Refund模型对象
* @var \app\admin\model\wdsxh\mall\Refund
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\wdsxh\mall\Refund;
}
/**
* 查看
*
* @return string|Json
* @throws \think\Exception
* @throws DbException
*/
public function index()
{
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if (false === $this->request->isAjax()) {
return $this->view->fetch();
}
//如果发送的来源是 Selectpage则转发到 Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
$list = $this->model
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $item){
$item->order_no = (new \app\admin\model\wdsxh\mall\Order())->where('id',$item['order_id'])->value('order_no');
$item->real_name = (new \app\admin\model\wdsxh\mall\Order())->where('id',$item['order_id'])->value('real_name');
$item->refund_status = (new \app\admin\model\wdsxh\mall\Order())->where('id',$item['order_id'])->value('refund_status');
}
$result = ['total' => $list->total(), 'rows' => $list->items()];
return json($result);
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 通过
*/
public function three_adopt($ids = null){
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
if (false === $this->request->isPost()) {
$this->view->assign('row', $row);
return $this->view->fetch();
}
$order = (new \app\admin\model\wdsxh\mall\Order())->where('id',$row['order_id'])->find();
if ($order['state'] == 2){
$refundSn=wdsxh_create_order();
$res=\addons\wdsxh\library\Wxapp::payRefund($order->order_no,$refundSn,$order->pay_price,array('refund_desc'=>'退款'));
if($res && $res['return_code'] == 'SUCCESS' && $res['result_code'] == 'SUCCESS'){
$order->complete_time=time();
$order->state='-2';
$order->refund_status='5';
$order->save();
$row->refund_time=time();
$row->save();
$this->success('退款操作成功');
}else{
$this->error('退款失败,错误信息:'.$res['err_code_des']);
}
}else{
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException()->validate($validate);
}
$params['refund_status'] = 3;
$result = (new \app\admin\model\wdsxh\mall\Order())->allowField(true)->where('id',$row['order_id'])->update($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
$this->success();
}
}
/**
* 驳回
*/
public function three_reject($ids = null){
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
if (false === $this->request->isPost()) {
$this->view->assign('row', $row);
return $this->view->fetch();
}
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException()->validate($validate);
}
$params['refund_status'] = 1;
$params['state'] = $row['state'];
(new \app\admin\model\wdsxh\mall\Order())->allowField(true)->where('id',$row['order_id'])->update($params);
$result = $row->delete();
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
$this->success();
}
//退款
public function refund($ids = null){
$data = $this->model->get($ids);
if(!$data){
$this->error('退款信息不存在');
}
$user=Wechat::where('id',$data->wechat_id)->field('applet_openid')->find();
if(!$user){
$this->error('用户信息不存在');
}
$mep = array(
'wechat_id'=>$data->wechat_id,
'refund_status' =>'4',
'id'=>$data->order_id,
);
$order = \app\admin\model\wdsxh\mall\Order::where($mep)->find();
$refundModel = \app\admin\model\wdsxh\mall\Refund::where('id',$data->id)->find();
if(!$order){
$this->error('支付订单信息不存在');
}
$refundLogModel = [
'order_sn' => $order['order_no'],
'refund_sn'=>$data['refund_express_no'],
'order_id' =>$order['id'],
'status' => -1,
'pay_fee'=>$order['pay_price'],
'refund_fee' =>$order['refund_price'],
'createtime'=> time()
];
$refundSn=wdsxh_create_order();
$res=\addons\wdsxh\library\Wxapp::payRefund($order->order_no,$refundSn,$order->pay_price,array('refund_desc'=>'退款'));
if($res && $res['return_code'] == 'SUCCESS' && $res['result_code'] == 'SUCCESS'){
$order->complete_time=time();
$order->state='-2';
$order->refund_status='5';
$order->save();
$refundModel->refund_time=time();
$refundModel->save();
$this->success('退款操作成功');
}else{
(new OrderRefundLog())->save($refundLogModel);
$this->error('退款失败,错误信息:'.$res['err_code_des']);
}
}
public function multi($ids = null)
{
return;
}
public function edit($ids = null)
{
return;
}
public function add()
{
return;
}
}

View File

@@ -0,0 +1,110 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
// +----------------------------------------------------------------------
/**
* Class SelfPickup
* Desc 自提点控制器
* Create on 2025/4/15 14:22
* Create by wangyafang
*/
namespace app\admin\controller\wdsxh\mall;
use app\common\controller\Backend;
use think\Db;
use think\exception\PDOException;
use think\exception\ValidateException;
class SelfPickup extends Backend
{
/**
* Config模型对象
* @var \app\admin\model\wdsxh\Config
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\wdsxh\mall\SelfPickup();
$this->view->assign("IsStatusList", $this->model->getIsStatusList());
}
public function config(){
$row = $this->model->get(1);
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
if (false === $this->request->isPost()) {
$this->view->assign('row', $row);
return $this->view->fetch();
}
$params = $this->request->post('row/a');
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$params = $this->preExcludeFields($params);
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->modelConfig));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException()->validate($validate);
}
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
$this->success();
}
public function index()
{
return;
}
public function edit($ids = null)
{
return;
}
public function add()
{
return;
}
public function del($ids = null)
{
return;
}
public function multi($ids = NULL)
{
return;
}
}