mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-29 05:50:50 +00:00
【程序目录】优化代码
This commit is contained in:
parent
306cfc310e
commit
3ef09698c8
@ -734,8 +734,8 @@ class UpgradeController
|
||||
*/
|
||||
public function upData()
|
||||
{
|
||||
$data['new_version'] = 'CRMEB-BZ-BETA v5.4.0';
|
||||
$data['new_code'] = '540';
|
||||
$data['new_version'] = 'CRMEB-BZ v5.4.0';
|
||||
$data['new_code'] = '540.1';
|
||||
$data['update_sql'] = [
|
||||
[
|
||||
'code' => '540',
|
||||
|
||||
@ -141,11 +141,13 @@ class Division extends AuthController
|
||||
if ((int)$data['uid'] == 0) $data['uid'] = $data['image']['uid'];
|
||||
$userInfo = $userServices->getUserInfo($data['uid'], 'is_division,is_agent,is_staff');
|
||||
if (!$userInfo) throw new AdminException(100100);
|
||||
if ($userInfo['is_division']) throw new AdminException('此用户是事业部,请勿添加为代理商');
|
||||
if ($userInfo['is_agent']) throw new AdminException('此用户是代理商,无法重复添加');
|
||||
if ($userInfo['is_staff']) throw new AdminException('此用户是下级员工,无法添加为代理商');
|
||||
$divisionUserInfo = $userServices->count(['uid' => (int)$data['division_id'], 'is_division' => 1, 'division_id' => $data['division_id']]);
|
||||
if (!$divisionUserInfo) throw new AdminException(100100);
|
||||
if ($data['edit'] == 0) {
|
||||
if ($userInfo['is_division']) throw new AdminException('此用户是事业部,请勿添加为代理商');
|
||||
if ($userInfo['is_agent']) throw new AdminException('此用户是代理商,无法重复添加');
|
||||
if ($userInfo['is_staff']) throw new AdminException('此用户是下级员工,无法添加为代理商');
|
||||
$divisionUserInfo = $userServices->count(['uid' => (int)$data['division_id'], 'is_division' => 1, 'division_id' => $data['division_id']]);
|
||||
if (!$divisionUserInfo) throw new AdminException(100100);
|
||||
}
|
||||
$this->services->divisionAgentSave($data);
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
@ -153,7 +153,14 @@ class StoreBargain extends AuthController
|
||||
{
|
||||
/** @var StoreBargainUserServices $bargainUserService */
|
||||
$bargainUserService = app()->make(StoreBargainUserServices::class);
|
||||
$bargainUserService->userBargainStatusFail($id, false);
|
||||
if ($status == 0) {
|
||||
$bargainUserService->userBargainStatusFail($id, false);
|
||||
} else {
|
||||
$info = $this->services->get($id);
|
||||
if ($info['stop_time'] < time()) {
|
||||
return app('json')->fail('活动已结束,无法继续上架');
|
||||
}
|
||||
}
|
||||
$this->services->update($id, ['status' => $status]);
|
||||
return app('json')->success(100001);
|
||||
}
|
||||
|
||||
@ -161,6 +161,12 @@ class StoreCombination extends AuthController
|
||||
*/
|
||||
public function set_status($id, $status)
|
||||
{
|
||||
if ($status == 1) {
|
||||
$info = $this->services->get($id);
|
||||
if ($info['stop_time'] < time()) {
|
||||
return app('json')->fail('活动已结束,无法继续上架');
|
||||
}
|
||||
}
|
||||
$this->services->update($id, ['is_show' => $status]);
|
||||
return app('json')->success($status == 0 ? 100014 : 100015);
|
||||
}
|
||||
|
||||
@ -120,6 +120,12 @@ class StoreSeckill extends AuthController
|
||||
*/
|
||||
public function set_status($id, $status)
|
||||
{
|
||||
if ($status == 1) {
|
||||
$info = $this->services->get($id);
|
||||
if ($info['stop_time'] < time()) {
|
||||
return app('json')->fail('活动已结束,无法继续上架');
|
||||
}
|
||||
}
|
||||
$this->services->update($id, ['status' => $status]);
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ class StoreOrderInvoice extends AuthController
|
||||
$data['invoice_type'] = 82;
|
||||
$data['is_enterprise'] = 0;
|
||||
} else {
|
||||
$data['invoice_type'] = 81;
|
||||
$data['invoice_type'] = $info['type'] == 1 ? 82 : 81;
|
||||
$data['tax_id'] = $info['duty_number'];
|
||||
$data['is_enterprise'] = 1;
|
||||
}
|
||||
|
||||
@ -267,7 +267,7 @@ class StoreOrderController
|
||||
//创建订单jspay支付
|
||||
/** @var StoreOrderSuccessServices $success */
|
||||
$success = app()->make(StoreOrderSuccessServices::class);
|
||||
$payPriceStatus = $success->zeroYuanPayment($orderInfo, $uid, $paytype);
|
||||
$payPriceStatus = $success->zeroYuanPayment($orderInfo, $uid);
|
||||
if ($payPriceStatus)//0元支付成功
|
||||
return app('json')->status('success', '支付成功', ['order_id' => $orderInfo['order_id'], 'key' => $orderInfo['unique']]);
|
||||
else
|
||||
|
||||
@ -634,4 +634,9 @@ class StoreOrder extends BaseModel
|
||||
{
|
||||
$query->where('agent_brokerage', '>', $value);
|
||||
}
|
||||
|
||||
public function searchVirtualTypeAttr($query, $value)
|
||||
{
|
||||
if ($value !== '') $query->where('virtual_type', $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,6 +96,6 @@ class StoreCategory extends BaseModel
|
||||
*/
|
||||
public function searchIdAttr($query, $value, $data)
|
||||
{
|
||||
if ($value) $query->whereIn('id', $value);
|
||||
if ($value) $query->whereIn('id', is_array($value) ? $value : (string)$value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,7 +311,7 @@ class StoreProduct extends BaseModel
|
||||
$query->where(['is_show' => 0, 'is_del' => 0]);
|
||||
break;
|
||||
case 3:
|
||||
$query->where(['is_del' => 0]);
|
||||
$query->where(['is_del' => 0, 'vip_product' => 0]);
|
||||
break;
|
||||
case 4:
|
||||
$query->where(['is_del' => 0])->where(function ($query) {
|
||||
|
||||
@ -100,20 +100,28 @@ class StoreBargainServices extends BaseServices
|
||||
/** @var StoreBargainUserHelpServices $storeBargainUserHelpServices */
|
||||
$storeBargainUserHelpServices = app()->make(StoreBargainUserHelpServices::class);
|
||||
$countHelpAll = $storeBargainUserHelpServices->getHelpAllCount([['bargain_id', 'in', $ids]]);
|
||||
$stopIds = [];
|
||||
foreach ($list as &$item) {
|
||||
$item['count_people_all'] = $countAll[$item['id']] ?? 0;//参与人数
|
||||
$item['count_people_help'] = $countHelpAll[$item['id']] ?? 0;//帮忙砍价人数
|
||||
$item['count_people_success'] = $countSuccess[$item['id']] ?? 0;//砍价成功人数
|
||||
$item['stop_status'] = $item['stop_time'] < time() ? 1 : 0;
|
||||
if ($item['status']) {
|
||||
if ($item['start_time'] > time())
|
||||
if ($item['start_time'] > time()) {
|
||||
$item['start_name'] = '未开始';
|
||||
else if ($item['stop_time'] < time())
|
||||
} else if ($item['stop_time'] < time()) {
|
||||
$item['start_name'] = '已结束';
|
||||
else if ($item['stop_time'] > time() && $item['start_time'] < time()) {
|
||||
$item['status'] = 0;
|
||||
$stopIds[] = $item['id'];
|
||||
} else if ($item['stop_time'] > time() && $item['start_time'] < time()) {
|
||||
$item['start_name'] = '进行中';
|
||||
}
|
||||
} else $item['start_name'] = '已结束';
|
||||
} else {
|
||||
$item['start_name'] = '已结束';
|
||||
}
|
||||
}
|
||||
if ($stopIds) {
|
||||
$this->dao->batchUpdate($stopIds, ['status' => 0]);
|
||||
}
|
||||
return compact('list', 'count');
|
||||
}
|
||||
|
||||
@ -136,20 +136,28 @@ class StoreCombinationServices extends BaseServices
|
||||
$countAll = $storePinkServices->getPinkCount([]);
|
||||
$countTeam = $storePinkServices->getPinkCount(['k_id' => 0, 'status' => 2]);
|
||||
$countPeople = $storePinkServices->getPinkCount(['k_id' => 0]);
|
||||
$stopIds = [];
|
||||
foreach ($list as &$item) {
|
||||
$item['count_people'] = $countPeople[$item['id']] ?? 0;//拼团数量
|
||||
$item['count_people_all'] = $countAll[$item['id']] ?? 0;//参与人数
|
||||
$item['count_people_pink'] = $countTeam[$item['id']] ?? 0;//成团数量
|
||||
$item['stop_status'] = $item['stop_time'] < time() ? 1 : 0;
|
||||
if ($item['is_show']) {
|
||||
if ($item['start_time'] > time())
|
||||
if ($item['start_time'] > time()) {
|
||||
$item['start_name'] = '未开始';
|
||||
else if ($item['stop_time'] < time())
|
||||
} else if ($item['stop_time'] < time()) {
|
||||
$item['start_name'] = '已结束';
|
||||
else if ($item['stop_time'] > time() && $item['start_time'] < time()) {
|
||||
$item['is_show'] = 0;
|
||||
$stopIds[] = $item['id'];
|
||||
} else if ($item['stop_time'] > time() && $item['start_time'] < time()) {
|
||||
$item['start_name'] = '进行中';
|
||||
}
|
||||
} else $item['start_name'] = '已结束';
|
||||
} else {
|
||||
$item['start_name'] = '已结束';
|
||||
}
|
||||
}
|
||||
if ($stopIds) {
|
||||
$this->dao->batchUpdate($stopIds, ['is_show' => 0]);
|
||||
}
|
||||
return compact('list', 'count');
|
||||
}
|
||||
|
||||
@ -206,14 +206,17 @@ class StoreSeckillServices extends BaseServices
|
||||
[$page, $limit] = $this->getPageValue();
|
||||
$list = $this->dao->getList($where, $page, $limit);
|
||||
$count = $this->dao->count($where + ['is_del' => 0]);
|
||||
$stopIds = [];
|
||||
foreach ($list as &$item) {
|
||||
$item['store_name'] = $item['title'];
|
||||
if ($item['status']) {
|
||||
if ($item['start_time'] > time())
|
||||
if ($item['start_time'] > time()) {
|
||||
$item['start_name'] = '未开始';
|
||||
else if (bcadd($item['stop_time'], '86400') < time())
|
||||
} else if (bcadd($item['stop_time'], '86400') < time()) {
|
||||
$item['start_name'] = '已结束';
|
||||
else if (bcadd($item['stop_time'], '86400') > time() && $item['start_time'] < time()) {
|
||||
$item['status'] = 0;
|
||||
$stopIds[] = $item['id'];
|
||||
} else if (bcadd($item['stop_time'], '86400') > time() && $item['start_time'] < time()) {
|
||||
$item['start_name'] = '进行中';
|
||||
}
|
||||
} else $item['start_name'] = '已结束';
|
||||
@ -221,6 +224,9 @@ class StoreSeckillServices extends BaseServices
|
||||
$item['_stop_time'] = $end_time;
|
||||
$item['stop_status'] = $item['stop_time'] + 86400 < time() ? 1 : 0;
|
||||
}
|
||||
if ($stopIds) {
|
||||
$this->dao->batchUpdate($stopIds, ['status' => 0]);
|
||||
}
|
||||
return compact('list', 'count');
|
||||
}
|
||||
|
||||
|
||||
@ -626,7 +626,7 @@ class StoreOrderDeliveryServices extends BaseServices
|
||||
}
|
||||
$orderInfo->delivery_id = $data['delivery_id'];
|
||||
}
|
||||
if ($data['express_record_type'] != 3) {
|
||||
if (true) {
|
||||
$data['status'] = 1;
|
||||
$orderInfo->delivery_type = $data['delivery_type'];
|
||||
$orderInfo->delivery_name = $data['delivery_name'];
|
||||
|
||||
@ -271,7 +271,7 @@ class StoreOrderInvoiceServices extends BaseServices
|
||||
$data['tax_id'] = '';
|
||||
$data['is_enterprise'] = 0;
|
||||
} else {
|
||||
$data['invoice_type'] = 81;
|
||||
$data['invoice_type'] = $info['type'] == 1 ? 82 : 81;
|
||||
$data['tax_id'] = $info['duty_number'];
|
||||
$data['is_enterprise'] = 1;
|
||||
}
|
||||
|
||||
@ -796,6 +796,15 @@ HTML;
|
||||
if ($order['two_brokerage'] > 0) {
|
||||
$data['two_brokerage'] = bcmul((string)$order['two_brokerage'], $percent, 2);
|
||||
}
|
||||
if ($order['staff_brokerage'] > 0) {
|
||||
$data['staff_brokerage'] = bcmul((string)$order['staff_brokerage'], $percent, 2);
|
||||
}
|
||||
if ($order['agent_brokerage'] > 0) {
|
||||
$data['agent_brokerage'] = bcmul((string)$order['agent_brokerage'], $percent, 2);
|
||||
}
|
||||
if ($order['division_brokerage'] > 0) {
|
||||
$data['division_brokerage'] = bcmul((string)$order['division_brokerage'], $percent, 2);
|
||||
}
|
||||
}
|
||||
/** @var StoreOrderStatusServices $services */
|
||||
$services = app()->make(StoreOrderStatusServices::class);
|
||||
@ -2582,7 +2591,7 @@ HTML;
|
||||
}
|
||||
// 判断是否开启小程序订单管理
|
||||
$orderData['order_shipping_open'] = false;
|
||||
if (sys_config('order_shipping_open', 0) && $order['is_channel'] == 1 && $order['pay_type'] == 'weixin' && MiniOrderService::isManaged()) {
|
||||
if (sys_config('order_shipping_open', 0) && $order['pay_price'] > 0 && $order['is_channel'] == 1 && $order['pay_type'] == 'weixin' && MiniOrderService::isManaged()) {
|
||||
// 判断是否存在子未收货子订单
|
||||
if ($order['pid'] > 0) {
|
||||
if ($this->checkSubOrderNotTake((int)$order['pid'], (int)$order['id'])) {
|
||||
|
||||
@ -572,7 +572,7 @@ class StoreOrderTakeServices extends BaseServices
|
||||
//自定义事件-佣金到账
|
||||
event('CustomEventListener', ['order_brokerage', [
|
||||
'uid' => $spread_uid,
|
||||
'order_id' => $orderInfo['order_id'],
|
||||
'order_id' => $orderInfo['order_id'] ?? '',
|
||||
'phone' => $spreadPhone,
|
||||
'brokeragePrice' => $brokeragePrice,
|
||||
'goodsName' => $goodsName,
|
||||
|
||||
@ -218,7 +218,7 @@ class ExportServices extends BaseServices
|
||||
$export = $fileKey = [];
|
||||
/** @var StoreOrderServices $orderServices */
|
||||
$orderServices = app()->make(StoreOrderServices::class);
|
||||
$data = $orderServices->getOrderList(['status' => 1, 'shipping_type' => 1])['data'];
|
||||
$data = $orderServices->getOrderList(['status' => 1, 'shipping_type' => 1, 'virtual_type' => 0])['data'];
|
||||
if (!empty($data)) {
|
||||
$i = 0;
|
||||
foreach ($data as $item) {
|
||||
|
||||
@ -782,6 +782,27 @@ class SystemConfigServices extends BaseServices
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
$sonData = $this->dao->getColumn(['level' => 1, 'link_id' => $data['id']], 'menu_name,link_value');
|
||||
if ($sonData) {
|
||||
$sonValue = [];
|
||||
foreach ($sonData as $sv) {
|
||||
$sonValue[$sv['link_value']][] = $sv['menu_name'];
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($sonValue as $pk => $pv) {
|
||||
$label = $data['menu_name'];
|
||||
if ($i == 1) $label = $data['menu_name'] . '@';
|
||||
if ($i == 2) $label = $data['menu_name'] . '#';
|
||||
if (!isset($relateRule[$label])) {
|
||||
$relateRule[$label]['show_value'] = (int)$pk;
|
||||
}
|
||||
foreach ($pv as $pvv) {
|
||||
$relateRule[$label]['son_type'][$pvv] = '';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($relateRule[$key])) {
|
||||
$role = $relateRule[$key];
|
||||
|
||||
@ -96,6 +96,7 @@ class UserExtractServices extends BaseServices
|
||||
$list = $this->dao->getExtractList($where, $field, $page, $limit);
|
||||
foreach ($list as &$item) {
|
||||
$item['nickname'] = $item['user']['nickname'] ?? '';
|
||||
$item['receive_price'] = bcsub((string)$item['extract_price'], (string)$item['extract_fee'], 2);
|
||||
}
|
||||
$count = $this->dao->count($where);
|
||||
return compact('list', 'count');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user