zengyyh 7 months ago
parent 9d7737a32a
commit de262831d5
  1. 2
      app/admin/controller/Wxserve.php
  2. 31
      app/api/controller/Goods.php
  3. 74
      app/api/controller/Order.php
  4. 4
      app/api/controller/StoreKeeper.php
  5. 5
      app/api/service/Setting.php
  6. 4
      app/common/library/wxserver/Server.php
  7. 7
      app/common/model/MerchantRemarks.php
  8. 38
      app/common/model/store/Setting.php
  9. 12
      app/store/controller/Order.php
  10. 17
      app/store/controller/Setting.php
  11. 25
      app/store/controller/order/Event.php
  12. 47
      app/store/model/Setting.php

@ -332,7 +332,7 @@ class Wxserve extends Controller
if ($appid) {
$obj = new Server();
$msg = $obj->applySetOrderPathInfo([$appid]);
if ($msg == 'ok') {
if ($msg['errmsg'] == 'ok') {
return $this->renderSuccess('success');
}
}

@ -17,6 +17,7 @@ use think\response\Json;
use app\common\enum\goods\GoodsDeliveryTime;
use think\facade\Cache;
use EasyWeChat\Factory;
use app\api\service\Setting as SettingService;
/**
* 商品控制器
@ -68,6 +69,13 @@ class Goods extends Controller
if ($goodsInfo['channel'] == 'sn') {
$goodsInfo['link'] = "";
}
//获取商户id
$merchantId = $goodsInfo['merchant_id'];
$storeId = $goodsInfo['store_id'];
//获取客服设置
$service = new SettingService;
$setting = $service->getGoodsCustomer($merchantId,$storeId);
$goodsInfo['setting'] = $setting;
return $this->renderSuccess(['detail' => $goodsInfo]);
}
@ -479,4 +487,27 @@ class Goods extends Controller
return $this->renderSuccess(['url' => $url]);
}
public function detailTest(int $goodsId, bool $verifyStatus = true): Json
{
// wmc商品详情
$model = new GoodsModel;
$goodsInfo = $model->getDetails($goodsId, $verifyStatus);
if (!empty($goodsInfo['content'])) {
$goodsInfo['content'] = str_ireplace('onload="if(this.width>750){this.height=this.height*(750.0/this.width); this.width = 750;}', '', $goodsInfo['content']);
}
//苏宁的商品不展示链接
if ($goodsInfo['channel'] == 'sn') {
$goodsInfo['link'] = "";
}
//获取商户id
$merchantId = $goodsInfo['merchant_id'];
$storeId = $goodsInfo['store_id'];
//获取客服设置
$service = new SettingService;
$setting = $service->getGoodsCustomer($merchantId,$storeId);
$goodsInfo['setting'] = $setting;
return $this->renderSuccess(['detail' => $goodsInfo]);
}
}

@ -23,6 +23,8 @@ use app\common\model\UploadFile;
use app\common\service\qrcode\Extract as ExtractQRcode;
use cores\exception\BaseException;
use think\response\Json;
use app\common\model\MerchantRemarks as MerchantRemarksModel;
use app\api\service\Setting as SettingService;
/**
* 我的订单控制器
@ -78,12 +80,35 @@ class Order extends Controller
{
// 订单详情
$model = OrderModel::getUserOrderDetail($orderId);
$MerchantRemarks = new MerchantRemarksModel;
$merchant = $MerchantRemarks->orderRemarkList($orderId);
foreach ($merchant as $key => $value) {
if (isset($value['image_id'])) {
// 解码 JSON 字符串并确保返回的是数组
$decodedImageId = json_decode($value['image_id'], true);
if (is_array($decodedImageId) && isset($decodedImageId['image_id'])) {
$value['image_id'] = $decodedImageId['image_id'];
$value['image_url'] = UploadFile::getFileList($value['image_id']);
}
}
}
$model['merchant'] = $merchant;
//获取商户id
$merchantId = $model['merchant_id'];
$storeId = $model['store_id'];
//获取客服设置
$service = new SettingService;
$customer = $service->getGoodsCustomer($merchantId,$storeId);
return $this->renderSuccess([
'order' => $model, // 订单详情
'setting' => [
// 积分名称
'points_name' => SettingModel::getPointsName(),
],
'customer' => $customer,
]);
}
@ -321,5 +346,54 @@ class Order extends Controller
return $this->renderSuccess('ok');
}
/**
* 添加商家备注
* @param int $orderId
*/
public function addRemark(int $orderId): Json
{
$data = $this->postForm();
$data['store_id'] = $this->storeId;
$data['user_id'] = $this->user['user_id'];
$data['order_id'] = $orderId;
$model = new MerchantRemarksModel;
if(isset($data['image_id']) && !empty($data['image_id'])){
$image_ids = $data['image_id'];
$image = array(
"image_id" => $image_ids
);
$data['image_id'] = json_encode($image);
}
if ($model->add($data)) {
return $this->renderSuccess('操作成功');
}
return $this->renderError($model->getError() ?: '操作失败');
}
/**
* 查看商家备注
* @param int $orderId
* @return Json
*/
public function getRemark(int $orderId): Json
{
$model = new MerchantRemarksModel;
// 备注详情
$list = $model->getRemarkImage($orderId);
foreach ($list as $key => $value) {
if (isset($value['image_id'])) {
// 解码 JSON 字符串并确保返回的是数组
$decodedImageId = json_decode($value['image_id'], true);
if (is_array($decodedImageId) && isset($decodedImageId['image_id'])) {
$value['image_id'] = $decodedImageId['image_id'];
$value['image_url'] = UploadFile::getFileList($value['image_id']);
}
}
}
return $this->renderSuccess(compact('list'));
}
}

@ -29,6 +29,7 @@ use cores\exception\BaseException;
use think\App;
use think\db\exception\DbException;
use think\response\Json;
use app\common\model\MerchantRemarks as MerchantRemarksModel;
/**
* 店主管理
@ -187,6 +188,7 @@ class StoreKeeper extends Controller
$params = $this->request->param();
$params['searchType'] = 'all';
$goodsModel = new GoodsModel;
$MerchantRemarks = new MerchantRemarksModel();
// 订单列表
if (!empty($params['dataType']) && $params['dataType'] == 'refund') {
$model = new OrderRefundModel;
@ -226,7 +228,7 @@ class StoreKeeper extends Controller
//复制信息
$copy_text = "订单号:{$value['order_no']}\n";
$goods_images = $goodsModel->storeUsePlatformGoodsImage(array_column($value['goods'], 'origin_goods_id'));
foreach ($value['goods'] as &$good) {
//使用总后台的商品图片
if ($good['origin_goods_id'] && $value['store_id'] > 0) {

@ -175,4 +175,9 @@ class Setting extends BaseService
{
return SettingModel::getItem(SettingEnum::APP_THEME)['data'];
}
public function getGoodsCustomer(int $merchantId ,int $storeId): array
{
$values = SettingModel::getItem(SettingEnum::CUSTOMER , $storeId ,$merchantId);
return helper::pick($values, ['enabled', 'provider', 'config']);
}
}

@ -141,6 +141,7 @@ class Server
*/
public function applySetOrderPathInfo(array $appid, string $path = 'pages/order/index')
{
$msg = '操作失败(未知错误)';
$token = $this->getComponentAccessToken();
$data['batch_req'] = [
'path' => $path,
@ -148,7 +149,8 @@ class Server
];
$url = "https://api.weixin.qq.com/wxa/security/applysetorderpathinfo?component_access_token=$token";
$result = $this->curlPost($url, json_encode($data));
return json_decode($result, true);
$result = json_decode($result, true);
return !empty($result['errmsg']) ? $result['errmsg'] : $msg;
}
/**

@ -12,6 +12,7 @@ declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
use app\common\model\UploadFile;
class MerchantRemarks extends BaseModel
{
@ -32,7 +33,7 @@ class MerchantRemarks extends BaseModel
return self::save($data);
}
public function orderDetail($orderId){
public function orderRemarkList($orderId){
return $this->where('order_id',$orderId)->order('create_time asc')->select();
}
@ -49,4 +50,8 @@ class MerchantRemarks extends BaseModel
return $this->where('id', $MerchantRemarkId)->delete();
}
public function getRemarkImage($data)
{
return UploadFile::withoutGlobalScope()->whereIn('file_id',$data)->select();
}
}

@ -62,9 +62,9 @@ class Setting extends BaseModel
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function getItem(string $key, int $storeId = null)
{
$data = self::getAll($storeId);
public static function getItem(string $key, int $storeId = null , int $merchantId = 0)
{
$data = self::getAll($storeId,$merchantId);
return isset($data[$key]) ? $data[$key]['values'] : [];
}
@ -77,13 +77,31 @@ class Setting extends BaseModel
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function detail(string $key, int $storeId = null)
public static function detail(string $key, int $storeId = null, int $merchantId = 0)
{
$query = (new static)->getNewQuery();
$storeId > 0 && $query->where('store_id', '=', $storeId);
$query->where('merchant_id', '=', $merchantId);
return $query->where('key', '=', $key)->find();
}
/**
* 获取设置项信息
* @param string $key
* @param int|null $storeId
* @return static|array|null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function merchantSetting(string $key ,int $merchantId, int $storeId = null)
{
$query = (new static)->getNewQuery();
$query->where('merchant_id', '=', $merchantId);
$storeId > 0 && $query->where('store_id', '=', $storeId);
return $query->where('key', '=', $key)->where('merchant_id', $merchantId)->find();
}
/**
* 全局缓存: 系统设置
* @param int|null $storeId
@ -92,16 +110,16 @@ class Setting extends BaseModel
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function getAll(int $storeId = null): array
public static function getAll(int $storeId = null , int $merchantId =0): array
{
$model = new static;
is_null($storeId) && $storeId = $model::$storeId;
if (!$data = Cache::get("setting_{$storeId}")) {
if (!$data = Cache::get("setting_{$storeId}{$merchantId}")) {
// 获取商城设置列表
$setting = $model->getList($storeId);
$setting = $model->getList($storeId,$merchantId);
$data = $setting->isEmpty() ? [] : helper::arrayColumn2Key($setting->toArray(), 'key');
// 写入缓存中
Cache::tag('cache')->set("setting_{$storeId}", $data);
Cache::tag('cache')->set("setting_{$storeId}{$merchantId}", $data);
}
// 重组setting缓存数据 (多维)
return static::reorganize($model->defaultData(), $data, $type = 'cache');
@ -115,9 +133,9 @@ class Setting extends BaseModel
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
private function getList(int $storeId): \think\Collection
private function getList(int $storeId,int $merchantId = 0): \think\Collection
{
return $this->where('store_id', '=', $storeId)->select();
return $this->where('store_id', '=', $storeId)->where('merchant_id', '=' ,$merchantId )->select();
}
/**

@ -17,6 +17,7 @@ use app\store\model\Goods as GoodsModel;
use think\response\Json;
use app\common\model\UploadFile as UploadFileModel;
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\F;
use app\common\model\MerchantRemarks as MerchantRemarksModel;
/**
* 订单管理
@ -113,9 +114,20 @@ class Order extends Controller
{
// 订单详情
$model = new OrderModel;
$MerchantRemarks = new MerchantRemarksModel;
if (!$detail = $model->getDetail($orderId)) {
return $this->renderError('未找到该订单记录');
}
$merchant = $MerchantRemarks->orderRemarkList($orderId);
if($merchant){
foreach($merchant as $key => $value){
if(isset($value['image_id']) && !empty($value['image_id']))
$image_id = json_decode($value['image_id'],true);
$item['image_id'] = $image_id['image_id'];
$value['image_url'] = $MerchantRemarks->getRemarkImage($item['image_id']);
}
}
$detail['merchant'] = $merchant;
return $this->renderSuccess(compact('detail'));
}

@ -31,8 +31,8 @@ class Setting extends Controller
* @throws \think\db\exception\ModelNotFoundException
*/
public function detail(string $key): Json
{
$values = SettingModel::getItem($key);
{
$values = SettingModel::getItem($key, $this->storeId, $this->merchantId);
return $this->renderSuccess(compact('values'));
}
@ -48,9 +48,16 @@ class Setting extends Controller
{
// 保存商城设置
$model = new SettingModel;
if ($model->edit($key, $this->postForm())) {
return $this->renderSuccess('操作成功');
}
$param = $this->postForm();
$param['merchant_id'] = $this->merchantId;
if ($model->edit($key, $param)) {
return $this->renderSuccess('操作成功');
}
// if($merchant_id != 0){
// if ($model->editMerchant($key, $this->postForm(),$merchant_id)) {
// return $this->renderSuccess('操作成功');
// }
// }
return $this->renderError($model->getError() ?: '操作失败');
}
}

@ -153,14 +153,20 @@ class Event extends Controller
{
$model = new MerchantRemarksModel;
// 备注详情
$list = $model->orderDetail($orderId);
if($list){
foreach($list as $key => $value){
if(isset($value['image_id']) && !empty($value['image_id']))
$value['image_id'] = json_decode($value['image_id'],true);
$value['image_id'] = $value['image_id']['image_id'];
$value['image_url'] = UploadFile::getFileList($value['image_id']);
$list = $model->orderRemarkList($orderId);
if (!$list) {
return $this->renderError('暂无备注');
}
foreach ($list as $key => $value) {
if (isset($value['image_id'])) {
// 解码 JSON 字符串并确保返回的是数组
$decodedImageId = json_decode($value['image_id'], true);
if (is_array($decodedImageId) && isset($decodedImageId['image_id'])) {
$value['image_id'] = $decodedImageId['image_id'];
$value['image_url'] = UploadFile::getFileList($value['image_id']);
}
}
}
return $this->renderSuccess(compact('list'));
@ -185,7 +191,8 @@ class Event extends Controller
}
public function deleteRemark(int $MerchantRemarkId): Json
{
{
$model = new MerchantRemarksModel;
// 确认核销
if ($model->setDelete($MerchantRemarkId)) {
return $this->renderSuccess('删除成功');

@ -34,14 +34,15 @@ class Setting extends SettingModel
*/
public function edit(string $key, array $values): bool
{
// 设置项详情记录
$model = self::detail($key) ?: $this;
$model = self::detail($key , self::$storeId ,$values['merchant_id']) ?: $this;
// 数据验证
if (!$this->validValues($key, $values)) {
return false;
}
// 删除系统设置缓存
Cache::delete('setting_' . self::$storeId);
Cache::delete('setting_' . self::$storeId.$values['merchant_id']);
// 更新记录
return $model->save([
'key' => $key,
@ -49,6 +50,7 @@ class Setting extends SettingModel
'values' => $values,
'update_time' => time(),
'store_id' => self::$storeId,
'merchant_id' => $values['merchant_id']
]) !== false;
}
@ -106,4 +108,45 @@ class Setting extends SettingModel
}
return true;
}
/**
* 更新系统设置
* @param string $key
* @param array $values
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function editMerchant(string $key, array $values ,int $merchantId): bool
{
// 数据验证
if (!$this->validValues($key, $values)) {
return false;
}
// 删除系统设置缓存
Cache::delete('setting_' . self::$storeId);
// 设置项详情记录
$model = $this->merchantSetting($key,$merchantId) ?: $this;
if(isset($model)){
return self::save([
'key' => $key,
'describe' => SettingEnum::data()[$key]['describe'],
'values' => $values,
'update_time' => time(),
'create_time' => time(),
'store_id' => self::$storeId,
'merchant_id' => $merchantId,
]) !== false;
}
// 更新记录
return $model->save([
'key' => $key,
'describe' => SettingEnum::data()[$key]['describe'],
'values' => $values,
'update_time' => time(),
'store_id' => self::$storeId,
'merchant_id' => $merchantId,
]) !== false;
}
}

Loading…
Cancel
Save