提交 eebe2bb6 authored 作者: Whispa's avatar Whispa

Merge remote-tracking branch 'origin/master'

...@@ -62,6 +62,12 @@ public class AddressController extends Controller{ ...@@ -62,6 +62,12 @@ public class AddressController extends Controller{
return new Result<>(save); return new Result<>(save);
} }
@GetMapping("/findAddressById/{id}")
public Result findAddressById(@PathVariable("id") String id){
return new Result(repository.findById(id));
}
@PutMapping("/{addressId}") @PutMapping("/{addressId}")
public Result editAddressInfo(@PathVariable("addressId") String addressId,@RequestBody TbCfAddress address) { public Result editAddressInfo(@PathVariable("addressId") String addressId,@RequestBody TbCfAddress address) {
......
...@@ -14,10 +14,7 @@ import org.springframework.data.domain.Sort; ...@@ -14,10 +14,7 @@ import org.springframework.data.domain.Sort;
import static org.springframework.data.domain.Sort.Order.asc; import static org.springframework.data.domain.Sort.Order.asc;
import static org.springframework.data.domain.Sort.Order.desc; import static org.springframework.data.domain.Sort.Order.desc;
import java.util.Date; import java.util.*;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Optional;
/** /**
* @Auther: wudepeng * @Auther: wudepeng
...@@ -46,7 +43,7 @@ public class AdvertisementController { ...@@ -46,7 +43,7 @@ public class AdvertisementController {
*/ */
@GetMapping("/info/{link}") @GetMapping("/info/{link}")
public Result getAdvertisementById(@PathVariable("link") String link, public Result getAdvertisementById(@PathVariable("link") String link,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageNum", defaultValue = "0") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "12") Integer pageSize, @RequestParam(value = "pageSize", defaultValue = "12") Integer pageSize,
@RequestParam(value = "order", required = false) String order) { @RequestParam(value = "order", required = false) String order) {
LinkedHashMap advertisementMap = new LinkedHashMap(); LinkedHashMap advertisementMap = new LinkedHashMap();
...@@ -61,8 +58,14 @@ public class AdvertisementController { ...@@ -61,8 +58,14 @@ public class AdvertisementController {
if (now > endTime.getTime()) { if (now > endTime.getTime()) {
advertisement.setStatus(3); advertisement.setStatus(3);
} }
List<TbCfStationItem> itemList = new ArrayList<>();
if (StringUtils.isBlank(order)) {
List<TbCfStationItem> itemList = itemRepository.getAdvertisementItem(advertisement.getId(), PageRequest.of(pageNum - 1, pageSize)).toList(); itemList = itemRepository.getAdvertisementItem(advertisement.getId(), PageRequest.of(pageNum, pageSize)).toList();
} else {
itemList = itemRepository.getAdvertisementItem2(advertisement.getId(), PageRequest.of(pageNum, pageSize, sort(order))).toList();
}
advertisementMap.put("advertisement", advertisement); advertisementMap.put("advertisement", advertisement);
advertisementMap.put("itemList", itemList); advertisementMap.put("itemList", itemList);
} }
......
...@@ -49,38 +49,6 @@ public class DpoPayController extends Controller { ...@@ -49,38 +49,6 @@ public class DpoPayController extends Controller {
} }
@GetMapping("/notify") @GetMapping("/notify")
public Result payNotify(HttpServletRequest request, HttpServletResponse response) {
Result result = new Result();
try {
System.out.println("DPO支付回调");
//订单号
String orderId = request.getParameter("CompanyRef");
//交易ID
String transId = request.getParameter("TransID");
//交易令牌
String transToken = request.getParameter("TransactionToken");
System.err.println("transID:" + transId);
System.err.println("transToken:" + transToken);
//logger.info("DPO支付:" + "开始支付校验");
if (!StringUtils.isBlank(orderId) && !StringUtils.isBlank(transToken)) {
boolean verifyPay = verifyPay(transToken, orderId);
if (verifyPay) {
//logger.info("DPO支付:" + "支付校验成功");
result.setMessage("Pay for success");
result.setCode(ResultCodeEnum.SUCCESS.getCode());
return result;
}
}
return new Result<>(result,ResultCodeEnum.SERVICE_ERROR.getCode(), "Pay for failure");
} catch (Exception e) {
return new Result<>(result,ResultCodeEnum.SERVICE_ERROR.getCode(), "Pay for failure");
//logger.error("DPO支付回调发生异常--->>>" + e.toString());
}
}
@GetMapping("/notifyWeb")
public void payNotifyWeb(HttpServletRequest request, HttpServletResponse response) throws IOException { public void payNotifyWeb(HttpServletRequest request, HttpServletResponse response) throws IOException {
// Result result = new Result(); // Result result = new Result();
// try { // try {
...@@ -94,8 +62,11 @@ public class DpoPayController extends Controller { ...@@ -94,8 +62,11 @@ public class DpoPayController extends Controller {
System.err.println("transID:" + transId); System.err.println("transID:" + transId);
System.err.println("transToken:" + transToken); System.err.println("transToken:" + transToken);
//logger.info("DPO支付:" + "开始支付校验"); //logger.info("DPO支付:" + "开始支付校验");
Optional<TbCfOrder> byId = repository.findById(orderId); // Optional<TbCfOrder> byId = repository.findById(orderId);
// String orderSource = null;
// if (byId.isPresent()) {
// orderSource = byId.get().getOrderSource().toString();
// }
if (!StringUtils.isBlank(orderId) && !StringUtils.isBlank(transToken)) { if (!StringUtils.isBlank(orderId) && !StringUtils.isBlank(transToken)) {
boolean verifyPay = verifyPay(transToken, orderId); boolean verifyPay = verifyPay(transToken, orderId);
if (verifyPay) { if (verifyPay) {
......
...@@ -2,6 +2,7 @@ package com.example.afrishop_v3.models; ...@@ -2,6 +2,7 @@ package com.example.afrishop_v3.models;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
...@@ -18,6 +19,7 @@ import java.util.Date; ...@@ -18,6 +19,7 @@ import java.util.Date;
@Entity @Entity
@Setter @Setter
@Getter @Getter
@DynamicUpdate
public class TbCfAddress{ public class TbCfAddress{
/** /**
......
...@@ -39,4 +39,7 @@ public interface TbCfStationItemRepository extends PagingAndSortingRepository<Tb ...@@ -39,4 +39,7 @@ public interface TbCfStationItemRepository extends PagingAndSortingRepository<Tb
@Query(value = "select i from #{#entityName} i inner join AdvertisementItem a on i.itemId=a.itemId where a.adId=?1 order by a.sort") @Query(value = "select i from #{#entityName} i inner join AdvertisementItem a on i.itemId=a.itemId where a.adId=?1 order by a.sort")
Page<TbCfStationItem> getAdvertisementItem(String adId, Pageable pageable); Page<TbCfStationItem> getAdvertisementItem(String adId, Pageable pageable);
@Query(value = "select i from #{#entityName} i inner join AdvertisementItem a on i.itemId=a.itemId where a.adId=?1")
Page<TbCfStationItem> getAdvertisementItem2(String adId, Pageable pageable);
} }
...@@ -65,7 +65,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -65,7 +65,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
http.cors().and().csrf().disable() http.cors().and().csrf().disable()
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and() .exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.authorizeRequests().antMatchers("/api/auth/**","/search/image/**", "/itemStation/**", "/startPage/**", "/goodsType/**", "/home/**", "/spider/**", "/store/**", "/shopify/**", "/community/**","/version/**","/flutterwave/notify/**","/dpo/notify/**").permitAll() .authorizeRequests().antMatchers("/api/auth/**","/search/image/**", "/itemStation/**", "/startPage/**", "/goodsType/**", "/home/**", "/spider/**", "/store/**", "/shopify/**", "/community/**","/version/**","/flutterwave/notify/**","/dpo/notify/**","/advertisement/**").permitAll()
.antMatchers("/api/test/**").permitAll() .antMatchers("/api/test/**").permitAll()
.anyRequest().authenticated(); .anyRequest().authenticated();
......
package com.example.afrishop_v3.vo;
import com.example.afrishop_v3.models.TbCfDescripiton;
import lombok.Data;
import java.util.List;
/**
* @Auther: wudepeng
* @Date: 2020/11/23
* @Description:商品分类
*/
@Data
public class Category {
private String id;
private String category;
private List<TbCfDescripiton> categoryList;
}
package com.example.afrishop_v3.website.controller;
import com.example.afrishop_v3.base.Result;
import com.example.afrishop_v3.models.TbCfDescripiton;
import com.example.afrishop_v3.models.TbCfGoodstwotype;
import com.example.afrishop_v3.repository.TbCfDescripitonRepository;
import com.example.afrishop_v3.repository.TbCfGoodstwotypeRepository;
import com.example.afrishop_v3.repository.TbCfGoodstypeRepository;
import com.example.afrishop_v3.vo.Category;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
/**
* @Auther: wudepeng
* @Date: 2020/11/23
* @Description:PC官网首页商品分类管理
*/
@RestController
@RequestMapping(value = "/website/column")
public class ColumnController {
private final TbCfGoodstypeRepository repository;
private final TbCfGoodstwotypeRepository secondaryRepository;
private final TbCfDescripitonRepository tertiaryRepository;
public ColumnController(TbCfGoodstypeRepository repository, TbCfGoodstwotypeRepository secondaryRepository, TbCfDescripitonRepository tertiaryRepository) {
this.repository = repository;
this.secondaryRepository = secondaryRepository;
this.tertiaryRepository = tertiaryRepository;
}
/**
* 查询所有一级分类
*/
@GetMapping
public Result findTopCategory() {
return new Result(repository.findAll());
}
/**
* 查询一级分类的子分类
*/
@GetMapping("/{id}")
public Result findCategoryChildrens(@PathVariable("id") String id) {
LinkedList<Category> categoryList = new LinkedList();
//二级分类
List<TbCfGoodstwotype> secondaryCategory = secondaryRepository.findAllByGoodstypeId(id);
secondaryCategory.forEach(category -> {
//三级分类
List<TbCfDescripiton> tertiaryCategory = tertiaryRepository.findAllByGoodstwotypeId(category.getGoodstwotypeId());
Category c = new Category();
c.setId(category.getGoodstwotypeId());
c.setCategory(category.getGoodstwotypeTitle());
c.setCategoryList(tertiaryCategory);
categoryList.add(c);
});
return new Result(categoryList);
}
}
server:
servlet:
context-path: /afrishop
port: 8099
spring: spring:
datasource: datasource:
url: jdbc:mysql://159.138.48.71:3306/chinafrica_ref?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC url: jdbc:mysql://159.138.48.71:3306/chinafrica_ref?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
...@@ -71,3 +75,4 @@ flutter: ...@@ -71,3 +75,4 @@ flutter:
redirect_url: https://www.afrieshop.com/afrishop/flutterwave/notify redirect_url: https://www.afrieshop.com/afrishop/flutterwave/notify
public_key: FLWPUBK_TEST-e3cc948e7cb24b2128fca3b781f6fce0-X public_key: FLWPUBK_TEST-e3cc948e7cb24b2128fca3b781f6fce0-X
secret_key: FLWSECK_TEST-f88371ca63a989a4af95625475a0d22d-X secret_key: FLWSECK_TEST-f88371ca63a989a4af95625475a0d22d-X
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论