|
@@ -1,20 +1,33 @@
|
|
package com.ruixuan.isc.controller;
|
|
package com.ruixuan.isc.controller;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
|
+import com.ruixuan.common.constant.HttpStatus;
|
|
import com.ruixuan.common.core.controller.BaseController;
|
|
import com.ruixuan.common.core.controller.BaseController;
|
|
|
|
+import com.ruixuan.common.core.page.TableDataInfo;
|
|
|
|
+import com.ruixuan.common.utils.Check;
|
|
import com.ruixuan.common.utils.DateUtils;
|
|
import com.ruixuan.common.utils.DateUtils;
|
|
|
|
+import com.ruixuan.isc.entity.KuaishouAccessToken;
|
|
|
|
+import com.ruixuan.isc.entity.KuaishouRewardBaseInfo;
|
|
|
|
+import com.ruixuan.isc.entity.KwaixiaodianItemGet;
|
|
|
|
+import com.ruixuan.isc.service.IAccessTokenService;
|
|
import com.ruixuan.isc.service.IKwaixiaodianItemGetService;
|
|
import com.ruixuan.isc.service.IKwaixiaodianItemGetService;
|
|
import com.ruixuan.isc.service.IKwaixiaodianOrderCursorListService;
|
|
import com.ruixuan.isc.service.IKwaixiaodianOrderCursorListService;
|
|
|
|
+import com.ruixuan.system.service.ISysDeptService;
|
|
|
|
+import com.ruixuan.system.service.ISysRoleService;
|
|
|
|
+import com.ruixuan.system.service.ISysUserService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
+import io.swagger.models.auth.In;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* kwaixiaodian商品详情Controller
|
|
* kwaixiaodian商品详情Controller
|
|
@@ -24,12 +37,76 @@ import java.util.List;
|
|
@Api(tags = "Kwaixiaodian")
|
|
@Api(tags = "Kwaixiaodian")
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/kwaixiaodian/item")
|
|
@RequestMapping("/kwaixiaodian/item")
|
|
|
|
+@Slf4j
|
|
public class KwaixiaodianItemGetController extends BaseController {
|
|
public class KwaixiaodianItemGetController extends BaseController {
|
|
@Autowired
|
|
@Autowired
|
|
private IKwaixiaodianItemGetService kwaixiaodianItemGetService;
|
|
private IKwaixiaodianItemGetService kwaixiaodianItemGetService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private IKwaixiaodianOrderCursorListService orderCursorListService;
|
|
private IKwaixiaodianOrderCursorListService orderCursorListService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IAccessTokenService accessTokenService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysRoleService sysRoleService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysDeptService sysDeptService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysUserService sysUserService;
|
|
|
|
+
|
|
|
|
+ @GetMapping("/list")
|
|
|
|
+ public TableDataInfo list(Long itemId, String title, Integer itemType, Long userId) {
|
|
|
|
+ TableDataInfo rspData = new TableDataInfo();
|
|
|
|
+ try {
|
|
|
|
+ if (Check.isNull(userId)) {
|
|
|
|
+ throw new Exception("请传入用户ID");
|
|
|
|
+ }
|
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ String roleId = sysRoleService.getRoleBYUserId(userId);
|
|
|
|
+ if ("admin".equals(roleId)) { // 管理员查看所有
|
|
|
|
+
|
|
|
|
+ } else if ("industry_admin".equals(roleId)) { // 供应链管理员查看所属公司
|
|
|
|
+ Long companyId = kwaixiaodianItemGetService.getCompanyId(userId);
|
|
|
|
+ if (Check.isNull(companyId)) {
|
|
|
|
+ throw new Exception("此用户未查询到归属公司");
|
|
|
|
+ }
|
|
|
|
+ requestMap.put("companyId", companyId);
|
|
|
|
+ } else if ("industry_sale_manager".equals(roleId) || "industry_courtship_manager".equals(roleId) || "industry_purchase_manager".equals(roleId)) { // 经理角色查看部门下所有成员数据
|
|
|
|
+ List<Long> userIds = kwaixiaodianItemGetService.getUserIds(userId);
|
|
|
|
+ if (Check.isNull(userIds)) {
|
|
|
|
+ throw new Exception("此用户未查询到部门成员信息");
|
|
|
|
+ }
|
|
|
|
+ requestMap.put("userIds", userIds);
|
|
|
|
+ } else if ("industry_sale".equals(roleId) || "industry_purchase".equals(roleId) || "industry_courtship".equals(roleId)) { // 销售 采购 招商 查看自己的数据
|
|
|
|
+ List<Long> userIds = new ArrayList<>();
|
|
|
|
+ userIds.add(userId);
|
|
|
|
+ requestMap.put("userIds", userIds);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(itemId)) {
|
|
|
|
+ requestMap.put("itemId", itemId);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(title)) {
|
|
|
|
+ requestMap.put("title", title);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(itemType)) {
|
|
|
|
+ requestMap.put("itemType", itemType);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ startPage();
|
|
|
|
+ List<KwaixiaodianItemGet> list = kwaixiaodianItemGetService.getItemList(requestMap);
|
|
|
|
+ rspData.setCode(HttpStatus.SUCCESS);
|
|
|
|
+ rspData.setMsg("查询成功");
|
|
|
|
+ rspData.setRows(list);
|
|
|
|
+ rspData.setTotal(new PageInfo(list).getTotal());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ rspData.setCode(HttpStatus.ERROR);
|
|
|
|
+ rspData.setMsg(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return rspData;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取商品详情(open.item.get)
|
|
* 获取商品详情(open.item.get)
|
|
@@ -37,16 +114,35 @@ public class KwaixiaodianItemGetController extends BaseController {
|
|
*/
|
|
*/
|
|
@GetMapping("/querykwaiItmInfo")
|
|
@GetMapping("/querykwaiItmInfo")
|
|
@ApiOperation(value = "获kwai商品详情")
|
|
@ApiOperation(value = "获kwai商品详情")
|
|
- public void querykwaiItmInfo(
|
|
|
|
- @ApiParam("商品ID") @RequestParam(value = "kwaiItemId", required = false) Long kwaiItemId,
|
|
|
|
- @ApiParam("店铺ID") @RequestParam(value = "shopId", required = false) String shopId,
|
|
|
|
- @ApiParam("用户ID") @RequestParam(value = "userId", required = false) String userId,
|
|
|
|
- @ApiParam("用户") @RequestParam(value = "userName", required = false) String userName) {
|
|
|
|
|
|
+ public JSONObject querykwaiItmInfo(@ApiParam("商品ID") @RequestParam(value = "itemId", required = false) Long itemId, @ApiParam("店铺ID") @RequestParam(value = "shopId", required = false) String shopId, @ApiParam("用户ID") @RequestParam(value = "userId", required = false) Long userId, @ApiParam("用户") @RequestParam(value = "userName", required = false) String userName, @ApiParam("用户") @RequestParam(value = "itemType", required = false) Integer itemType) {
|
|
|
|
+
|
|
|
|
+ JSONObject returnJson = new JSONObject();
|
|
try {
|
|
try {
|
|
- kwaixiaodianItemGetService.querykwaiItmInfo(kwaiItemId, shopId, userId, userName);
|
|
|
|
|
|
+ KuaishouAccessToken token = accessTokenService.getKWaiAccessToken(shopId);
|
|
|
|
+ if (Check.isNull(token)) {
|
|
|
|
+ throw new Exception("未获取到授权信息,请联系管理员");
|
|
|
|
+ }
|
|
|
|
+ Long companyId = token.getCompanyId();
|
|
|
|
+ Integer count = kwaixiaodianItemGetService.checkItem(companyId, itemId);
|
|
|
|
+ if (count >= 1) {
|
|
|
|
+ throw new Exception("此商品已绑定");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSONObject jsonObject = kwaixiaodianItemGetService.querykwaiItmInfo(token, itemId, shopId, userId, userName, itemType);
|
|
|
|
+ if (jsonObject.getBoolean("success")) {
|
|
|
|
+ returnJson.put("code", 200);
|
|
|
|
+ returnJson.put("message", "新增商品成功");
|
|
|
|
+ } else {
|
|
|
|
+ returnJson.put("code", 500);
|
|
|
|
+ returnJson.put("message", jsonObject.getString("message"));
|
|
|
|
+ }
|
|
|
|
+
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
|
+ returnJson.put("code", 500);
|
|
|
|
+ returnJson.put("message", e.getMessage());
|
|
}
|
|
}
|
|
|
|
+ return returnJson;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -55,11 +151,7 @@ public class KwaixiaodianItemGetController extends BaseController {
|
|
*/
|
|
*/
|
|
@GetMapping("/querykwaiOrderList")
|
|
@GetMapping("/querykwaiOrderList")
|
|
@ApiOperation(value = "获kwai订单列表")
|
|
@ApiOperation(value = "获kwai订单列表")
|
|
- public void querykwaiOrderList(
|
|
|
|
- @ApiParam("店铺ID") @RequestParam(value = "shopId", required = false) String shopId
|
|
|
|
- , @ApiParam("1按创建时间查找 2按更新时间查找") @RequestParam(value = "queryType", required = false) Integer queryType
|
|
|
|
- , @ApiParam("开始日期") @RequestParam(value = "beginDate", required = false) String beginDate
|
|
|
|
- , @ApiParam("结束日期(间隔不大于7天)") @RequestParam(value = "endDate", required = false) String endDate
|
|
|
|
|
|
+ public void querykwaiOrderList(@ApiParam("店铺ID") @RequestParam(value = "shopId", required = false) String shopId, @ApiParam("1按创建时间查找 2按更新时间查找") @RequestParam(value = "queryType", required = false) Integer queryType, @ApiParam("开始日期") @RequestParam(value = "beginDate", required = false) String beginDate, @ApiParam("结束日期(间隔不大于7天)") @RequestParam(value = "endDate", required = false) String endDate
|
|
|
|
|
|
) {
|
|
) {
|
|
try {
|
|
try {
|
|
@@ -71,8 +163,7 @@ public class KwaixiaodianItemGetController extends BaseController {
|
|
|
|
|
|
@GetMapping("/queryNowdayKWaiOrderList")
|
|
@GetMapping("/queryNowdayKWaiOrderList")
|
|
@ApiOperation(value = "获当天kwai订单")
|
|
@ApiOperation(value = "获当天kwai订单")
|
|
- public void queryNowdayKWaiOrderList(
|
|
|
|
- @ApiParam("店铺ID") @RequestParam(value = "shopId", required = false) String shopId) {
|
|
|
|
|
|
+ public void queryNowdayKWaiOrderList(@ApiParam("店铺ID") @RequestParam(value = "shopId", required = false) String shopId) {
|
|
try {
|
|
try {
|
|
orderCursorListService.queryNowdayKWaiOrderList(shopId.trim(), "");
|
|
orderCursorListService.queryNowdayKWaiOrderList(shopId.trim(), "");
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|