Commit b8c40ad0 by 吕明尚

调试团购劵适用门店接口

parent 2804e028
package share.web.controller.system;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.dianping.openapi.sdk.api.customerauth.session.entity.CustomerKeyShopScopeResponseEntity;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import share.common.annotation.Log;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.domain.entity.SysUser;
import share.common.core.page.TableDataInfo;
import share.common.enums.BusinessType;
import share.common.utils.poi.ExcelUtil;
import share.system.domain.SConsumer;
import share.system.domain.SStore;
import share.system.domain.SStoreConsumer;
import share.system.domain.SysUserRole;
import share.system.domain.tiktok.TiktokCouponDto;
import share.system.domain.tiktok.TiktokPoi;
import share.system.domain.vo.SConsumerVo;
import share.system.domain.vo.SStoreConsumerVo;
import share.system.service.ISStoreService;
import share.common.utils.poi.ExcelUtil;
import share.common.core.page.TableDataInfo;
import share.system.service.QPService;
import share.system.service.SConsumerService;
import share.system.service.TiktokService;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 门店Controller
*
......@@ -205,9 +191,9 @@ public class SStoreController extends BaseController
}
@GetMapping("/poi/query")
public AjaxResult poiQuery(TiktokCouponDto tiktokCouponDto) {
return success(tiktokService.poiQuery(tiktokCouponDto));
@GetMapping("/poiQuery")
public AjaxResult poiQuery() {
return success(tiktokService.poiList());
}
......
......@@ -22,6 +22,7 @@ wechat:
signKey: ZEKu56XCezuESfNEdM4zVZEN3cz2PuHz
certPath: /var/gxpt/wechat_ssl/apiclient_cert.p12
token: coujio
miniprogram_state: trial
wx:
miniapp:
configs:
......@@ -30,6 +31,10 @@ wx:
token: coujio
aesKey: zf8vTHbI0ZDPTkkCXHEuwh9EbtVtOn6n4vQjMb9OFrS
msgDataFormat: XML
tiktok:
appId: awt50u5zommqxkl9
appSecret: c567551e0c4ce1db4f985d0233025d8d
accountId: 7325762036464355343
#扫呗支付配置
saobei:
key: 15490267
......@@ -219,3 +224,5 @@ order:
mqtt:
device-op-last-time: -5
device-gateway-last-report-time: -10
api:
domain: https://www.coujio.com
\ No newline at end of file
......@@ -5,12 +5,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import share.common.core.domain.AjaxResult;
import share.system.domain.tiktok.TiktokCouponDto;
import share.system.domain.tiktok.TiktokPoi;
import share.system.domain.vo.OnlineQueryDto;
import share.system.service.TiktokService;
import java.util.List;
import static share.common.core.domain.AjaxResult.success;
@RestController
......@@ -50,8 +47,8 @@ public class TiktokController {
}
@GetMapping("/poi/query")
public List<TiktokPoi> poiQuery(TiktokCouponDto tiktokCouponDto) {
return tiktokService.poiQuery(tiktokCouponDto);
public AjaxResult poiQuery(TiktokCouponDto tiktokCouponDto) {
return success(tiktokService.poiQuery(tiktokCouponDto));
}
//查询所有线上商品数据列表
......
......@@ -25,4 +25,6 @@ public interface TiktokService {
JSONObject onlineGet(String productIds, String accountId);
String consumeByUser(String code, String poiId);
List<TiktokPoi> poiList();
}
......@@ -283,21 +283,18 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
List<SStore> sStores = storeService.list();
//过滤掉没有poiId的门店
sStores = sStores.stream().filter(store -> StringUtils.isNotBlank(store.getPoiId())).collect(Collectors.toList());
Map<String, SCoupon> sCouponList = new LinkedHashMap<>();
List<SCoupon> sCouponList = new ArrayList<>();
OnlineQueryDto onlineQueryDto = new OnlineQueryDto();
onlineQueryDto.setAccountId(ACCOUNT_Id);
JSONObject entries = tiktokService.onlineQuery(onlineQueryDto);
JSONArray products = entries.getJSONArray("products");
List<SStore> finalSStores = sStores;
List<SStore> finalSStores1 = sStores;
products.stream().forEach(item -> {
JSONObject jsonObject = (JSONObject) item;
if (jsonObject.getInt("online_status").equals(YesNoEnum.yes.getIndex())) {
JSONObject sku = jsonObject.getJSONObject("sku");
JSONObject product = jsonObject.getJSONObject("product");
JSONArray pois = product.getJSONArray("pois");
SCoupon sCoupon1 = sCouponList.get(sku.getStr("sku_id"));
if (ObjectUtils.isEmpty(sCoupon1)) {
SCoupon sCoupon = new SCoupon();
sCoupon.setSkuId(sku.getStr("sku_id"));
sCoupon.setName(sku.getStr("sku_name"));
......@@ -313,28 +310,14 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
sCoupon.setMinPrice(new BigDecimal("0.00"));
sCoupon.setCouponType(CouponTypeEnum.CASH.getCode());
if (finalSStores.size() == 0) {
sCouponList.put(sku.getStr("sku_id"), sCoupon);
sCouponList.add(sCoupon);
return;
}
pois.stream().forEach(poi -> {
JSONObject jsonObject1 = (JSONObject) poi;
if (StringUtils.isEmpty(sCoupon.getStoreIds())) {
//判断
sCoupon.setStoreIds(String.valueOf(finalSStores.stream().filter(store -> jsonObject1.getStr("poi_id").equals(store.getPoiId())).findFirst().get().getId()));
} else {
sCoupon.setStoreIds(sCoupon.getStoreIds() + "," + finalSStores.stream().filter(store -> jsonObject1.getStr("poi_id").equals(store.getPoiId())).findFirst().get().getId());
Set<String> poiIds = pois.stream().map(poi -> ((JSONObject) poi).getStr("poi_id")).collect(Collectors.toSet());
sCoupon.setStoreIds(String.valueOf(finalSStores.stream().filter(store -> poiIds.contains(store.getPoiId())).map(SStore::getId).collect(Collectors.toList())).replace("[", "").replace("]", "").replace(" ", "").trim());
sCouponList.add(sCoupon);
}
});
sCouponList.put(sku.getStr("sku_id"), sCoupon);
} else {
pois.stream().forEach(poi -> {
JSONObject jsonObject1 = (JSONObject) poi;
sCoupon1.setStoreIds(sCoupon1.getStoreIds() + "," + finalSStores1.stream().filter(store -> store.getPoiId().equals(jsonObject1.getStr("poi_id"))).findFirst().get().getId());
});
}
}
});
return new ArrayList<>(sCouponList.values());
return sCouponList;
}
}
......@@ -132,7 +132,7 @@ public class TiktokServiceImpl implements TiktokService {
String expiresTime = DateUtil.format(date, DatePattern.NORM_DATETIME_PATTERN);
map.put("expiresTime", expiresTime);
JSONObject jsonObject = new JSONObject(map);
redisUtil.set(ReceiptRdeisEnum.TIKTOK_CLIENT_TOKEN.getValue(), jsonObject.toString(), 6400L, TimeUnit.SECONDS);
redisUtil.set(ReceiptRdeisEnum.TIKTOK_CLIENT_TOKEN.getValue(), jsonObject.toString(), 6600L, TimeUnit.SECONDS);
redisUtil.set(ReceiptRdeisEnum.TIKTOK_CLIENT_TOKEN_KEY.getValue(), jsonObject.toString());
}
......@@ -406,6 +406,21 @@ public class TiktokServiceImpl implements TiktokService {
return "验卷成功";
}
@Override
public List<TiktokPoi> poiList() {
List<TiktokPoi> tiktokPois = poiQuery(new TiktokCouponDto());
List<SStore> list = storeService.list();
//过滤以增加的门店 根据poiId
List<TiktokPoi> collect = tiktokPois.stream().filter(o1 -> {
Optional<SStore> first = list.stream().filter(o2 -> o1.getPoiId().equals(o2.getPoiId())).findFirst();
if (first.isPresent()) {
return false;
}
return true;
}).collect(java.util.stream.Collectors.toList());
return collect;
}
public String obtain() {
String o;
o = redisUtil.get(ReceiptRdeisEnum.TIKTOK_CLIENT_TOKEN.getValue());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment