member_goods.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. <?php
  2. //$type = Dever::db('setting/role_goods')->config['set']['type'];
  3. $type = array
  4. (
  5. 1 => '商品',
  6. 2 => '礼品卡',
  7. 3 => '名额',
  8. );
  9. $button = array();
  10. $info = '';
  11. $mid = Dever::input('search_option_mid');
  12. $search_api_mid = Dever::input('search_api_mid');
  13. if ($search_api_mid) {
  14. $member = Dever::db('agent/member')->find(array('mobile' => $search_api_mid));
  15. if ($member) {
  16. if (Dever::load('manage/auth')->checkFunc('agent.member_goods', 'edit', '手动调整权益')) {
  17. $button['手动调整权益'] = array('location', 'agent/lib/member_set.home?mid=' . $member['id'] . '&search_api_mid=' . $search_api_mid . '&[refer]');
  18. }
  19. $button['权益操作记录'] = array('location', 'l=project/database/list&project=agent&table=member_goods_log&search_option_state=1&search_option_mid='.$member['id'].'&search_api_mid=' . $search_api_mid . '&[refer]');
  20. // $button = array
  21. // (
  22. // '手动调整权益' => array('location', 'agent/lib/member_set.home?mid=' . $member['id'] . '&search_api_mid=' . $search_api_mid),
  23. // '权益操作记录' => array('location', 'l=project/database/list&project=agent&table=member_goods_log&search_option_mid='.$member['id'].'&search_api_mid=' . $search_api_mid),
  24. // );
  25. // $info = Dever::load('agent/lib/member')->getInfoString($member);
  26. $mid = false;
  27. }
  28. } else {
  29. if ($mid) {
  30. $button['返回上一页'] = array('location', 'l=project/database/list&project=agent&table=member_area&page_type=1&mid=' . $mid);
  31. if (Dever::load('manage/auth')->checkFunc('agent.member_goods', 'edit', '手动调整权益')) {
  32. $button['手动调整权益'] = array('location', 'agent/lib/member_set.home?mid=' . $mid . '&[refer]');
  33. }
  34. $button['权益操作记录'] = array('location', 'l=project/database/list&project=agent&table=member_goods_log&search_option_state=1&search_option_mid=' . $mid . '&[refer]');
  35. // $button = array
  36. // (
  37. // '返回上一页' => array('location', 'l=project/database/list&project=agent&table=member_area&page_type=1&mid=' . $mid),
  38. // '手动调整权益' => array('location', 'agent/lib/member_set.home?mid=' . $mid),
  39. // '权益操作记录' => array('location', 'l=project/database/list&project=agent&table=member_goods_log&search_option_mid=' . $mid),
  40. // );
  41. // $info = Dever::load('agent/lib/member')->getInfoString($mid);
  42. }
  43. }
  44. $excel = false;
  45. if(Dever::load('manage/auth')->checkFunc('agent.member_goods', 'editMout', '数据导出')){
  46. $excel[] = array('数据导出','权益管理', 'agent/lib/dhorder.out_member_goods');
  47. }
  48. if(Dever::load('manage/auth')->checkFunc('agent.member_goods', 'editMout1', '未使用数据导出')){
  49. $excel[] = array('未使用数据导出','权益管理', 'agent/lib/dhorder.out_member_nogoods');
  50. }
  51. $admin = Dever::load('manage/auth.info');
  52. $admin_auth = false;
  53. if ($admin && $admin['role'] == 24){
  54. $admin_auth = $admin['role'];
  55. }
  56. return array
  57. (
  58. # 表名
  59. 'name' => 'member_goods',
  60. # 显示给用户看的名称
  61. 'lang' => '权益管理',
  62. 'order' => 81,
  63. 'info' => $info,
  64. 'set' => array
  65. (
  66. 'type' => $type,
  67. ),
  68. # 数据结构
  69. 'struct' => array
  70. (
  71. 'id' => array
  72. (
  73. 'type' => 'int-11',
  74. 'name' => 'ID',
  75. 'default' => '',
  76. 'desc' => '',
  77. 'match' => 'is_numeric',
  78. 'search' => 'order',
  79. 'update' => 'hidden',
  80. //'list' => true,
  81. ),
  82. 'mid' => array
  83. (
  84. 'type' => 'int-11',
  85. 'name' => '代理商姓名/手机号',
  86. 'default' => '-1',
  87. 'desc' => '代理商',
  88. 'match' => 'is_string',
  89. 'update' => 'text',
  90. 'search' => array
  91. (
  92. 'api' => 'agent/member-getSearch',
  93. 'col' => 'col',
  94. 'result' => 'id',
  95. 'search' => 'mid',
  96. ),
  97. 'list_name' => '代理商信息',
  98. 'list' => $admin_auth ? 'Dever::load("agent/lib/member.getOne", {mid}, "agent/member", true,true)' : 'Dever::load("agent/lib/member.getOne", {mid}, "agent/member", true)',
  99. 'list_order' => 3,
  100. ),
  101. 'agent-member-name'=> array
  102. (
  103. 'name' => '姓名',
  104. 'default' => '',
  105. 'desc' => '姓名',
  106. 'match' => 'option',
  107. 'searchs' => array
  108. (
  109. 'api' => 'agent/member-find',
  110. 'col' => 'name',
  111. 'result' => 'id',
  112. 'search' => 'mid',
  113. ),
  114. # 读取另外表的关联方式
  115. 'sync' => array('mid', 'id'),
  116. //'list' => $mid ? false : true,
  117. //'list_order' => 1,
  118. ),
  119. 'agent-member-idcard'=> array
  120. (
  121. 'name' => '身份证号',
  122. 'default' => '',
  123. 'desc' => '手机号',
  124. 'match' => 'option',
  125. 'searchs' => array
  126. (
  127. 'api' => 'agent/member-find',
  128. 'col' => 'idcard',
  129. 'result' => 'id',
  130. 'search' => 'mid',
  131. ),
  132. # 读取另外表的关联方式
  133. 'sync' => array('mid', 'id'),
  134. ),
  135. 'agent-member-role'=> array
  136. (
  137. 'name' => '代理角色',
  138. 'default' => '',
  139. 'desc' => '代理角色',
  140. 'match' => 'option',
  141. # 读取另外表的关联方式
  142. 'sync' => array('mid', 'id'),
  143. //'list' => 'Dever::load("setting/role-find#name", "{agent-member-role}")',
  144. //'list_order' => 3,
  145. ),
  146. 'type' => array
  147. (
  148. 'type' => 'tinyint-1',
  149. 'name' => '类型',
  150. 'default' => '1',
  151. 'desc' => '类型',
  152. 'match' => 'is_numeric',
  153. 'update' => 'radio',
  154. 'option' => $type,
  155. 'search' => 'select',
  156. 'list' => true,
  157. 'list_order' => 4,
  158. ),
  159. 'type_id' => array
  160. (
  161. 'type' => 'int-11',
  162. 'name' => '类型id',
  163. 'default' => '-1',
  164. 'desc' => '类型id',
  165. 'match' => 'is_numeric',
  166. 'list_name' => '权益名称',
  167. //'list' => 'Dever::load("agent/lib/manage.getGoods#name", "{type}", "{type_id}", "{sku_id}")',
  168. 'list_order' => 5,
  169. ),
  170. 'sku_id' => array
  171. (
  172. 'type' => 'int-11',
  173. 'name' => 'sku_id',
  174. 'default' => '-1',
  175. 'desc' => 'sku_id',
  176. 'match' => 'is_numeric',
  177. ),
  178. 'name' => array
  179. (
  180. 'type' => 'varchar-100',
  181. 'name' => '权益名称',
  182. 'default' => '',
  183. 'desc' => '权益名称',
  184. 'match' => 'is_string',
  185. 'update' => 'text',
  186. 'search' => 'fulltext',
  187. 'list' => 'Dever::load("agent/lib/manage.getGoods#name", "{type}", "{type_id}", "{sku_id}", "{name}")',
  188. 'list_order' => 5,
  189. ),
  190. 'total_num' => array
  191. (
  192. 'type' => 'int-11',
  193. 'name' => '总数量',
  194. 'default' => '0',
  195. 'desc' => '总数量',
  196. 'match' => 'is_numeric',
  197. 'list_name' => '剩余数量/总数量',
  198. 'list' => '{total_num} - {sell_num} . " / " . {total_num}',
  199. 'list_order' => 6,
  200. ),
  201. 'sell_num' => array
  202. (
  203. 'type' => 'int-11',
  204. 'name' => '已兑换数量',
  205. 'default' => '0',
  206. 'desc' => '已兑换数量',
  207. 'match' => 'option',
  208. //'list' => 'Dever::load("agent/lib/manage.getGoods#price", "{type}", "{type_id}", "{sku_id}")',
  209. 'list_name' => '单件价值',
  210. 'list' => '{price}',
  211. 'list_order' => 7,
  212. ),
  213. 'cash' => array
  214. (
  215. 'type' => 'decimal-11,2',
  216. 'name' => '总价值',
  217. 'default' => '0',
  218. 'desc' => '总价值',
  219. 'match' => 'is_numeric',
  220. 'update' => 'text',
  221. 'list' => true,
  222. 'list_name' => '未兑换价值',
  223. 'list' => '({total_num} - {sell_num})*{price}',
  224. 'list_order' => 9,
  225. ),
  226. 'price' => array
  227. (
  228. 'type' => 'decimal-11,2',
  229. 'name' => '单件价值',
  230. 'default' => '0',
  231. 'desc' => '单件价值',
  232. 'match' => 'is_numeric',
  233. 'update' => 'text',
  234. 'list' => true,
  235. 'list_name' => '已兑换价值',
  236. 'list' => '{sell_num}*{price}',
  237. 'list_order' => 10,
  238. ),
  239. 'state' => array
  240. (
  241. 'type' => 'tinyint-1',
  242. 'name' => '状态',
  243. 'default' => '1',
  244. 'desc' => '请选择状态',
  245. 'match' => 'is_numeric',
  246. ),
  247. 'cdate' => array
  248. (
  249. 'type' => 'int-11',
  250. 'name' => '分配时间',
  251. 'match' => array('is_numeric', time()),
  252. 'desc' => '',
  253. # 只有insert时才生效
  254. 'insert' => true,
  255. 'search' => 'date',
  256. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  257. ),
  258. ),
  259. 'alter' => array
  260. (
  261. 5 => array
  262. (
  263. array('update', 'price', 'price', 'decimal-11,2 0 单件价值'),
  264. array('update', 'cash', 'cash', 'decimal-11,2 0 总价值'),
  265. ),
  266. 'version' => 5,
  267. ),
  268. 'manage' => array
  269. (
  270. 'edit' => false,
  271. 'insert' => false,
  272. 'delete' => false,
  273. 'button' => $button,
  274. 'excel' => $excel,
  275. ),
  276. 'request' => array
  277. (
  278. 'getData' => array
  279. (
  280. # 匹配的正则或函数 选填项
  281. 'option' => array
  282. (
  283. 'mid' => 'yes',
  284. 'type' => 'yes',
  285. 'type_id' => 'yes',
  286. 'sku_id' => 'yes',
  287. 'state' => 1,
  288. ),
  289. 'order' => array('type' => 'desc', 'id' => 'desc'),
  290. 'type' => 'all',
  291. 'page' => array(500, 'list'),
  292. 'col' => '*, total_num-sell_num as num',
  293. ),
  294. 'getOne' => array
  295. (
  296. # 匹配的正则或函数 选填项
  297. 'option' => array
  298. (
  299. 'id' => 'yes',
  300. 'mid' => 'yes',
  301. 'type' => 'yes',
  302. 'type_id' => 'yes',
  303. 'sku_id' => 'yes',
  304. 'state' => 1,
  305. ),
  306. 'type' => 'one',
  307. 'col' => '*, total_num-sell_num as num',
  308. ),
  309. 'getAll' => array
  310. (
  311. # 匹配的正则或函数 选填项
  312. 'option' => array
  313. (
  314. 'id' => 'yes',
  315. 'mid' => 'yes',
  316. 'type' => 'yes',
  317. 'type_id' => 'yes',
  318. 'sku_id' => 'yes',
  319. 'state' => 1,
  320. ),
  321. 'type' => 'all',
  322. 'col' => '*, total_num-sell_num as num',
  323. ),
  324. 'findData' => array
  325. (
  326. # 匹配的正则或函数 选填项
  327. 'where' => array
  328. (
  329. 'mid' => 'yes',
  330. 'type' => 'yes',
  331. 'type_id' => 'yes',
  332. 'sku_id' => 'yes',
  333. 'state' => 1,
  334. ),
  335. 'type' => 'one',
  336. 'col' => '*, total_num-sell_num as num',
  337. ),
  338. 'findAll' => array
  339. (
  340. # 匹配的正则或函数 选填项
  341. 'option' => array
  342. (
  343. 'mid' => 'yes',
  344. 'type' => 'yes',
  345. 'type_id' => 'yes',
  346. 'sku_id' => 'yes',
  347. 'start' => array('yes-cdate', '>='),
  348. 'end' => array('yes-cdate', '<='),
  349. 'state' => 1,
  350. ),
  351. 'type' => 'all',
  352. 'group' => 'type,type_id,sku_id',
  353. 'col' => '*,sum(total_num) as total_num, sum(sell_num) as sell_num, sum(total_num*price) as cash, sum(sell_num*price) as y_cash',
  354. ),
  355. # 更新售出量
  356. 'incSell' => array
  357. (
  358. 'type' => 'update',
  359. 'where' => array
  360. (
  361. 'mid' => 'yes',
  362. 'type' => 'yes',
  363. 'type_id' => 'yes',
  364. 'sku_id' => 'yes',
  365. ),
  366. 'set' => array
  367. (
  368. 'sell_num' => array('yes', '+='),
  369. ),
  370. ),
  371. # 减少售出量
  372. 'decSell' => array
  373. (
  374. 'type' => 'update',
  375. 'where' => array
  376. (
  377. 'mid' => 'yes',
  378. 'type' => 'yes',
  379. 'type_id' => 'yes',
  380. 'sku_id' => 'yes',
  381. ),
  382. 'set' => array
  383. (
  384. 'sell_num' => array('yes', '-='),
  385. ),
  386. ),
  387. # 更新总库存
  388. 'updateTotal' => array
  389. (
  390. 'type' => 'update',
  391. 'where' => array
  392. (
  393. 'id' => 'yes',
  394. ),
  395. 'set' => array
  396. (
  397. 'total_num' => array('yes', '+='),
  398. ),
  399. ),
  400. # 增加总库存
  401. 'incTotal' => array
  402. (
  403. 'type' => 'update',
  404. 'where' => array
  405. (
  406. 'mid' => 'yes',
  407. 'type' => 'yes',
  408. 'type_id' => 'yes',
  409. 'sku_id' => 'yes',
  410. ),
  411. 'set' => array
  412. (
  413. 'total_num' => array('yes', '+='),
  414. ),
  415. ),
  416. # 减少总库存
  417. 'decTotal' => array
  418. (
  419. 'type' => 'update',
  420. 'where' => array
  421. (
  422. 'mid' => 'yes',
  423. 'type' => 'yes',
  424. 'type_id' => 'yes',
  425. 'sku_id' => 'yes',
  426. ),
  427. 'set' => array
  428. (
  429. 'total_num' => array('yes', '-='),
  430. ),
  431. ),
  432. 'getExcelAll' => array
  433. (
  434. # 匹配的正则或函数 选填项
  435. 'option' => array
  436. (
  437. 'type' => 'yes',
  438. 'name' => array('yes', 'like'),
  439. 'status' => 'yes',
  440. 'state' => 1,
  441. ),
  442. 'type' => 'all',
  443. 'col' => '*, total_num-sell_num as num',
  444. ),
  445. 'getQone' => array
  446. (
  447. # 匹配的正则或函数 选填项
  448. 'option' => array
  449. (
  450. 'mid' => 'yes',
  451. 'type' => 'yes',
  452. 'type_id' => 'yes',
  453. 'state' => 1,
  454. ),
  455. 'type' => 'one',
  456. 'order' => array('cdate'=>'desc'),
  457. 'col' => '*',
  458. ),
  459. 'getTotal' => array
  460. (
  461. # 匹配的正则或函数 选填项
  462. 'option' => array
  463. (
  464. 'start' => array('yes-cdate','>='),
  465. 'end' => array('yes-cdate','<='),
  466. 'fstart' => array('yes-cdate','>='),
  467. 'fend' => array('yes-cdate','<='),
  468. 'mid' => 'yes',
  469. 'type' => array('yes','in'),
  470. 'type_id' => 'yes',
  471. 'state' => 1,
  472. ),
  473. 'type' => 'one',
  474. // 'order' => array('cdate'=>'desc'),
  475. 'col' => 'sum(cash) as cash,sum(total_num) as total_num,sum(sell_num) as sell_num,price',
  476. ),
  477. 'getDhTotal' => array
  478. (
  479. # 匹配的正则或函数 选填项
  480. 'option' => array
  481. (
  482. 'start' => array('yes-t_2.ddate','>='),
  483. 'end' => array('yes-t_2.ddate','<='),
  484. 'mid' => 'yes-t_1.mid',
  485. 'type' => array('yes-t_1.type','in'),
  486. 'type_id' => 'yes-t_1.type_id',
  487. 'state' => 'yes-t_1.state-1',
  488. ),
  489. 'join' => array
  490. (
  491. array
  492. (
  493. 'table' => 'card/code',
  494. 'type' => 'left join',
  495. 'on' => array('sku_id', 'id'),
  496. 'col' => 't_2.id as cid',
  497. )
  498. ),
  499. 'type' => 'one',
  500. // 'order' => array('cdate'=>'desc'),
  501. 'col' => 'id,sum(t_1.cash) as cash,sum(t_1.total_num) as total_num,sum(t_1.sell_num) as sell_num,t_1.price',
  502. ),
  503. 'getProduct' => array
  504. (
  505. # 匹配的正则或函数 选填项
  506. 'option' => array
  507. (
  508. 'start' => array('yes-cdate','>='),
  509. 'end' => array('yes-cdate','<='),
  510. 'mid' => 'yes',
  511. 'type' => array('yes','in'),
  512. 'type_id' => array('yes','in'),
  513. 'state' => 1,
  514. ),
  515. 'type' => 'all',
  516. 'group' => 'type,type_id',
  517. 'order' => array('type'=>'asc', 'type_id' => 'desc'),
  518. 'col' => '*,sum(total_num)-sum(sell_num) as num',
  519. ),
  520. 'getSearchAll' => array
  521. (
  522. # 匹配的正则或函数 选填项
  523. 'option' => array
  524. (
  525. 'start' => array('yes-cdate','>='),
  526. 'end' => array('yes-cdate','<='),
  527. 'type' => array('yes','in'),
  528. 'state' => 1,
  529. ),
  530. 'type' => 'all',
  531. 'col' => '*',
  532. ),
  533. 'getCardAll' => array
  534. (
  535. # 匹配的正则或函数 选填项
  536. 'option' => array
  537. (
  538. 'start' => array('yes-cdate','>='),
  539. 'end' => array('yes-cdate','<='),
  540. 'mid' => 'yes',
  541. 'type'=>'yes',
  542. 'type_id' => array('yes','in'),
  543. 'state' => 1,
  544. ),
  545. 'type' => 'all',
  546. 'col' => 'sku_id',
  547. ),
  548. 'getTOne' => array
  549. (
  550. # 匹配的正则或函数 选填项
  551. 'option' => array
  552. (
  553. 'mid' => 'yes',
  554. 'type'=>array('yes','in'),
  555. 'type_id' => array('yes','in'),
  556. 'state' => 1,
  557. ),
  558. 'type' => 'one',
  559. 'col' => '*',
  560. ),
  561. 'getMingxi' => array
  562. (
  563. # 匹配的正则或函数 选填项
  564. 'option' => array
  565. (
  566. 'name' => 'yes-t_1.name',
  567. 'sku_id' => 'yes-t_1.sku_id',
  568. 'start' => array('yes-t_1.cdate','>='),
  569. 'end' => array('yes-t_1.cdate','<='),
  570. // 'shop_name' => array('yes-t_2.name','like'),
  571. // 'shop_num' =>'yes-t_2.sid',
  572. 'mobile' => 'yes-t_2.mobile',
  573. // 'mid' => 'yes-t_1.mid',
  574. 'type' => array('yes-t_1.type','in'),
  575. // 'type_id' => 'yes-t_1.type_id',
  576. 'state' => 'yes-t_1.state-1',
  577. ),
  578. 'join' => array
  579. (
  580. array
  581. (
  582. 'table' => 'agent/member',
  583. 'type' => 'left join',
  584. 'on' => array('mid', 'id'),
  585. 'col' => 't_2.id as aid',
  586. )
  587. ),
  588. 'type' => 'all',
  589. 'page' => array(20,'list'),
  590. // 'order' => array('cdate'=>'desc'),
  591. 'col' => '*',
  592. ),
  593. ),
  594. );