123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- <?php
-
-
- namespace app\admin\controller;
-
- use think\Page;
- use think\Db;
- use think\Config;
- use app\common\logic\ShopCommonLogic;
-
- class ShopService extends Base {
-
- private $UsersConfigData = [];
-
-
-
- public function __construct(){
- parent::__construct();
-
-
- $functionLogic = new \app\common\logic\FunctionLogic;
- $functionLogic->check_authorfile(1.5);
-
- $this->language_access();
-
- $this->users_db = Db::name('users');
- $this->shop_order_service_db = Db::name('shop_order_service');
-
-
- $this->shop_common = new ShopCommonLogic();
-
-
- $this->UsersConfigData = getUsersConfigData('all');
- $this->assign('userConfig', $this->UsersConfigData);
-
-
- $channeltype_row = \think\Cache::get('extra_global_channeltype');
- $this->assign('channeltype_row', $channeltype_row);
-
- $this->shopOrderServiceModel = model('ShopOrderService');
- }
-
-
- public function after_service()
- {
- $param = input('param.');
-
-
- $Result = $this->shopOrderServiceModel->GetAllServiceInfo($param);
- $this->assign('Service', $Result['Service']);
- $this->assign('page', $Result['pageStr']);
- $this->assign('pager', $Result['pageObj']);
- $this->assign('pay_name', $Result['pay_name']);
- $this->assign('order_terminal', $Result['order_terminal']);
- $this->assign('serviceJsonArr', $Result['serviceJsonArr']);
-
- $ServiceStatus = Config::get('global.order_service_status');
- $this->assign('ServiceStatus', $ServiceStatus);
-
- $admin_order_status_arr = Config::get('global.admin_order_status_arr');
- $this->assign('admin_order_status_arr', $admin_order_status_arr);
-
-
- $channelRow = Db::name('channeltype')->where('nid', 'in',['article','download'])->getAllWithIndex('nid');
- foreach ($channelRow as &$val){
- if (!empty($val['data'])) $val['data'] = json_decode($val['data'], true);
- }
- $this->assign('channelRow', $channelRow);
-
-
- $shopOpenOffline = 1;
- if (0 === intval($this->UsersConfigData['shop_open_offline']) || !isset($this->UsersConfigData['shop_open_offline'])) {
- $shopOpenOffline = 0;
- }
- $this->assign('shopOpenOffline', $shopOpenOffline);
-
-
- $where = [
- 'status' => 1,
- 'pay_mark' => ['IN', ['wechat', 'alipay']]
- ];
- $payApiConfig = Db::name('pay_api_config')->where($where)->select();
- $openWeChat = $openAliPay = 1;
- foreach ($payApiConfig as $key => $value) {
- $payInfo = unserialize($value['pay_info']);
- if (!empty($payInfo) && isset($payInfo['is_open_wechat']) && 0 === intval($payInfo['is_open_wechat'])) {
- $openWeChat = 0;
- }
- if (!empty($payInfo) && isset($payInfo['is_open_alipay']) && 0 === intval($payInfo['is_open_alipay'])) {
- $openAliPay = 0;
- }
- }
- $this->assign('openWeChat', $openWeChat);
- $this->assign('openAliPay', $openAliPay);
-
-
- $where = [
- 'status' => 1,
- 'code' => 'DiyminiproMall'
- ];
- $openMall = Db::name('weapp')->where($where)->count();
- $this->assign('openMall', $openMall);
-
-
- $isMobile = input('param.isMobile/d', 0);
-
- if (is_dir('./weapp/Mbackend/') && !empty($isMobile)) {
- $mbPage = input('param.p/d', 1);
- $nullShow = intval($Result['pageObj']->totalPages) === intval($mbPage) ? 1 : 0;
- $this->assign('nullShow', $nullShow);
- if ($mbPage >= 2) {
- return $this->display('shop/after_service_list');
- } else {
- return $this->display('shop/after_service');
- }
- } else {
- return $this->fetch('after_service');
- }
- }
-
-
- public function after_service_details()
- {
- $service_id = input('param.service_id/d');
- if (!empty($service_id)) {
-
- $Result = $this->shopOrderServiceModel->GetFieldServiceInfo($service_id);
- $this->assign('Log', $Result['Log']);
- $this->assign('Users', $Result['Users']);
- $this->assign('Order', $Result['Order']);
- $this->assign('Details', $Result['Details']);
- $this->assign('Service', $Result['Service']);
- $this->assign('weappVerifyLog', $Result['weappVerifyLog']);
- $this->assign('iframe', input('param.iframe/d', 0));
-
-
- $isMobile = input('param.isMobile/d', 0);
- if (is_dir('./weapp/Mbackend/') && !empty($isMobile)) {
- return $this->display('shop/after_service_details');
- } else {
- return $this->fetch('after_service_details');
- }
- }else{
- $this->error('非法访问!');
- }
- }
-
-
- public function after_service_handle()
- {
- if (IS_AJAX_POST) {
- $post = input('post.');
- if (empty($post['status']) || empty($post['service_id'])) $this->error('请选择审核意见!');
- if (empty($post['users_id']) || empty($post['order_id']) || empty($post['details_id'])) $this->error('数据错误,刷新重试!');
-
-
- $result = $this->shopOrderServiceModel->afterServiceHandle($post);
- if (!empty($result)) {
- $this->success('操作成功!', url('ShopService/after_service'));
- } else {
- $this->error('操作失败!');
- }
- }
- }
-
-
- public function after_service_refund()
- {
-
- $service_id = input('param.service_id/d', 0);
- $result = $this->shopOrderServiceModel->GetFieldServiceInfo($service_id);
- if (empty($result)) $this->error('维权订单不存在');
- $this->assign($result);
-
- return $this->fetch();
- }
-
-
- public function after_service_resend()
- {
-
- $service_id = input('param.service_id/d', 0);
- $result = $this->shopOrderServiceModel->GetFieldServiceInfo($service_id);
- if (empty($result)) $this->error('维权订单不存在');
- $this->assign($result);
-
- $where = [
- 'is_choose' => 1,
- ];
- $express = Db::name('shop_express')->where($where)->order('sort_order asc, express_id asc')->select();
- $this->assign('express', $express);
-
- return $this->fetch();
- }
-
-
- public function after_service_deal_with()
- {
- if (IS_AJAX) {
- $param = input('param.');
- if (empty($param)) $this->error('请正确操作!');
- if (empty($param['status'])) $this->error('请选择审核意见!');
- $param['manual_refund'] = !empty($param['manual_refund']) ? $param['manual_refund'] : 0;
-
-
- if (6 == $param['status']) {
-
-
- }
-
-
- $where = [
- 'users_id' => $param['users_id'],
- 'service_id' => $param['service_id']
- ];
- $update = [
- 'update_time' => getTime(),
- 'status' => $param['status']
- ];
- if (!empty($param['admin_note'])) $update['admin_note'] = $param['admin_note'];
- if (!empty($param['refund_price'])) $update['refund_balance'] = $param['refund_price'];
- if (!empty($param['delivery'])) $update['admin_delivery'] = serialize($param['delivery']);
- $ResultID = $this->shop_order_service_db->where($where)->update($update);
-
- if (!empty($ResultID)) {
- $ResultData['status'] = $param['status'];
-
-
- if (7 == $param['status']) {
- if (!isset($param['is_refund']) || 1 == $param['is_refund']) {
-
- $field = 'users_id, username, nickname, email, mobile, users_money';
- $Users = $this->users_db->field($field)->where('users_id', $param['users_id'])->find();
-
-
- $UpDate = [
- 'users_money' => Db::raw('users_money+'.($param['refund_price'])),
- ];
- $ResultID = $this->users_db->where('users_id', $param['users_id'])->update($UpDate);
- if (!empty($ResultID)) {
-
- if (empty($param['order_code'])) {
- $param['order_code'] = Db::name('shop_order')->where('order_id', $param['order_id'])->getField('order_code');
- }
-
- UsersMoneyRecording($param['order_code'], $Users, $param['refund_price'], '商品退换货');
- }
- }
- }
-
-
- if (in_array($param['status'], [6, 7]) && 0 == $param['is_refund'] && 1 == $param['manual_refund']) {
- $where = [
- 'users_id' => $param['users_id'],
- 'service_id' => $param['service_id']
- ];
- $update = [
- 'manual_refund' => 1,
- 'manual_time' => getTime(),
- 'refund_note' => trim($param['refund_note']),
- 'update_time' => getTime(),
- ];
- $this->shop_order_service_db->where($where)->update($update);
- }
-
-
- $this->shop_common->AddOrderServiceLog($param, 0);
-
-
- $this->success('操作成功!', null, $ResultData);
- } else {
- $this->error('操作失败!');
- }
- }
- }
-
-
- public function after_service_del()
- {
- $service_id = input('del_id/a');
- $service_id = eyIntval($service_id);
- if (IS_AJAX_POST && !empty($service_id)) {
-
- $Where = [
- 'lang' => $this->admin_lang,
- 'service_id' => ['IN', $service_id]
- ];
-
- $result = $this->shop_order_service_db->field('order_code')->where($Where)->select();
- $order_code_list = get_arr_column($result, 'order_code');
-
-
- $ResultID = $this->shop_order_service_db->where($Where)->delete();
- if (!empty($ResultID)) {
-
- Db::name('shop_order_service_log')->where($Where)->delete();
-
-
- adminLog('删除订单:'.implode(',', $order_code_list));
- $this->success('删除成功');
- } else {
- $this->error('删除失败');
- }
- }
- $this->error('参数有误');
- }
-
-
- public function users_edit_after_service()
- {
- $param = input('param.');
-
-
- $Result = $this->shopOrderServiceModel->GetUserAllServiceInfo($param);
-
-
- $ServiceStatus = Config::get('global.order_service_status');
-
- $this->assign('Service', $Result['Service']);
- $this->assign('page', $Result['pageStr']);
- $this->assign('pager', $Result['pageObj']);
- $this->assign('ServiceStatus', $ServiceStatus);
-
-
- $channelRow = Db::name('channeltype')->where('nid', 'article')->find();
- $channelRow['data'] = json_decode($channelRow['data'], true);
- $this->assign('channelRow', $channelRow);
-
-
- $shopOpenOffline = 1;
- if (0 === intval($this->UsersConfigData['shop_open_offline']) || !isset($this->UsersConfigData['shop_open_offline'])) {
- $shopOpenOffline = 0;
- }
- $this->assign('shopOpenOffline', $shopOpenOffline);
-
-
- $where = [
- 'status' => 1,
- 'pay_mark' => ['IN', ['wechat', 'alipay']]
- ];
- $payApiConfig = Db::name('pay_api_config')->where($where)->select();
- $openWeChat = $openAliPay = 1;
- foreach ($payApiConfig as $key => $value) {
- $payInfo = unserialize($value['pay_info']);
- if (!empty($payInfo) && isset($payInfo['is_open_wechat']) && 0 === intval($payInfo['is_open_wechat'])) {
- $openWeChat = 0;
- }
- if (!empty($payInfo) && isset($payInfo['is_open_alipay']) && 0 === intval($payInfo['is_open_alipay'])) {
- $openAliPay = 0;
- }
- }
- $this->assign('openWeChat', $openWeChat);
- $this->assign('openAliPay', $openAliPay);
-
-
- $where = [
- 'status' => 1,
- 'code' => 'DiyminiproMall'
- ];
- $openMall = Db::name('weapp')->where($where)->count();
- $this->assign('openMall', $openMall);
-
- return $this->fetch('member/edit/refund_index');
- }
- }
|