Commit 02e3d98f authored by Junling Bu's avatar Junling Bu
Browse files

管理后台litemall-admin和litemall-admin-wx更新

parent b05140b9
......@@ -3,24 +3,24 @@ package org.linlinjava.litemall.admin.dao;
import org.linlinjava.litemall.db.domain.LitemallGoods;
import org.linlinjava.litemall.db.domain.LitemallGoodsAttribute;
import org.linlinjava.litemall.db.domain.LitemallGoodsSpecification;
import org.linlinjava.litemall.db.domain.LitemallProduct;
import org.linlinjava.litemall.db.domain.LitemallGoodsProduct;
public class GoodsAllinone {
LitemallGoods goods;
LitemallGoodsSpecification[] specifications;
LitemallGoodsAttribute[] attributes;
// 这里采用 Product 再转换到 LitemallProduct
LitemallProduct[] products;
// 这里采用 Product 再转换到 LitemallGoodsProduct
LitemallGoodsProduct[] products;
public LitemallGoods getGoods() {
return goods;
}
public LitemallProduct[] getProducts() {
public LitemallGoodsProduct[] getProducts() {
return products;
}
public void setProducts(LitemallProduct[] products) {
public void setProducts(LitemallGoodsProduct[] products) {
this.products = products;
}
......
......@@ -69,7 +69,6 @@ public class AdminAdController {
if(error != null){
return error;
}
ad.setAddTime(LocalDateTime.now());
adService.add(ad);
return ResponseUtil.ok(ad);
}
......
......@@ -111,8 +111,6 @@ public class AdminAdminController {
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
String encodedPassword = encoder.encode(rawPassword);
admin.setPassword(encodedPassword);
admin.setAddTime(LocalDateTime.now());
adminService.add(admin);
return ResponseUtil.ok(admin);
}
......
......@@ -76,8 +76,6 @@ public class AdminBrandController {
if(error != null){
return error;
}
brand.setAddTime(LocalDateTime.now());
brandService.add(brand);
return ResponseUtil.ok(brand);
}
......
......@@ -81,7 +81,6 @@ public class AdminCategoryController {
if(error != null){
return error;
}
category.setAddTime(LocalDateTime.now());
categoryService.add(category);
return ResponseUtil.ok();
}
......
......@@ -5,7 +5,7 @@ import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.admin.annotation.LoginAdmin;
import org.linlinjava.litemall.db.service.LitemallGoodsService;
import org.linlinjava.litemall.db.service.LitemallOrderService;
import org.linlinjava.litemall.db.service.LitemallProductService;
import org.linlinjava.litemall.db.service.LitemallGoodsProductService;
import org.linlinjava.litemall.db.service.LitemallUserService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -26,7 +26,7 @@ public class AdminDashbordController {
@Autowired
private LitemallGoodsService goodsService;
@Autowired
private LitemallProductService productService;
private LitemallGoodsProductService productService;
@Autowired
private LitemallOrderService orderService;
......
......@@ -41,7 +41,7 @@ public class AdminGoodsController {
@Autowired
private LitemallGoodsAttributeService attributeService;
@Autowired
private LitemallProductService productService;
private LitemallGoodsProductService productService;
@Autowired
private LitemallCategoryService categoryService;
@Autowired
......@@ -119,8 +119,8 @@ public class AdminGoodsController {
}
}
LitemallProduct[] products = goodsAllinone.getProducts();
for(LitemallProduct product : products){
LitemallGoodsProduct[] products = goodsAllinone.getProducts();
for(LitemallGoodsProduct product : products){
Integer number = product.getNumber();
if(number == null || number < 0){
return ResponseUtil.badArgument();
......@@ -165,7 +165,7 @@ public class AdminGoodsController {
LitemallGoods goods = goodsAllinone.getGoods();
LitemallGoodsAttribute[] attributes = goodsAllinone.getAttributes();
LitemallGoodsSpecification[] specifications = goodsAllinone.getSpecifications();
LitemallProduct[] products = goodsAllinone.getProducts();
LitemallGoodsProduct[] products = goodsAllinone.getProducts();
// 开启事务管理
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
......@@ -179,7 +179,7 @@ public class AdminGoodsController {
// 商品基本信息表litemall_goods
if(goodsService.updateById(goods) == 0){
throw new Exception("跟新数据已失效");
throw new Exception("跟新数据失败");
}
Integer gid = goods.getId();
......@@ -190,21 +190,18 @@ public class AdminGoodsController {
// 商品规格表litemall_goods_specification
for (LitemallGoodsSpecification specification : specifications) {
specification.setGoodsId(goods.getId());
specification.setAddTime(LocalDateTime.now());
specificationService.add(specification);
}
// 商品参数表litemall_goods_attribute
for (LitemallGoodsAttribute attribute : attributes) {
attribute.setGoodsId(goods.getId());
attribute.setAddTime(LocalDateTime.now());
attributeService.add(attribute);
}
// 商品货品表litemall_product
for (LitemallProduct product : products) {
for (LitemallGoodsProduct product : products) {
product.setGoodsId(goods.getId());
product.setAddTime(LocalDateTime.now());
productService.add(product);
}
} catch (Exception ex) {
......@@ -263,7 +260,7 @@ public class AdminGoodsController {
LitemallGoods goods = goodsAllinone.getGoods();
LitemallGoodsAttribute[] attributes = goodsAllinone.getAttributes();
LitemallGoodsSpecification[] specifications = goodsAllinone.getSpecifications();
LitemallProduct[] products = goodsAllinone.getProducts();
LitemallGoodsProduct[] products = goodsAllinone.getProducts();
String name = goods.getName();
if (goodsService.checkExistByName(name)) {
......@@ -277,8 +274,6 @@ public class AdminGoodsController {
try {
// 商品基本信息表litemall_goods
goods.setAddTime(LocalDateTime.now());
goodsService.add(goods);
//将生成的分享图片地址写入数据库
......@@ -286,28 +281,25 @@ public class AdminGoodsController {
if(!StringUtils.isEmpty(url)) {
goods.setShareUrl(url);
if (goodsService.updateById(goods) == 0) {
throw new Exception("跟新数据已失效");
throw new Exception("跟新数据失败");
}
}
// 商品规格表litemall_goods_specification
for (LitemallGoodsSpecification specification : specifications) {
specification.setGoodsId(goods.getId());
specification.setAddTime(LocalDateTime.now());
specificationService.add(specification);
}
// 商品参数表litemall_goods_attribute
for (LitemallGoodsAttribute attribute : attributes) {
attribute.setGoodsId(goods.getId());
attribute.setAddTime(LocalDateTime.now());
attributeService.add(attribute);
}
// 商品货品表litemall_product
for (LitemallProduct product : products) {
for (LitemallGoodsProduct product : products) {
product.setGoodsId(goods.getId());
product.setAddTime(LocalDateTime.now());
productService.add(product);
}
} catch (Exception ex) {
......@@ -374,7 +366,7 @@ public class AdminGoodsController {
}
LitemallGoods goods = goodsService.findById(id);
List<LitemallProduct> products = productService.queryByGid(id);
List<LitemallGoodsProduct> products = productService.queryByGid(id);
List<LitemallGoodsSpecification> specifications = specificationService.queryByGid(id);
List<LitemallGoodsAttribute> attributes = attributeService.queryByGid(id);
......
......@@ -164,7 +164,6 @@ public class AdminGrouponController {
return ResponseUtil.badArgumentValue();
}
grouponRules.setAddTime(LocalDateTime.now());
grouponRules.setGoodsName(goods.getName());
grouponRules.setPicUrl(goods.getPicUrl());
......
......@@ -69,7 +69,6 @@ public class AdminIssueController {
if(error != null){
return error;
}
issue.setAddTime(LocalDateTime.now());
issueService.add(issue);
return ResponseUtil.ok(issue);
}
......
......@@ -69,7 +69,6 @@ public class AdminKeywordController {
if(error != null){
return error;
}
keywords.setAddTime(LocalDateTime.now());
keywordService.add(keywords);
return ResponseUtil.ok(keywords);
}
......
......@@ -11,7 +11,7 @@ import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.domain.*;
import org.linlinjava.litemall.db.service.LitemallOrderGoodsService;
import org.linlinjava.litemall.db.service.LitemallOrderService;
import org.linlinjava.litemall.db.service.LitemallProductService;
import org.linlinjava.litemall.db.service.LitemallGoodsProductService;
import org.linlinjava.litemall.db.service.LitemallUserService;
import org.linlinjava.litemall.db.util.OrderUtil;
import org.linlinjava.litemall.core.util.ResponseUtil;
......@@ -45,7 +45,7 @@ public class AdminOrderController {
@Autowired
private LitemallOrderService orderService;
@Autowired
private LitemallProductService productService;
private LitemallGoodsProductService productService;
@Autowired
private LitemallUserService userService;
......@@ -127,8 +127,6 @@ public class AdminOrderController {
return ResponseUtil.fail(403, "订单不能确认收货");
}
Integer version = order.getVersion();
// 开启事务管理
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
......@@ -136,7 +134,7 @@ public class AdminOrderController {
try {
// 设置订单取消状态
order.setOrderStatus(OrderUtil.STATUS_REFUND_CONFIRM);
if(orderService.updateByIdWithVersion(version, order) == 0) {
if(orderService.updateWithOptimisticLocker(order) == 0) {
throw new Exception("跟新数据已失效");
}
......@@ -144,11 +142,11 @@ public class AdminOrderController {
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(orderId);
for (LitemallOrderGoods orderGoods : orderGoodsList) {
Integer productId = orderGoods.getProductId();
LitemallProduct product = productService.findById(productId);
LitemallGoodsProduct product = productService.findById(productId);
Integer number = product.getNumber() + orderGoods.getNumber();
product.setNumber(number);
if(productService.updateById(product) == 0){
throw new Exception("跟新数据已失效");
throw new Exception("跟新数据失败");
}
}
} catch (Exception ex) {
......@@ -201,8 +199,6 @@ public class AdminOrderController {
return ResponseUtil.badArgument();
}
Integer version = order.getVersion();
// 如果订单不是已付款状态,则不能发货
if (!order.getOrderStatus().equals(OrderUtil.STATUS_PAY)) {
return ResponseUtil.fail(403, "订单不能确认收货");
......@@ -212,7 +208,7 @@ public class AdminOrderController {
order.setShipSn(shipSn);
order.setShipChannel(shipChannel);
order.setShipTime(LocalDateTime.now());
if(orderService.updateByIdWithVersion(version, order) == 0){
if(orderService.updateWithOptimisticLocker(order) == 0){
return ResponseUtil.updatedDateExpired();
}
......@@ -247,8 +243,6 @@ public class AdminOrderController {
continue;
}
Integer version = order.getVersion();
// 开启事务管理
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
......@@ -257,7 +251,7 @@ public class AdminOrderController {
// 设置订单已取消状态
order.setOrderStatus(OrderUtil.STATUS_AUTO_CANCEL);
order.setEndTime(LocalDateTime.now());
if(orderService.updateByIdWithVersion(version, order) == 0){
if(orderService.updateWithOptimisticLocker(order) == 0){
throw new Exception("跟新数据已失效");
}
......@@ -266,7 +260,7 @@ public class AdminOrderController {
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(orderId);
for (LitemallOrderGoods orderGoods : orderGoodsList) {
Integer productId = orderGoods.getProductId();
LitemallProduct product = productService.findById(productId);
LitemallGoodsProduct product = productService.findById(productId);
Integer number = product.getNumber() + orderGoods.getNumber();
product.setNumber(number);
if(productService.updateById(product) == 0){
......@@ -313,12 +307,10 @@ public class AdminOrderController {
continue;
}
Integer version = order.getVersion();
// 设置订单已取消状态
order.setOrderStatus(OrderUtil.STATUS_AUTO_CONFIRM);
order.setConfirmTime(now);
if(orderService.updateByIdWithVersion(version, order) == 0){
if(orderService.updateWithOptimisticLocker(order) == 0){
logger.info("订单 ID=" + order.getId() + " 数据已经更新,放弃自动确认收货");
}
else{
......@@ -326,4 +318,34 @@ public class AdminOrderController {
}
}
}
/**
* 可评价订单商品超期
* <p>
* 定时检查订单商品评价情况,如果确认商品超时七天则取消可评价状态
* 定时时间是每天凌晨4点。
*/
@Scheduled(cron = "0 0 4 * * ?")
public void checkOrderComment() {
logger.info("系统开启任务检查订单是否已经超期未评价");
LocalDateTime now = LocalDateTime.now();
List<LitemallOrder> orderList = orderService.queryComment();
for (LitemallOrder order : orderList) {
LocalDateTime confirm = order.getConfirmTime();
LocalDateTime expired = confirm.plusDays(7);
if (expired.isAfter(now)) {
continue;
}
order.setComments((short)0);
orderService.updateWithOptimisticLocker(order);
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(order.getId());
for(LitemallOrderGoods orderGoods : orderGoodsList){
orderGoods.setComment(-1);
orderGoodsService.updateById(orderGoods);
}
}
}
}
......@@ -74,7 +74,6 @@ public class AdminTopicController {
if(error != null){
return error;
}
topic.setAddTime(LocalDateTime.now());
topicService.add(topic);
return ResponseUtil.ok(topic);
}
......
......@@ -113,7 +113,6 @@ public class AdminUserController {
String encodedPassword = encoder.encode(password);
user.setPassword(encodedPassword);
user.setAddTime(LocalDateTime.now());
userService.add(user);
return ResponseUtil.ok(user);
}
......
......@@ -77,6 +77,9 @@
<el-form-item label="订单用户">
<span>{{ orderDetail.user.nickname }}</span>
</el-form-item>
<el-form-item label="用户留言">
<span>{{ orderDetail.order.message }}</span>
</el-form-item>
<el-form-item label="收货信息">
<span>(收货人){{ orderDetail.order.consignee }}</span>
<span>(手机号){{ orderDetail.order.mobile }}</span>
......
Supports Markdown
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