提交代码
This commit is contained in:
parent
62208980e3
commit
2ae2ea87e1
|
|
@ -6,6 +6,7 @@ use app\common\server\RedisHelper;
|
|||
use \think\facade\Request;
|
||||
use \think\facade\View;
|
||||
use think\facade\Db;
|
||||
use think\Response;
|
||||
|
||||
|
||||
class Config extends Base
|
||||
|
|
@ -241,6 +242,49 @@ class Config extends Base
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回动态生成的JavaScript
|
||||
* @return Response
|
||||
*/
|
||||
public function dynamicJs()
|
||||
{
|
||||
// 解决跨域问题
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: GET');
|
||||
|
||||
// 获取需要的配置数据
|
||||
$config = getConfig('systemconfig');
|
||||
|
||||
// 构建JavaScript内容
|
||||
$jsContent = "// 动态生成的JS文件\n";
|
||||
$jsContent .= "const siteConfig = " . json_encode($config, JSON_UNESCAPED_UNICODE) . ";\n";
|
||||
$jsContent .= "console.log('配置已加载');\n";
|
||||
|
||||
// 创建响应并设置Content-Type
|
||||
return Response::create($jsContent)
|
||||
->contentType('application/javascript')
|
||||
->header(['Content-Type' => 'application/javascript']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接输出JS内容的备用方法
|
||||
*/
|
||||
public function getJs()
|
||||
{
|
||||
// 解决跨域问题
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: GET');
|
||||
header('Content-Type: application/javascript');
|
||||
|
||||
// 获取需要的配置数据
|
||||
$config = getConfig('systemconfig');
|
||||
|
||||
// 直接输出JS内容
|
||||
echo "// 动态生成的JS文件\n";
|
||||
echo "const siteConfig = " . json_encode($config, JSON_UNESCAPED_UNICODE) . ";\n";
|
||||
echo "console.log('配置已加载');\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -289,8 +289,9 @@ class Finance extends Base
|
|||
$mobile = trim(input('get.mobile'));
|
||||
$pay_time = trim(input('get.pay_time'));
|
||||
$whe = [];
|
||||
// $whe[] = ['status', '=', 2];
|
||||
|
||||
if ($user_id) {
|
||||
$user_id = $this->convertUidToUserId($user_id);
|
||||
$whe[] = ['user_id', '=', $user_id];
|
||||
}
|
||||
if ($mobile) {
|
||||
|
|
@ -306,25 +307,28 @@ class Finance extends Base
|
|||
}
|
||||
$whe[] = ['addtime', 'BETWEEN', array($start_time, $end_time)];
|
||||
}
|
||||
$data = WxpayLog::getList($whe, '*', 'id desc', $this->page);
|
||||
|
||||
// 从profit_pay表获取充值记录,而不是从WxpayLog表
|
||||
$data = \app\common\model\ProfitPay::getList($whe, '*', 'id desc', $this->page);
|
||||
$total_money = 0;
|
||||
|
||||
foreach ($data['list'] as &$value) {
|
||||
$content = json_decode($value['content'], true);
|
||||
|
||||
$value['money'] = $content['total_fee'] / 100;
|
||||
|
||||
$total_money += $value['money'];
|
||||
$user_info = User::field('nickname,headimg,mobile')->where(['id' => $value['user_id']])->find();
|
||||
$total_money += $value['change_money'];
|
||||
|
||||
$user_info = User::field('nickname,headimg,mobile,uid')->where(['id' => $value['user_id']])->find();
|
||||
if ($user_info != null) {
|
||||
$value['nickname'] = $user_info['nickname'];
|
||||
$value['headimg'] = $user_info['headimg'];
|
||||
$value['mobile'] = $user_info['mobile'];
|
||||
$value['uid'] = $user_info['uid'] ?: $value['user_id'];
|
||||
} else {
|
||||
$value['nickname'] ='';
|
||||
$value['nickname'] = '';
|
||||
$value['headimg'] = '';
|
||||
$value['mobile'] = '';
|
||||
$value['uid'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
View::assign('list', $data['list']);
|
||||
View::assign('count', $data['count']);
|
||||
View::assign('page', $data['page']);
|
||||
|
|
@ -397,4 +401,22 @@ class Finance extends Base
|
|||
View::assign('total_money', $total_money);
|
||||
return View::fetch("Finance/infinite_list");
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据迁移:从WxpayLog迁移到ProfitPay
|
||||
*/
|
||||
public function migrate_payment_logs()
|
||||
{
|
||||
$page = input('page/d', 1);
|
||||
$limit = input('limit/d', 100);
|
||||
$offset = ($page - 1) * $limit;
|
||||
|
||||
$result = \app\common\model\WxpayLog::migrateToNewTable($limit, $offset);
|
||||
|
||||
if ($result['status'] == 1) {
|
||||
return $this->renderSuccess($result['message'], $result);
|
||||
} else {
|
||||
return $this->renderError($result['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -510,10 +510,13 @@ class Order extends Base
|
|||
if ($info['freight'] > 0) {
|
||||
$wxServer = new \app\common\server\WechatRefund($this->app);
|
||||
$refund_res = $wxServer->OrderRefund($info);
|
||||
Db::name('wxpay_log')->insert([
|
||||
'order_no' => 'QX_' . $info['send_num'],
|
||||
'content' => json_encode($refund_res['msg']),
|
||||
'type' => 2,
|
||||
Db::name('profit_pay')->insert([
|
||||
'user_id' => $info['user_id'],
|
||||
'order_num' => 'QX_' . $info['send_num'],
|
||||
'change_money' => -$info['freight'],
|
||||
'content' => '背包发货退款',
|
||||
'pay_type' => 1,
|
||||
'addtime' => time(),
|
||||
]);
|
||||
// if ($refund_res['status'] == 0) {
|
||||
// return $this->renderError($refund_res['msg']);
|
||||
|
|
@ -917,4 +920,78 @@ class Order extends Base
|
|||
return View::fetch('Order/unpaid_order');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除发货订单中的单个商品
|
||||
*/
|
||||
public function delete_order_item()
|
||||
{
|
||||
$id = request()->param('id/d', 0);
|
||||
$send_num = request()->param('send_num', '');
|
||||
|
||||
// 查找商品记录
|
||||
$orderItem = OrderList::where('id', '=', $id)
|
||||
->where('send_num', '=', $send_num)
|
||||
->find();
|
||||
|
||||
if (!$orderItem) {
|
||||
return $this->renderError('商品不存在或参数错误');
|
||||
}
|
||||
|
||||
// 获取订单信息
|
||||
$orderInfo = OrderListSend::where('send_num', '=', $send_num)->find();
|
||||
if (!$orderInfo) {
|
||||
return $this->renderError('订单不存在');
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 更新商品状态
|
||||
$orderItem->send_num = NULL;
|
||||
$orderItem->status = 0;
|
||||
$orderItem->choice_time = 0;
|
||||
$orderItem->fh_status = 0;
|
||||
$orderItem->save();
|
||||
|
||||
// 检查订单中是否还有其他商品
|
||||
$remainingItems = OrderList::where('send_num', '=', $send_num)->count();
|
||||
|
||||
// 如果没有其他商品,取消整个订单
|
||||
if ($remainingItems <= 1) { // 1表示当前要删除的商品
|
||||
// 如果订单有运费且已支付,需要处理退款
|
||||
if ($orderInfo['freight'] > 0 && $orderInfo['status'] > 0) {
|
||||
$wxServer = new \app\common\server\WechatRefund($this->app);
|
||||
$refund_res = $wxServer->OrderRefund($orderInfo);
|
||||
|
||||
// 记录退款
|
||||
Db::name('profit_pay')->insert([
|
||||
'user_id' => $orderInfo['user_id'],
|
||||
'order_num' => 'QX_' . $orderInfo['send_num'],
|
||||
'change_money' => -$orderInfo['freight'],
|
||||
'content' => '背包发货退款(商品删除)',
|
||||
'pay_type' => 1,
|
||||
'addtime' => time(),
|
||||
]);
|
||||
}
|
||||
|
||||
// 更新订单状态为取消
|
||||
OrderListSend::where('id', '=', $orderInfo['id'])->update([
|
||||
'status' => 4,
|
||||
'cancel_time' => time(),
|
||||
'admin_id' => $this->admin_id,
|
||||
]);
|
||||
} else {
|
||||
// 更新订单中的商品数量
|
||||
OrderListSend::where('id', '=', $orderInfo['id'])->update([
|
||||
'count' => $remainingItems - 1 // 减去当前要删除的商品
|
||||
]);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return $this->renderSuccess('商品已成功从订单中删除');
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $this->renderError('删除失败:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -222,6 +222,7 @@ Route::rule('recovery_order_daochu', 'Order/recovery_order_daochu');
|
|||
Route::rule('send_order_daochu', 'Order/send_order_daochu');
|
||||
Route::rule('send_order_dandufahuo', 'Order/send_order_dandufahuo');
|
||||
Route::rule('unpaid_order', 'Order/unpaid_order');
|
||||
Route::rule('delete_order_item', 'Order/delete_order_item');
|
||||
|
||||
|
||||
#============================
|
||||
|
|
@ -434,4 +435,11 @@ Route::rule('statistics_exportProfit', 'Statistics/exportProfit', 'GET');
|
|||
|
||||
// 盒子下架日志相关路由
|
||||
Route::post('goods_offshelf_read', 'GoodsOffshelfController/read');
|
||||
Route::get('goods_offshelf_unread_count', 'GoodsOffshelfController/getUnreadCount');
|
||||
Route::get('goods_offshelf_unread_count', 'GoodsOffshelfController/getUnreadCount');
|
||||
|
||||
|
||||
#============================
|
||||
# dynamicJs
|
||||
#============================
|
||||
Route::get('dynamicJs.js', 'Config/dynamicJs')->ext('js');
|
||||
|
||||
|
|
@ -38,7 +38,9 @@
|
|||
<tr>
|
||||
<th>用户信息</th>
|
||||
<th>订单号</th>
|
||||
<th>充值数量</th>
|
||||
<th>充值金额</th>
|
||||
<th>支付类型</th>
|
||||
<th>支付描述</th>
|
||||
<th>支付时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
@ -49,14 +51,16 @@
|
|||
<div style="display: flex;">
|
||||
<div><img src="{:imageUrl($vo['headimg'])}" alt="" width="50px" height="50px"></div>
|
||||
<div style="margin-left: 10px">
|
||||
<p style="color: #e91e63;font-size: 9px">UID:{$vo['user_id']}</p>
|
||||
<p style="color: #e91e63;font-size: 9px">UID:{$vo['uid'] ? $vo['uid'] : $vo['user_id']}</p>
|
||||
<p style="color: #666666ba;font-size: 9px">{$vo['mobile']}</p>
|
||||
<p style="color: #666666ba;font-size: 9px">{$vo['nickname']}</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>{$vo['order_no']}</td>
|
||||
<td>{$vo['money']}</td>
|
||||
<td>{$vo['order_num']}</td>
|
||||
<td>{$vo['change_money']}</td>
|
||||
<td>{$vo['pay_type'] == 1 ? '微信支付' : '支付宝支付'}</td>
|
||||
<td>{$vo['content']}</td>
|
||||
<td>{$vo['addtime']|date="Y-m-d H:i:s"}</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
|
|
@ -86,10 +90,6 @@
|
|||
,format: 'yyyy-MM-dd'
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -119,6 +119,8 @@
|
|||
<td style="width: 200px">
|
||||
{if $vo.status lt 4}
|
||||
<a onClick="detail({$vo.id})" class="layui-btn layui-btn-normal layui-btn-xs">查看详情</a>
|
||||
{/if}
|
||||
{if $vo['status'] eq 1 || $vo['status'] eq 2}
|
||||
<a onClick="cancel_order({$vo.id})"
|
||||
class="layui-btn layui-btn-danger layui-btn-xs">取消发货</a>
|
||||
{/if}
|
||||
|
|
|
|||
|
|
@ -112,17 +112,21 @@
|
|||
</td>
|
||||
<td colspan='1'>
|
||||
{if $info['status'] eq 2 && $vo['fh_status'] eq 0}
|
||||
<a onClick="fahuo({$vo['id']},1,`{$vo['fh_remarks']}`,`发货成功!`)""
|
||||
<a onClick="fahuo({$vo['id']},1,`{$vo['fh_remarks']}`,`发货成功!`)"
|
||||
class="layui-btn layui-btn-normal layui-btn-xs">发货</a>
|
||||
{/if}
|
||||
{if $info['status'] eq 2 && $vo['fh_status'] eq 1}
|
||||
<a onClick="fahuo({$vo['id']},0,`{$vo['fh_remarks']}`,`取消发货成功!`)""
|
||||
<a onClick="fahuo({$vo['id']},0,`{$vo['fh_remarks']}`,`取消发货成功!`)"
|
||||
class="layui-btn layui-btn-warm layui-btn-xs">取消发货</a>
|
||||
{/if}
|
||||
{if $info['status'] eq 2}
|
||||
<a onClick="fahuo({$vo['id']},{$vo['fh_status']},`{$vo['fh_remarks']}`,`修改成功!`)"
|
||||
class="layui-btn layui-btn-normal layui-btn-xs">修改备注</a>
|
||||
{/if}
|
||||
{if $info['status'] eq 2 && $vo['fh_status'] eq 0}
|
||||
<a onClick="deleteItem({$vo['id']}, '{$info.send_num}')"
|
||||
class="layui-btn layui-btn-danger layui-btn-xs">移除商品</a>
|
||||
{/if}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
|
@ -269,6 +273,23 @@
|
|||
// });
|
||||
}
|
||||
|
||||
//删除单个商品
|
||||
function deleteItem(id, send_num) {
|
||||
layer.confirm('确定要从订单中移除商品此商品吗?', {
|
||||
btn: ['确定','取消'] //按钮
|
||||
}, function(){
|
||||
var url = "{:url('/admin/delete_order_item')}";
|
||||
$.post(url, {"id": id, "send_num": send_num}, function(data) {
|
||||
if(data.status == 1) {
|
||||
layer.msg('移除成功', {icon: 1, time: 1000}, function(){
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
<option value="1">推广</option>
|
||||
<option value="2">活动</option>
|
||||
<option value="3">发货</option>
|
||||
<option value="4">退款</option>
|
||||
<option value="5">其他</option>
|
||||
</select>
|
||||
</div>
|
||||
<label class="layui-form-label">支出金额</label>
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
<option value="1" {if $info['expense_type'] eq 1} selected {/if}>推广</option>
|
||||
<option value="2" {if $info['expense_type'] eq 2} selected {/if}>活动</option>
|
||||
<option value="3" {if $info['expense_type'] eq 3} selected {/if}>发货</option>
|
||||
<option value="4" {if $info['expense_type'] eq 4} selected {/if}>退款</option>
|
||||
<option value="5" {if $info['expense_type'] eq 5} selected {/if}>其他</option>
|
||||
</select>
|
||||
</div>
|
||||
<label class="layui-form-label">支出金额</label>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<script src="/static/admin/jquery-3.1.1.min.js"></script>
|
||||
<script src="/static/admin/layui/layui.js"></script>
|
||||
<script src="/static/admin/reward-component.js"></script>
|
||||
<script src="/js/reward-component.js"></script>
|
||||
<!-- <script src="/static/admin/lib/admin.js"></script> -->
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -198,11 +198,13 @@ class Notify extends Base
|
|||
if ($data['return_code'] == 'SUCCESS' && $data['result_code'] == 'SUCCESS') {
|
||||
$user = User::where('openid', $data['openid'])->find();
|
||||
try {
|
||||
Db::name('wxpay_log')->insert([
|
||||
'order_no' => $data['out_trade_no'],
|
||||
'content' => json_encode($data),
|
||||
'type' => 1,
|
||||
// 使用profit_pay表记录支付信息,而不是wxpay_log表
|
||||
Db::name('profit_pay')->insert([
|
||||
'user_id' => $user['id'],
|
||||
'order_num' => $data['out_trade_no'],
|
||||
'change_money' => isset($data['total_fee']) ? ($data['total_fee'] / 100) : 0,
|
||||
'content' => $data['attach'] ? $data['attach'] : '微信支付',
|
||||
'pay_type' => 1, // 1微信 2支付宝
|
||||
'addtime' => time(),
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
|
|
|
|||
|
|
@ -25,4 +25,65 @@ class WxpayLog extends Base
|
|||
$data['page']=$page;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 迁移旧数据到ProfitPay表
|
||||
* 将WxpayLog表中的旧数据迁移到profit_pay表
|
||||
* @param int $limit 每次处理的数据量
|
||||
* @param int $offset 起始偏移量
|
||||
* @return array 处理结果
|
||||
*/
|
||||
public static function migrateToNewTable($limit = 100, $offset = 0)
|
||||
{
|
||||
try {
|
||||
// 获取旧表数据
|
||||
$oldRecords = self::limit($limit)->offset($offset)->order('id asc')->select();
|
||||
$total = count($oldRecords);
|
||||
$success = 0;
|
||||
$failed = 0;
|
||||
$detail = [];
|
||||
|
||||
// 处理每条记录
|
||||
foreach ($oldRecords as $record) {
|
||||
try {
|
||||
// 解析content字段中的json数据
|
||||
$content = json_decode($record['content'], true);
|
||||
$change_money = isset($content['total_fee']) ? ($content['total_fee'] / 100) : 0;
|
||||
|
||||
// 检查记录是否已经存在
|
||||
$exists = ProfitPay::where('order_num', $record['order_no'])->find();
|
||||
if ($exists) {
|
||||
$detail[] = "订单 {$record['order_no']} 已存在于新表中,跳过";
|
||||
continue;
|
||||
}
|
||||
|
||||
// 插入到新表
|
||||
ProfitPay::insert([
|
||||
'user_id' => $record['user_id'],
|
||||
'order_num' => $record['order_no'],
|
||||
'change_money' => $change_money,
|
||||
'content' => isset($content['attach']) ? $content['attach'] : '微信支付',
|
||||
'pay_type' => $record['channel'] == 2 ? 2 : 1, // 1微信 2支付宝
|
||||
'addtime' => $record['addtime'],
|
||||
]);
|
||||
|
||||
$success++;
|
||||
} catch (\Exception $e) {
|
||||
$failed++;
|
||||
$detail[] = "处理订单 {$record['order_no']} 失败: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 1,
|
||||
'message' => "迁移完成:共处理 {$total} 条记录,成功 {$success} 条,失败 {$failed} 条",
|
||||
'detail' => $detail
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
return [
|
||||
'status' => 0,
|
||||
'message' => "迁移过程发生错误: " . $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -30,4 +30,6 @@ Route::get('baji', function () {
|
|||
Route::get('baji1', function () {
|
||||
// return 'hello';
|
||||
return view('baji');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user