This commit is contained in:
youc
2018-08-10 09:10:44 +08:00
70 changed files with 8894 additions and 869 deletions

View File

@@ -97,8 +97,8 @@ public class AdminGoodsController {
try {
//将生成的分享图片地址写入数据库
qCodeService.createGoodShareImage(goods.getId().toString(), goods.getPicUrl(), goods.getName());
goods.setShareUrl(qCodeService.getShareImageUrl(goods.getId().toString()));
String url = qCodeService.createGoodShareImage(goods.getId().toString(), goods.getPicUrl(), goods.getName());
goods.setShareUrl(url);
// 商品基本信息表litemall_goods
goodsService.updateById(goods);
@@ -194,8 +194,8 @@ public class AdminGoodsController {
goodsService.add(goods);
//将生成的分享图片地址写入数据库
qCodeService.createGoodShareImage(goods.getId().toString(), goods.getPicUrl(), goods.getName());
goods.setShareUrl(qCodeService.getShareImageUrl(goods.getId().toString()));
String url = qCodeService.createGoodShareImage(goods.getId().toString(), goods.getPicUrl(), goods.getName());
goods.setShareUrl(url);
goodsService.updateById(goods);
// 商品规格表litemall_goods_specification

View File

@@ -0,0 +1,176 @@
package org.linlinjava.litemall.admin.web;
import org.linlinjava.litemall.admin.annotation.LoginAdmin;
import org.linlinjava.litemall.core.util.JacksonUtil;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.domain.LitemallGoods;
import org.linlinjava.litemall.db.domain.LitemallGroupon;
import org.linlinjava.litemall.db.domain.LitemallGrouponRules;
import org.linlinjava.litemall.db.service.LitemallGoodsService;
import org.linlinjava.litemall.db.service.LitemallGrouponRulesService;
import org.linlinjava.litemall.db.service.LitemallGrouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/admin/groupon")
@Validated
public class AdminGrouponController {
@Autowired
private LitemallGrouponRulesService rulesService;
@Autowired
private LitemallGoodsService goodsService;
@Autowired
private LitemallGrouponService grouponService;
@GetMapping("/listRecord")
public Object listRecord(@LoginAdmin Integer adminId,
String grouponId,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
List<LitemallGroupon> grouponList = grouponService.querySelective(grouponId, page, limit, sort, order);
int total = grouponService.countSelective(grouponId, page, limit, sort, order);
List<Map<String, Object>> records = new ArrayList<>();
for (LitemallGroupon groupon : grouponList) {
Map<String, Object> RecordData = new HashMap<>();
List<LitemallGroupon> subGrouponList = grouponService.queryJoiners(groupon.getId());
LitemallGrouponRules rules = rulesService.queryById(groupon.getRulesId());
LitemallGoods goods = goodsService.findById(rules.getGoodsId());
RecordData.put("groupon", groupon);
RecordData.put("subGroupons", subGrouponList);
RecordData.put("rules", rules);
RecordData.put("goods", goods);
records.add(RecordData);
}
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", records);
return ResponseUtil.ok(data);
}
@GetMapping("/list")
public Object list(@LoginAdmin Integer adminId,
String goodsId,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
List<LitemallGrouponRules> rulesList = rulesService.querySelective(goodsId, page, limit, sort, order);
int total = rulesService.countSelective(goodsId, page, limit, sort, order);
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", rulesList);
return ResponseUtil.ok(data);
}
@PostMapping("/update")
public Object update(@LoginAdmin Integer adminId, @RequestBody String grouponRulesBody) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
Integer id = JacksonUtil.parseInteger(grouponRulesBody, "id");
Integer goodsId = JacksonUtil.parseInteger(grouponRulesBody, "goodsId");
String discount = JacksonUtil.parseString(grouponRulesBody, "discount");
Integer discountMember = JacksonUtil.parseInteger(grouponRulesBody, "discountMember");
String expireTimeString = JacksonUtil.parseString(grouponRulesBody, "expireTime");
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime expireTime = LocalDateTime.parse(expireTimeString, df);
LitemallGoods goods = goodsService.findById(goodsId);
if (goods == null) {
return ResponseUtil.badArgumentValue();
}
LitemallGrouponRules grouponRules = rulesService.queryById(id);
if (grouponRules == null) {
return ResponseUtil.badArgumentValue();
}
grouponRules.setGoodsId(goodsId);
grouponRules.setDiscount(new BigDecimal(discount));
grouponRules.setDiscountMember(discountMember);
grouponRules.setGoodsName(goods.getName());
grouponRules.setExpireTime(expireTime);
grouponRules.setPicUrl(goods.getPicUrl());
rulesService.update(grouponRules);
return ResponseUtil.ok();
}
@PostMapping("/create")
public Object create(@LoginAdmin Integer adminId, @RequestBody String grouponRulesBody) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
Integer goodsId = JacksonUtil.parseInteger(grouponRulesBody, "goodsId");
String discount = JacksonUtil.parseString(grouponRulesBody, "discount");
Integer discountMember = JacksonUtil.parseInteger(grouponRulesBody, "discountMember");
String expireTimeString = JacksonUtil.parseString(grouponRulesBody, "expireTime");
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime expireTime = LocalDateTime.parse(expireTimeString, df);
LitemallGoods goods = goodsService.findById(goodsId);
if (goods == null) {
return ResponseUtil.badArgumentValue();
}
LitemallGrouponRules grouponRules = new LitemallGrouponRules();
grouponRules.setGoodsId(goodsId);
grouponRules.setDiscount(new BigDecimal(discount));
grouponRules.setDiscountMember(discountMember);
grouponRules.setAddTime(LocalDateTime.now());
grouponRules.setGoodsName(goods.getName());
grouponRules.setExpireTime(expireTime);
grouponRules.setPicUrl(goods.getPicUrl());
rulesService.createRules(grouponRules);
return ResponseUtil.ok();
}
@PostMapping("/delete")
public Object delete(@LoginAdmin Integer adminId, @RequestBody String body) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
Integer id = JacksonUtil.parseInteger(body, "id");
rulesService.delete(id);
return ResponseUtil.ok();
}
}

View File

@@ -2,25 +2,18 @@ package org.linlinjava.litemall.admin.web;
import org.linlinjava.litemall.admin.annotation.LoginAdmin;
import org.linlinjava.litemall.core.storage.StorageService;
import org.linlinjava.litemall.core.util.CharUtil;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.domain.LitemallStorage;
import org.linlinjava.litemall.db.service.LitemallStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -35,29 +28,13 @@ public class AdminStorageController {
@Autowired
private LitemallStorageService litemallStorageService;
private String generateKey(String originalFilename){
int index = originalFilename.lastIndexOf('.');
String suffix = originalFilename.substring(index);
String key = null;
LitemallStorage storageInfo = null;
do{
key = CharUtil.getRandomString(20) + suffix;
storageInfo = litemallStorageService.findByKey(key);
}
while(storageInfo != null);
return key;
}
@GetMapping("/list")
public Object list(@LoginAdmin Integer adminId,
String key, String name,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order){
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallStorage> storageList = litemallStorageService.querySelective(key, name, page, limit, sort, order);
int total = litemallStorageService.countSelective(key, name, page, limit, sort, order);
Map<String, Object> data = new HashMap<>();
@@ -69,40 +46,21 @@ public class AdminStorageController {
@PostMapping("/create")
public Object create(@LoginAdmin Integer adminId, @RequestParam("file") MultipartFile file) throws IOException {
if(adminId == null){
if (adminId == null) {
return ResponseUtil.unlogin();
}
String originalFilename = file.getOriginalFilename();
InputStream inputStream = null;
try {
inputStream = file.getInputStream();
} catch (IOException e) {
e.printStackTrace();
return ResponseUtil.badArgumentValue();
}
String key = generateKey(originalFilename);
storageService.store(file.getInputStream(), file.getSize(), file.getContentType(), key);
String url = storageService.generateUrl(key);
LitemallStorage storageInfo = new LitemallStorage();
storageInfo.setName(originalFilename);
storageInfo.setSize((int)file.getSize());
storageInfo.setType(file.getContentType());
storageInfo.setAddTime(LocalDateTime.now());
storageInfo.setModified(LocalDateTime.now());
storageInfo.setKey(key);
storageInfo.setUrl(url);
litemallStorageService.add(storageInfo);
return ResponseUtil.ok(storageInfo);
storageService.store(file.getInputStream(), file.getSize(), file.getContentType(), originalFilename);
return ResponseUtil.ok();
}
@PostMapping("/read")
public Object read(@LoginAdmin Integer adminId, @NotNull Integer id) {
if(adminId == null){
if (adminId == null) {
return ResponseUtil.unlogin();
}
LitemallStorage storageInfo = litemallStorageService.findById(id);
if(storageInfo == null){
if (storageInfo == null) {
return ResponseUtil.badArgumentValue();
}
return ResponseUtil.ok(storageInfo);
@@ -110,7 +68,7 @@ public class AdminStorageController {
@PostMapping("/update")
public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallStorage litemallStorage) {
if(adminId == null){
if (adminId == null) {
return ResponseUtil.unlogin();
}
litemallStorageService.update(litemallStorage);
@@ -119,7 +77,7 @@ public class AdminStorageController {
@PostMapping("/delete")
public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallStorage litemallStorage) {
if(adminId == null){
if (adminId == null) {
return ResponseUtil.unlogin();
}
litemallStorageService.deleteByKey(litemallStorage.getKey());

View File

@@ -1,5 +1,5 @@
module.exports = {
NODE_ENV: '"production"',
ENV_CONFIG: '"dep"',
BASE_API: '"http://localhost:8080/admin"'
BASE_API: '"https://www.menethil.com.cn/admin"'
}

View File

@@ -0,0 +1,41 @@
import request from '@/utils/request'
export function listRecord(query) {
return request({
url: '/groupon/listRecord',
method: 'get',
params: query
})
}
export function listGroupon(query) {
return request({
url: '/groupon/list',
method: 'get',
params: query
})
}
export function deleteGroupon(data) {
return request({
url: '/groupon/delete',
method: 'post',
data
})
}
export function publishGroupon(data) {
return request({
url: '/groupon/create',
method: 'post',
data
})
}
export function editGroupon(data) {
return request({
url: '/groupon/update',
method: 'post',
data
})
}

View File

@@ -105,6 +105,21 @@ export const asyncRouterMap = [
]
},
{
path: '/groupon',
component: Layout,
redirect: 'noredirect',
name: 'grouponManage',
meta: {
title: '团购管理',
icon: 'chart'
},
children: [
{ path: 'list', component: _import('groupon/list'), name: 'list', meta: { title: '团购规则', noCache: true }},
{ path: 'record', component: _import('groupon/record'), name: 'record', meta: { title: '团购活动', noCache: true }}
]
},
{
path: '/promotion',
component: Layout,

View File

@@ -23,7 +23,7 @@
</el-form-item>
<el-form-item label="商品介绍">
<span>{{ props.row.brief }}</span>
</el-form-item>
</el-form-item>
<el-form-item label="商品单位">
<span>{{ props.row.unit }}</span>
</el-form-item>
@@ -32,14 +32,14 @@
</el-form-item>
<el-form-item label="类目ID">
<span>{{ props.row.categoryId }}</span>
</el-form-item>
</el-form-item>
<el-form-item label="品牌商ID">
<span>{{ props.row.brandId }}</span>
</el-form-item>
</el-form>
</el-form>
</template>
</el-table-column>
<el-table-column align="center" label="商品编号" prop="goodsSn">
</el-table-column>
@@ -52,6 +52,12 @@
</template>
</el-table-column>
<el-table-column align="center" property="iconUrl" label="分享图">
<template slot-scope="scope">
<img :src="scope.row.shareUrl" width="40"/>
</template>
</el-table-column>
<el-table-column align="center" label="详情" prop="detail">
<template slot-scope="scope">
<el-dialog title="商品详情" :visible.sync="detailDialogVisible">
@@ -71,19 +77,19 @@
<template slot-scope="scope">
<el-tag :type="scope.row.isNew ? 'success' : 'error' ">{{scope.row.isNew ? '新品' : '非新品'}}</el-tag>
</template>
</el-table-column>
</el-table-column>
<el-table-column align="center" label="是否热品" prop="isHot">
<template slot-scope="scope">
<el-tag :type="scope.row.isHot ? 'success' : 'error' ">{{scope.row.isHot ? '热品' : '非热品'}}</el-tag>
</template>
</el-table-column>
</el-table-column>
<el-table-column align="center" label="是否在售" prop="isOnSale">
<template slot-scope="scope">
<el-tag :type="scope.row.isOnSale ? 'success' : 'error' ">{{scope.row.isOnSale ? '在售' : '未售'}}</el-tag>
</template>
</el-table-column>
</el-table-column>
<el-table-column align="center" label="操作" width="200" class-name="small-padding fixed-width">
<template slot-scope="scope">
@@ -211,4 +217,4 @@ export default {
}
}
}
</script>
</script>

View File

@@ -0,0 +1,290 @@
<template>
<div class="app-container calendar-list-container">
<!-- 查询和其他操作 -->
<div class="filter-container">
<el-input clearable class="filter-item" style="width: 200px;" placeholder="请输入商品编号" v-model="listQuery.goodsId">
</el-input>
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">查找</el-button>
<el-button class="filter-item" type="primary" @click="handleCreate" icon="el-icon-edit">添加</el-button>
<el-button class="filter-item" type="primary" :loading="downloadLoading" icon="el-icon-download"
@click="handleDownload">导出
</el-button>
</div>
<!-- 查询结果 -->
<el-table size="small" :data="list" v-loading="listLoading" element-loading-text="正在查询中。。。" border fit
highlight-current-row>
<el-table-column type="expand">
<template slot-scope="props">
<el-form label-position="left" class="table-expand">
<el-form-item label="宣传画廊">
<img class="gallery" v-for="pic in props.row.gallery" :key="pic" :src="pic"/>
</el-form-item>
<el-form-item label="商品介绍">
<span>{{ props.row.brief }}</span>
</el-form-item>
<el-form-item label="商品单位">
<span>{{ props.row.unit }}</span>
</el-form-item>
<el-form-item label="关键字">
<span>{{ props.row.keyword }}</span>
</el-form-item>
<el-form-item label="类目ID">
<span>{{ props.row.categoryId }}</span>
</el-form-item>
<el-form-item label="品牌商ID">
<span>{{ props.row.brandId }}</span>
</el-form-item>
</el-form>
</template>
</el-table-column>
<el-table-column align="center" label="商品ID" prop="goodsId">
</el-table-column>
<el-table-column align="center" min-width="100" label="名称" prop="goodsName">
</el-table-column>
<el-table-column align="center" property="iconUrl" label="图片">
<template slot-scope="scope">
<img :src="scope.row.picUrl" width="40"/>
</template>
</el-table-column>
<el-table-column align="center" label="团购优惠" prop="discount">
</el-table-column>
<el-table-column align="center" label="团购要求" prop="discountMember">
</el-table-column>
<el-table-column align="center" label="开始时间" prop="addTime">
</el-table-column>
<el-table-column align="center" label="结束时间" prop="expireTime">
</el-table-column>
<el-table-column align="center" label="操作" width="200" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 添加或修改对话框 -->
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
<el-form :rules="rules" ref="dataForm" :model="dataForm" status-icon label-position="left" label-width="100px"
style='width: 400px; margin-left:50px;'>
<el-form-item label="商品ID" prop="goodsId">
<el-input v-model="dataForm.goodsId"></el-input>
</el-form-item>
<el-form-item label="团购折扣" prop="discount">
<el-input v-model="dataForm.discount"></el-input>
</el-form-item>
<el-form-item label="团购人数要求" prop="discountMember">
<el-input v-model="dataForm.discountMember"></el-input>
</el-form-item>
<el-form-item label="过期时间" prop="expireTime">
<el-date-picker v-model="dataForm.expireTime" type="datetime" placeholder="选择日期"
value-format="yyyy-MM-dd HH:mm:ss">
</el-date-picker>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">取消</el-button>
<el-button v-if="dialogStatus=='create'" type="primary" @click="createData">确定</el-button>
<el-button v-else type="primary" @click="updateData">确定</el-button>
</div>
</el-dialog>
<!-- 分页 -->
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-page="listQuery.page"
:page-sizes="[10,20,30,50]" :page-size="listQuery.limit"
layout="total, sizes, prev, pager, next, jumper" :total="total">
</el-pagination>
</div>
<el-tooltip placement="top" content="返回顶部">
<back-to-top :visibilityHeight="100"></back-to-top>
</el-tooltip>
</div>
</template>
<style>
.table-expand {
font-size: 0;
}
.table-expand label {
width: 100px;
color: #99a9bf;
}
.table-expand .el-form-item {
margin-right: 0;
margin-bottom: 0;
}
.gallery {
width: 80px;
margin-right: 10px;
}
</style>
<script>
import {listGroupon, publishGroupon, deleteGroupon, editGroupon} from '@/api/groupon'
import BackToTop from '@/components/BackToTop'
export default {
name: 'GoodsList',
components: {BackToTop},
data() {
return {
list: [],
total: 0,
listLoading: true,
listQuery: {
page: 1,
limit: 20,
goodsId: undefined,
sort: 'add_time',
order: 'desc'
},
goodsDetail: '',
detailDialogVisible: false,
downloadLoading: false,
dataForm: {
id: undefined,
goodsId: '',
discount: '',
discountMember: '',
expireTime: undefined,
},
dialogFormVisible: false,
dialogStatus: '',
textMap: {
update: '编辑',
create: '创建'
},
}
},
created() {
this.getList()
},
methods: {
getList() {
this.listLoading = true
listGroupon(this.listQuery).then(response => {
this.list = response.data.data.items
this.total = response.data.data.total
this.listLoading = false
}).catch(() => {
this.list = []
this.total = 0
this.listLoading = false
})
},
handleFilter() {
this.listQuery.page = 1
this.getList()
},
handleSizeChange(val) {
this.listQuery.limit = val
this.getList()
},
handleCurrentChange(val) {
this.listQuery.page = val
this.getList()
},
resetForm() {
this.dataForm = {
id: undefined,
goodsId: '',
discount: '',
discountMember: '',
expireTime: undefined,
}
},
handleCreate() {
this.resetForm()
this.dialogStatus = 'create'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['dataForm'].clearValidate()
})
},
createData() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
publishGroupon(this.dataForm).then(response => {
this.list.unshift(response.data.data)
this.dialogFormVisible = false
this.$notify({
title: '成功',
message: '创建成功',
type: 'success',
duration: 2000
})
})
}
})
},
handleUpdate(row) {
this.dataForm = Object.assign({}, row)
this.dialogStatus = 'update'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['dataForm'].clearValidate()
})
},
updateData() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
editGroupon(this.dataForm).then(() => {
for (const v of this.list) {
if (v.id === this.dataForm.id) {
const index = this.list.indexOf(v)
this.list.splice(index, 1, this.dataForm)
break
}
}
this.dialogFormVisible = false
this.$notify({
title: '成功',
message: '更新成功',
type: 'success',
duration: 2000
})
})
}
})
},
handleDelete(row) {
deleteGroupon(row).then(response => {
this.$notify({
title: '成功',
message: '删除成功',
type: 'success',
duration: 2000
})
const index = this.list.indexOf(row)
this.list.splice(index, 1)
})
},
handleDownload() {
this.downloadLoading = true
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['商品ID', '名称', '首页主图', '折扣', '人数要求', '活动开始时间', '活动结束时间']
const filterVal = ['id', 'name', 'pic_url', 'discount', 'discountMember', 'addTime', 'expireTime']
excel.export_json_to_excel2(tHeader, this.list, filterVal, '商品信息')
this.downloadLoading = false
})
}
}
}
</script>

View File

@@ -0,0 +1,158 @@
<template>
<div class="app-container calendar-list-container">
<!-- 查询和其他操作 -->
<div class="filter-container">
<el-input clearable class="filter-item" style="width: 200px;" placeholder="请输入商品编号" v-model="listQuery.goodsId">
</el-input>
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">查找</el-button>
<!--<el-button class="filter-item" type="primary" @click="handleCreate" icon="el-icon-edit">添加</el-button>-->
<el-button class="filter-item" type="primary" :loading="downloadLoading" icon="el-icon-download"
@click="handleDownload">导出
</el-button>
</div>
<!-- 查询结果 -->
<el-table size="small" :data="list" v-loading="listLoading" element-loading-text="正在查询中。。。" border fit
highlight-current-row>
<el-table-column type="expand">
<template slot-scope="scope">
<el-table :data="scope.row.subGroupons" border style="width: 100%">
<el-table-column align="center" label="订单ID" prop="orderId">
</el-table-column>
<el-table-column align="center" label="用户ID" prop="userId">
</el-table-column>
</el-table>
</template>
</el-table-column>
<el-table-column align="center" label="订单ID" prop="groupon.orderId">
</el-table-column>
<el-table-column align="center" label="用户ID" prop="groupon.userId">
</el-table-column>
<el-table-column align="center" label="参与人数" prop="subGroupons.length">
</el-table-column>
<el-table-column align="center" label="团购折扣" prop="rules.discount">
</el-table-column>
<el-table-column align="center" label="团购要求" prop="rules.discountMember">
</el-table-column>
<el-table-column align="center" property="iconUrl" label="分享图片">
<template slot-scope="scope">
<img :src="scope.row.groupon.shareUrl" width="40"/>
</template>
</el-table-column>
<el-table-column align="center" label="开始时间" prop="rules.addTime">
</el-table-column>
<el-table-column align="center" label="结束时间" prop="rules.expireTime">
</el-table-column>
</el-table>
<!-- 分页 -->
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-page="listQuery.page"
:page-sizes="[10,20,30,50]" :page-size="listQuery.limit"
layout="total, sizes, prev, pager, next, jumper" :total="total">
</el-pagination>
</div>
<el-tooltip placement="top" content="返回顶部">
<back-to-top :visibilityHeight="100"></back-to-top>
</el-tooltip>
</div>
</template>
<style>
.table-expand {
font-size: 0;
}
.table-expand label {
width: 100px;
color: #99a9bf;
}
.table-expand .el-form-item {
margin-right: 0;
margin-bottom: 0;
}
.gallery {
width: 80px;
margin-right: 10px;
}
</style>
<script>
import {listRecord} from '@/api/groupon'
import BackToTop from '@/components/BackToTop'
export default {
name: 'GoodsList',
components: {BackToTop},
data() {
return {
list: [],
total: 0,
listLoading: true,
listQuery: {
page: 1,
limit: 20,
goodsId: undefined,
sort: 'add_time',
order: 'desc'
},
goodsDetail: '',
detailDialogVisible: false,
downloadLoading: false,
}
},
created() {
this.getList()
},
methods: {
getList() {
this.listLoading = true
listRecord(this.listQuery).then(response => {
this.list = response.data.data.items
this.total = response.data.data.total
this.listLoading = false
}).catch(() => {
this.list = []
this.total = 0
this.listLoading = false
})
},
handleFilter() {
this.listQuery.page = 1
this.getList()
},
handleSizeChange(val) {
this.listQuery.limit = val
this.getList()
},
handleCurrentChange(val) {
this.listQuery.page = val
this.getList()
},
handleDownload() {
this.downloadLoading = true
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['商品ID', '名称', '首页主图', '折扣', '人数要求', '活动开始时间', '活动结束时间']
const filterVal = ['id', 'name', 'pic_url', 'discount', 'discountMember', 'addTime', 'expireTime']
excel.export_json_to_excel2(tHeader, this.list, filterVal, '商品信息')
this.downloadLoading = false
})
}
}
}
</script>

View File

@@ -5,7 +5,7 @@ spring:
encoding: UTF-8
server:
port: 8080
port: 8082
logging:
level:

View File

@@ -18,31 +18,37 @@ import java.util.Set;
@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(IllegalArgumentException.class)
@ResponseBody
public Object badArgumentHandler(IllegalArgumentException e){
e.printStackTrace();
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
@ResponseBody
public Object argumentHandler(MethodArgumentTypeMismatchException e){
public Object badArgumentHandler(MethodArgumentTypeMismatchException e){
e.printStackTrace();
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(MissingServletRequestParameterException.class)
@ResponseBody
public Object argumentHandler(MissingServletRequestParameterException e){
public Object badArgumentHandler(MissingServletRequestParameterException e){
e.printStackTrace();
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(HttpMessageNotReadableException.class)
@ResponseBody
public Object httpMessageNotReadableHandler(HttpMessageNotReadableException e){
public Object badArgumentHandler(HttpMessageNotReadableException e){
e.printStackTrace();
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(ValidationException.class)
@ResponseBody
public Object handle(ValidationException e) {
public Object badArgumentHandler(ValidationException e) {
e.printStackTrace();
if(e instanceof ConstraintViolationException){
ConstraintViolationException exs = (ConstraintViolationException) e;
@@ -57,7 +63,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler(Exception.class)
@ResponseBody
public Object exceptionHandler(Exception e){
public Object seriousHandler(Exception e){
e.printStackTrace();
return ResponseUtil.serious();
}

View File

@@ -0,0 +1,119 @@
package org.linlinjava.litemall.core.qcode;
import cn.binarywang.wx.miniapp.api.WxMaService;
import me.chanjar.weixin.common.error.WxErrorException;
import org.linlinjava.litemall.core.storage.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public abstract class QCodeBase {
@Autowired
protected WxMaService wxMaService;
@Autowired
protected StorageService storageService;
protected abstract String getKeyName(String id);
/**
* 获取图片地址
*
* @param id
* @return
*/
public String getShareImageUrl(String id) {
return storageService.generateUrl(getKeyName(id));
}
protected BufferedImage getQCode(String scene, String page) {
//创建该商品的二维码
File file = null;
try {
file = wxMaService.getQrcodeService().createWxaCodeUnlimit(scene, page);
FileInputStream inputStream = new FileInputStream(file);
BufferedImage qrCodeImage = ImageIO.read(inputStream);
return qrCodeImage;
} catch (WxErrorException | IOException e) {
e.printStackTrace();
}
return null;
}
protected void saveImage(String id, byte[] imageData) {
// MultipartFile multipartFile = new MockMultipartFile(getKeyName(id), getKeyName(id), "image/jpeg", imageData);
// //存储分享图
// storageService.store(multipartFile, getKeyName(id));
}
/**
* 居中写文字
*
* @param baseImage
* @param textToWrite
* @param font
* @param color
* @param y
*/
protected void drawTextInImgCenter(BufferedImage baseImage, String textToWrite, Font font, Color color, int y) {
Graphics2D g2D = (Graphics2D) baseImage.getGraphics();
g2D.setColor(color);
g2D.setFont(font);
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// 计算文字长度计算居中的x点坐标
FontMetrics fm = g2D.getFontMetrics(font);
int textWidth = fm.stringWidth(textToWrite);
int widthX = (baseImage.getWidth() - textWidth) / 2;
// 表示这段文字在图片上的位置(x,y) .第一个是你设置的内容。
g2D.drawString(textToWrite, widthX, y);
// 释放对象
g2D.dispose();
}
/**
* 写上文字
*
* @param baseImage
* @param textToWrite
* @param font
* @param color
* @param x
* @param y
*/
protected void drawTextInImg(BufferedImage baseImage, String textToWrite, Font font, Color color, int x, int y) {
Graphics2D g2D = (Graphics2D) baseImage.getGraphics();
g2D.setColor(color);
g2D.setFont(font);
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2D.drawString(textToWrite, x, y);
g2D.dispose();
}
/**
* 画中画
*
* @param baseImage
* @param imageToWrite
* @param x
* @param y
* @param width
* @param height
*/
protected void drawImgInImg(BufferedImage baseImage, BufferedImage imageToWrite, int x, int y, int width, int height) {
Graphics2D g2D = (Graphics2D) baseImage.getGraphics();
g2D.drawImage(imageToWrite, x, y, width, height, null);
g2D.dispose();
}
}

View File

@@ -0,0 +1,96 @@
package org.linlinjava.litemall.core.qcode;
import org.linlinjava.litemall.core.system.SystemConfig;
import org.springframework.core.io.ClassPathResource;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.URL;
public class QCodeGoodShare extends QCodeBase {
@Override
protected String getKeyName(String id) {
return "GOOD_QCODE_" + id + ".jpg";
}
/**
* 创建商品分享图
*
* @param goodId
* @param goodPicUrl
* @param goodName
*/
public void createGoodShareImage(String goodId, String goodPicUrl, String goodName) {
if (!SystemConfig.isAutoCreateShareImage())
return;
BufferedImage qrCodeImage = getQCode("goods," + goodId, "pages/index/index");
//将商品图片,商品名字,商城名字画到模版图中
byte[] imageData = new byte[0];
try {
imageData = drawPicture(qrCodeImage, goodPicUrl, goodName, SystemConfig.getMallName());
} catch (IOException e) {
e.printStackTrace();
}
saveImage(goodId, imageData);
}
/**
* 将商品图片,商品名字画到模版图中
*
* @param qrCodeImage 二维码图片
* @param goodPicUrl 商品图片地址
* @param goodName 商品名称
* @return
* @throws IOException
*/
private byte[] drawPicture(BufferedImage qrCodeImage, String goodPicUrl, String goodName, String shopName) throws IOException {
//底图
ClassPathResource redResource = new ClassPathResource("back.jpg");
BufferedImage red = ImageIO.read(redResource.getInputStream());
//商品图片
URL goodPic = new URL(goodPicUrl);
BufferedImage goodImage = ImageIO.read(goodPic);
// --- 画图 ---
//底层空白 bufferedImage
BufferedImage baseImage = new BufferedImage(red.getWidth(), red.getHeight(), BufferedImage.TYPE_4BYTE_ABGR_PRE);
//画上图片
drawImgInImg(baseImage, red, 0, 0, red.getWidth(), red.getHeight());
//画上商品图片
drawImgInImg(baseImage, goodImage, 56, 135, 720, 720);
//画上小程序二维码
drawImgInImg(baseImage, qrCodeImage, 442, 1006, 340, 340);
Font font = new Font("Microsoft YaHei", Font.PLAIN, 42);
Color color = new Color(167, 136, 69);
//写上商品名称
drawTextInImg(baseImage, goodName, font, color, 112, 955);
//写上商城名称
drawTextInImgCenter(baseImage, shopName, font, color, 98);
//转jpg
BufferedImage result = new BufferedImage(baseImage.getWidth(), baseImage
.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
result.getGraphics().drawImage(baseImage, 0, 0, null);
ByteArrayOutputStream bs = new ByteArrayOutputStream();
ImageIO.write(result, "jpg", bs);
//最终byte数组
return bs.toByteArray();
}
}

View File

@@ -0,0 +1,88 @@
package org.linlinjava.litemall.core.qcode;
import org.linlinjava.litemall.core.system.SystemConfig;
import org.linlinjava.litemall.db.domain.LitemallGroupon;
import org.springframework.core.io.ClassPathResource;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
public class QCodeGroupon extends QCodeBase {
@Override
protected String getKeyName(String id) {
return null;
}
public void createGrouponShareImage(String goodName, String goodPicUrl, LitemallGroupon groupon) {
try {
BufferedImage qrCodeImage = getQCode("groupon," + groupon.getId(), "pages/index/index");
//将商品图片,商品名字,商城名字画到模版图中
byte[] imageData = drawPicture(qrCodeImage, goodPicUrl, goodName, SystemConfig.getMallName());
saveImage(groupon.getId().toString(), imageData);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 将商品图片,商品名字画到模版图中
*
* @param qrCodeImage 二维码图片
* @param goodPicUrl 商品图片地址
* @param goodName 商品名称
* @return
* @throws IOException
*/
private byte[] drawPicture(BufferedImage qrCodeImage, String goodPicUrl, String goodName, String shopName) throws IOException {
//底图
ClassPathResource redResource = new ClassPathResource("back.jpg");
BufferedImage red = ImageIO.read(redResource.getInputStream());
//商品图片
URL goodPic = new URL(goodPicUrl);
BufferedImage goodImage = ImageIO.read(goodPic);
// --- 画图 ---
//底层空白 bufferedImage
BufferedImage baseImage = new BufferedImage(red.getWidth(), red.getHeight(), BufferedImage.TYPE_4BYTE_ABGR_PRE);
//画上图片
drawImgInImg(baseImage, red, 0, 0, red.getWidth(), red.getHeight());
//画上商品图片
drawImgInImg(baseImage, goodImage, 56, 135, 720, 720);
//画上小程序二维码
drawImgInImg(baseImage, qrCodeImage, 442, 1006, 340, 340);
Font font = new Font("Microsoft YaHei", Font.PLAIN, 42);
Color color = new Color(167, 136, 69);
//写上商品名称
drawTextInImg(baseImage, goodName, font, color, 112, 955);
//写上商城名称
drawTextInImgCenter(baseImage, shopName, font, color, 98);
//转jpg
BufferedImage result = new BufferedImage(baseImage.getWidth(), baseImage
.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
result.getGraphics().drawImage(baseImage, 0, 0, null);
ByteArrayOutputStream bs = new ByteArrayOutputStream();
ImageIO.write(result, "jpg", bs);
//最终byte数组
return bs.toByteArray();
}
}

View File

@@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
import me.chanjar.weixin.common.error.WxErrorException;
import org.linlinjava.litemall.core.storage.StorageService;
import org.linlinjava.litemall.core.system.SystemConfig;
import org.linlinjava.litemall.db.domain.LitemallGroupon;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
@@ -22,6 +23,31 @@ public class QCodeService {
@Autowired
private StorageService storageService;
public String createGrouponShareImage(String goodName, String goodPicUrl, LitemallGroupon groupon) {
try {
//创建该商品的二维码
File file = wxMaService.getQrcodeService().createWxaCodeUnlimit("groupon," + groupon.getId(), "pages/index/index");
FileInputStream inputStream = new FileInputStream(file);
//将商品图片,商品名字,商城名字画到模版图中
byte[] imageData = drawPicture(inputStream, goodPicUrl, goodName);
ByteArrayInputStream inputStream2 = new ByteArrayInputStream(imageData);
//存储分享图
String url = storageService.store(inputStream2, imageData.length, "image/jpeg", getKeyName(groupon.getId().toString()));
return url;
} catch (WxErrorException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return "";
}
/**
* 创建商品分享图
*
@@ -29,32 +55,30 @@ public class QCodeService {
* @param goodPicUrl
* @param goodName
*/
public void createGoodShareImage(String goodId, String goodPicUrl, String goodName) {
public String createGoodShareImage(String goodId, String goodPicUrl, String goodName) {
if (!SystemConfig.isAutoCreateShareImage())
return;
return "";
try {
//创建该商品的二维码
File file = wxMaService.getQrcodeService().createWxaCodeUnlimit(goodId, "pages/index/index");
File file = wxMaService.getQrcodeService().createWxaCodeUnlimit("goods," + goodId, "pages/index/index");
FileInputStream inputStream = new FileInputStream(file);
//将商品图片,商品名字,商城名字画到模版图中
byte[] imageData = drawPicture(inputStream, goodPicUrl, goodName, SystemConfig.getMallName());
byte[] imageData = drawPicture(inputStream, goodPicUrl, goodName);
ByteArrayInputStream inputStream2 = new ByteArrayInputStream(imageData);
//存储分享图
storageService.store(inputStream2, imageData.length, "image/jpeg", getKeyName(goodId));
String url = storageService.store(inputStream2, imageData.length, "image/jpeg", getKeyName(goodId));
return url;
} catch (WxErrorException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (FontFormatException e) {
e.printStackTrace();
}
}
public String getShareImageUrl(String goodId) {
return storageService.generateUrl(getKeyName(goodId));
return "";
}
private String getKeyName(String goodId) {
@@ -70,9 +94,9 @@ public class QCodeService {
* @return
* @throws IOException
*/
private byte[] drawPicture(InputStream qrCodeImg, String goodPicUrl, String goodName, String shopName) throws IOException, FontFormatException {
private byte[] drawPicture(InputStream qrCodeImg, String goodPicUrl, String goodName) throws IOException {
//底图
ClassPathResource redResource = new ClassPathResource("back.jpg");
ClassPathResource redResource = new ClassPathResource("back.png");
BufferedImage red = ImageIO.read(redResource.getInputStream());
@@ -92,16 +116,16 @@ public class QCodeService {
drawImgInImg(baseImage, red, 0, 0, red.getWidth(), red.getHeight());
//画上商品图片
drawImgInImg(baseImage, goodImage, 56, 135, 720, 720);
drawImgInImg(baseImage, goodImage, 71, 69, 660, 660);
//画上小程序二维码
drawImgInImg(baseImage, qrCodeImage, 442, 1006, 340, 340);
drawImgInImg(baseImage, qrCodeImage, 448, 767, 300, 300);
//写上商品名称
drawTextInImg(baseImage, goodName, 112, 955);
drawTextInImg(baseImage, goodName, 65, 867);
//写上商城名称
drawTextInImgCenter(baseImage, shopName, 112, 98);
// drawTextInImgCenter(baseImage, shopName, 98);
//转jpg
@@ -115,13 +139,13 @@ public class QCodeService {
return bs.toByteArray();
}
private void drawTextInImgCenter(BufferedImage baseImage, String textToWrite, int x, int y) {
private void drawTextInImgCenter(BufferedImage baseImage, String textToWrite, int y) {
Graphics2D g2D = (Graphics2D) baseImage.getGraphics();
g2D.setColor(new Color(167, 136, 69));
String fontName = "Microsoft YaHei";
Font f = new Font(fontName, Font.PLAIN, 42);
Font f = new Font(fontName, Font.PLAIN, 28);
g2D.setFont(f);
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
@@ -131,17 +155,17 @@ public class QCodeService {
int widthX = (baseImage.getWidth() - textWidth) / 2;
// 表示这段文字在图片上的位置(x,y) .第一个是你设置的内容。
g2D.drawString(textToWrite, widthX, 100);
g2D.drawString(textToWrite, widthX, y);
// 释放对象
g2D.dispose();
}
private void drawTextInImg(BufferedImage baseImage, String textToWrite, int x, int y) throws IOException, FontFormatException {
private void drawTextInImg(BufferedImage baseImage, String textToWrite, int x, int y) {
Graphics2D g2D = (Graphics2D) baseImage.getGraphics();
g2D.setColor(new Color(167, 136, 69));
//TODO 注意,这里的字体必须安装在服务器上
g2D.setFont(new Font("Microsoft YaHei", Font.PLAIN, 42));
g2D.setFont(new Font("Microsoft YaHei", Font.PLAIN, 28));
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2D.drawString(textToWrite, x, y);

View File

@@ -58,7 +58,7 @@ public class QiniuStorage implements Storage {
}
/**
* 阿里云OSS对象存储简单上传实现
* 七牛云OSS对象存储简单上传实现
*/
@Override
public void store(InputStream inputStream, long contentLength, String contentType, String keyName) {

View File

@@ -16,7 +16,7 @@ public interface Storage {
* @param inputStream 文件输入流
* @param contentLength 文件长度
* @param contentType 文件类型
* @param keyName 文件索引
* @param keyName 文件名
*/
void store(InputStream inputStream, long contentLength, String contentType, String keyName);

View File

@@ -1,10 +1,15 @@
package org.linlinjava.litemall.core.storage;
import org.linlinjava.litemall.core.util.CharUtil;
import org.linlinjava.litemall.db.domain.LitemallStorage;
import org.linlinjava.litemall.db.service.LitemallStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.web.multipart.MultipartFile;
import java.io.InputStream;
import java.nio.file.Path;
import java.time.LocalDateTime;
import java.util.stream.Stream;
/**
@@ -13,6 +18,8 @@ import java.util.stream.Stream;
public class StorageService {
private String active;
private Storage storage;
@Autowired
private LitemallStorageService litemallStorageService;
public String getActive() {
return active;
@@ -32,13 +39,44 @@ public class StorageService {
/**
* 存储一个文件对象
* @param inputStream 文件输入流
*
* @param inputStream 文件输入流
* @param contentLength 文件长度
* @param contentType 文件类型
* @param keyName 文件索引名
* @param contentType 文件类型
* @param fileName 文件索引名
*/
public void store(InputStream inputStream, long contentLength, String contentType, String keyName) {
storage.store(inputStream, contentLength, contentType, keyName);
public String store(InputStream inputStream, long contentLength, String contentType, String fileName) {
String key = generateKey(fileName);
storage.store(inputStream, contentLength, contentType, key);
String url = generateUrl(key);
LitemallStorage storageInfo = new LitemallStorage();
storageInfo.setName(fileName);
storageInfo.setSize((int) contentLength);
storageInfo.setType(contentType);
storageInfo.setAddTime(LocalDateTime.now());
storageInfo.setModified(LocalDateTime.now());
storageInfo.setKey(key);
storageInfo.setUrl(url);
litemallStorageService.add(storageInfo);
return url;
}
private String generateKey(String originalFilename) {
int index = originalFilename.lastIndexOf('.');
String suffix = originalFilename.substring(index);
String key = null;
LitemallStorage storageInfo = null;
do {
key = CharUtil.getRandomString(20) + suffix;
storageInfo = litemallStorageService.findByKey(key);
}
while (storageInfo != null);
return key;
}
public Stream<Path> loadAll() {

View File

@@ -21,7 +21,6 @@ public class StorageAutoConfiguration {
@Bean
public StorageService storageService() {
StorageService storageService = new StorageService();
Map<String, Storage> supportedStorage = new HashMap<String, Storage>(3);
String active = this.properties.getActive();
storageService.setActive(active);
if(active.equals("local")){
@@ -34,7 +33,7 @@ public class StorageAutoConfiguration {
storageService.setStorage(tencentStorage());
}
else if(active.equals("qiniu")){
storageService.setStorage(tencentStorage());
storageService.setStorage(qiniuStorage());
}
else{
throw new RuntimeException("当前存储模式 " + active + " 不支持");

View File

@@ -22,7 +22,11 @@ class SystemInistService {
private void inist() {
systemInistService = this;
SystemInfoPrinter.printInfo("Litemall 初始化信息", getSystemInfo());
try {
SystemInfoPrinter.printInfo("Litemall 初始化信息", getSystemInfo());
} catch (Exception e) {
e.printStackTrace();
}
}
private Map<String, String> getSystemInfo() {
@@ -48,6 +52,7 @@ class SystemInistService {
infos.put("本地对象访问地址", environment.getProperty("litemall.storage.local.address"));
infos.put("本地对象访问端口", environment.getProperty("litemall.storage.local.port"));
// 微信相关信息
infos.put(SystemInfoPrinter.CREATE_PART_COPPER + 2, "微信相关");
infos.put("微信APP KEY", environment.getProperty("litemall.wx.app-id"));
infos.put("微信APP-SECRET", environment.getProperty("litemall.wx.app-secret"));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@@ -45,9 +45,9 @@
<!--数据库连接信息-->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/litemall?useUnicode=true&amp;characterEncoding=UTF-8&amp;serverTimezone=UTC&amp;verifyServerCertificate=false&amp;useSSL=false"
userId="litemall"
password="litemall123456"/>
connectionURL="jdbc:mysql://127.0.0.1:3306/litemall2?useUnicode=true&amp;characterEncoding=UTF-8&amp;serverTimezone=UTC&amp;verifyServerCertificate=false&amp;useSSL=false"
userId="root"
password="Menethil.2822"/>
<javaModelGenerator targetPackage="org.linlinjava.litemall.db.domain" targetProject="src/main/java"/>
@@ -172,5 +172,15 @@
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride javaType="java.time.LocalDateTime" column="expire_time"/>
</table>
<table tableName="litemall_groupon_rules">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
<columnOverride javaType="java.time.LocalDateTime" column="expire_time"/>
</table>
<table tableName="litemall_groupon">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride javaType="java.time.LocalDateTime" column="add_time"/>
</table>
</context>
</generatorConfiguration>

View File

@@ -0,0 +1,39 @@
/*
Navicat MySQL Data Transfer
Source Server : 127.0.0.1
Source Server Type : MySQL
Source Server Version : 80011
Source Host : localhost:3306
Source Schema : litemall2
Target Server Type : MySQL
Target Server Version : 80011
File Encoding : 65001
Date: 06/08/2018 20:16:26
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for litemall_groupon
-- ----------------------------
DROP TABLE IF EXISTS `litemall_groupon`;
CREATE TABLE `litemall_groupon` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`order_id` int(11) NOT NULL COMMENT '关联的订单ID',
`groupon_id` int(11) NULL DEFAULT 0 COMMENT '参与的团购ID仅当user_type不是1',
`rules_id` int(11) NOT NULL COMMENT '团购规则ID关联litemall_groupon_rules表ID字段',
`user_id` int(11) NOT NULL COMMENT '用户ID',
`creator_user_id` int(11) NOT NULL COMMENT '创建者ID',
`add_time` datetime(0) NOT NULL COMMENT '创建时间',
`share_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '团购分享图片地址',
`payed` tinyint(1) NOT NULL COMMENT '是否已经支付',
`deleted` tinyint(1) NULL DEFAULT 0 COMMENT '逻辑删除',
`version` int(11) NULL DEFAULT 0 COMMENT '乐观锁字段',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 44 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -0,0 +1,38 @@
/*
Navicat MySQL Data Transfer
Source Server : 127.0.0.1
Source Server Type : MySQL
Source Server Version : 80011
Source Host : localhost:3306
Source Schema : litemall2
Target Server Type : MySQL
Target Server Version : 80011
File Encoding : 65001
Date: 06/08/2018 20:16:37
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for litemall_groupon_rules
-- ----------------------------
DROP TABLE IF EXISTS `litemall_groupon_rules`;
CREATE TABLE `litemall_groupon_rules` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`goods_id` int(11) NOT NULL COMMENT '商品表的商品ID',
`goods_name` varchar(127) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '商品名称',
`pic_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商品图片或者商品货品图片',
`discount` decimal(63, 0) NOT NULL COMMENT '优惠金额',
`discount_member` int(11) NOT NULL COMMENT '达到优惠条件的人数',
`add_time` datetime(0) NOT NULL COMMENT '创建时间',
`expire_time` datetime(0) NULL DEFAULT NULL COMMENT '团购过期时间',
`deleted` tinyint(1) NULL DEFAULT NULL COMMENT '逻辑删除',
`version` int(11) NULL DEFAULT NULL COMMENT '乐观锁字段',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -0,0 +1,159 @@
package org.linlinjava.litemall.db.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.linlinjava.litemall.db.domain.LitemallGroupon;
import org.linlinjava.litemall.db.domain.LitemallGrouponExample;
public interface LitemallGrouponMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
long countByExample(LitemallGrouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
int deleteByExample(LitemallGrouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
int insert(LitemallGroupon record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
int insertSelective(LitemallGroupon record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallGroupon selectOneByExample(LitemallGrouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallGroupon selectOneByExampleSelective(@Param("example") LitemallGrouponExample example, @Param("selective") LitemallGroupon.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<LitemallGroupon> selectByExampleSelective(@Param("example") LitemallGrouponExample example, @Param("selective") LitemallGroupon.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
List<LitemallGroupon> selectByExample(LitemallGrouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallGroupon selectByPrimaryKeySelective(@Param("id") Integer id, @Param("selective") LitemallGroupon.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
LitemallGroupon selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallGroupon selectByPrimaryKeyWithLogicalDelete(@Param("id") Integer id, @Param("andLogicalDeleted") boolean andLogicalDeleted);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") LitemallGroupon record, @Param("example") LitemallGrouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
int updateByExample(@Param("record") LitemallGroupon record, @Param("example") LitemallGrouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(LitemallGroupon record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
int updateByPrimaryKey(LitemallGroupon record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int logicalDeleteByExample(@Param("example") LitemallGrouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int logicalDeleteByPrimaryKey(Integer id);
}

View File

@@ -0,0 +1,159 @@
package org.linlinjava.litemall.db.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.linlinjava.litemall.db.domain.LitemallGrouponRules;
import org.linlinjava.litemall.db.domain.LitemallGrouponRulesExample;
public interface LitemallGrouponRulesMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
long countByExample(LitemallGrouponRulesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
int deleteByExample(LitemallGrouponRulesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
int insert(LitemallGrouponRules record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
int insertSelective(LitemallGrouponRules record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallGrouponRules selectOneByExample(LitemallGrouponRulesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallGrouponRules selectOneByExampleSelective(@Param("example") LitemallGrouponRulesExample example, @Param("selective") LitemallGrouponRules.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<LitemallGrouponRules> selectByExampleSelective(@Param("example") LitemallGrouponRulesExample example, @Param("selective") LitemallGrouponRules.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
List<LitemallGrouponRules> selectByExample(LitemallGrouponRulesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallGrouponRules selectByPrimaryKeySelective(@Param("id") Integer id, @Param("selective") LitemallGrouponRules.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
LitemallGrouponRules selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallGrouponRules selectByPrimaryKeyWithLogicalDelete(@Param("id") Integer id, @Param("andLogicalDeleted") boolean andLogicalDeleted);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") LitemallGrouponRules record, @Param("example") LitemallGrouponRulesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
int updateByExample(@Param("record") LitemallGrouponRules record, @Param("example") LitemallGrouponRulesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(LitemallGrouponRules record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
int updateByPrimaryKey(LitemallGrouponRules record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int logicalDeleteByExample(@Param("example") LitemallGrouponRulesExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int logicalDeleteByPrimaryKey(Integer id);
}

View File

@@ -0,0 +1,623 @@
package org.linlinjava.litemall.db.domain;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
public class LitemallGroupon {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static final Boolean NOT_DELETED = false;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static final Boolean IS_DELETED = true;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon.id
*
* @mbg.generated
*/
private Integer id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon.order_id
*
* @mbg.generated
*/
private Integer orderId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon.groupon_id
*
* @mbg.generated
*/
private Integer grouponId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon.rules_id
*
* @mbg.generated
*/
private Integer rulesId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon.user_id
*
* @mbg.generated
*/
private Integer userId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon.creator_user_id
*
* @mbg.generated
*/
private Integer creatorUserId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon.add_time
*
* @mbg.generated
*/
private LocalDateTime addTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon.share_url
*
* @mbg.generated
*/
private String shareUrl;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon.payed
*
* @mbg.generated
*/
private Boolean payed;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon.deleted
*
* @mbg.generated
*/
private Boolean deleted;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon.version
*
* @mbg.generated
*/
private Integer version;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon.id
*
* @return the value of litemall_groupon.id
*
* @mbg.generated
*/
public Integer getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon.id
*
* @param id the value for litemall_groupon.id
*
* @mbg.generated
*/
public void setId(Integer id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon.order_id
*
* @return the value of litemall_groupon.order_id
*
* @mbg.generated
*/
public Integer getOrderId() {
return orderId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon.order_id
*
* @param orderId the value for litemall_groupon.order_id
*
* @mbg.generated
*/
public void setOrderId(Integer orderId) {
this.orderId = orderId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon.groupon_id
*
* @return the value of litemall_groupon.groupon_id
*
* @mbg.generated
*/
public Integer getGrouponId() {
return grouponId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon.groupon_id
*
* @param grouponId the value for litemall_groupon.groupon_id
*
* @mbg.generated
*/
public void setGrouponId(Integer grouponId) {
this.grouponId = grouponId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon.rules_id
*
* @return the value of litemall_groupon.rules_id
*
* @mbg.generated
*/
public Integer getRulesId() {
return rulesId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon.rules_id
*
* @param rulesId the value for litemall_groupon.rules_id
*
* @mbg.generated
*/
public void setRulesId(Integer rulesId) {
this.rulesId = rulesId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon.user_id
*
* @return the value of litemall_groupon.user_id
*
* @mbg.generated
*/
public Integer getUserId() {
return userId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon.user_id
*
* @param userId the value for litemall_groupon.user_id
*
* @mbg.generated
*/
public void setUserId(Integer userId) {
this.userId = userId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon.creator_user_id
*
* @return the value of litemall_groupon.creator_user_id
*
* @mbg.generated
*/
public Integer getCreatorUserId() {
return creatorUserId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon.creator_user_id
*
* @param creatorUserId the value for litemall_groupon.creator_user_id
*
* @mbg.generated
*/
public void setCreatorUserId(Integer creatorUserId) {
this.creatorUserId = creatorUserId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon.add_time
*
* @return the value of litemall_groupon.add_time
*
* @mbg.generated
*/
public LocalDateTime getAddTime() {
return addTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon.add_time
*
* @param addTime the value for litemall_groupon.add_time
*
* @mbg.generated
*/
public void setAddTime(LocalDateTime addTime) {
this.addTime = addTime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon.share_url
*
* @return the value of litemall_groupon.share_url
*
* @mbg.generated
*/
public String getShareUrl() {
return shareUrl;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon.share_url
*
* @param shareUrl the value for litemall_groupon.share_url
*
* @mbg.generated
*/
public void setShareUrl(String shareUrl) {
this.shareUrl = shareUrl;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon.payed
*
* @return the value of litemall_groupon.payed
*
* @mbg.generated
*/
public Boolean getPayed() {
return payed;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon.payed
*
* @param payed the value for litemall_groupon.payed
*
* @mbg.generated
*/
public void setPayed(Boolean payed) {
this.payed = payed;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon.deleted
*
* @return the value of litemall_groupon.deleted
*
* @mbg.generated
*/
public Boolean getDeleted() {
return deleted;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon.deleted
*
* @param deleted the value for litemall_groupon.deleted
*
* @mbg.generated
*/
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon.version
*
* @return the value of litemall_groupon.version
*
* @mbg.generated
*/
public Integer getVersion() {
return version;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon.version
*
* @param version the value for litemall_groupon.version
*
* @mbg.generated
*/
public void setVersion(Integer version) {
this.version = version;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", orderId=").append(orderId);
sb.append(", grouponId=").append(grouponId);
sb.append(", rulesId=").append(rulesId);
sb.append(", userId=").append(userId);
sb.append(", creatorUserId=").append(creatorUserId);
sb.append(", addTime=").append(addTime);
sb.append(", shareUrl=").append(shareUrl);
sb.append(", payed=").append(payed);
sb.append(", deleted=").append(deleted);
sb.append(", version=").append(version);
sb.append("]");
return sb.toString();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
LitemallGroupon other = (LitemallGroupon) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId()))
&& (this.getGrouponId() == null ? other.getGrouponId() == null : this.getGrouponId().equals(other.getGrouponId()))
&& (this.getRulesId() == null ? other.getRulesId() == null : this.getRulesId().equals(other.getRulesId()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getCreatorUserId() == null ? other.getCreatorUserId() == null : this.getCreatorUserId().equals(other.getCreatorUserId()))
&& (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime()))
&& (this.getShareUrl() == null ? other.getShareUrl() == null : this.getShareUrl().equals(other.getShareUrl()))
&& (this.getPayed() == null ? other.getPayed() == null : this.getPayed().equals(other.getPayed()))
&& (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()))
&& (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion()));
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode());
result = prime * result + ((getGrouponId() == null) ? 0 : getGrouponId().hashCode());
result = prime * result + ((getRulesId() == null) ? 0 : getRulesId().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getCreatorUserId() == null) ? 0 : getCreatorUserId().hashCode());
result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode());
result = prime * result + ((getShareUrl() == null) ? 0 : getShareUrl().hashCode());
result = prime * result + ((getPayed() == null) ? 0 : getPayed().hashCode());
result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
result = prime * result + ((getVersion() == null) ? 0 : getVersion().hashCode());
return result;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public void andLogicalDeleted(boolean deleted) {
setDeleted(deleted ? IS_DELETED : NOT_DELETED);
}
/**
* This enum was generated by MyBatis Generator.
* This enum corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public enum Column {
id("id", "id", "INTEGER"),
orderId("order_id", "orderId", "INTEGER"),
grouponId("groupon_id", "grouponId", "INTEGER"),
rulesId("rules_id", "rulesId", "INTEGER"),
userId("user_id", "userId", "INTEGER"),
creatorUserId("creator_user_id", "creatorUserId", "INTEGER"),
addTime("add_time", "addTime", "TIMESTAMP"),
shareUrl("share_url", "shareUrl", "VARCHAR"),
payed("payed", "payed", "BIT"),
deleted("deleted", "deleted", "BIT"),
version("version", "version", "INTEGER");
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String column;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String javaProperty;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String jdbcType;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String value() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getValue() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJavaProperty() {
return this.javaProperty;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJdbcType() {
return this.jdbcType;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
Column(String column, String javaProperty, String jdbcType) {
this.column = column;
this.javaProperty = javaProperty;
this.jdbcType = jdbcType;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String desc() {
return this.column + " DESC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String asc() {
return this.column + " ASC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static Column[] excludes(Column ... excludes) {
ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
if (excludes != null && excludes.length > 0) {
columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
}
return columns.toArray(new Column[]{});
}
}
}

View File

@@ -0,0 +1,587 @@
package org.linlinjava.litemall.db.domain;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
public class LitemallGrouponRules {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static final Boolean NOT_DELETED = false;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static final Boolean IS_DELETED = true;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.id
*
* @mbg.generated
*/
private Integer id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.goods_id
*
* @mbg.generated
*/
private Integer goodsId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.goods_name
*
* @mbg.generated
*/
private String goodsName;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.pic_url
*
* @mbg.generated
*/
private String picUrl;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.discount
*
* @mbg.generated
*/
private BigDecimal discount;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.discount_member
*
* @mbg.generated
*/
private Integer discountMember;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.add_time
*
* @mbg.generated
*/
private LocalDateTime addTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.expire_time
*
* @mbg.generated
*/
private LocalDateTime expireTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.deleted
*
* @mbg.generated
*/
private Boolean deleted;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_groupon_rules.version
*
* @mbg.generated
*/
private Integer version;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.id
*
* @return the value of litemall_groupon_rules.id
*
* @mbg.generated
*/
public Integer getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.id
*
* @param id the value for litemall_groupon_rules.id
*
* @mbg.generated
*/
public void setId(Integer id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.goods_id
*
* @return the value of litemall_groupon_rules.goods_id
*
* @mbg.generated
*/
public Integer getGoodsId() {
return goodsId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.goods_id
*
* @param goodsId the value for litemall_groupon_rules.goods_id
*
* @mbg.generated
*/
public void setGoodsId(Integer goodsId) {
this.goodsId = goodsId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.goods_name
*
* @return the value of litemall_groupon_rules.goods_name
*
* @mbg.generated
*/
public String getGoodsName() {
return goodsName;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.goods_name
*
* @param goodsName the value for litemall_groupon_rules.goods_name
*
* @mbg.generated
*/
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.pic_url
*
* @return the value of litemall_groupon_rules.pic_url
*
* @mbg.generated
*/
public String getPicUrl() {
return picUrl;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.pic_url
*
* @param picUrl the value for litemall_groupon_rules.pic_url
*
* @mbg.generated
*/
public void setPicUrl(String picUrl) {
this.picUrl = picUrl;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.discount
*
* @return the value of litemall_groupon_rules.discount
*
* @mbg.generated
*/
public BigDecimal getDiscount() {
return discount;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.discount
*
* @param discount the value for litemall_groupon_rules.discount
*
* @mbg.generated
*/
public void setDiscount(BigDecimal discount) {
this.discount = discount;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.discount_member
*
* @return the value of litemall_groupon_rules.discount_member
*
* @mbg.generated
*/
public Integer getDiscountMember() {
return discountMember;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.discount_member
*
* @param discountMember the value for litemall_groupon_rules.discount_member
*
* @mbg.generated
*/
public void setDiscountMember(Integer discountMember) {
this.discountMember = discountMember;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.add_time
*
* @return the value of litemall_groupon_rules.add_time
*
* @mbg.generated
*/
public LocalDateTime getAddTime() {
return addTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.add_time
*
* @param addTime the value for litemall_groupon_rules.add_time
*
* @mbg.generated
*/
public void setAddTime(LocalDateTime addTime) {
this.addTime = addTime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.expire_time
*
* @return the value of litemall_groupon_rules.expire_time
*
* @mbg.generated
*/
public LocalDateTime getExpireTime() {
return expireTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.expire_time
*
* @param expireTime the value for litemall_groupon_rules.expire_time
*
* @mbg.generated
*/
public void setExpireTime(LocalDateTime expireTime) {
this.expireTime = expireTime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.deleted
*
* @return the value of litemall_groupon_rules.deleted
*
* @mbg.generated
*/
public Boolean getDeleted() {
return deleted;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.deleted
*
* @param deleted the value for litemall_groupon_rules.deleted
*
* @mbg.generated
*/
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_groupon_rules.version
*
* @return the value of litemall_groupon_rules.version
*
* @mbg.generated
*/
public Integer getVersion() {
return version;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_groupon_rules.version
*
* @param version the value for litemall_groupon_rules.version
*
* @mbg.generated
*/
public void setVersion(Integer version) {
this.version = version;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", goodsId=").append(goodsId);
sb.append(", goodsName=").append(goodsName);
sb.append(", picUrl=").append(picUrl);
sb.append(", discount=").append(discount);
sb.append(", discountMember=").append(discountMember);
sb.append(", addTime=").append(addTime);
sb.append(", expireTime=").append(expireTime);
sb.append(", deleted=").append(deleted);
sb.append(", version=").append(version);
sb.append("]");
return sb.toString();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
LitemallGrouponRules other = (LitemallGrouponRules) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getGoodsId() == null ? other.getGoodsId() == null : this.getGoodsId().equals(other.getGoodsId()))
&& (this.getGoodsName() == null ? other.getGoodsName() == null : this.getGoodsName().equals(other.getGoodsName()))
&& (this.getPicUrl() == null ? other.getPicUrl() == null : this.getPicUrl().equals(other.getPicUrl()))
&& (this.getDiscount() == null ? other.getDiscount() == null : this.getDiscount().equals(other.getDiscount()))
&& (this.getDiscountMember() == null ? other.getDiscountMember() == null : this.getDiscountMember().equals(other.getDiscountMember()))
&& (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime()))
&& (this.getExpireTime() == null ? other.getExpireTime() == null : this.getExpireTime().equals(other.getExpireTime()))
&& (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()))
&& (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion()));
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getGoodsId() == null) ? 0 : getGoodsId().hashCode());
result = prime * result + ((getGoodsName() == null) ? 0 : getGoodsName().hashCode());
result = prime * result + ((getPicUrl() == null) ? 0 : getPicUrl().hashCode());
result = prime * result + ((getDiscount() == null) ? 0 : getDiscount().hashCode());
result = prime * result + ((getDiscountMember() == null) ? 0 : getDiscountMember().hashCode());
result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode());
result = prime * result + ((getExpireTime() == null) ? 0 : getExpireTime().hashCode());
result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
result = prime * result + ((getVersion() == null) ? 0 : getVersion().hashCode());
return result;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public void andLogicalDeleted(boolean deleted) {
setDeleted(deleted ? IS_DELETED : NOT_DELETED);
}
/**
* This enum was generated by MyBatis Generator.
* This enum corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public enum Column {
id("id", "id", "INTEGER"),
goodsId("goods_id", "goodsId", "INTEGER"),
goodsName("goods_name", "goodsName", "VARCHAR"),
picUrl("pic_url", "picUrl", "VARCHAR"),
discount("discount", "discount", "DECIMAL"),
discountMember("discount_member", "discountMember", "INTEGER"),
addTime("add_time", "addTime", "TIMESTAMP"),
expireTime("expire_time", "expireTime", "TIMESTAMP"),
deleted("deleted", "deleted", "BIT"),
version("version", "version", "INTEGER");
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String column;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String javaProperty;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String jdbcType;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String value() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getValue() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJavaProperty() {
return this.javaProperty;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJdbcType() {
return this.jdbcType;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
Column(String column, String javaProperty, String jdbcType) {
this.column = column;
this.javaProperty = javaProperty;
this.jdbcType = jdbcType;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String desc() {
return this.column + " DESC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String asc() {
return this.column + " ASC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_groupon_rules
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static Column[] excludes(Column ... excludes) {
ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
if (excludes != null && excludes.length > 0) {
columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
}
return columns.toArray(new Column[]{});
}
}
}

View File

@@ -123,6 +123,15 @@ public class LitemallOrder {
*/
private BigDecimal integralPrice;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_order.groupon_price
*
* @mbg.generated
*/
private BigDecimal grouponPrice;
/**
*
* This field was generated by MyBatis Generator.
@@ -495,6 +504,30 @@ public class LitemallOrder {
this.integralPrice = integralPrice;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_order.groupon_price
*
* @return the value of litemall_order.groupon_price
*
* @mbg.generated
*/
public BigDecimal getGrouponPrice() {
return grouponPrice;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_order.groupon_price
*
* @param grouponPrice the value for litemall_order.groupon_price
*
* @mbg.generated
*/
public void setGrouponPrice(BigDecimal grouponPrice) {
this.grouponPrice = grouponPrice;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_order.order_price
@@ -806,6 +839,7 @@ public class LitemallOrder {
sb.append(", freightPrice=").append(freightPrice);
sb.append(", couponPrice=").append(couponPrice);
sb.append(", integralPrice=").append(integralPrice);
sb.append(", grouponPrice=").append(grouponPrice);
sb.append(", orderPrice=").append(orderPrice);
sb.append(", actualPrice=").append(actualPrice);
sb.append(", payId=").append(payId);
@@ -851,6 +885,7 @@ public class LitemallOrder {
&& (this.getFreightPrice() == null ? other.getFreightPrice() == null : this.getFreightPrice().equals(other.getFreightPrice()))
&& (this.getCouponPrice() == null ? other.getCouponPrice() == null : this.getCouponPrice().equals(other.getCouponPrice()))
&& (this.getIntegralPrice() == null ? other.getIntegralPrice() == null : this.getIntegralPrice().equals(other.getIntegralPrice()))
&& (this.getGrouponPrice() == null ? other.getGrouponPrice() == null : this.getGrouponPrice().equals(other.getGrouponPrice()))
&& (this.getOrderPrice() == null ? other.getOrderPrice() == null : this.getOrderPrice().equals(other.getOrderPrice()))
&& (this.getActualPrice() == null ? other.getActualPrice() == null : this.getActualPrice().equals(other.getActualPrice()))
&& (this.getPayId() == null ? other.getPayId() == null : this.getPayId().equals(other.getPayId()))
@@ -886,6 +921,7 @@ public class LitemallOrder {
result = prime * result + ((getFreightPrice() == null) ? 0 : getFreightPrice().hashCode());
result = prime * result + ((getCouponPrice() == null) ? 0 : getCouponPrice().hashCode());
result = prime * result + ((getIntegralPrice() == null) ? 0 : getIntegralPrice().hashCode());
result = prime * result + ((getGrouponPrice() == null) ? 0 : getGrouponPrice().hashCode());
result = prime * result + ((getOrderPrice() == null) ? 0 : getOrderPrice().hashCode());
result = prime * result + ((getActualPrice() == null) ? 0 : getActualPrice().hashCode());
result = prime * result + ((getPayId() == null) ? 0 : getPayId().hashCode());
@@ -931,6 +967,7 @@ public class LitemallOrder {
freightPrice("freight_price", "freightPrice", "DECIMAL"),
couponPrice("coupon_price", "couponPrice", "DECIMAL"),
integralPrice("integral_price", "integralPrice", "DECIMAL"),
grouponPrice("groupon_price", "grouponPrice", "DECIMAL"),
orderPrice("order_price", "orderPrice", "DECIMAL"),
actualPrice("actual_price", "actualPrice", "DECIMAL"),
payId("pay_id", "payId", "VARCHAR"),

View File

@@ -927,6 +927,66 @@ public class LitemallOrderExample {
return (Criteria) this;
}
public Criteria andGrouponPriceIsNull() {
addCriterion("groupon_price is null");
return (Criteria) this;
}
public Criteria andGrouponPriceIsNotNull() {
addCriterion("groupon_price is not null");
return (Criteria) this;
}
public Criteria andGrouponPriceEqualTo(BigDecimal value) {
addCriterion("groupon_price =", value, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceNotEqualTo(BigDecimal value) {
addCriterion("groupon_price <>", value, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceGreaterThan(BigDecimal value) {
addCriterion("groupon_price >", value, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("groupon_price >=", value, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceLessThan(BigDecimal value) {
addCriterion("groupon_price <", value, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceLessThanOrEqualTo(BigDecimal value) {
addCriterion("groupon_price <=", value, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceIn(List<BigDecimal> values) {
addCriterion("groupon_price in", values, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceNotIn(List<BigDecimal> values) {
addCriterion("groupon_price not in", values, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("groupon_price between", value1, value2, "grouponPrice");
return (Criteria) this;
}
public Criteria andGrouponPriceNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("groupon_price not between", value1, value2, "grouponPrice");
return (Criteria) this;
}
public Criteria andOrderPriceIsNull() {
addCriterion("order_price is null");
return (Criteria) this;

View File

@@ -0,0 +1,78 @@
package org.linlinjava.litemall.db.service;
import com.alibaba.druid.util.StringUtils;
import com.github.pagehelper.PageHelper;
import org.linlinjava.litemall.db.dao.LitemallGrouponRulesMapper;
import org.linlinjava.litemall.db.domain.LitemallGrouponRules;
import org.linlinjava.litemall.db.domain.LitemallGrouponRulesExample;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class LitemallGrouponRulesService {
@Resource
LitemallGrouponRulesMapper mapper;
public int createRules(LitemallGrouponRules rules) {
return mapper.insertSelective(rules);
}
public LitemallGrouponRules queryById(Integer id) {
return mapper.selectByPrimaryKey(id);
}
/**
* 查询某个商品关联的团购规则
*
* @param goodsId
* @return
*/
public List<LitemallGrouponRules> queryByGoodsId(Integer goodsId) {
LitemallGrouponRulesExample example = new LitemallGrouponRulesExample();
example.or().andGoodsIdEqualTo(goodsId).andDeletedEqualTo(false);
return mapper.selectByExample(example);
}
public List<LitemallGrouponRules> queryByIndex(int offset, int limit) {
LitemallGrouponRulesExample example = new LitemallGrouponRulesExample();
example.or().andDeletedEqualTo(false);
example.orderBy("add_time desc");
PageHelper.startPage(offset, limit);
return mapper.selectByExample(example);
}
public List<LitemallGrouponRules> querySelective(String goodsId, Integer page, Integer size, String sort, String order) {
LitemallGrouponRulesExample example = new LitemallGrouponRulesExample();
LitemallGrouponRulesExample.Criteria criteria = example.createCriteria();
if (!StringUtils.isEmpty(goodsId)) {
criteria.andGoodsIdEqualTo(Integer.parseInt(goodsId));
}
criteria.andDeletedEqualTo(false);
PageHelper.startPage(page, size);
return mapper.selectByExample(example);
}
public int countSelective(String goodsId, Integer page, Integer limit, String sort, String order) {
LitemallGrouponRulesExample example = new LitemallGrouponRulesExample();
LitemallGrouponRulesExample.Criteria criteria = example.createCriteria();
if (!StringUtils.isEmpty(goodsId)) {
criteria.andGoodsIdEqualTo(Integer.parseInt(goodsId));
}
criteria.andDeletedEqualTo(false);
return (int) mapper.countByExample(example);
}
public void delete(Integer id) {
mapper.logicalDeleteByPrimaryKey(id);
}
public void update(LitemallGrouponRules grouponRules) {
mapper.updateByPrimaryKeySelective(grouponRules);
}
}

View File

@@ -0,0 +1,133 @@
package org.linlinjava.litemall.db.service;
import com.alibaba.druid.util.StringUtils;
import com.github.pagehelper.PageHelper;
import org.linlinjava.litemall.db.dao.LitemallGrouponMapper;
import org.linlinjava.litemall.db.domain.LitemallGroupon;
import org.linlinjava.litemall.db.domain.LitemallGrouponExample;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class LitemallGrouponService {
@Resource
LitemallGrouponMapper mapper;
/**
* 查询用户所有参与的团购
*
* @param userId
* @return
*/
public List<LitemallGroupon> queryByUserId(Integer userId) {
LitemallGrouponExample example = new LitemallGrouponExample();
example.or().andUserIdEqualTo(userId).andDeletedEqualTo(false);
return mapper.selectByExample(example);
}
public List<LitemallGroupon> queryMyGroupon(Integer userId) {
LitemallGrouponExample example = new LitemallGrouponExample();
example.or().andUserIdEqualTo(userId).andCreatorUserIdEqualTo(userId).andGrouponIdEqualTo(0).andDeletedEqualTo(false).andPayedEqualTo(true);
example.orderBy("add_time desc");
return mapper.selectByExample(example);
}
public List<LitemallGroupon> queryMyJoinGroupon(Integer userId) {
LitemallGrouponExample example = new LitemallGrouponExample();
example.or().andUserIdEqualTo(userId).andGrouponIdNotEqualTo(0).andDeletedEqualTo(false).andPayedEqualTo(true);
example.orderBy("add_time desc");
return mapper.selectByExample(example);
}
public LitemallGroupon queryByOrderId(Integer orderId) {
LitemallGrouponExample example = new LitemallGrouponExample();
example.or().andOrderIdEqualTo(orderId).andDeletedEqualTo(false);
return mapper.selectOneByExample(example);
}
public List<LitemallGroupon> queryJoiners(Integer id) {
LitemallGrouponExample example = new LitemallGrouponExample();
example.or().andGrouponIdEqualTo(id).andDeletedEqualTo(false).andPayedEqualTo(true);
example.orderBy("add_time desc");
return mapper.selectByExample(example);
}
/**
* 根据ID查询记录
*
* @param id
* @return
*/
public LitemallGroupon queryById(Integer id) {
return mapper.selectByPrimaryKey(id);
}
/**
* 返回某个发起的团购参与人数
*
* @param grouponId
* @return
*/
public int countGroupon(Integer grouponId) {
LitemallGrouponExample example = new LitemallGrouponExample();
example.or().andGrouponIdEqualTo(grouponId).andDeletedEqualTo(false).andPayedEqualTo(true);
return (int) mapper.countByExample(example);
}
/**
* 返回某个团购活动参与人数
*
* @param rulesId
* @return
*/
public int countRules(Integer rulesId) {
LitemallGrouponExample example = new LitemallGrouponExample();
example.or().andRulesIdEqualTo(rulesId).andDeletedEqualTo(false);
return (int) mapper.countByExample(example);
}
public void update(LitemallGroupon groupon) {
mapper.updateByPrimaryKey(groupon);
}
/**
* 创建或参与一个团购
*
* @param groupon
* @return
*/
public int createGroupon(LitemallGroupon groupon) {
return mapper.insertSelective(groupon);
}
public List<LitemallGroupon> querySelective(String rulesId, Integer page, Integer size, String sort, String order) {
LitemallGrouponExample example = new LitemallGrouponExample();
LitemallGrouponExample.Criteria criteria = example.createCriteria();
if (!StringUtils.isEmpty(rulesId)) {
criteria.andRulesIdEqualTo(Integer.parseInt(rulesId));
}
criteria.andDeletedEqualTo(false);
criteria.andPayedEqualTo(true);
criteria.andGrouponIdEqualTo(0);
PageHelper.startPage(page, size);
return mapper.selectByExample(example);
}
public int countSelective(String rulesId, Integer page, Integer limit, String sort, String order) {
LitemallGrouponExample example = new LitemallGrouponExample();
LitemallGrouponExample.Criteria criteria = example.createCriteria();
if (!StringUtils.isEmpty(rulesId)) {
criteria.andRulesIdEqualTo(Integer.parseInt(rulesId));
}
criteria.andDeletedEqualTo(false);
criteria.andPayedEqualTo(true);
criteria.andGrouponIdEqualTo(0);
return (int) mapper.countByExample(example);
}
}

View File

@@ -0,0 +1,504 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.linlinjava.litemall.db.dao.LitemallGrouponMapper">
<resultMap id="BaseResultMap" type="org.linlinjava.litemall.db.domain.LitemallGroupon">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="order_id" jdbcType="INTEGER" property="orderId" />
<result column="groupon_id" jdbcType="INTEGER" property="grouponId" />
<result column="rules_id" jdbcType="INTEGER" property="rulesId" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="creator_user_id" jdbcType="INTEGER" property="creatorUserId" />
<result column="add_time" jdbcType="TIMESTAMP" property="addTime" />
<result column="share_url" jdbcType="VARCHAR" property="shareUrl" />
<result column="payed" jdbcType="BIT" property="payed" />
<result column="deleted" jdbcType="BIT" property="deleted" />
<result column="version" jdbcType="INTEGER" property="version" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, order_id, groupon_id, rules_id, user_id, creator_user_id, add_time, share_url,
payed, deleted, version
</sql>
<select id="selectByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallGrouponExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from litemall_groupon
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExampleSelective" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<if test="example.distinct">
distinct
</if>
<choose>
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.value}
</foreach>
</when>
<otherwise>
id, order_id, groupon_id, rules_id, user_id, creator_user_id, add_time, share_url,
payed, deleted, version
</otherwise>
</choose>
from litemall_groupon
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
<if test="example.orderByClause != null">
order by ${example.orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from litemall_groupon
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByPrimaryKeyWithLogicalDelete" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from litemall_groupon
where id = #{id,jdbcType=INTEGER}
and deleted =
<choose>
<when test="andLogicalDeleted">
'1'
</when>
<otherwise>
'0'
</otherwise>
</choose>
</select>
<select id="selectByPrimaryKeySelective" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<choose>
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.value}
</foreach>
</when>
<otherwise>
id, order_id, groupon_id, rules_id, user_id, creator_user_id, add_time, share_url,
payed, deleted, version
</otherwise>
</choose>
from litemall_groupon
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from litemall_groupon
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallGrouponExample">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from litemall_groupon
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="org.linlinjava.litemall.db.domain.LitemallGroupon">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into litemall_groupon (order_id, groupon_id, rules_id,
user_id, creator_user_id, add_time,
share_url, payed, deleted, version
)
values (#{orderId,jdbcType=INTEGER}, #{grouponId,jdbcType=INTEGER}, #{rulesId,jdbcType=INTEGER},
#{userId,jdbcType=INTEGER}, #{creatorUserId,jdbcType=INTEGER}, #{addTime,jdbcType=TIMESTAMP},
#{shareUrl,jdbcType=VARCHAR}, #{payed,jdbcType=BIT}, #{deleted,jdbcType=BIT}, #{version,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="org.linlinjava.litemall.db.domain.LitemallGroupon">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into litemall_groupon
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderId != null">
order_id,
</if>
<if test="grouponId != null">
groupon_id,
</if>
<if test="rulesId != null">
rules_id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="creatorUserId != null">
creator_user_id,
</if>
<if test="addTime != null">
add_time,
</if>
<if test="shareUrl != null">
share_url,
</if>
<if test="payed != null">
payed,
</if>
<if test="deleted != null">
deleted,
</if>
<if test="version != null">
version,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">
#{orderId,jdbcType=INTEGER},
</if>
<if test="grouponId != null">
#{grouponId,jdbcType=INTEGER},
</if>
<if test="rulesId != null">
#{rulesId,jdbcType=INTEGER},
</if>
<if test="userId != null">
#{userId,jdbcType=INTEGER},
</if>
<if test="creatorUserId != null">
#{creatorUserId,jdbcType=INTEGER},
</if>
<if test="addTime != null">
#{addTime,jdbcType=TIMESTAMP},
</if>
<if test="shareUrl != null">
#{shareUrl,jdbcType=VARCHAR},
</if>
<if test="payed != null">
#{payed,jdbcType=BIT},
</if>
<if test="deleted != null">
#{deleted,jdbcType=BIT},
</if>
<if test="version != null">
#{version,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallGrouponExample" resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from litemall_groupon
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_groupon
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.orderId != null">
order_id = #{record.orderId,jdbcType=INTEGER},
</if>
<if test="record.grouponId != null">
groupon_id = #{record.grouponId,jdbcType=INTEGER},
</if>
<if test="record.rulesId != null">
rules_id = #{record.rulesId,jdbcType=INTEGER},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=INTEGER},
</if>
<if test="record.creatorUserId != null">
creator_user_id = #{record.creatorUserId,jdbcType=INTEGER},
</if>
<if test="record.addTime != null">
add_time = #{record.addTime,jdbcType=TIMESTAMP},
</if>
<if test="record.shareUrl != null">
share_url = #{record.shareUrl,jdbcType=VARCHAR},
</if>
<if test="record.payed != null">
payed = #{record.payed,jdbcType=BIT},
</if>
<if test="record.deleted != null">
deleted = #{record.deleted,jdbcType=BIT},
</if>
<if test="record.version != null">
version = #{record.version,jdbcType=INTEGER},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_groupon
set id = #{record.id,jdbcType=INTEGER},
order_id = #{record.orderId,jdbcType=INTEGER},
groupon_id = #{record.grouponId,jdbcType=INTEGER},
rules_id = #{record.rulesId,jdbcType=INTEGER},
user_id = #{record.userId,jdbcType=INTEGER},
creator_user_id = #{record.creatorUserId,jdbcType=INTEGER},
add_time = #{record.addTime,jdbcType=TIMESTAMP},
share_url = #{record.shareUrl,jdbcType=VARCHAR},
payed = #{record.payed,jdbcType=BIT},
deleted = #{record.deleted,jdbcType=BIT},
version = #{record.version,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="org.linlinjava.litemall.db.domain.LitemallGroupon">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_groupon
<set>
<if test="orderId != null">
order_id = #{orderId,jdbcType=INTEGER},
</if>
<if test="grouponId != null">
groupon_id = #{grouponId,jdbcType=INTEGER},
</if>
<if test="rulesId != null">
rules_id = #{rulesId,jdbcType=INTEGER},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="creatorUserId != null">
creator_user_id = #{creatorUserId,jdbcType=INTEGER},
</if>
<if test="addTime != null">
add_time = #{addTime,jdbcType=TIMESTAMP},
</if>
<if test="shareUrl != null">
share_url = #{shareUrl,jdbcType=VARCHAR},
</if>
<if test="payed != null">
payed = #{payed,jdbcType=BIT},
</if>
<if test="deleted != null">
deleted = #{deleted,jdbcType=BIT},
</if>
<if test="version != null">
version = #{version,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="org.linlinjava.litemall.db.domain.LitemallGroupon">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_groupon
set order_id = #{orderId,jdbcType=INTEGER},
groupon_id = #{grouponId,jdbcType=INTEGER},
rules_id = #{rulesId,jdbcType=INTEGER},
user_id = #{userId,jdbcType=INTEGER},
creator_user_id = #{creatorUserId,jdbcType=INTEGER},
add_time = #{addTime,jdbcType=TIMESTAMP},
share_url = #{shareUrl,jdbcType=VARCHAR},
payed = #{payed,jdbcType=BIT},
deleted = #{deleted,jdbcType=BIT},
version = #{version,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectOneByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallGrouponExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<include refid="Base_Column_List" />
from litemall_groupon
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
limit 1
</select>
<select id="selectOneByExampleSelective" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<choose>
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.value}
</foreach>
</when>
<otherwise>
id, order_id, groupon_id, rules_id, user_id, creator_user_id, add_time, share_url,
payed, deleted, version
</otherwise>
</choose>
from litemall_groupon
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
<if test="example.orderByClause != null">
order by ${example.orderByClause}
</if>
limit 1
</select>
<update id="logicalDeleteByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
update litemall_groupon set deleted = 1
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="logicalDeleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
update litemall_groupon set deleted = 1
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@@ -0,0 +1,489 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.linlinjava.litemall.db.dao.LitemallGrouponRulesMapper">
<resultMap id="BaseResultMap" type="org.linlinjava.litemall.db.domain.LitemallGrouponRules">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="goods_id" jdbcType="INTEGER" property="goodsId" />
<result column="goods_name" jdbcType="VARCHAR" property="goodsName" />
<result column="pic_url" jdbcType="VARCHAR" property="picUrl" />
<result column="discount" jdbcType="DECIMAL" property="discount" />
<result column="discount_member" jdbcType="INTEGER" property="discountMember" />
<result column="add_time" jdbcType="TIMESTAMP" property="addTime" />
<result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" />
<result column="deleted" jdbcType="BIT" property="deleted" />
<result column="version" jdbcType="INTEGER" property="version" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, goods_id, goods_name, pic_url, discount, discount_member, add_time, expire_time,
deleted, version
</sql>
<select id="selectByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallGrouponRulesExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from litemall_groupon_rules
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExampleSelective" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<if test="example.distinct">
distinct
</if>
<choose>
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.value}
</foreach>
</when>
<otherwise>
id, goods_id, goods_name, pic_url, discount, discount_member, add_time, expire_time,
deleted, version
</otherwise>
</choose>
from litemall_groupon_rules
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
<if test="example.orderByClause != null">
order by ${example.orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from litemall_groupon_rules
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByPrimaryKeyWithLogicalDelete" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from litemall_groupon_rules
where id = #{id,jdbcType=INTEGER}
and deleted =
<choose>
<when test="andLogicalDeleted">
'1'
</when>
<otherwise>
'0'
</otherwise>
</choose>
</select>
<select id="selectByPrimaryKeySelective" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<choose>
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.value}
</foreach>
</when>
<otherwise>
id, goods_id, goods_name, pic_url, discount, discount_member, add_time, expire_time,
deleted, version
</otherwise>
</choose>
from litemall_groupon_rules
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from litemall_groupon_rules
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallGrouponRulesExample">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from litemall_groupon_rules
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="org.linlinjava.litemall.db.domain.LitemallGrouponRules">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into litemall_groupon_rules (goods_id, goods_name, pic_url,
discount, discount_member, add_time,
expire_time, deleted, version
)
values (#{goodsId,jdbcType=INTEGER}, #{goodsName,jdbcType=VARCHAR}, #{picUrl,jdbcType=VARCHAR},
#{discount,jdbcType=DECIMAL}, #{discountMember,jdbcType=INTEGER}, #{addTime,jdbcType=TIMESTAMP},
#{expireTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT}, #{version,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="org.linlinjava.litemall.db.domain.LitemallGrouponRules">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into litemall_groupon_rules
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="goodsId != null">
goods_id,
</if>
<if test="goodsName != null">
goods_name,
</if>
<if test="picUrl != null">
pic_url,
</if>
<if test="discount != null">
discount,
</if>
<if test="discountMember != null">
discount_member,
</if>
<if test="addTime != null">
add_time,
</if>
<if test="expireTime != null">
expire_time,
</if>
<if test="deleted != null">
deleted,
</if>
<if test="version != null">
version,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="goodsId != null">
#{goodsId,jdbcType=INTEGER},
</if>
<if test="goodsName != null">
#{goodsName,jdbcType=VARCHAR},
</if>
<if test="picUrl != null">
#{picUrl,jdbcType=VARCHAR},
</if>
<if test="discount != null">
#{discount,jdbcType=DECIMAL},
</if>
<if test="discountMember != null">
#{discountMember,jdbcType=INTEGER},
</if>
<if test="addTime != null">
#{addTime,jdbcType=TIMESTAMP},
</if>
<if test="expireTime != null">
#{expireTime,jdbcType=TIMESTAMP},
</if>
<if test="deleted != null">
#{deleted,jdbcType=BIT},
</if>
<if test="version != null">
#{version,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallGrouponRulesExample" resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from litemall_groupon_rules
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_groupon_rules
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.goodsId != null">
goods_id = #{record.goodsId,jdbcType=INTEGER},
</if>
<if test="record.goodsName != null">
goods_name = #{record.goodsName,jdbcType=VARCHAR},
</if>
<if test="record.picUrl != null">
pic_url = #{record.picUrl,jdbcType=VARCHAR},
</if>
<if test="record.discount != null">
discount = #{record.discount,jdbcType=DECIMAL},
</if>
<if test="record.discountMember != null">
discount_member = #{record.discountMember,jdbcType=INTEGER},
</if>
<if test="record.addTime != null">
add_time = #{record.addTime,jdbcType=TIMESTAMP},
</if>
<if test="record.expireTime != null">
expire_time = #{record.expireTime,jdbcType=TIMESTAMP},
</if>
<if test="record.deleted != null">
deleted = #{record.deleted,jdbcType=BIT},
</if>
<if test="record.version != null">
version = #{record.version,jdbcType=INTEGER},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_groupon_rules
set id = #{record.id,jdbcType=INTEGER},
goods_id = #{record.goodsId,jdbcType=INTEGER},
goods_name = #{record.goodsName,jdbcType=VARCHAR},
pic_url = #{record.picUrl,jdbcType=VARCHAR},
discount = #{record.discount,jdbcType=DECIMAL},
discount_member = #{record.discountMember,jdbcType=INTEGER},
add_time = #{record.addTime,jdbcType=TIMESTAMP},
expire_time = #{record.expireTime,jdbcType=TIMESTAMP},
deleted = #{record.deleted,jdbcType=BIT},
version = #{record.version,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="org.linlinjava.litemall.db.domain.LitemallGrouponRules">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_groupon_rules
<set>
<if test="goodsId != null">
goods_id = #{goodsId,jdbcType=INTEGER},
</if>
<if test="goodsName != null">
goods_name = #{goodsName,jdbcType=VARCHAR},
</if>
<if test="picUrl != null">
pic_url = #{picUrl,jdbcType=VARCHAR},
</if>
<if test="discount != null">
discount = #{discount,jdbcType=DECIMAL},
</if>
<if test="discountMember != null">
discount_member = #{discountMember,jdbcType=INTEGER},
</if>
<if test="addTime != null">
add_time = #{addTime,jdbcType=TIMESTAMP},
</if>
<if test="expireTime != null">
expire_time = #{expireTime,jdbcType=TIMESTAMP},
</if>
<if test="deleted != null">
deleted = #{deleted,jdbcType=BIT},
</if>
<if test="version != null">
version = #{version,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="org.linlinjava.litemall.db.domain.LitemallGrouponRules">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_groupon_rules
set goods_id = #{goodsId,jdbcType=INTEGER},
goods_name = #{goodsName,jdbcType=VARCHAR},
pic_url = #{picUrl,jdbcType=VARCHAR},
discount = #{discount,jdbcType=DECIMAL},
discount_member = #{discountMember,jdbcType=INTEGER},
add_time = #{addTime,jdbcType=TIMESTAMP},
expire_time = #{expireTime,jdbcType=TIMESTAMP},
deleted = #{deleted,jdbcType=BIT},
version = #{version,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectOneByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallGrouponRulesExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<include refid="Base_Column_List" />
from litemall_groupon_rules
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
limit 1
</select>
<select id="selectOneByExampleSelective" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<choose>
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.value}
</foreach>
</when>
<otherwise>
id, goods_id, goods_name, pic_url, discount, discount_member, add_time, expire_time,
deleted, version
</otherwise>
</choose>
from litemall_groupon_rules
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
<if test="example.orderByClause != null">
order by ${example.orderByClause}
</if>
limit 1
</select>
<update id="logicalDeleteByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
update litemall_groupon_rules set deleted = 1
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="logicalDeleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
update litemall_groupon_rules set deleted = 1
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@@ -17,6 +17,7 @@
<result column="freight_price" jdbcType="DECIMAL" property="freightPrice" />
<result column="coupon_price" jdbcType="DECIMAL" property="couponPrice" />
<result column="integral_price" jdbcType="DECIMAL" property="integralPrice" />
<result column="groupon_price" jdbcType="DECIMAL" property="grouponPrice" />
<result column="order_price" jdbcType="DECIMAL" property="orderPrice" />
<result column="actual_price" jdbcType="DECIMAL" property="actualPrice" />
<result column="pay_id" jdbcType="VARCHAR" property="payId" />
@@ -102,8 +103,8 @@
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, user_id, order_sn, order_status, consignee, mobile, address, goods_price, freight_price,
coupon_price, integral_price, order_price, actual_price, pay_id, pay_time, ship_sn,
ship_channel, ship_time, confirm_time, end_time, add_time, deleted, version
coupon_price, integral_price, groupon_price, order_price, actual_price, pay_id, pay_time,
ship_sn, ship_channel, ship_time, confirm_time, end_time, add_time, deleted, version
</sql>
<select id="selectByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallOrderExample" resultMap="BaseResultMap">
<!--
@@ -141,8 +142,9 @@
</when>
<otherwise>
id, user_id, order_sn, order_status, consignee, mobile, address, goods_price, freight_price,
coupon_price, integral_price, order_price, actual_price, pay_id, pay_time, ship_sn,
ship_channel, ship_time, confirm_time, end_time, add_time, deleted, version
coupon_price, integral_price, groupon_price, order_price, actual_price, pay_id,
pay_time, ship_sn, ship_channel, ship_time, confirm_time, end_time, add_time, deleted,
version
</otherwise>
</choose>
from litemall_order
@@ -202,8 +204,9 @@
</when>
<otherwise>
id, user_id, order_sn, order_status, consignee, mobile, address, goods_price, freight_price,
coupon_price, integral_price, order_price, actual_price, pay_id, pay_time, ship_sn,
ship_channel, ship_time, confirm_time, end_time, add_time, deleted, version
coupon_price, integral_price, groupon_price, order_price, actual_price, pay_id,
pay_time, ship_sn, ship_channel, ship_time, confirm_time, end_time, add_time, deleted,
version
</otherwise>
</choose>
from litemall_order
@@ -238,19 +241,19 @@
insert into litemall_order (user_id, order_sn, order_status,
consignee, mobile, address,
goods_price, freight_price, coupon_price,
integral_price, order_price, actual_price,
pay_id, pay_time, ship_sn,
ship_channel, ship_time, confirm_time,
end_time, add_time, deleted,
version)
integral_price, groupon_price, order_price,
actual_price, pay_id, pay_time,
ship_sn, ship_channel, ship_time,
confirm_time, end_time, add_time,
deleted, version)
values (#{userId,jdbcType=INTEGER}, #{orderSn,jdbcType=VARCHAR}, #{orderStatus,jdbcType=SMALLINT},
#{consignee,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR},
#{goodsPrice,jdbcType=DECIMAL}, #{freightPrice,jdbcType=DECIMAL}, #{couponPrice,jdbcType=DECIMAL},
#{integralPrice,jdbcType=DECIMAL}, #{orderPrice,jdbcType=DECIMAL}, #{actualPrice,jdbcType=DECIMAL},
#{payId,jdbcType=VARCHAR}, #{payTime,jdbcType=TIMESTAMP}, #{shipSn,jdbcType=VARCHAR},
#{shipChannel,jdbcType=VARCHAR}, #{shipTime,jdbcType=TIMESTAMP}, #{confirmTime,jdbcType=TIMESTAMP},
#{endTime,jdbcType=TIMESTAMP}, #{addTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT},
#{version,jdbcType=INTEGER})
#{integralPrice,jdbcType=DECIMAL}, #{grouponPrice,jdbcType=DECIMAL}, #{orderPrice,jdbcType=DECIMAL},
#{actualPrice,jdbcType=DECIMAL}, #{payId,jdbcType=VARCHAR}, #{payTime,jdbcType=TIMESTAMP},
#{shipSn,jdbcType=VARCHAR}, #{shipChannel,jdbcType=VARCHAR}, #{shipTime,jdbcType=TIMESTAMP},
#{confirmTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{addTime,jdbcType=TIMESTAMP},
#{deleted,jdbcType=BIT}, #{version,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="org.linlinjava.litemall.db.domain.LitemallOrder">
<!--
@@ -292,6 +295,9 @@
<if test="integralPrice != null">
integral_price,
</if>
<if test="grouponPrice != null">
groupon_price,
</if>
<if test="orderPrice != null">
order_price,
</if>
@@ -360,6 +366,9 @@
<if test="integralPrice != null">
#{integralPrice,jdbcType=DECIMAL},
</if>
<if test="grouponPrice != null">
#{grouponPrice,jdbcType=DECIMAL},
</if>
<if test="orderPrice != null">
#{orderPrice,jdbcType=DECIMAL},
</if>
@@ -448,6 +457,9 @@
<if test="record.integralPrice != null">
integral_price = #{record.integralPrice,jdbcType=DECIMAL},
</if>
<if test="record.grouponPrice != null">
groupon_price = #{record.grouponPrice,jdbcType=DECIMAL},
</if>
<if test="record.orderPrice != null">
order_price = #{record.orderPrice,jdbcType=DECIMAL},
</if>
@@ -506,6 +518,7 @@
freight_price = #{record.freightPrice,jdbcType=DECIMAL},
coupon_price = #{record.couponPrice,jdbcType=DECIMAL},
integral_price = #{record.integralPrice,jdbcType=DECIMAL},
groupon_price = #{record.grouponPrice,jdbcType=DECIMAL},
order_price = #{record.orderPrice,jdbcType=DECIMAL},
actual_price = #{record.actualPrice,jdbcType=DECIMAL},
pay_id = #{record.payId,jdbcType=VARCHAR},
@@ -559,6 +572,9 @@
<if test="integralPrice != null">
integral_price = #{integralPrice,jdbcType=DECIMAL},
</if>
<if test="grouponPrice != null">
groupon_price = #{grouponPrice,jdbcType=DECIMAL},
</if>
<if test="orderPrice != null">
order_price = #{orderPrice,jdbcType=DECIMAL},
</if>
@@ -614,6 +630,7 @@
freight_price = #{freightPrice,jdbcType=DECIMAL},
coupon_price = #{couponPrice,jdbcType=DECIMAL},
integral_price = #{integralPrice,jdbcType=DECIMAL},
groupon_price = #{grouponPrice,jdbcType=DECIMAL},
order_price = #{orderPrice,jdbcType=DECIMAL},
actual_price = #{actualPrice,jdbcType=DECIMAL},
pay_id = #{payId,jdbcType=VARCHAR},
@@ -660,8 +677,9 @@
</when>
<otherwise>
id, user_id, order_sn, order_status, consignee, mobile, address, goods_price, freight_price,
coupon_price, integral_price, order_price, actual_price, pay_id, pay_time, ship_sn,
ship_channel, ship_time, confirm_time, end_time, add_time, deleted, version
coupon_price, integral_price, groupon_price, order_price, actual_price, pay_id,
pay_time, ship_sn, ship_channel, ship_time, confirm_time, end_time, add_time, deleted,
version
</otherwise>
</choose>
from litemall_order

View File

@@ -0,0 +1,77 @@
package org.linlinjava.litemall.wx.service;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
/**
* 简单缓存的数据
*/
public class HomeCacheManager {
public static final String INDEX = "index";
public static final String CATALOG = "catalog";
public static final String GOODS = "goods";
private static Map<String, Map<String, Object>> cacheDataList = new HashMap<>();
/**
* 缓存首页数据
*
* @param data
*/
public static void loadData(String cacheKey, Map<String, Object> data) {
Map<String, Object> cacheData = cacheDataList.get(cacheKey);
//有记录,则先丢弃
if (cacheData != null) {
cacheData.remove(cacheKey);
}
cacheData = new HashMap<>();
//深拷贝
cacheData.putAll(data);
cacheData.put("isCache", "true");
//设置缓存有效期为10分钟
cacheData.put("expireTime", LocalDateTime.now().plusMinutes(10));
cacheDataList.put(cacheKey, cacheData);
}
public static Map<String, Object> getCacheData(String cacheKey) {
return cacheDataList.get(cacheKey);
}
/**
* 判断缓存中是否有数据
*
* @return
*/
public static boolean hasData(String cacheKey) {
Map<String, Object> cacheData = cacheDataList.get(cacheKey);
if (cacheData == null) {
return false;
} else {
LocalDateTime expire = (LocalDateTime) cacheData.get("expireTime");
if (expire.isBefore(LocalDateTime.now())) {
return false;
} else {
return true;
}
}
}
/**
* 清除所有缓存
*/
public static void clearAll() {
cacheDataList = new HashMap<>();
}
/**
* 清除缓存数据
*/
public static void clear(String cacheKey) {
Map<String, Object> cacheData = cacheDataList.get(cacheKey);
if (cacheData != null) {
cacheDataList.remove(cacheKey);
}
}
}

View File

@@ -14,6 +14,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -32,33 +33,33 @@ public class WxCartController {
@Autowired
private LitemallProductService productService;
@Autowired
private LitemallGoodsSpecificationService goodsSpecificationService;
@Autowired
private LitemallAddressService addressService;
@Autowired
private LitemallGrouponRulesService grouponRulesService;
/**
* 购物车
*
* @param userId 用户ID
* @return 购物车
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data:
* {
* cartList: xxx,
* cartTotal: xxx
* }
* }
* 失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data:
* {
* cartList: xxx,
* cartTotal: xxx
* }
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping("index")
public Object index(@LoginUser Integer userId) {
if(userId == null){
if (userId == null) {
return ResponseUtil.unlogin();
}
List<LitemallCart> cartList = cartService.queryByUid(userId);
Integer goodsCount = 0;
BigDecimal goodsAmount = new BigDecimal(0.00);
@@ -91,29 +92,29 @@ public class WxCartController {
* 否则添加新的购物车货品项。
*
* @param userId 用户ID
* @param cart 购物车商品信息, { goodsId: xxx, productId: xxx, number: xxx }
* @param cart 购物车商品信息, { goodsId: xxx, productId: xxx, number: xxx }
* @return 加入购物车操作结果
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data: xxx
* }
* 失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data: xxx
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@PostMapping("add")
public Object add(@LoginUser Integer userId, @RequestBody LitemallCart cart) {
if(userId == null){
if (userId == null) {
return ResponseUtil.unlogin();
}
if(cart == null){
if (cart == null) {
return ResponseUtil.badArgument();
}
Integer productId = cart.getProductId();
Integer number = cart.getNumber().intValue();
Integer goodsId = cart.getGoodsId();
if(!ObjectUtils.allNotNull(productId, number, goodsId)){
if (!ObjectUtils.allNotNull(productId, number, goodsId)) {
return ResponseUtil.badArgument();
}
@@ -126,9 +127,9 @@ public class WxCartController {
LitemallProduct product = productService.findById(productId);
//判断购物车中是否存在此规格商品
LitemallCart existCart = cartService.queryExist(goodsId, productId, userId);
if(existCart == null){
if (existCart == null) {
//取得规格的信息,判断规格库存
if(product == null || number > product.getNumber() ){
if (product == null || number > product.getNumber()) {
return ResponseUtil.fail(400, "库存不足");
}
@@ -140,15 +141,15 @@ public class WxCartController {
cart.setSpecifications(product.getSpecifications());
cart.setUserId(userId);
cart.setChecked(true);
cart.setAddTime(LocalDateTime.now());
cartService.add(cart);
}
else{
} else {
//取得规格的信息,判断规格库存
int num = existCart.getNumber() + number;
if(num > product.getNumber()){
if (num > product.getNumber()) {
return ResponseUtil.fail(400, "库存不足");
}
existCart.setNumber((short)num);
existCart.setNumber((short) num);
cartService.update(existCart);
}
@@ -157,35 +158,35 @@ public class WxCartController {
/**
* 立即购买商品
*
* <p>
* 和 前面一个方法add的区别在于
* 1. 如果购物车内已经存在购物车货品,前者的逻辑是数量添加,这里的逻辑是数量覆盖
* 2. 添加成功以后前者的逻辑是返回当前购物车商品数量这里的逻辑是返回对应购物车项的ID
*
* @param userId 用户ID
* @param cart 购物车商品信息, { goodsId: xxx, productId: xxx, number: xxx }
* @param cart 购物车商品信息, { goodsId: xxx, productId: xxx, number: xxx }
* @return 即购买操作结果
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data: xxx
* }
* 失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data: xxx
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@PostMapping("fastadd")
public Object fastadd(@LoginUser Integer userId, @RequestBody LitemallCart cart) {
if(userId == null){
if (userId == null) {
return ResponseUtil.unlogin();
}
if(cart == null){
if (cart == null) {
return ResponseUtil.badArgument();
}
Integer productId = cart.getProductId();
Integer number = cart.getNumber().intValue();
Integer goodsId = cart.getGoodsId();
if(!ObjectUtils.allNotNull(productId, number, goodsId)){
if (!ObjectUtils.allNotNull(productId, number, goodsId)) {
return ResponseUtil.badArgument();
}
@@ -198,9 +199,9 @@ public class WxCartController {
LitemallProduct product = productService.findById(productId);
//判断购物车中是否存在此规格商品
LitemallCart existCart = cartService.queryExist(goodsId, productId, userId);
if(existCart == null){
if (existCart == null) {
//取得规格的信息,判断规格库存
if(product == null || number > product.getNumber() ){
if (product == null || number > product.getNumber()) {
return ResponseUtil.fail(400, "库存不足");
}
@@ -213,14 +214,13 @@ public class WxCartController {
cart.setUserId(userId);
cart.setChecked(true);
cartService.add(cart);
}
else{
} else {
//取得规格的信息,判断规格库存
int num = number;
if(num > product.getNumber()){
if (num > product.getNumber()) {
return ResponseUtil.fail(400, "库存不足");
}
existCart.setNumber((short)num);
existCart.setNumber((short) num);
cartService.update(existCart);
}
@@ -232,39 +232,39 @@ public class WxCartController {
* 目前只支持修改商品的数量
*
* @param userId 用户ID
* @param cart 购物车商品信息, { id: xxx, goodsId: xxx, productId: xxx, number: xxx }
* @param cart 购物车商品信息, { id: xxx, goodsId: xxx, productId: xxx, number: xxx }
* @return 更新购物车操作结果
* 成功则 { errno: 0, errmsg: '成功' }
* 失败则 { errno: XXX, errmsg: XXX }
* 成功则 { errno: 0, errmsg: '成功' }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@PostMapping("update")
public Object update(@LoginUser Integer userId, @RequestBody LitemallCart cart) {
if(userId == null){
if (userId == null) {
return ResponseUtil.unlogin();
}
if(cart == null){
if (cart == null) {
return ResponseUtil.badArgument();
}
Integer productId = cart.getProductId();
Integer number = cart.getNumber().intValue();
Integer goodsId = cart.getGoodsId();
Integer id = cart.getId();
if(!ObjectUtils.allNotNull(id, productId, number, goodsId)){
if (!ObjectUtils.allNotNull(id, productId, number, goodsId)) {
return ResponseUtil.badArgument();
}
//判断是否存在该订单
// 如果不存在,直接返回错误
LitemallCart existCart = cartService.findById(id);
if(existCart == null){
if (existCart == null) {
return ResponseUtil.badArgumentValue();
}
// 判断goodsId和productId是否与当前cart里的值一致
if(!existCart.getGoodsId().equals(goodsId)){
if (!existCart.getGoodsId().equals(goodsId)) {
return ResponseUtil.badArgumentValue();
}
if(!existCart.getProductId().equals(productId)){
if (!existCart.getProductId().equals(productId)) {
return ResponseUtil.badArgumentValue();
}
@@ -276,7 +276,7 @@ public class WxCartController {
//取得规格的信息,判断规格库存
LitemallProduct product = productService.findById(productId);
if(product == null || product.getNumber() < number){
if (product == null || product.getNumber() < number) {
return ResponseUtil.fail(403, "库存不足");
}
@@ -290,32 +290,32 @@ public class WxCartController {
* 如果原来没有勾选,则设置勾选状态;如果商品已经勾选,则设置非勾选状态。
*
* @param userId 用户ID
* @param body 购物车商品信息, { productIds: xxx }
* @param body 购物车商品信息, { productIds: xxx }
* @return 购物车信息
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data: xxx
* }
* 失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data: xxx
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@PostMapping("checked")
public Object checked(@LoginUser Integer userId, @RequestBody String body) {
if(userId == null){
if (userId == null) {
return ResponseUtil.unlogin();
}
if(body == null){
if (body == null) {
return ResponseUtil.badArgument();
}
List<Integer> productIds = JacksonUtil.parseIntegerList(body, "productIds");
if(productIds == null){
if (productIds == null) {
return ResponseUtil.badArgument();
}
Integer checkValue = JacksonUtil.parseInteger(body, "isChecked");
if(checkValue == null){
if (checkValue == null) {
return ResponseUtil.badArgument();
}
Boolean isChecked = (checkValue == 1);
@@ -328,28 +328,28 @@ public class WxCartController {
* 购物车商品删除
*
* @param userId 用户ID
* @param body 购物车商品信息, { productIds: xxx }
* @param body 购物车商品信息, { productIds: xxx }
* @return 购物车信息
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data: xxx
* }
* 失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data: xxx
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@PostMapping("delete")
public Object delete(@LoginUser Integer userId, @RequestBody String body) {
if(userId == null){
if (userId == null) {
return ResponseUtil.unlogin();
}
if(body == null){
if (body == null) {
return ResponseUtil.badArgument();
}
List<Integer> productIds = JacksonUtil.parseIntegerList(body, "productIds");
if(productIds == null || productIds.size() == 0){
if (productIds == null || productIds.size() == 0) {
return ResponseUtil.badArgument();
}
@@ -363,23 +363,23 @@ public class WxCartController {
*
* @param userId 用户ID
* @return 购物车商品数量
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data: xxx
* }
* 失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data: xxx
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping("goodscount")
public Object goodscount(@LoginUser Integer userId) {
if(userId == null){
if (userId == null) {
return ResponseUtil.ok(0);
}
int goodsCount = 0;
List<LitemallCart> cartList = cartService.queryByUid(userId);
for(LitemallCart cart : cartList){
for (LitemallCart cart : cartList) {
goodsCount += cart.getNumber();
}
@@ -389,61 +389,59 @@ public class WxCartController {
/**
* 购物车下单信息
*
* @param userId 用户ID
* @param cartId 购物车商品ID
* 如果购物车商品ID是空则下单当前用户所有购物车商品
* 如果购物车商品ID非空则只下单当前购物车商品。
* @param userId 用户ID
* @param cartId 购物车商品ID
* 如果购物车商品ID是空则下单当前用户所有购物车商品
* 如果购物车商品ID非空则只下单当前购物车商品。
* @param addressId 收货地址ID
* 如果收货地址ID是空则查询当前用户的默认地址。
* @param couponId 优惠券ID
* 目前不支持
* 如果收货地址ID是空则查询当前用户的默认地址。
* @param couponId 优惠券ID
* 目前不支持
* @return 购物车下单信息
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data:
* {
* addressId: xxx,
* checkedAddress: xxx,
* couponId: xxx,
* checkedCoupon: xxx,
* goodsTotalPrice: xxx,
* freightPrice: xxx,
* couponPrice: xxx,
* orderTotalPrice: xxx,
* actualPrice: xxx,
* checkedGoodsList: xxx
* }
* }
* 失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data:
* {
* addressId: xxx,
* checkedAddress: xxx,
* couponId: xxx,
* checkedCoupon: xxx,
* goodsTotalPrice: xxx,
* freightPrice: xxx,
* couponPrice: xxx,
* orderTotalPrice: xxx,
* actualPrice: xxx,
* checkedGoodsList: xxx
* }
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping("checkout")
public Object checkout(@LoginUser Integer userId, Integer cartId, Integer addressId, Integer couponId) {
if(userId == null){
public Object checkout(@LoginUser Integer userId, Integer cartId, Integer addressId, Integer couponId, Integer grouponRulesId) {
if (userId == null) {
return ResponseUtil.unlogin();
}
// 收货地址
LitemallAddress checkedAddress = null;
if(addressId == null || addressId.equals(0)){
if (addressId == null || addressId.equals(0)) {
checkedAddress = addressService.findDefault(userId);
// 如果仍然没有地址,则是没有收获地址
// 返回一个空的地址id=0这样前端则会提醒添加地址
if(checkedAddress == null){
if (checkedAddress == null) {
checkedAddress = new LitemallAddress();
checkedAddress.setId(0);
addressId = 0;
}
else{
} else {
addressId = checkedAddress.getId();
}
}
else {
} else {
checkedAddress = addressService.findById(addressId);
// 如果null, 则报错
if(checkedAddress == null){
if (checkedAddress == null) {
return ResponseUtil.badArgumentValue();
}
}
@@ -452,14 +450,20 @@ public class WxCartController {
// 使用优惠券减免的金额
BigDecimal couponPrice = new BigDecimal(0.00);
// 团购优惠
BigDecimal grouponPrice = new BigDecimal(0.00);
LitemallGrouponRules grouponRules = grouponRulesService.queryById(grouponRulesId);
if (grouponRules != null) {
grouponPrice = grouponRules.getDiscount();
}
// 商品价格
List<LitemallCart> checkedGoodsList = null;
if(cartId == null || cartId.equals(0)) {
if (cartId == null || cartId.equals(0)) {
checkedGoodsList = cartService.queryByUidAndChecked(userId);
}
else {
} else {
LitemallCart cart = cartService.findById(cartId);
if (cart == null){
if (cart == null) {
return ResponseUtil.badArgumentValue();
}
checkedGoodsList = new ArrayList<>(1);
@@ -467,7 +471,12 @@ public class WxCartController {
}
BigDecimal checkedGoodsPrice = new BigDecimal(0.00);
for (LitemallCart cart : checkedGoodsList) {
checkedGoodsPrice = checkedGoodsPrice.add(cart.getPrice().multiply(new BigDecimal(cart.getNumber())));
// 只有当团购规格商品ID符合才进行团购优惠
if (grouponRules != null && grouponRules.getGoodsId().equals(cart.getGoodsId())) {
checkedGoodsPrice = checkedGoodsPrice.add(cart.getPrice().subtract(grouponPrice).multiply(new BigDecimal(cart.getNumber())));
} else {
checkedGoodsPrice = checkedGoodsPrice.add(cart.getPrice().multiply(new BigDecimal(cart.getNumber())));
}
}
// 根据订单商品总价计算运费满88则免运费否则8元
@@ -485,6 +494,7 @@ public class WxCartController {
Map<String, Object> data = new HashMap<>();
data.put("addressId", addressId);
data.put("grouponRulesId", grouponRulesId);
data.put("checkedAddress", checkedAddress);
data.put("couponId", couponId);
data.put("checkedCoupon", 0);
@@ -504,17 +514,17 @@ public class WxCartController {
*
* @param userId 用户ID
* @return 商品优惠券信息
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data: xxx
* }
* 失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data: xxx
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping("checkedCouponList")
public Object checkedCouponList(@LoginUser Integer userId) {
if(userId == null){
if (userId == null) {
return ResponseUtil.unlogin();
}
return ResponseUtil.unsupport();

View File

@@ -3,6 +3,7 @@ package org.linlinjava.litemall.wx.web;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LitemallCategory;
import org.linlinjava.litemall.db.service.LitemallCategoryService;
import org.linlinjava.litemall.wx.service.HomeCacheManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
@@ -80,6 +81,12 @@ public class WxCatalogController {
*/
@GetMapping("all")
public Object queryAll() {
//优先从缓存中读取
if (HomeCacheManager.hasData(HomeCacheManager.CATALOG)) {
return ResponseUtil.ok(HomeCacheManager.getCacheData(HomeCacheManager.CATALOG));
}
// 所有一级分类目录
List<LitemallCategory> l1CatList = categoryService.queryL1();
@@ -105,6 +112,9 @@ public class WxCatalogController {
data.put("allList", allList);
data.put("currentCategory", currentCategory);
data.put("currentSubCategory", currentSubCategory);
//缓存数据
HomeCacheManager.loadData(HomeCacheManager.CATALOG, data);
return ResponseUtil.ok(data);
}

View File

@@ -10,6 +10,7 @@ import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.domain.*;
import org.linlinjava.litemall.db.service.*;
import org.linlinjava.litemall.wx.annotation.LoginUser;
import org.linlinjava.litemall.wx.service.HomeCacheManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
@@ -54,6 +55,8 @@ public class WxGoodsController {
private LitemallSearchHistoryService searchHistoryService;
@Autowired
private LitemallGoodsSpecificationService goodsSpecificationService;
@Autowired
private LitemallGrouponRulesService rulesService;
/**
@@ -123,6 +126,9 @@ public class WxGoodsController {
commentList.put("count", commentCount);
commentList.put("data", commentsVo);
//团购信息
List<LitemallGrouponRules> rules = rulesService.queryByGoodsId(id);
// 用户收藏
int userHasCollect = 0;
if (userId != null) {
@@ -147,10 +153,10 @@ public class WxGoodsController {
data.put("productList", productList);
data.put("attribute", goodsAttributeList);
data.put("brand", brand);
data.put("groupon", rules);
//商品分享图片地址
data.put("shareImage", info.getShareUrl());
return ResponseUtil.ok(data);
}
@@ -231,7 +237,7 @@ public class WxGoodsController {
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer size,
@Sort(accepts = {"add_time", "retail_price"}) @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order){
@Order @RequestParam(defaultValue = "desc") String order) {
//添加到搜索历史
if (userId != null && !StringUtils.isNullOrEmpty(keyword)) {

View File

@@ -0,0 +1,229 @@
package org.linlinjava.litemall.wx.web;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.*;
import org.linlinjava.litemall.db.service.*;
import org.linlinjava.litemall.db.util.OrderUtil;
import org.linlinjava.litemall.wx.annotation.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/wx/groupon")
@Validated
public class WxGrouponController {
@Autowired
private LitemallGrouponRulesService rulesService;
@Autowired
private LitemallGrouponService grouponService;
@Autowired
private LitemallGoodsService goodsService;
@Autowired
private LitemallOrderService orderService;
@Autowired
private LitemallOrderGoodsService orderGoodsService;
@Autowired
private LitemallUserService userService;
@GetMapping("detail")
public Object detail(@LoginUser Integer userId, @NotNull Integer grouponId) {
if (userId == null) {
return ResponseUtil.unlogin();
}
LitemallGroupon groupon = grouponService.queryById(grouponId);
if (groupon == null) {
return ResponseUtil.badArgumentValue();
}
LitemallGrouponRules rules = rulesService.queryById(groupon.getRulesId());
if (rules == null) {
return ResponseUtil.badArgumentValue();
}
// 订单信息
LitemallOrder order = orderService.findById(groupon.getOrderId());
if (null == order) {
return ResponseUtil.fail(403, "订单不存在");
}
if (!order.getUserId().equals(userId)) {
return ResponseUtil.fail(403, "不是当前用户的订单");
}
Map<String, Object> orderVo = new HashMap<String, Object>();
orderVo.put("id", order.getId());
orderVo.put("orderSn", order.getOrderSn());
orderVo.put("addTime", LocalDate.now());
orderVo.put("consignee", order.getConsignee());
orderVo.put("mobile", order.getMobile());
orderVo.put("address", order.getAddress());
orderVo.put("goodsPrice", order.getGoodsPrice());
orderVo.put("freightPrice", order.getFreightPrice());
orderVo.put("actualPrice", order.getActualPrice());
orderVo.put("orderStatusText", OrderUtil.orderStatusText(order));
orderVo.put("handleOption", OrderUtil.build(order));
orderVo.put("expCode", order.getShipChannel());
orderVo.put("expNo", order.getShipSn());
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(order.getId());
List<Map<String, Object>> orderGoodsVoList = new ArrayList<>(orderGoodsList.size());
for (LitemallOrderGoods orderGoods : orderGoodsList) {
Map<String, Object> orderGoodsVo = new HashMap<>();
orderGoodsVo.put("id", orderGoods.getId());
orderGoodsVo.put("orderId", orderGoods.getOrderId());
orderGoodsVo.put("goodsId", orderGoods.getGoodsId());
orderGoodsVo.put("goodsName", orderGoods.getGoodsName());
orderGoodsVo.put("number", orderGoods.getNumber());
orderGoodsVo.put("retailPrice", orderGoods.getPrice());
orderGoodsVo.put("picUrl", orderGoods.getPicUrl());
orderGoodsVo.put("goodsSpecificationValues", orderGoods.getSpecifications());
orderGoodsVoList.add(orderGoodsVo);
}
Map<String, Object> result = new HashMap<>();
result.put("orderInfo", orderVo);
result.put("orderGoods", orderGoodsVoList);
UserVo creator = userService.findUserVoById(groupon.getCreatorUserId());
List<UserVo> joiners = new ArrayList<>();
joiners.add(creator);
int linkGrouponId;
// 这是一个团购发起记录
if (groupon.getGrouponId() == 0) {
linkGrouponId = groupon.getId();
} else {
linkGrouponId = groupon.getGrouponId();
}
List<LitemallGroupon> groupons = grouponService.queryJoiners(linkGrouponId);
UserVo joiner;
for (LitemallGroupon grouponItem : groupons) {
joiner = userService.findUserVoById(grouponItem.getUserId());
joiners.add(joiner);
}
result.put("linkGrouponId", linkGrouponId);
result.put("creator", creator);
result.put("joiners", joiners);
result.put("groupon", groupon);
result.put("rules", rules);
return ResponseUtil.ok(result);
}
@GetMapping("join")
public Object join(@NotNull Integer grouponId) {
LitemallGroupon groupon = grouponService.queryById(grouponId);
if (groupon == null) {
return ResponseUtil.badArgumentValue();
}
LitemallGrouponRules rules = rulesService.queryById(groupon.getRulesId());
if (rules == null) {
return ResponseUtil.badArgumentValue();
}
LitemallGoods goods = goodsService.findById(rules.getGoodsId());
if (goods == null) {
return ResponseUtil.badArgumentValue();
}
Map<String, Object> result = new HashMap<>();
result.put("groupon", groupon);
result.put("goods", goods);
return ResponseUtil.ok(result);
}
@GetMapping("my")
public Object my(@LoginUser Integer userId, @RequestParam(defaultValue = "0") Integer showType) {
if (userId == null) {
return ResponseUtil.unlogin();
}
List<LitemallGroupon> myGroupons;
if (showType == 0) {
myGroupons = grouponService.queryMyGroupon(userId);
} else {
myGroupons = grouponService.queryMyJoinGroupon(userId);
}
List<Map<String, Object>> grouponVoList = new ArrayList<>(myGroupons.size());
LitemallOrder order;
LitemallGrouponRules rules;
LitemallUser creator;
for (LitemallGroupon groupon : myGroupons) {
order = orderService.findById(groupon.getOrderId());
rules = rulesService.queryById(groupon.getRulesId());
creator = userService.findById(groupon.getCreatorUserId());
Map<String, Object> grouponVo = new HashMap<>();
//填充团购信息
grouponVo.put("id", groupon.getId());
grouponVo.put("groupon", groupon);
grouponVo.put("rules", rules);
grouponVo.put("creator", creator.getNickname());
int linkGrouponId;
// 这是一个团购发起记录
if (groupon.getGrouponId() == 0) {
linkGrouponId = groupon.getId();
grouponVo.put("isCreator", creator.getId() == userId);
} else {
linkGrouponId = groupon.getGrouponId();
grouponVo.put("isCreator", false);
}
int joinerCount = grouponService.countGroupon(linkGrouponId);
grouponVo.put("joinerCount", joinerCount + 1);
//填充订单信息
grouponVo.put("orderId", order.getId());
grouponVo.put("orderSn", order.getOrderSn());
grouponVo.put("actualPrice", order.getActualPrice());
grouponVo.put("orderStatusText", OrderUtil.orderStatusText(order));
grouponVo.put("handleOption", OrderUtil.build(order));
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(order.getId());
List<Map<String, Object>> orderGoodsVoList = new ArrayList<>(orderGoodsList.size());
for (LitemallOrderGoods orderGoods : orderGoodsList) {
Map<String, Object> orderGoodsVo = new HashMap<>();
orderGoodsVo.put("id", orderGoods.getId());
orderGoodsVo.put("goodsName", orderGoods.getGoodsName());
orderGoodsVo.put("number", orderGoods.getNumber());
orderGoodsVo.put("picUrl", orderGoods.getPicUrl());
orderGoodsVoList.add(orderGoodsVo);
}
grouponVo.put("goodsList", orderGoodsVoList);
grouponVoList.add(grouponVo);
}
Map<String, Object> result = new HashMap<>();
result.put("count", grouponVoList.size());
result.put("data", grouponVoList);
return ResponseUtil.ok(result);
}
@GetMapping("query")
public Object query(@NotNull Integer goodsId) {
LitemallGoods goods = goodsService.findById(goodsId);
if (goods == null) {
return ResponseUtil.fail(-1, "未找到对应的商品");
}
List<LitemallGrouponRules> rules = rulesService.queryByGoodsId(goodsId);
return ResponseUtil.ok(rules);
}
}

View File

@@ -4,12 +4,14 @@ import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.*;
import org.linlinjava.litemall.db.service.*;
import org.linlinjava.litemall.core.system.SystemConfig;
import org.linlinjava.litemall.wx.service.HomeCacheManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -29,6 +31,20 @@ public class WxHomeController {
private LitemallTopicService topicService;
@Autowired
private LitemallCategoryService categoryService;
@Autowired
private LitemallGrouponRulesService grouponRulesService;
@GetMapping("/cache")
public Object cache(@NotNull String key) {
if (!key.equals("litemall_cache")) {
return ResponseUtil.fail();
}
// 清除缓存
HomeCacheManager.clearAll();
return ResponseUtil.ok("缓存已清除");
}
/**
* app首页
@@ -52,6 +68,12 @@ public class WxHomeController {
*/
@GetMapping("/index")
public Object index() {
//优先从缓存中读取
if (HomeCacheManager.hasData(HomeCacheManager.INDEX)) {
return ResponseUtil.ok(HomeCacheManager.getCacheData(HomeCacheManager.INDEX));
}
Map<String, Object> data = new HashMap<>();
List<LitemallAd> banner = adService.queryIndex();
@@ -72,6 +94,26 @@ public class WxHomeController {
List<LitemallTopic> topicList = topicService.queryList(0, SystemConfig.getTopicLimit());
data.put("topicList", topicList);
//优惠专区
List<LitemallGrouponRules> grouponRules = grouponRulesService.queryByIndex(0, 4);
List<LitemallGoods> grouponGoods = new ArrayList<>();
List<Map<String, Object>> grouponList = new ArrayList<>();
for (LitemallGrouponRules rule : grouponRules) {
LitemallGoods goods = goodsService.findById(rule.getGoodsId());
if (goods == null)
continue;
if (!grouponGoods.contains(goods)) {
Map<String, Object> item = new HashMap<>();
item.put("goods", goods);
item.put("groupon_price", goods.getRetailPrice().subtract(rule.getDiscount()));
item.put("groupon_member", rule.getDiscountMember());
grouponList.add(item);
grouponGoods.add(goods);
}
}
data.put("grouponList", grouponList);
List<Map> categoryList = new ArrayList<>();
List<LitemallCategory> catL1List = categoryService.queryL1WithoutRecommend(0, SystemConfig.getCatlogListLimit());
for (LitemallCategory catL1 : catL1List) {
@@ -96,6 +138,8 @@ public class WxHomeController {
}
data.put("floorGoodsList", categoryList);
//缓存数据
HomeCacheManager.loadData(HomeCacheManager.INDEX, data);
return ResponseUtil.ok(data);
}
}

View File

@@ -11,6 +11,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.core.notify.NotifyService;
import org.linlinjava.litemall.core.notify.NotifyType;
import org.linlinjava.litemall.core.qcode.QCodeService;
import org.linlinjava.litemall.core.util.DateTimeUtil;
import org.linlinjava.litemall.core.util.JacksonUtil;
import org.linlinjava.litemall.core.util.ResponseUtil;
@@ -82,15 +83,18 @@ public class WxOrderController {
private LitemallRegionService regionService;
@Autowired
private LitemallProductService productService;
@Autowired
private WxPayService wxPayService;
@Autowired
private NotifyService notifyService;
@Autowired
private LitemallUserFormIdService formIdService;
@Autowired
private LitemallGrouponRulesService grouponRulesService;
@Autowired
private LitemallGrouponService grouponService;
@Autowired
private QCodeService qCodeService;
public WxOrderController() {
}
@@ -153,6 +157,13 @@ public class WxOrderController {
orderVo.put("orderStatusText", OrderUtil.orderStatusText(order));
orderVo.put("handleOption", OrderUtil.build(order));
LitemallGroupon groupon = grouponService.queryByOrderId(order.getId());
if (groupon != null) {
orderVo.put("isGroupin", true);
} else {
orderVo.put("isGroupin", false);
}
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(order.getId());
List<Map<String, Object>> orderGoodsVoList = new ArrayList<>(orderGoodsList.size());
for (LitemallOrderGoods orderGoods : orderGoodsList) {
@@ -167,6 +178,7 @@ public class WxOrderController {
orderVoList.add(orderVo);
}
Map<String, Object> result = new HashMap<>();
result.put("count", count);
result.put("data", orderVoList);
@@ -267,6 +279,9 @@ public class WxOrderController {
Integer cartId = JacksonUtil.parseInteger(body, "cartId");
Integer addressId = JacksonUtil.parseInteger(body, "addressId");
Integer couponId = JacksonUtil.parseInteger(body, "couponId");
Integer grouponRulesId = JacksonUtil.parseInteger(body, "grouponRulesId");
Integer grouponLinkId = JacksonUtil.parseInteger(body, "grouponLinkId");
if (cartId == null || addressId == null || couponId == null) {
return ResponseUtil.badArgument();
}
@@ -278,6 +293,13 @@ public class WxOrderController {
// 使用优惠券减免的金额
BigDecimal couponPrice = new BigDecimal(0.00);
// 团购优惠
BigDecimal grouponPrice = new BigDecimal(0.00);
LitemallGrouponRules grouponRules = grouponRulesService.queryById(grouponRulesId);
if (grouponRules != null) {
grouponPrice = grouponRules.getDiscount();
}
// 货品价格
List<LitemallCart> checkedGoodsList = null;
if (cartId.equals(0)) {
@@ -292,7 +314,12 @@ public class WxOrderController {
}
BigDecimal checkedGoodsPrice = new BigDecimal(0.00);
for (LitemallCart checkGoods : checkedGoodsList) {
checkedGoodsPrice = checkedGoodsPrice.add(checkGoods.getPrice().multiply(new BigDecimal(checkGoods.getNumber())));
// 只有当团购规格商品ID符合才进行团购优惠
if (grouponRules != null && grouponRules.getGoodsId().equals(checkGoods.getGoodsId())) {
checkedGoodsPrice = checkedGoodsPrice.add(checkGoods.getPrice().subtract(grouponPrice).multiply(new BigDecimal(checkGoods.getNumber())));
} else {
checkedGoodsPrice = checkedGoodsPrice.add(checkGoods.getPrice().multiply(new BigDecimal(checkGoods.getNumber())));
}
}
// 根据订单商品总价计算运费满88则免运费否则8元
@@ -304,7 +331,6 @@ public class WxOrderController {
// 可以使用的其他钱,例如用户积分
BigDecimal integralPrice = new BigDecimal(0.00);
// 订单费用
BigDecimal orderTotalPrice = checkedGoodsPrice.add(freightPrice).subtract(couponPrice);
BigDecimal actualPrice = orderTotalPrice.subtract(integralPrice);
@@ -332,6 +358,14 @@ public class WxOrderController {
order.setIntegralPrice(integralPrice);
order.setOrderPrice(orderTotalPrice);
order.setActualPrice(actualPrice);
// 有团购活动
if (grouponRules != null) {
order.setGrouponPrice(grouponPrice); // 团购价格
} else {
order.setGrouponPrice(new BigDecimal(0.00)); // 团购价格
}
// 添加订单表项
orderService.add(order);
orderId = order.getId();
@@ -369,6 +403,30 @@ public class WxOrderController {
product.setNumber(remainNumber);
productService.updateById(product);
}
//如果是团购项目,添加团购信息
if (grouponRulesId != null && grouponRulesId > 0) {
LitemallGroupon groupon = new LitemallGroupon();
groupon.setOrderId(orderId);
groupon.setPayed(false);
groupon.setUserId(userId);
groupon.setRulesId(grouponRulesId);
//参与者
if (grouponLinkId != null && grouponLinkId > 0) {
LitemallGroupon baseGroupon = grouponService.queryById(grouponLinkId);
groupon.setCreatorUserId(baseGroupon.getCreatorUserId());
groupon.setGrouponId(grouponLinkId);
groupon.setShareUrl(baseGroupon.getShareUrl());
} else {
groupon.setCreatorUserId(userId);
groupon.setGrouponId(0);
}
groupon.setAddTime(LocalDateTime.now());
grouponService.createGroupon(groupon);
}
} catch (Exception ex) {
txManager.rollback(status);
logger.error("系统内部错误", ex);
@@ -545,6 +603,7 @@ public class WxOrderController {
String orderSn = result.getOutTradeNo();
String payId = result.getTransactionId();
// 分转化成元
String totalFee = BaseWxPayResult.fenToYuan(result.getTotalFee());
@@ -568,6 +627,20 @@ public class WxOrderController {
order.setOrderStatus(OrderUtil.STATUS_PAY);
orderService.updateById(order);
// 支付成功,有团购信息,更新团购信息
LitemallGroupon groupon = grouponService.queryByOrderId(order.getId());
if (groupon != null) {
LitemallGrouponRules grouponRules = grouponRulesService.queryById(groupon.getRulesId());
//仅当发起者才创建分享图片
if (groupon.getGrouponId() == 0) {
String url = qCodeService.createGrouponShareImage(grouponRules.getGoodsName(), grouponRules.getPicUrl(), groupon);
groupon.setShareUrl(url);
}
groupon.setPayed(true);
grouponService.update(groupon);
}
//TODO 发送邮件和短信通知,这里采用异步发送
// 订单支付成功以后,会发送短信给用户,以及发送邮件给管理员
notifyService.notifyMail("新订单通知", order.toString());

View File

@@ -1,82 +1,84 @@
{
"pages": [
"pages/index/index",
"pages/catalog/catalog",
"pages/newGoods/newGoods",
"pages/hotGoods/hotGoods",
"pages/ucenter/index/index",
"pages/ucenter/address/address",
"pages/ucenter/addressAdd/addressAdd",
"pages/ucenter/footprint/footprint",
"pages/ucenter/order/order",
"pages/ucenter/orderDetail/orderDetail",
"pages/ucenter/coupon/coupon",
"pages/ucenter/collect/collect",
"pages/auth/login/login",
"pages/auth/accountLogin/accountLogin",
"pages/auth/register/register",
"pages/auth/reset/reset",
"pages/payResult/payResult",
"pages/comment/comment",
"pages/commentPost/commentPost",
"pages/topic/topic",
"pages/topicComment/topicComment",
"pages/topicDetail/topicDetail",
"pages/topicCommentPost/topicCommentPost",
"pages/brand/brand",
"pages/brandDetail/brandDetail",
"pages/search/search",
"pages/category/category",
"pages/cart/cart",
"pages/checkout/checkout",
"pages/goods/goods",
"pages/about/about"
],
"window": {
"navigationBarBackgroundColor": "#FFFFFF",
"navigationBarTitleText": "litemall小程序商城",
"enablePullDownRefresh": true,
"navigationBarTextStyle": "black",
"backgroundColor": "#FFFFFF",
"backgroundTextStyle": "dark"
},
"tabBar": {
"backgroundColor": "#fafafa",
"borderStyle": "white",
"selectedColor": "#AB956D",
"color": "#666",
"list": [
{
"pagePath": "pages/index/index",
"iconPath": "static/images/ic_menu_choice_nor.png",
"selectedIconPath": "static/images/home@selected.png",
"text": "首页"
},
{
"pagePath": "pages/catalog/catalog",
"iconPath": "static/images/ic_menu_sort_nor.png",
"selectedIconPath": "static/images/category@selected.png",
"text": "分类"
},
{
"pagePath": "pages/cart/cart",
"iconPath": "static/images/ic_menu_shoping_nor.png",
"selectedIconPath": "static/images/cart@selected.png",
"text": "购物车"
},
{
"pagePath": "pages/ucenter/index/index",
"iconPath": "static/images/ic_menu_me_nor.png",
"selectedIconPath": "static/images/my@selected.png",
"text": "个人"
}
]
},
"networkTimeout": {
"request": 10000,
"connectSocket": 10000,
"uploadFile": 10000,
"downloadFile": 10000
},
"debug": true
"pages": [
"pages/index/index",
"pages/catalog/catalog",
"pages/newGoods/newGoods",
"pages/hotGoods/hotGoods",
"pages/ucenter/index/index",
"pages/ucenter/address/address",
"pages/ucenter/addressAdd/addressAdd",
"pages/ucenter/footprint/footprint",
"pages/ucenter/order/order",
"pages/ucenter/orderDetail/orderDetail",
"pages/ucenter/coupon/coupon",
"pages/ucenter/collect/collect",
"pages/auth/login/login",
"pages/auth/accountLogin/accountLogin",
"pages/auth/register/register",
"pages/auth/reset/reset",
"pages/payResult/payResult",
"pages/comment/comment",
"pages/commentPost/commentPost",
"pages/topic/topic",
"pages/topicComment/topicComment",
"pages/topicDetail/topicDetail",
"pages/topicCommentPost/topicCommentPost",
"pages/brand/brand",
"pages/brandDetail/brandDetail",
"pages/search/search",
"pages/category/category",
"pages/cart/cart",
"pages/checkout/checkout",
"pages/goods/goods",
"pages/about/about",
"pages/groupon/myGroupon/myGroupon",
"pages/groupon/grouponDetail/grouponDetail"
],
"window": {
"navigationBarBackgroundColor": "#FFFFFF",
"navigationBarTitleText": "litemall小程序商城",
"enablePullDownRefresh": true,
"navigationBarTextStyle": "black",
"backgroundColor": "#FFFFFF",
"backgroundTextStyle": "dark"
},
"tabBar": {
"backgroundColor": "#fafafa",
"borderStyle": "white",
"selectedColor": "#AB956D",
"color": "#666",
"list": [
{
"pagePath": "pages/index/index",
"iconPath": "static/images/ic_menu_choice_nor.png",
"selectedIconPath": "static/images/home@selected.png",
"text": "首页"
},
{
"pagePath": "pages/catalog/catalog",
"iconPath": "static/images/ic_menu_sort_nor.png",
"selectedIconPath": "static/images/category@selected.png",
"text": "分类"
},
{
"pagePath": "pages/cart/cart",
"iconPath": "static/images/ic_menu_shoping_nor.png",
"selectedIconPath": "static/images/cart@selected.png",
"text": "购物车"
},
{
"pagePath": "pages/ucenter/index/index",
"iconPath": "static/images/ic_menu_me_nor.png",
"selectedIconPath": "static/images/my@selected.png",
"text": "个人"
}
]
},
"networkTimeout": {
"request": 10000,
"connectSocket": 10000,
"uploadFile": 10000,
"downloadFile": 10000
},
"debug": true
}

View File

@@ -4,9 +4,9 @@
// 局域网测试使用
// var WxApiRoot = 'http://192.168.0.101:8080/wx/';
// 云平台部署时使用
var WxApiRoot = 'http://122.152.206.172:8080/wx/';
// var WxApiRoot = 'http://122.152.206.172:8080/wx/';
// 云平台上线时使用
// var WxApiRoot = 'https://www.menethil.com.cn/wx/';
var WxApiRoot = 'https://www.menethil.com.cn/wx/';
module.exports = {
IndexUrl: WxApiRoot + 'home/index', //首页数据接口
@@ -79,5 +79,9 @@ module.exports = {
UserFormIdCreate: WxApiRoot + 'formid/create', //用户FromId用于发送模版消息
GroupOn: WxApiRoot + 'groupon/query', //团购API-查询
GroupOnMy: WxApiRoot + 'groupon/my', //团购API-我的团购
GroupOnDetail: WxApiRoot + 'groupon/detail', //团购API-详情
GroupOnJoin: WxApiRoot + 'groupon/join', //团购API-详情
StorageUpload: WxApiRoot + 'storage/upload' //图片上传
};

31
litemall-wx/dist/capsule/index.js vendored Normal file
View File

@@ -0,0 +1,31 @@
'use strict';
Component({
externalClasses: ['custom-class'],
/**
* 组件的属性列表
* 用于组件自定义设置
*/
properties: {
// 颜色状态
type: {
type: String,
value: ''
},
// 自定义颜色
color: {
type: String,
value: ''
},
// 左侧内容
leftText: {
type: String,
value: ''
},
// 右侧内容
rightText: {
type: String,
value: ''
}
}
});

3
litemall-wx/dist/capsule/index.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"component": true
}

10
litemall-wx/dist/capsule/index.wxml vendored Normal file
View File

@@ -0,0 +1,10 @@
<view class="custom-class zan-capsule zan-capsule--{{type}}">
<block wx:if="{{color}}">
<view class="zan-capsule__left" style="background: {{ color }}; border-color: {{ color }}">{{ leftText }}</view>
<view class="zan-capsule__right" style="color: {{ color }}; border-color: {{ color }}">{{ rightText }}</view>
</block>
<block wx:else>
<view class="zan-capsule__left">{{ leftText }}</view>
<view class="zan-capsule__right">{{ rightText }}</view>
</block>
</view>

42
litemall-wx/dist/capsule/index.wxss vendored Normal file
View File

@@ -0,0 +1,42 @@
.zan-capsule {
display: inline-block;
font-size: 12px;
vertical-align: middle;
line-height: 19px;
-webkit-transform: scale(0.83);
transform: scale(0.83);
}
.zan-capsule__left, .zan-capsule__right {
display: inline-block;
line-height: 17px;
height: 19px;
vertical-align: middle;
box-sizing: border-box;
}
.zan-capsule__left {
padding: 0 2px;
color: #fff;
background: #999;
border-radius: 2px 0 0 2px;
border: 1rpx solid #999;
}
.zan-capsule__right {
padding: 0 5px;
color: #999;
border-radius: 0 2px 2px 0;
border: 1rpx solid #999;
}
.zan-capsule--danger .zan-capsule__left {
color: #fff;
background: #f24544;
border-color: #f24544;
}
.zan-capsule--danger .zan-capsule__right {
color: #f24544;
border-color: #f24544;
}

View File

@@ -12,168 +12,170 @@ Page({
goodsTotalPrice: 0.00, //商品总价
freightPrice: 0.00, //快递费
couponPrice: 0.00, //优惠券的价格
grouponPrice: 0.00, //团购优惠价格
orderTotalPrice: 0.00, //订单总价
actualPrice: 0.00, //实际需要支付的总价
cartId: 0,
addressId: 0,
couponId: 0
},
onLoad: function (options) {
// 页面初始化 options为页面跳转所带来的参数
},
getCheckoutInfo: function () {
let that = this;
util.request(api.CartCheckout, { cartId: that.data.cartId, addressId: that.data.addressId, couponId: that.data.couponId }).then(function (res) {
if (res.errno === 0) {
that.setData({
checkedGoodsList: res.data.checkedGoodsList,
checkedAddress: res.data.checkedAddress,
actualPrice: res.data.actualPrice,
checkedCoupon: res.data.checkedCoupon,
couponList: res.data.couponList,
couponPrice: res.data.couponPrice,
freightPrice: res.data.freightPrice,
goodsTotalPrice: res.data.goodsTotalPrice,
orderTotalPrice: res.data.orderTotalPrice,
addressId: res.data.addressId,
couponId: res.data.couponId
});
}
wx.hideLoading();
couponId: 0,
grouponLinkId: 0, //参与的团购如果是发起则为0
grouponRulesId: 0 //团购规则ID
},
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
},
//获取checkou信息
getCheckoutInfo: function() {
let that = this;
util.request(api.CartCheckout, {
cartId: that.data.cartId,
addressId: that.data.addressId,
couponId: that.data.couponId,
grouponRulesId: that.data.grouponRulesId
}).then(function(res) {
if (res.errno === 0) {
that.setData({
checkedGoodsList: res.data.checkedGoodsList,
checkedAddress: res.data.checkedAddress,
actualPrice: res.data.actualPrice,
checkedCoupon: res.data.checkedCoupon,
couponPrice: res.data.couponPrice,
grouponPrice: res.data.grouponPrice,
freightPrice: res.data.freightPrice,
goodsTotalPrice: res.data.goodsTotalPrice,
orderTotalPrice: res.data.orderTotalPrice,
addressId: res.data.addressId,
couponId: res.data.couponId,
grouponRulesId: res.data.grouponRulesId,
});
},
selectAddress() {
wx.navigateTo({
url: '/pages/ucenter/address/address',
})
},
addAddress() {
wx.navigateTo({
url: '/pages/ucenter/addressAdd/addressAdd',
})
},
onReady: function () {
// 页面渲染完成
}
wx.hideLoading();
});
},
selectAddress() {
wx.navigateTo({
url: '/pages/ucenter/address/address',
})
},
addAddress() {
wx.navigateTo({
url: '/pages/ucenter/addressAdd/addressAdd',
})
},
onReady: function() {
// 页面渲染完成
},
onShow: function () {
// 页面显示
wx.showLoading({
title: '加载中...',
})
try {
var cartId = wx.getStorageSync('cartId');
if (cartId) {
this.setData({
'cartId': cartId
});
}
var addressId = wx.getStorageSync('addressId');
if (addressId) {
this.setData({
'addressId': addressId
});
}
var couponId = wx.getStorageSync('couponId');
if (couponId) {
this.setData({
'couponId': couponId
});
}
} catch (e) {
// Do something when catch error
console.log(e);
}
this.getCheckoutInfo();
},
onHide: function () {
// 页面隐藏
},
onUnload: function () {
// 页面关闭
},
submitOrder: function () {
if (this.data.addressId <= 0) {
util.showErrorToast('请选择收货地址');
return false;
}
util.request(api.OrderSubmit, { cartId: this.data.cartId, addressId: this.data.addressId, couponId: this.data.couponId }, 'POST').then(res => {
if (res.errno === 0) {
const orderId = res.data.orderId;
// 模拟支付成功,同理,后台也仅仅是返回一个成功的消息而已
// wx.showModal({
// title: '目前不能微信支付',
// content: '点击确定模拟支付成功,点击取消模拟未支付成功',
// success: function(res) {
// if (res.confirm) {
// util.request(api.OrderPrepay, { orderId: orderId }, 'POST').then(res => {
// if (res.errno === 0) {
// wx.redirectTo({
// url: '/pages/payResult/payResult?status=1&orderId=' + orderId
// });
// }
// else{
// wx.redirectTo({
// url: '/pages/payResult/payResult?status=0&orderId=' + orderId
// });
// }
// });
// }
// else if (res.cancel) {
// wx.redirectTo({
// url: '/pages/payResult/payResult?status=0&orderId=' + orderId
// });
// }
// }
// });
util.request(api.OrderPrepay, {
orderId: orderId
}, 'POST').then(function (res) {
if (res.errno === 0) {
const payParam = res.data;
console.log("支付过程开始")
wx.requestPayment({
'timeStamp': payParam.timeStamp,
'nonceStr': payParam.nonceStr,
'package': payParam.packageValue,
'signType': payParam.signType,
'paySign': payParam.paySign,
'success': function (res) {
console.log("支付过程成功")
wx.redirectTo({
url: '/pages/payResult/payResult?status=1&orderId=' + orderId
});
},
'fail': function (res) {
console.log("支付过程失败")
wx.redirectTo({
url: '/pages/payResult/payResult?status=0&orderId=' + orderId
});
},
'complete': function (res) {
console.log("支付过程结束")
}
});
}
else{
wx.redirectTo({
url: '/pages/payResult/payResult?status=0&orderId=' + orderId
});
}
});
} else {
wx.redirectTo({
url: '/pages/payResult/payResult?status=0&orderId=' + orderId
});
}
},
onShow: function() {
// 页面显示
wx.showLoading({
title: '加载中...',
});
try {
var cartId = wx.getStorageSync('cartId');
if (cartId) {
this.setData({
'cartId': cartId
});
}
var addressId = wx.getStorageSync('addressId');
if (addressId) {
this.setData({
'addressId': addressId
});
}
var couponId = wx.getStorageSync('couponId');
if (couponId) {
this.setData({
'couponId': couponId
});
}
var grouponRulesId = wx.getStorageSync('grouponRulesId');
if (grouponRulesId) {
this.setData({
'grouponRulesId': grouponRulesId
});
}
var grouponLinkId = wx.getStorageSync('grouponLinkId');
if (grouponLinkId) {
this.setData({
'grouponLinkId': grouponLinkId
});
}
} catch (e) {
// Do something when catch error
console.log(e);
}
})
this.getCheckoutInfo();
},
onHide: function() {
// 页面隐藏
},
onUnload: function() {
// 页面关闭
},
submitOrder: function() {
if (this.data.addressId <= 0) {
util.showErrorToast('请选择收货地址');
return false;
}
util.request(api.OrderSubmit, {
cartId: this.data.cartId,
addressId: this.data.addressId,
couponId: this.data.couponId,
grouponRulesId: this.data.grouponRulesId,
grouponLinkId: this.data.grouponLinkId
}, 'POST').then(res => {
if (res.errno === 0) {
const orderId = res.data.orderId;
util.request(api.OrderPrepay, {
orderId: orderId
}, 'POST').then(function(res) {
if (res.errno === 0) {
const payParam = res.data;
console.log("支付过程开始");
wx.requestPayment({
'timeStamp': payParam.timeStamp,
'nonceStr': payParam.nonceStr,
'package': payParam.packageValue,
'signType': payParam.signType,
'paySign': payParam.paySign,
'success': function(res) {
console.log("支付过程成功");
wx.redirectTo({
url: '/pages/payResult/payResult?status=1&orderId=' + orderId
});
},
'fail': function(res) {
console.log("支付过程失败");
wx.redirectTo({
url: '/pages/payResult/payResult?status=0&orderId=' + orderId
});
},
'complete': function(res) {
console.log("支付过程结束")
}
});
} else {
wx.redirectTo({
url: '/pages/payResult/payResult?status=0&orderId=' + orderId
});
}
});
} else {
wx.redirectTo({
url: '/pages/payResult/payResult?status=0&orderId=' + orderId
});
}
});
}
});

View File

@@ -8,6 +8,8 @@ Page({
data: {
id: 0,
goods: {},
groupon: [], //该商品支持的团购规格
grouponLink: {}, //参与的团购
attribute: [],
issueList: [],
comment: [],
@@ -26,16 +28,21 @@ Page({
hasCollectImage: '/static/images/icon_collect_checked.png',
collectImage: '/static/images/icon_collect.png',
shareImage: '',
isGroupon: false, //标识是否是一个参团购买
soldout: false
},
onPullDownRefresh() {
wx.showNavigationBarLoading() //在标题栏中显示加载
this.getGoodsInfo();
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
// 页面分享
onShareAppMessage: function() {
let that = this;
return {
title: that.data.goods.name,
desc: '唯爱与美食不可辜负',
path: '/pages/index/index?goodId=' + this.data.id
}
},
// 保存分享图
saveShare: function() {
let that = this;
wx.downloadFile({
@@ -69,6 +76,24 @@ Page({
})
},
//从分享的团购进入
getGrouponInfo: function(grouponId) {
let that = this;
util.request(api.GroupOnJoin, {
grouponId: grouponId
}).then(function(res) {
if (res.errno === 0) {
that.setData({
grouponLink: res.data.groupon,
id: res.data.goods.id
});
//获取商品详情
that.getGoodsInfo();
}
});
},
// 获取商品信息
getGoodsInfo: function() {
let that = this;
util.request(api.GoodsDetail, {
@@ -107,9 +132,26 @@ Page({
productList: res.data.productList,
userHasCollect: res.data.userHasCollect,
shareImage: res.data.shareImage,
checkedSpecPrice: res.data.info.retailPrice
checkedSpecPrice: res.data.info.retailPrice,
groupon: res.data.groupon
});
//如果是通过分享的团购参加团购,则团购项目应该与分享的一致并且不可更改
if (that.data.isGroupon) {
let groupons = that.data.groupon;
for (var i = 0; i < groupons.length; i++) {
if (groupons[i].id != that.data.grouponLink.rulesId) {
groupons.splice(i, 1);
}
}
groupons[0].checked = true;
//重设团购规格
that.setData({
groupon: groupons
});
}
if (res.data.userHasCollect == 1) {
that.setData({
collectImage: that.data.hasCollectImage
@@ -121,12 +163,13 @@ Page({
}
WxParse.wxParse('goodsDetail', 'html', res.data.info.detail, that);
//获取推荐商品
that.getGoodsRelated();
}
});
},
// 获取推荐商品
getGoodsRelated: function() {
let that = this;
util.request(api.GoodsRelated, {
@@ -138,8 +181,39 @@ Page({
});
}
});
},
// 团购选择
clickGroupon: function(event) {
let that = this;
//参与团购,不可更改选择
if (that.data.isGroupon) {
return;
}
let specName = event.currentTarget.dataset.name;
let specValueId = event.currentTarget.dataset.valueId;
let _grouponList = this.data.groupon;
for (let i = 0; i < _grouponList.length; i++) {
if (_grouponList[i].id == specValueId) {
if (_grouponList[i].checked) {
_grouponList[i].checked = false;
} else {
_grouponList[i].checked = true;
}
} else {
_grouponList[i].checked = false;
}
}
this.setData({
groupon: _grouponList,
});
},
// 规格选择
clickSkuValue: function(event) {
let that = this;
let specName = event.currentTarget.dataset.name;
@@ -173,6 +247,20 @@ Page({
//重新计算哪些值不可以点击
},
//获取选中的团购信息
getCheckedGrouponValue: function() {
let checkedValues = {};
let _grouponList = this.data.groupon;
for (let i = 0; i < _grouponList.length; i++) {
if (_grouponList[i].checked) {
checkedValues = _grouponList[i];
}
}
return checkedValues;
},
//获取选中的规格信息
getCheckedSpecValue: function() {
let checkedValues = [];
@@ -194,10 +282,7 @@ Page({
return checkedValues;
},
//根据已选的值,计算其它值的状态
setSpecValueStatus: function() {
},
//判断规格是否选择完整
isCheckedAllSpec: function() {
return !this.getCheckedSpecValue().some(function(v) {
@@ -206,13 +291,15 @@ Page({
}
});
},
getCheckedSpecKey: function() {
let checkedValue = this.getCheckedSpecValue().map(function(v) {
return v.valueText;
});
return checkedValue;
},
// 规格改变时,重新计算价格及显示信息
changeSpecInfo: function() {
let checkedNameValue = this.getCheckedSpecValue();
@@ -236,7 +323,6 @@ Page({
});
}
if (this.isCheckedAllSpec()) {
this.setData({
checkedSpecText: this.data.tmpSpecText
@@ -274,6 +360,8 @@ Page({
}
},
// 获取选中的产品(根据规格)
getCheckedProductItem: function(key) {
return this.data.productList.filter(function(v) {
if (v.specifications.toString() == key.toString()) {
@@ -283,16 +371,22 @@ Page({
}
});
},
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
this.setData({
id: parseInt(options.id)
});
this.getGoodsInfo();
},
onReady: function() {
// 页面渲染完成
if (options.id) {
this.setData({
id: parseInt(options.id)
});
this.getGoodsInfo();
}
if (options.grouponId) {
this.setData({
isGroupon: true,
});
this.getGrouponInfo(options.grouponId);
}
},
onShow: function() {
// 页面显示
@@ -305,29 +399,10 @@ Page({
}
});
},
onHide: function() {
// 页面隐藏
},
onUnload: function() {
// 页面关闭
},
switchAttrPop: function() {
if (this.data.openAttr == false) {
this.setData({
openAttr: !this.data.openAttr
});
}
},
closeAttr: function() {
this.setData({
openAttr: false,
});
},
//添加或是取消收藏
addCollectOrNot: function() {
let that = this;
//添加或是取消收藏
util.request(api.CollectAddOrDelete, {
type: 0,
valueId: this.data.id
@@ -356,11 +431,8 @@ Page({
});
},
openCartPage: function() {
wx.switchTab({
url: '/pages/cart/cart'
});
},
//立即购买(先自动加入购物车)
addFast: function() {
var that = this;
if (this.data.openAttr == false) {
@@ -400,6 +472,9 @@ Page({
return false;
}
//验证团购是否有效
let checkedGroupon = this.getCheckedGrouponValue();
//立即购买
util.request(api.CartFastAdd, {
goodsId: this.data.goods.id,
@@ -412,6 +487,8 @@ Page({
// 如果storage中设置了cartId则是立即购买否则是购物车购买
try {
wx.setStorageSync('cartId', res.data);
wx.setStorageSync('grouponRulesId', checkedGroupon.id);
wx.setStorageSync('grouponLinkId', that.data.grouponLink.id);
wx.navigateTo({
url: '/pages/checkout/checkout'
})
@@ -429,6 +506,8 @@ Page({
},
//添加到购物车
addToCart: function() {
var that = this;
if (this.data.openAttr == false) {
@@ -505,6 +584,7 @@ Page({
}
},
cutNumber: function() {
this.setData({
number: (this.data.number - 1 > 1) ? this.data.number - 1 : 1
@@ -514,5 +594,46 @@ Page({
this.setData({
number: this.data.number + 1
});
}
},
onHide: function() {
// 页面隐藏
},
onUnload: function() {
// 页面关闭
},
switchAttrPop: function() {
if (this.data.openAttr == false) {
this.setData({
openAttr: !this.data.openAttr
});
}
},
closeAttr: function() {
this.setData({
openAttr: false,
});
},
openCartPage: function() {
wx.switchTab({
url: '/pages/cart/cart'
});
},
onReady: function() {
// 页面渲染完成
},
// 下拉刷新
onPullDownRefresh() {
wx.showNavigationBarLoading() //在标题栏中显示加载
this.getGoodsInfo();
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
},
//根据已选的值,计算其它值的状态
setSpecValueStatus: function() {
},
})

View File

@@ -1,153 +1,177 @@
<view class="container">
<swiper class="goodsimgs" indicator-dots="true" autoplay="true" interval="3000" duration="1000">
<swiper-item wx:for="{{goods.gallery}}" wx:key="*this">
<image src="{{item}}" background-size="cover"></image>
</swiper-item>
</swiper>
<view class="service-policy">
<swiper class="goodsimgs" indicator-dots="true" autoplay="true" interval="3000" duration="1000">
<swiper-item wx:for="{{goods.gallery}}" wx:key="*this">
<image src="{{item}}" background-size="cover"></image>
</swiper-item>
</swiper>
<!-- 分享 -->
<view class="service-policy" wx:if="{{!isGroupon}}">
<button class="savesharebtn" bindtap="saveShare">分享朋友圈</button>
<button class="sharebtn" open-type="share">分享给朋友</button>
</view>
<view class="goods-info">
<view class="c">
<text class="name">{{goods.name}}</text>
<text class="desc">{{goods.goodsBrief}}</text>
<text class="price">¥{{checkedSpecPrice}}</text>
<view class="brand" wx:if="{{brand.name}}">
<navigator url="../brandDetail/brandDetail?id={{brand.id}}">
<text>{{brand.name}}</text>
</navigator>
</view>
</view>
</view>
<view class="section-nav section-attr" bindtap="switchAttrPop">
<view class="t">{{checkedSpecText}}</view>
<image class="i" src="/static/images/address_right.png" background-size="cover"></image>
</view>
<view class="comments" wx:if="{{comment.count > 0}}">
<view class="h">
<navigator url="/pages/comment/comment?valueId={{goods.id}}&type=0">
<text class="t">评价({{comment.count > 999 ? '999+' : comment.count}})</text>
<text class="i">查看全部</text>
</navigator>
</view>
<view class="b">
<view class="item" wx:for="{{comment.data}}" wx:key="id">
<view class="info">
<view class="user">
<image src="{{item.avatar}}"></image>
<text>{{item.nickname}}</text>
</view>
<view class="time">{{item.addTime}}</view>
</view>
<view class="content">
{{item.content}}
</view>
<view class="imgs" wx:if="{{item.picList.length > 0}}">
<image class="img" wx:for="{{item.picList}}" wx:key="*this" wx:for-item="iitem" src="{{iitem}} "></image>
</view>
<!-- <view class="spec">白色 2件</view> -->
</view>
</view>
</view>
<view class="goods-attr">
<view class="t">商品参数</view>
<view class="l">
<view class="item" wx:for="{{attribute}}" wx:key="name">
<text class="left">{{item.attribute}}</text>
<text class="right">{{item.value}}</text>
</view>
</view>
</view>
<view class="goods-info">
<view class="c">
<text class="name">{{goods.name}}</text>
<text class="desc">{{goods.goodsBrief}}</text>
<view class="price">
<view class="counterPrice">原价:¥{{goods.counterPrice}}</view>
<view class="retailPrice">现价:¥{{checkedSpecPrice}}</view>
</view>
<view class="detail">
<import src="/lib/wxParse/wxParse.wxml" />
<template is="wxParse" data="{{wxParseData:goodsDetail.nodes}}" />
<view class="brand" wx:if="{{brand.name}}">
<navigator url="../brandDetail/brandDetail?id={{brand.id}}">
<text>{{brand.name}}</text>
</navigator>
</view>
</view>
<view class="common-problem">
<view class="h">
<view class="line"></view>
<text class="title">常见问题</text>
</view>
<view class="b">
<view class="item" wx:for="{{issueList}}" wx:key="id">
<view class="question-box">
<text class="spot"></text>
<text class="question">{{item.question}}</text>
</view>
<view class="answer">
{{item.answer}}
</view>
</view>
</view>
</view>
<view class="section-nav section-attr" bindtap="switchAttrPop">
<view class="t">{{checkedSpecText}}</view>
<image class="i" src="/static/images/address_right.png" background-size="cover"></image>
</view>
<view class="comments" wx:if="{{comment.count > 0}}">
<view class="h">
<navigator url="/pages/comment/comment?valueId={{goods.id}}&type=0">
<text class="t">评价({{comment.count > 999 ? '999+' : comment.count}})</text>
<text class="i">查看全部</text>
</navigator>
</view>
<view class="related-goods" wx:if="{{relatedGoods.length > 0}}">
<view class="h">
<view class="line"></view>
<text class="title">大家都在看</text>
<view class="b">
<view class="item" wx:for="{{comment.data}}" wx:key="id">
<view class="info">
<view class="user">
<image src="{{item.avatar}}"></image>
<text>{{item.nickname}}</text>
</view>
<view class="time">{{item.addTime}}</view>
</view>
<view class="b">
<view class="item" wx:for="{{relatedGoods}}" wx:key="id">
<navigator url="/pages/goods/goods?id={{item.id}}">
<image class="img" src="{{item.picUrl}}" background-size="cover"></image>
<text class="name">{{item.name}}</text>
<text class="price">¥{{item.retailPrice}}</text>
</navigator>
</view>
<view class="content">
{{item.content}}
</view>
<view class="imgs" wx:if="{{item.picList.length > 0}}">
<image class="img" wx:for="{{item.picList}}" wx:key="*this" wx:for-item="iitem" src="{{iitem}} "></image>
</view>
</view>
</view>
</view>
<view class="goods-attr">
<view class="t">商品参数</view>
<view class="l">
<view class="item" wx:for="{{attribute}}" wx:key="name">
<text class="left">{{item.attribute}}</text>
<text class="right">{{item.value}}</text>
</view>
</view>
</view>
<view class="detail">
<import src="/lib/wxParse/wxParse.wxml" />
<template is="wxParse" data="{{wxParseData:goodsDetail.nodes}}" />
</view>
<view class="common-problem">
<view class="h">
<view class="line"></view>
<text class="title">常见问题</text>
</view>
<view class="b">
<view class="item" wx:for="{{issueList}}" wx:key="id">
<view class="question-box">
<text class="spot"></text>
<text class="question">{{item.question}}</text>
</view>
<view class="answer">
{{item.answer}}
</view>
</view>
</view>
</view>
<!-- 大家都在看 -->
<view class="related-goods" wx:if="{{relatedGoods.length > 0}}">
<view class="h">
<view class="line"></view>
<text class="title">大家都在看</text>
</view>
<view class="b">
<view class="item" wx:for="{{relatedGoods}}" wx:key="id">
<navigator url="/pages/goods/goods?id={{item.id}}">
<image class="img" src="{{item.picUrl}}" background-size="cover"></image>
<text class="name">{{item.name}}</text>
<text class="price">¥{{item.retailPrice}}</text>
</navigator>
</view>
</view>
</view>
</view>
<!-- 规格选择界面 -->
<view class="attr-pop-box" hidden="{{!openAttr}}">
<view class="attr-pop">
<view class="close" bindtap="closeAttr">
<image class="icon" src="/static/images/icon_close.png"></image>
<view class="attr-pop">
<view class="close" bindtap="closeAttr">
<image class="icon" src="/static/images/icon_close.png"></image>
</view>
<view class="img-info">
<image class="img" src="{{goods.picUrl}}"></image>
<view class="info">
<view class="c">
<view class="p">价格:¥{{checkedSpecPrice}}</view>
<view class="a">{{tmpSpecText}}</view>
</view>
<view class="img-info">
<image class="img" src="{{goods.picUrl}}"></image>
<view class="info">
<view class="c">
<view class="p">价格:¥{{checkedSpecPrice}}</view>
<view class="a">{{tmpSpecText}}</view>
</view>
</view>
</view>
<view class="spec-con">
<view class="spec-item" wx:for="{{specificationList}}" wx:key="name">
<view class="name">{{item.name}}</view>
<view class="values">
<view class="value {{vitem.checked ? 'selected' : ''}}" bindtap="clickSkuValue" wx:for="{{item.valueList}}" wx:for-item="vitem" wx:key="{{vitem.id}}" data-value-id="{{vitem.id}}" data-name="{{vitem.specification}}">{{vitem.value}}</view>
</view>
</view>
</view>
</view>
<view class="number-item">
<view class="name">数量</view>
<view class="selnum">
<view class="cut" bindtap="cutNumber">-</view>
<input value="{{number}}" class="number" disabled="true" type="number" />
<view class="add" bindtap="addNumber">+</view>
</view>
</view>
<!-- 规格列表 -->
<view class="spec-con">
<view class="spec-item" wx:for="{{specificationList}}" wx:key="name">
<view class="name">{{item.name}}</view>
<view class="values">
<view class="value {{vitem.checked ? 'selected' : ''}}" bindtap="clickSkuValue" wx:for="{{item.valueList}}" wx:for-item="vitem" wx:key="{{vitem.id}}" data-value-id="{{vitem.id}}" data-name="{{vitem.specification}}">{{vitem.value}}</view>
</view>
</view>
<view class="spec-con" wx:if="{{groupon.length > 0}}">
<view class="spec-item">
<view class="name">团购立减</view>
<view class="values">
<view class="value {{vitem.checked ? 'selected' : ''}}" bindtap="clickGroupon" wx:for="{{groupon}}" wx:for-item="vitem" wx:key="{{vitem.id}}" data-value-id="{{vitem.id}}" data-name="{{vitem.specification}}">¥{{vitem.discount}} ({{vitem.discountMember}}人)</view>
</view>
</view>
</view>
<!-- 数量 -->
<view class="number-item">
<view class="name">数量</view>
<view class="selnum">
<view class="cut" bindtap="cutNumber">-</view>
<input value="{{number}}" class="number" disabled="true" type="number" />
<view class="add" bindtap="addNumber">+</view>
</view>
</view>
</view>
</view>
</view>
<!-- 联系客服 -->
<view class="contact">
<contact-button style="opacity:0;position:absolute;" type="default-dark" session-from="weapp" size="27">
</contact-button>
<contact-button style="opacity:0;position:absolute;" type="default-dark" session-from="weapp" size="27">
</contact-button>
</view>
<!-- 底部按钮 -->
<view class="bottom-btn">
<view class="l l-collect" bindtap="addCollectOrNot">
<image class="icon" src="{{ collectImage }}"></image>
<view class="l l-collect" bindtap="addCollectOrNot" wx:if="{{!isGroupon}}">
<image class="icon" src="{{ collectImage }}"></image>
</view>
<view class="l l-cart" wx:if="{{!isGroupon}}">
<view class="box">
<text class="cart-count">{{cartGoodsCount}}</text>
<image bindtap="openCartPage" class="icon" src="/static/images/ic_menu_shoping_nor.png"></image>
</view>
<view class="l l-cart">
<view class="box">
<text class="cart-count">{{cartGoodsCount}}</text>
<image bindtap="openCartPage" class="icon" src="/static/images/ic_menu_shoping_nor.png"></image>
</view>
</view>
<view class="c" bindtap="addFast" wx:if="{{!soldout}}">立即购买</view>
<view class="r" bindtap="addToCart" wx:if="{{!soldout}}">加入购物车</view>
<view class="n" wx:if="{{soldout}}">商品已售空</view>
</view>
<view class="r" bindtap="addToCart" wx:if="{{!soldout}}" wx:if="{{!isGroupon}}">加入购物车</view>
<view class="c" bindtap="addFast" wx:if="{{!soldout}}">{{isGroupon?'参加团购':'立即购买'}}</view>
<view class="n" wx:if="{{soldout}}">商品已售空</view>
</view>

View File

@@ -71,10 +71,23 @@
}
.goods-info .price {
height: 35rpx;
font-size: 35rpx;
line-height: 35rpx;
color: #b4282d;
height: 70rpx;
align-content: center;
}
.goods-info .counterPrice {
float: left;
padding-left: 120rpx;
text-decoration: line-through;
font-size: 30rpx;
color: #999;
}
.goods-info .retailPrice {
/* float: right; */
padding-left: 60rpx;
font-size: 30rpx;
color: #a78845;
}
.goods-info .brand {
@@ -418,6 +431,7 @@
width: 750rpx;
height: auto;
overflow: hidden;
padding-bottom: 80rpx;
}
.related-goods .h {

View File

@@ -0,0 +1,290 @@
var util = require('../../../utils/util.js');
var api = require('../../../config/api.js');
Page({
data: {
id: 0,
orderId: 0,
groupon: {},
linkGrouponId: 0,
joiners: [],
orderInfo: {},
orderGoods: [],
expressInfo: {},
flag: false,
handleOption: {}
},
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
this.setData({
id: options.id
});
this.getOrderDetail();
},
// 页面分享
onShareAppMessage: function() {
let that = this;
return {
title: '邀请团购',
desc: '唯爱与美食不可辜负',
path: '/pages/index/index?grouponId=' + this.data.linkGrouponId
}
},
shareGroupon: function() {
let that = this;
wx.showActionSheet({
itemList: ['分享给朋友', '分享到朋友圈'],
success: function(res) {
if (res.tapIndex == 0) {
wx.showModal({
title: '提示',
content: '点击右上角 "..." 转发给朋友',
showCancel: false
});
} else if (res.tapIndex == 1) {
that.saveShare();
} else {
console.log(res.tapIndex);
}
},
fail: function(res) {
console.log(res.errMsg);
}
})
},
// 保存分享图
saveShare: function() {
let that = this;
wx.downloadFile({
url: that.data.groupon.shareUrl,
success: function(res) {
console.log(res)
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: function(res) {
wx.showModal({
title: '存图成功',
content: '图片成功保存到相册了,可以分享到朋友圈了',
showCancel: false,
confirmText: '好的',
confirmColor: '#a78845',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
}
}
})
},
fail: function(res) {
console.log('fail')
}
})
},
fail: function() {
console.log('fail')
}
})
},
onPullDownRefresh() {
wx.showNavigationBarLoading() //在标题栏中显示加载
this.getOrderDetail();
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
},
//获取物流信息
getOrderExpress: function() {
let that = this;
util.request(api.ExpressQuery, {
expCode: that.data.orderInfo.expCode,
expNo: that.data.orderInfo.expNo
}, 'POST').then(function(res) {
if (res.errno === 0) {
that.setData({
expressInfo: res.data
});
}
});
},
expandDetail: function() {
let that = this;
this.setData({
flag: !that.data.flag
})
},
getOrderDetail: function() {
let that = this;
util.request(api.GroupOnDetail, {
grouponId: that.data.id
}).then(function(res) {
if (res.errno === 0) {
that.setData({
joiners: res.data.joiners,
groupon: res.data.groupon,
linkGrouponId: res.data.linkGrouponId,
orderId: res.data.orderInfo.id,
orderInfo: res.data.orderInfo,
orderGoods: res.data.orderGoods,
handleOption: res.data.orderInfo.handleOption
});
// 请求物流信息,仅当订单状态为发货时才请求
if (res.data.orderInfo.handleOption.confirm) {
that.getOrderExpress();
}
}
});
},
// “去付款”按钮点击效果
payOrder: function() {
let that = this;
util.request(api.OrderPrepay, {
orderId: that.data.orderId
}, 'POST').then(function(res) {
if (res.errno === 0) {
const payParam = res.data;
console.log("支付过程开始");
wx.requestPayment({
'timeStamp': payParam.timeStamp,
'nonceStr': payParam.nonceStr,
'package': payParam.packageValue,
'signType': payParam.signType,
'paySign': payParam.paySign,
'success': function(res) {
console.log("支付过程成功");
util.redirect('/pages/ucenter/order/order');
},
'fail': function(res) {
console.log("支付过程失败");
util.showErrorToast('支付失败');
},
'complete': function(res) {
console.log("支付过程结束")
}
});
}
});
},
// “取消订单”点击效果
cancelOrder: function() {
let that = this;
let orderInfo = that.data.orderInfo;
wx.showModal({
title: '',
content: '确定要取消此订单?',
success: function(res) {
if (res.confirm) {
util.request(api.OrderCancel, {
orderId: orderInfo.id
}, 'POST').then(function(res) {
if (res.errno === 0) {
wx.showToast({
title: '取消订单成功'
});
util.redirect('/pages/ucenter/order/order');
} else {
util.showErrorToast(res.errmsg);
}
});
}
}
});
},
// “取消订单并退款”点击效果
refundOrder: function() {
let that = this;
let orderInfo = that.data.orderInfo;
wx.showModal({
title: '',
content: '确定要取消此订单?',
success: function(res) {
if (res.confirm) {
util.request(api.OrderRefund, {
orderId: orderInfo.id
}, 'POST').then(function(res) {
if (res.errno === 0) {
wx.showToast({
title: '取消订单成功'
});
util.redirect('/pages/ucenter/order/order');
} else {
util.showErrorToast(res.errmsg);
}
});
}
}
});
},
// “删除”点击效果
deleteOrder: function() {
let that = this;
let orderInfo = that.data.orderInfo;
wx.showModal({
title: '',
content: '确定要删除此订单?',
success: function(res) {
if (res.confirm) {
util.request(api.OrderDelete, {
orderId: orderInfo.id
}, 'POST').then(function(res) {
if (res.errno === 0) {
wx.showToast({
title: '删除订单成功'
});
util.redirect('/pages/ucenter/order/order');
} else {
util.showErrorToast(res.errmsg);
}
});
}
}
});
},
// “确认收货”点击效果
confirmOrder: function() {
let that = this;
let orderInfo = that.data.orderInfo;
wx.showModal({
title: '',
content: '确认收货?',
success: function(res) {
if (res.confirm) {
util.request(api.OrderConfirm, {
orderId: orderInfo.id
}, 'POST').then(function(res) {
if (res.errno === 0) {
wx.showToast({
title: '确认收货成功!'
});
util.redirect('/pages/ucenter/order/order');
} else {
util.showErrorToast(res.errmsg);
}
});
}
}
});
},
onReady: function() {
// 页面渲染完成
},
onShow: function() {
// 页面显示
},
onHide: function() {
// 页面隐藏
},
onUnload: function() {
// 页面关闭
}
});

View File

@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "团购详情"
}

View File

@@ -0,0 +1,91 @@
<view class="container">
<view class="order-info">
<view class="item-a">下单时间:{{orderInfo.addTime}}</view>
<view class="item-b">订单编号:{{orderInfo.orderSn}}</view>
<view class="item-c">
<view class="l">实付:
<text class="cost">¥{{orderInfo.actualPrice}}</text>
</view>
<view class="r">
<view class="btn active" bindtap="shareGroupon">邀请参团</view>
</view>
</view>
</view>
<view class="menu-list-pro">
<view class="h">
<view class="label">参与团购 ( {{joiners.length}}人)</view>
<view class="status">查看全部</view>
</view>
<view class="menu-list-item" wx:for-items="{{joiners}}" wx:key="id" data-id="{{item.id}}">
<image class="icon" src="{{item.avatar}}"></image>
<text class="txt">{{item.nickname}}</text>
</view>
</view>
<view class="order-goods">
<view class="h">
<view class="label">商品信息</view>
<view class="status">{{orderInfo.orderStatusText}}</view>
</view>
<view class="goods">
<view class="item" wx:for="{{orderGoods}}" wx:key="id">
<view class="img">
<image src="{{item.picUrl}}"></image>
</view>
<view class="info">
<view class="t">
<text class="name">{{item.goodsName}}</text>
<text class="number">x{{item.number}}</text>
</view>
<view class="attr">{{item.goodsSpecificationValues}}</view>
<view class="price">¥{{item.retailPrice}}</view>
</view>
</view>
</view>
<view class="order-bottom">
<view class="address">
<view class="t">
<text class="name">{{orderInfo.consignee}}</text>
<text class="mobile">{{orderInfo.mobile}}</text>
</view>
<view class="b">{{orderInfo.address}}</view>
</view>
<view class="total">
<view class="t">
<text class="label">商品合计:</text>
<text class="txt">¥{{orderInfo.goodsPrice}}</text>
</view>
<view class="t">
<text class="label">运费:</text>
<text class="txt">¥{{orderInfo.freightPrice}}</text>
</view>
</view>
<view class="pay-fee">
<text class="label">实付:</text>
<text class="txt">¥{{orderInfo.actualPrice}}</text>
</view>
</view>
</view>
<!-- 物流信息,仅收货状态下可见 -->
<view class="order-express" bindtap="expandDetail" wx:if="{{ handleOption.confirm }}">
<view class="expand">
<view class="title">
<view class="t">快递公司:{{expressInfo.expName}}</view>
<view class="b">物流单号:{{expressInfo.expCode}}</view>
</view>
<image class="ti" src="/static/images/address_right.png" background-size="cover"></image>
</view>
<!-- <view class="order-express" > -->
<view class="traces" wx:for="{{expressInfo.Traces}}" wx:key="item" wx:for-item="iitem" wx:if="{{ flag }}">
<view class="trace">
<view class="acceptStation">{{iitem.AcceptStation}}</view>
<view class="acceptTime">{{iitem.AcceptTime}}</view>
</view>
</view>
</view>
<!-- </view> -->
</view>

View File

@@ -0,0 +1,395 @@
page {
height: 100%;
width: 100%;
background: #f4f4f4;
}
.order-info {
padding-top: 25rpx;
background: #fff;
height: auto;
overflow: hidden;
}
.item-a {
padding-left: 31.25rpx;
height: 42.5rpx;
padding-bottom: 12.5rpx;
line-height: 30rpx;
font-size: 30rpx;
color: #666;
}
.item-b {
padding-left: 31.25rpx;
height: 29rpx;
line-height: 29rpx;
margin-top: 12.5rpx;
margin-bottom: 41.5rpx;
font-size: 30rpx;
color: #666;
}
.item-c {
margin-left: 31.25rpx;
border-top: 1px solid #f4f4f4;
height: 103rpx;
line-height: 103rpx;
}
.item-c .l {
float: left;
}
.item-c .r {
height: 103rpx;
float: right;
display: flex;
align-items: center;
padding-right: 16rpx;
}
.item-c .r .btn {
float: right;
}
.item-c .cost {
color: #b4282d;
}
.item-c .btn {
line-height: 66rpx;
border-radius: 5rpx;
text-align: center;
margin: 0 15rpx;
padding: 0 20rpx;
height: 66rpx;
}
.item-c .btn.active {
background: #a78845;
color: #fff;
}
.order-goods {
margin-top: 20rpx;
background: #fff;
}
.order-goods .h {
height: 93.75rpx;
line-height: 93.75rpx;
margin-left: 31.25rpx;
border-bottom: 1px solid #f4f4f4;
padding-right: 31.25rpx;
}
.order-goods .h .label {
float: left;
font-size: 30rpx;
color: #333;
}
.order-goods .h .status {
float: right;
font-size: 30rpx;
color: #b4282d;
}
.order-goods .item {
display: flex;
align-items: center;
height: 192rpx;
margin-left: 31.25rpx;
padding-right: 31.25rpx;
border-bottom: 1px solid #f4f4f4;
}
.order-goods .item:last-child {
border-bottom: none;
}
.order-goods .item .img {
height: 145.83rpx;
width: 145.83rpx;
background: #f4f4f4;
}
.order-goods .item .img image {
height: 145.83rpx;
width: 145.83rpx;
}
.order-goods .item .info {
flex: 1;
height: 145.83rpx;
margin-left: 20rpx;
}
.order-goods .item .t {
margin-top: 8rpx;
height: 33rpx;
line-height: 33rpx;
margin-bottom: 10.5rpx;
}
.order-goods .item .t .name {
display: block;
float: left;
height: 33rpx;
line-height: 33rpx;
color: #333;
font-size: 30rpx;
}
.order-goods .item .t .number {
display: block;
float: right;
height: 33rpx;
text-align: right;
line-height: 33rpx;
color: #333;
font-size: 30rpx;
}
.order-goods .item .attr {
height: 29rpx;
line-height: 29rpx;
color: #666;
margin-bottom: 25rpx;
font-size: 25rpx;
}
.order-goods .item .price {
display: block;
float: left;
height: 30rpx;
line-height: 30rpx;
color: #333;
font-size: 30rpx;
}
.order-goods .item .btn {
height: 50rpx;
line-height: 50rpx;
border-radius: 5rpx;
text-align: center;
display: block;
float: right;
margin: 0 15rpx;
padding: 0 20rpx;
}
.order-goods .item .btn.active {
background: #b4282d;
color: #fff;
}
.order-bottom {
margin-top: 20rpx;
padding-left: 31.25rpx;
height: auto;
overflow: hidden;
background: #fff;
}
.order-bottom .address {
height: 128rpx;
padding-top: 25rpx;
border-bottom: 1px solid #f4f4f4;
}
.order-bottom .address .t {
height: 35rpx;
line-height: 35rpx;
margin-bottom: 7.5rpx;
}
.order-bottom .address .name {
display: inline-block;
height: 35rpx;
width: 140rpx;
line-height: 35rpx;
font-size: 30rpx;
}
.order-bottom .address .mobile {
display: inline-block;
height: 35rpx;
line-height: 35rpx;
font-size: 30rpx;
}
.order-bottom .address .b {
height: 35rpx;
line-height: 35rpx;
font-size: 30rpx;
}
.order-bottom .total {
height: 106rpx;
padding-top: 20rpx;
border-bottom: 1px solid #f4f4f4;
}
.order-bottom .total .t {
height: 30rpx;
line-height: 30rpx;
margin-bottom: 7.5rpx;
display: flex;
}
.order-bottom .total .label {
width: 150rpx;
display: inline-block;
height: 35rpx;
line-height: 35rpx;
font-size: 30rpx;
}
.order-bottom .total .txt {
flex: 1;
display: inline-block;
height: 35rpx;
line-height: 35rpx;
font-size: 30rpx;
}
.order-bottom .pay-fee {
height: 81rpx;
line-height: 81rpx;
}
.order-bottom .pay-fee .label {
display: inline-block;
width: 140rpx;
color: #b4282d;
}
.order-bottom .pay-fee .txt {
display: inline-block;
width: 140rpx;
color: #b4282d;
}
.order-express {
margin-top: 20rpx;
width: 100%;
height: 100rpx;
background: #fff;
}
.order-express .expand {
/* margin-top: 20rpx; */
width: 100%;
height: 100rpx;
background: #fff;
/* border: 10rpx #a78845; */
}
.order-express .title {
float: left;
margin-bottom: 20rpx;
padding: 10rpx;
}
.order-express .ti {
float: right;
width: 52rpx;
height: 52rpx;
margin-right: 16rpx;
margin-top: 28rpx;
}
.order-express .t {
font-size: 29rpx;
margin-left: 10.25rpx;
color: #a78845;
}
.order-express .b {
font-size: 29rpx;
margin-left: 10.25rpx;
color: #a78845;
}
.order-express .traces {
padding: 17.5rpx;
background: #fff;
border-bottom: 1rpx solid #f1e6cdcc;
}
.order-express .trace {
padding-bottom: 17.5rpx;
padding-top: 17.5rpx;
background: #fff;
}
.order-express .acceptTime {
margin-top: 20rpx;
margin-right: 40rpx;
text-align: right;
font-size: 26rpx;
}
.order-express .acceptStation {
font-size: 26rpx;
}
.menu-list-pro {
margin-top: 20rpx;
overflow-x: scroll;
white-space: nowrap;
text-overflow: ellipsis;
height: 260rpx;
width: 100%;
overflow: hidden;
border-bottom: 1rpx #cfc9ca;
background-color: #fff;
}
.menu-list-pro .h {
height: 93.75rpx;
line-height: 93.75rpx;
margin-left: 31.25rpx;
border-bottom: 1px solid #f4f4f4;
padding-right: 31.25rpx;
}
.menu-list-pro .h .label {
float: left;
font-size: 30rpx;
color: #333;
}
.menu-list-pro .h .status {
float: right;
font-size: 30rpx;
color: #a78845;
}
.menu-list-pro .menu-list-item {
display: block;
float: left;
height: 110rpx;
width: 80rpx;
margin-top: 30rpx;
margin-bottom: 30rpx;
margin-left: 40rpx;
}
.menu-list-pro .icon {
height: 80rpx;
width: 80rpx;
border-radius: 12rpx;
box-shadow: 0px 4rpx 4rpx 0px #cfc9ca;
}
.menu-list-pro .txt {
display: block;
float: left;
width: 80rpx;
margin-top: 5rpx;
font-size: 22rpx;
color: #a78845;
}

View File

@@ -0,0 +1,52 @@
var util = require('../../../utils/util.js');
var api = require('../../../config/api.js');
Page({
data: {
orderList: [],
showType: 0
},
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
},
onPullDownRefresh() {
wx.showNavigationBarLoading() //在标题栏中显示加载
this.getOrderList();
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
},
getOrderList() {
let that = this;
util.request(api.GroupOnMy, {
showType: that.data.showType
}).then(function(res) {
if (res.errno === 0) {
that.setData({
orderList: res.data.data
});
}
});
},
switchTab: function(event) {
let showType = event.currentTarget.dataset.index;
this.setData({
showType: showType
});
this.getOrderList();
},
onReady: function() {
// 页面渲染完成
},
onShow: function() {
// 页面显示
this.getOrderList();
},
onHide: function() {
// 页面隐藏
},
onUnload: function() {
// 页面关闭
}
})

View File

@@ -0,0 +1,6 @@
{
"navigationBarTitleText": "我的团购",
"usingComponents": {
"zan-capsule": "../../../dist/capsule/index"
}
}

View File

@@ -0,0 +1,52 @@
<view class="container">
<view class="orders-switch">
<view class="item {{ showType == 0 ? 'active' : ''}}" bindtap="switchTab" data-index='0'>
<view class="txt">发起的团购</view>
</view>
<view class="item {{ showType == 1 ? 'active' : ''}}" bindtap="switchTab" data-index='1'>
<view class="txt">参加的团购</view>
</view>
</view>
<view class="no-order" wx:if="{{orderList.length <= 0}}">
<view class="c">
<image src="http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/noCart-a8fe3f12e5.png" />
<text>尚未参加任何团购</text>
</view>
</view>
<view class="orders">
<navigator url="../grouponDetail/grouponDetail?id={{item.id}}" class="order" open-type="navigate" wx:for="{{orderList}}" wx:key="id">
<view class="h">
<view class="l">订单编号:{{item.orderSn}}</view>
<view class="r">{{item.orderStatusText}}</view>
</view>
<view class="j">
<view class="l">团购立减:¥{{item.rules.discount}}</view>
<view class="r">参与时间:{{item.groupon.addTime}}</view>
</view>
<view class="i">
<view class="l">团购要求:{{item.rules.discountMember}}人</view>
<view class="r">当前参与:{{item.joinerCount}}</view>
</view>
<view class="goods" wx:for="{{item.goodsList}}" wx:key="id" wx:for-item="gitem">
<view class="img">
<image src="{{gitem.picUrl}}"></image>
</view>
<view class="info">
<text class="name">{{gitem.goodsName}}</text>
<text class="number">共{{gitem.number}}件商品</text>
</view>
<view class="status"></view>
</view>
<view class="b">
<view class="l">实付:¥{{item.actualPrice}}</view>
<view class="capsule-tag">
<zan-capsule color="#a78845" leftText="状态" rightText="{{item.joinerCount>=item.rules.discountMember?'已达成':'团购中'}}" />
</view>
<view class="capsule-tag">
<zan-capsule color="#a78845" leftText="发起" rightText="{{item.creator}}" wx:if="{{!item.isCreator}}" />
</view>
</view>
</navigator>
</view>
</view>

View File

@@ -0,0 +1,222 @@
page {
height: 100%;
width: 100%;
background: #f4f4f4;
}
.capsule-tag {
float: right;
/* padding-right: 10rpx; */
}
.zan-capsule + .zan-capsule {
margin-left: 5px;
}
.orders-switch {
width: 100%;
background: #fff;
height: 84rpx;
border-bottom: 1px solid #a78845;
}
.orders-switch .item {
display: inline-block;
height: 82rpx;
width: 50%;
padding: 0 15rpx;
text-align: center;
}
.orders-switch .item .txt {
display: inline-block;
height: 82rpx;
padding: 0 20rpx;
line-height: 82rpx;
color: #333;
font-size: 30rpx;
width: 100%;
}
.orders-switch .item.active .txt {
color: #a78845;
border-bottom: 4rpx solid #a78845;
}
.no-order {
width: 100%;
height: auto;
margin: 0 auto;
}
.no-order .c {
width: 100%;
height: auto;
margin-top: 200rpx;
}
.no-order .c image {
margin: 0 auto;
display: block;
text-align: center;
width: 258rpx;
height: 258rpx;
}
.no-order .c text {
margin: 0 auto;
display: block;
width: 258rpx;
height: 29rpx;
line-height: 29rpx;
text-align: center;
font-size: 29rpx;
color: #999;
}
.orders {
height: auto;
width: 100%;
overflow: hidden;
}
.order {
margin-top: 20rpx;
background: #fff;
}
.order .h {
height: 83.3rpx;
line-height: 83.3rpx;
margin-left: 31.25rpx;
padding-right: 31.25rpx;
border-bottom: 1px solid #f4f4f4;
}
.order .h .l {
float: left;
color: #a78845;
font-size: 26rpx;
}
.order .h .r {
float: right;
color: #a78845;
font-size: 26rpx;
}
.order .i {
height: 56rpx;
line-height: 56rpx;
margin-left: 31.25rpx;
padding-right: 31.25rpx;
border-bottom: 1px solid #f4f4f4;
}
.order .i .l {
float: left;
color: #a78845;
font-size: 26rpx;
}
.order .i .r {
float: right;
color: #a78845;
font-size: 26rpx;
}
.order .j {
height: 56rpx;
line-height: 56rpx;
margin-left: 31.25rpx;
padding-right: 31.25rpx;
}
.order .j .l {
float: left;
font-size: 26rpx;
color: #a78845;
}
.order .j .r {
float: right;
color: #a78845;
font-size: 26rpx;
}
.order .goods {
display: flex;
align-items: center;
height: 199rpx;
margin-left: 31.25rpx;
}
.order .goods .img {
height: 145.83rpx;
width: 145.83rpx;
background: #f4f4f4;
}
.order .goods .img image {
height: 145.83rpx;
width: 145.83rpx;
}
.order .goods .info {
height: 145.83rpx;
flex: 1;
padding-left: 20rpx;
}
.order .goods .name {
margin-top: 30rpx;
display: block;
height: 44rpx;
line-height: 44rpx;
color: #333;
font-size: 30rpx;
}
.order .goods .number {
display: block;
height: 37rpx;
line-height: 37rpx;
color: #666;
font-size: 25rpx;
}
.order .goods .status {
width: 105rpx;
color: #a78845;
font-size: 25rpx;
}
.order .b {
height: 103rpx;
line-height: 103rpx;
margin-left: 31.25rpx;
padding-right: 31.25rpx;
border-top: 1px solid #f4f4f4;
font-size: 30rpx;
color: #333;
}
.order .b .l {
float: left;
}
.order .b .r {
float: right;
}
.order .b .btn {
margin-top: 19rpx;
height: 64.5rpx;
line-height: 64.5rpx;
text-align: center;
padding: 0 20rpx;
border-radius: 5rpx;
font-size: 28rpx;
color: #fff;
background: #a78845;
}

View File

@@ -3,13 +3,15 @@ const api = require('../../config/api.js');
const user = require('../../utils/user.js');
//获取应用实例
const app = getApp()
const app = getApp();
Page({
data: {
newGoods: [],
hotGoods: [],
topics: [],
brands: [],
groupons: [],
floorGoods: [],
banner: [],
channel: []
@@ -41,6 +43,7 @@ Page({
brands: res.data.brandList,
floorGoods: res.data.floorGoodsList,
banner: res.data.banner,
groupons: res.data.grouponList,
channel: res.data.channel
});
}
@@ -53,8 +56,32 @@ Page({
//这个scene的值存在则证明首页的开启来源于朋友圈分享的图,同时可以通过获取到的goodId的值跳转导航到对应的详情页
var scene = decodeURIComponent(options.scene);
console.log("scene:" + scene);
let info_arr = [];
info_arr = scene.split(',');
let _type = info_arr[0];
let id = info_arr[1];
if (_type == 'goods') {
wx.navigateTo({
url: '../goods/goods?id=' + id
});
} else if (_type == 'groupon') {
wx.navigateTo({
url: '../goods/goods?grouponId=' + id
});
} else {
wx.navigateTo({
url: '../index/index'
});
}
}
// 页面初始化 options为页面跳转所带来的参数
if (options.grouponId) {
//这个pageId的值存在则证明首页的开启来源于用户点击来首页,同时可以通过获取到的pageId的值跳转导航到对应的详情页
wx.navigateTo({
url: '../goods/goods?id=' + scene
url: '../goods/goods?grouponId=' + options.grouponId
});
}

View File

@@ -1 +1,7 @@
{}
{
"navigationBarTitleText": "",
"usingComponents": {
"zan-capsule": "../../dist/capsule/index"
}
}

View File

@@ -1,126 +1,162 @@
<!--index.wxml-->
<view class="container">
<swiper class="banner" indicator-dots="true" autoplay="true" interval="3000" duration="1000">
<swiper-item wx:for="{{banner}}" wx:key="id">
<!-- <navigator url="{{item.link}}"> -->
<image src="{{item.url}}" background-size="cover"></image>
<!-- </navigator> -->
</swiper-item>
</swiper>
<view class="m-menu">
<navigator class="item" url="/pages/category/category?id={{item.id}}" wx:for="{{channel}}" wx:key="id">
<image src="{{item.iconUrl}}" background-size="cover"></image>
<text>{{item.name}}</text>
<swiper class="banner" indicator-dots="true" autoplay="true" interval="3000" duration="1000">
<swiper-item wx:for="{{banner}}" wx:key="id">
<!-- <navigator url="{{item.link}}"> -->
<image src="{{item.url}}" background-size="cover"></image>
<!-- </navigator> -->
</swiper-item>
</swiper>
<view class="m-menu">
<navigator class="item" url="/pages/category/category?id={{item.id}}" wx:for="{{channel}}" wx:key="id">
<image src="{{item.iconUrl}}" background-size="cover"></image>
<text>{{item.name}}</text>
</navigator>
</view>
<view class="a-section a-groupon" wx:if="{{groupons.length > 0}}">
<view class="h">
<view class="title">
<view>
<!-- <navigator url="../hotGoods/hotGoods"> -->
<text class="txt">优惠专区</text>
<!-- </navigator> -->
</view>
</view>
</view>
<view class="b">
<view class="item" wx:for="{{groupons}}" wx:for-index="index" wx:for-item="item" wx:key="id">
<navigator url="/pages/goods/goods?id={{item.goods.id}}">
<image class="img" src="{{item.goods.picUrl}}" background-size="cover"></image>
<view class="right">
<view class="text">
<view class="header">
<text class="name">{{item.goods.name}}</text>
<view class="capsule-tag">
<zan-capsule color="#a78845" leftText="团购" rightText="{{item.groupon_member}}" />
</view>
</view>
<text class="desc">{{item.goods.brief}}</text>
<view class="price">
<view class="counterPrice">原价:¥{{item.goods.counterPrice}}</view>
<view class="retailPrice">现价:¥{{item.groupon_price}}</view>
</view>
</view>
</view>
</navigator>
</view>
</view>
<view class="a-section a-brand">
<view class="h">
<navigator url="../brand/brand">
<text class="txt">品牌制造商直供</text>
</navigator>
</view>
<view class="b">
<view class="item item-1" wx:for="{{brands}}" wx:key="id">
<navigator url="/pages/brandDetail/brandDetail?id={{item.id}}">
<view class="wrap">
<image class="img" src="{{item.picUrl}}" mode="aspectFill"></image>
<view class="mt">
<text class="brand">{{item.name}}</text>
<text class="price">{{item.floorPrice}}</text>
<text class="unit">元起</text>
</view>
</view>
</navigator>
</view>
</view>
</view>
<view class="a-section a-brand">
<view class="h">
<navigator url="../brand/brand">
<text class="txt">品牌制造商直供</text>
</navigator>
</view>
<view class="a-section a-new" wx:if="{{newGoods.length > 0}}">
<view class="h">
<view>
<navigator url="../newGoods/newGoods">
<text class="txt">周一周四 · 新品首发</text>
</navigator>
<view class="b">
<view class="item item-1" wx:for="{{brands}}" wx:key="id">
<navigator url="/pages/brandDetail/brandDetail?id={{item.id}}">
<view class="wrap">
<image class="img" src="{{item.picUrl}}" mode="aspectFill"></image>
<view class="mt">
<text class="brand">{{item.name}}</text>
<text class="price">{{item.floorPrice}}</text>
<text class="unit">元起</text>
</view>
</view>
<view class="b">
<view class="item" wx:for="{{newGoods}}" wx:for-index="index" wx:for-item="item" wx:key="id">
<navigator url="../goods/goods?id={{item.id}}">
<image class="img" src="{{item.picUrl}}" background-size="cover"></image>
<text class="name">{{item.name}}</text>
<text class="price">¥{{item.retailPrice}}</text>
</navigator>
</view>
</view>
</view>
</navigator>
</view>
</view>
<view class="a-section a-popular" wx:if="{{hotGoods.length > 0}}">
<view class="h">
<view>
<navigator url="../hotGoods/hotGoods">
<text class="txt">人气推荐</text>
</navigator>
</view>
</view>
<view class="b">
<view class="item" wx:for="{{hotGoods}}" wx:for-index="index" wx:for-item="item" wx:key="id">
<navigator url="/pages/goods/goods?id={{item.id}}">
<image class="img" src="{{item.picUrl}}" background-size="cover"></image>
<view class="right">
<view class="text">
<text class="name">{{item.name}}</text>
<text class="desc">{{item.brief}}</text>
<text class="price">¥{{item.retailPrice}}</text>
</view>
</view>
</navigator>
</view>
</view>
</view>
<view class="a-section a-new" wx:if="{{newGoods.length > 0}}">
<view class="h">
<view>
<navigator url="../newGoods/newGoods">
<text class="txt">周一周四 · 新品首发</text>
</navigator>
</view>
</view>
<view class="a-section a-topic" wx:if="topics.length > 0">
<view class="h">
<view>
<navigator url="/pages/topic/topic">
<text class="txt">专题精选</text>
</navigator>
</view>
</view>
<view class="b">
<scroll-view scroll-x class="list">
<view class="item" wx:for="{{topics}}" wx:for-index="index" wx:for-item="item" wx:key="id">
<navigator url="../topicDetail/topicDetail?id={{item.id}}">
<image class="img" src="{{item.picUrl}}" background-size="cover"></image>
<view class="np">
<text class="name">{{item.title}}</text>
<text class="price">¥{{item.price}}元起</text>
</view>
<text class="desc">{{item.subtitle}}</text>
</navigator>
</view>
</scroll-view>
</view>
<view class="b">
<view class="item" wx:for="{{newGoods}}" wx:for-index="index" wx:for-item="item" wx:key="id">
<navigator url="../goods/goods?id={{item.id}}">
<image class="img" src="{{item.picUrl}}" background-size="cover"></image>
<text class="name">{{item.name}}</text>
<text class="price">¥{{item.retailPrice}}</text>
</navigator>
</view>
</view>
<view class="good-grid" wx:for="{{floorGoods}}" wx:key="id">
<view class="h">
<view>
<text>{{item.name}}</text>
</view>
</view>
<view class="b">
<block wx:for="{{item.goodsList}}" wx:for-index="iindex" wx:for-item="iitem" wx:key="id">
<view class="item {{iindex % 2 == 0 ? '' : 'item-b'}}">
<navigator url="../goods/goods?id={{iitem.id}}" class="a">
<image class="img" src="{{iitem.picUrl}}" background-size="cover"></image>
<text class="name">{{iitem.name}}</text>
<text class="price">¥{{iitem.retailPrice}}</text>
</navigator>
</view>
</block>
<view class="item item-b item-more">
<navigator url="/pages/category/category?id={{item.id}}" class="more-a">
<view class="txt">{{'更多'+item.name+'好物'}}</view>
<image class="icon" src="../../static/images/icon_go_more.png" background-size="cover"></image>
</navigator>
</view>
</view>
</view>
<view class="a-section a-popular" wx:if="{{hotGoods.length > 0}}">
<view class="h">
<view>
<navigator url="../hotGoods/hotGoods">
<text class="txt">人气推荐</text>
</navigator>
</view>
</view>
<view class="b">
<view class="item" wx:for="{{hotGoods}}" wx:for-index="index" wx:for-item="item" wx:key="id">
<navigator url="/pages/goods/goods?id={{item.id}}">
<image class="img" src="{{item.picUrl}}" background-size="cover"></image>
<view class="right">
<view class="text">
<text class="name">{{item.name}}</text>
<text class="desc">{{item.brief}}</text>
<text class="price">¥{{item.retailPrice}}</text>
</view>
</view>
</navigator>
</view>
</view>
</view>
<view class="a-section a-topic" wx:if="topics.length > 0">
<view class="h">
<view>
<navigator url="/pages/topic/topic">
<text class="txt">专题精选</text>
</navigator>
</view>
</view>
<view class="b">
<scroll-view scroll-x class="list">
<view class="item" wx:for="{{topics}}" wx:for-index="index" wx:for-item="item" wx:key="id">
<navigator url="../topicDetail/topicDetail?id={{item.id}}">
<image class="img" src="{{item.picUrl}}" background-size="cover"></image>
<view class="np">
<text class="name">{{item.title}}</text>
<text class="price">¥{{item.price}}元起</text>
</view>
<text class="desc">{{item.subtitle}}</text>
</navigator>
</view>
</scroll-view>
</view>
</view>
<view class="good-grid" wx:for="{{floorGoods}}" wx:key="id">
<view class="h">
<view>
<text>{{item.name}}</text>
</view>
</view>
<view class="b">
<block wx:for="{{item.goodsList}}" wx:for-index="iindex" wx:for-item="iitem" wx:key="id">
<view class="item {{iindex % 2 == 0 ? '' : 'item-b'}}">
<navigator url="../goods/goods?id={{iitem.id}}" class="a">
<image class="img" src="{{iitem.picUrl}}" background-size="cover"></image>
<text class="name">{{iitem.name}}</text>
<text class="price">¥{{iitem.retailPrice}}</text>
</navigator>
</view>
</block>
<view class="item item-b item-more">
<navigator url="/pages/category/category?id={{item.id}}" class="more-a">
<view class="txt">{{'更多'+item.name+'好物'}}</view>
<image class="icon" src="../../static/images/icon_go_more.png" background-size="cover"></image>
</navigator>
</view>
</view>
</view>
</view>

View File

@@ -123,6 +123,92 @@
height: 253rpx;
}
.a-groupon {
width: 750rpx;
height: auto;
overflow: hidden;
}
.a-groupon .b .item {
border-top: 1px solid #d9d9d9;
margin: 0 20rpx;
height: 244rpx;
width: 710rpx;
}
.a-groupon .b .img {
margin-top: 12rpx;
margin-right: 12rpx;
float: left;
width: 220rpx;
height: 220rpx;
}
.a-groupon .b .right {
float: left;
height: 244rpx;
width: 476rpx;
display: flex;
flex-flow: row nowrap;
}
.a-groupon .b .text {
display: flex;
flex-wrap: nowrap;
flex-direction: column;
justify-content: center;
overflow: hidden;
height: 244rpx;
width: 476rpx;
}
.a-groupon .b .name {
float: left;
width: 330rpx;
display: block;
color: #333;
line-height: 50rpx;
font-size: 30rpx;
}
.a-groupon .capsule-tag {
float: right;
padding-right: 0rpx;
padding-top: 8rpx;
}
.a-groupon .zan-capsule + .zan-capsule {
margin-left: 10px;
}
.a-groupon .b .desc {
width: 476rpx;
display: block;
color: #999;
line-height: 50rpx;
font-size: 25rpx;
}
.a-groupon .b .price {
width: 476rpx;
display: flex;
color: #b4282d;
line-height: 50rpx;
font-size: 33rpx;
}
.a-groupon .b .counterPrice {
text-decoration: line-through;
font-size: 28rpx;
color: #999;
}
.a-groupon .b .retailPrice {
margin-left: 30rpx;
font-size: 28rpx;
color: #a78845;
}
.a-new .b {
width: 750rpx;
height: auto;

View File

@@ -62,61 +62,66 @@ Page({
url: "/pages/auth/login/login"
});
};
},
goCollect() {
if (app.globalData.hasLogin) {
wx.navigateTo({
url: "/pages/ucenter/collect/collect"
});
} else {
wx.navigateTo({
url: "/pages/auth/login/login"
});
};
},
goFootprint() {
if (app.globalData.hasLogin) {
wx.navigateTo({
url: "/pages/ucenter/footprint/footprint"
});
} else {
wx.navigateTo({
url: "/pages/auth/login/login"
});
};
},
goAddress() {
if (app.globalData.hasLogin) {
wx.navigateTo({
url: "/pages/ucenter/address/address"
});
} else {
wx.navigateTo({
url: "/pages/auth/login/login"
});
};
},
aboutUs: function() {
wx.navigateTo({
url: '/pages/about/about'
});
},
exitLogin: function() {
wx.showModal({
title: '',
confirmColor: '#b4282d',
content: '退出登录?',
success: function(res) {
if (res.confirm) {
wx.removeStorageSync('token');
wx.removeStorageSync('userInfo');
wx.switchTab({
url: '/pages/index/index'
});
}
}
})
},
goGroupon() {
if (app.globalData.hasLogin) {
wx.navigateTo({
url: "/pages/groupon/myGroupon/myGroupon"
});
} else {
wx.navigateTo({
url: "/pages/auth/login/login"
});
};
},
goCollect() {
if (app.globalData.hasLogin) {
wx.navigateTo({
url: "/pages/ucenter/collect/collect"
});
} else {
wx.navigateTo({
url: "/pages/auth/login/login"
});
};
},
goFootprint() {
if (app.globalData.hasLogin) {
wx.navigateTo({
url: "/pages/ucenter/footprint/footprint"
});
} else {
wx.navigateTo({
url: "/pages/auth/login/login"
});
};
},
goAddress() {
if (app.globalData.hasLogin) {
wx.navigateTo({
url: "/pages/ucenter/address/address"
});
} else {
wx.navigateTo({
url: "/pages/auth/login/login"
});
};
},
exitLogin: function() {
wx.showModal({
title: '',
confirmColor: '#b4282d',
content: '退出登录?',
success: function(res) {
if (res.confirm) {
wx.removeStorageSync('token');
wx.removeStorageSync('userInfo');
wx.switchTab({
url: '/pages/index/index'
});
}
}
})
}
})

View File

@@ -19,12 +19,12 @@
<text class="txt">优惠券</text>
</view>
</view>
<!-- <view class="item no-border">
<view class="item no-border" bindtap="goGroupon">
<view class="a">
<text class="icon gift"></text>
<text class="txt">礼品卡</text>
<text class="txt">团购</text>
</view>
</view> -->
</view>
<view class="item">
<view class="a" bindtap="goCollect">
<image class="user-menu .icon.collect" src="/static/images/icon_collect.png"></image>